iperf3使用

一、安装IPerf

1、Windows下:
在这个链接下载iperf3,目前存在D:\tools\iperf-3.1.3-win64下,此软件不需要安装,使用方法为:

./iperf3.exe  参数

2、Ubuntu下:

sudo apt install iperf3

3、v2x下
目前v2x默认已安装iperf3

二、测试

2.1 TCP 上行测试
# Server(Windows) 输入

hsns@HS070010672 MINGW32 /d/tools/iperf-3.1.3-win64
$ ./iperf3.exe -s
# Client(ubuntu) 输入

iperf3 -c 192.168.6.159
# Server(Windows) 输出
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Accepted connection from 192.168.6.159, port 64070
[  5] local 192.168.6.159 port 5201 connected to 192.168.6.159 port 64071
[ ID] Interval           Transfer     Bandwidth
[  5]   0.00-1.00   sec  64.5 MBytes   539 Mbits/sec
[  5]   1.00-2.00   sec  66.5 MBytes   561 Mbits/sec
[  5]   2.00-3.00   sec  77.5 MBytes   650 Mbits/sec
[  5]   3.00-4.00   sec  77.6 MBytes   651 Mbits/sec
[  5]   4.00-5.00   sec  79.3 MBytes   665 Mbits/sec
[  5]   5.00-6.00   sec  80.2 MBytes   673 Mbits/sec
[  5]   6.00-7.00   sec  80.6 MBytes   676 Mbits/sec
[  5]   7.00-8.00   sec  77.7 MBytes   652 Mbits/sec
[  5]   8.00-9.00   sec  77.2 MBytes   647 Mbits/sec
[  5]   9.00-10.00  sec  76.2 MBytes   639 Mbits/sec
[  5]  10.00-10.00  sec  44.2 KBytes   238 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth
[  5]   0.00-10.00  sec  0.00 Bytes  0.00 bits/sec                  sender
[  5]   0.00-10.00  sec   757 MBytes   635 Mbits/sec                  receiver

# Client(Ubuntu) 输出
Connecting to host 192.168.6.159, port 5201
[  5] local 192.168.88.129 port 48870 connected to 192.168.6.159 port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec  78.2 MBytes   656 Mbits/sec    0   67.0 KBytes
[  5]   1.00-2.00   sec  74.6 MBytes   626 Mbits/sec    0   67.0 KBytes
[  5]   2.00-3.00   sec  79.3 MBytes   665 Mbits/sec    0   67.0 KBytes
[  5]   3.00-4.00   sec  68.5 MBytes   575 Mbits/sec    0   67.0 KBytes
[  5]   4.00-5.00   sec  78.1 MBytes   655 Mbits/sec    0   67.0 KBytes
[  5]   5.00-6.00   sec  81.1 MBytes   680 Mbits/sec    0   67.0 KBytes
[  5]   6.00-7.00   sec  79.4 MBytes   666 Mbits/sec    0   67.0 KBytes
[  5]   7.00-8.00   sec  79.1 MBytes   664 Mbits/sec    0   67.0 KBytes
[  5]   8.00-9.00   sec  81.2 MBytes   681 Mbits/sec    0   67.0 KBytes
[  5]   9.00-10.00  sec  77.5 MBytes   650 Mbits/sec    0   67.0 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec   777 MBytes   652 Mbits/sec    0             sender
[  5]   0.00-10.00  sec   777 MBytes   652 Mbits/sec                  receiver

其中port 5021为端口,可以不指定,也可以使用-p,参数手动指定,例如

iperf3 -s -p 5224 #其中 -s 参数表示服务器端,-p 指定使用端口(默认端口 5201。别忘了防火墙放行端口)。如果需要以守护进程后台运行,追加 -D 参数。

iperf3 -c x.x.x.x -p 5224 -t 60 -P 10 -R # 在client发起测速。其中 -c 参数表示客户端并指定测速服务器地址,-p 指定服务器端口,-t 指定测试时长(单位秒),-P 指定并发连接数(越高越能测试到速度极限,多线程测试,指定线程数),-R 表示下载测速(不加参数则测试上传速度)。如果要测试 UDP 连接,追加 -u 参数。

由于是有client向server发送数据,此时,sender表示client向server发送 数据,reserver表示server从client接受到的数据总和

2.2 TCP 下行测试
# Server(Windows) 输入
./iperf3.exe -s
# client(Ubuntu)输入
jiyun@ubuntu:~$ iperf3 -c 192.168.6.159 -R
# server(Windows)输出
Accepted connection from 192.168.6.159, port 51113
[  5] local 192.168.6.159 port 5201 connected to 192.168.6.159 port 51114
[ ID] Interval           Transfer     Bandwidth
[  5]   0.00-1.01   sec  77.8 MBytes   644 Mbits/sec
[  5]   1.01-2.00   sec  69.2 MBytes   586 Mbits/sec
[  5]   2.00-3.01   sec  95.6 MBytes   796 Mbits/sec
[  5]   3.01-4.02   sec  93.9 MBytes   780 Mbits/sec
[  5]   4.02-5.01   sec  96.2 MBytes   813 Mbits/sec
[  5]   5.01-6.00   sec  87.4 MBytes   742 Mbits/sec
[  5]   6.00-7.00   sec  99.0 MBytes   828 Mbits/sec
[  5]   7.00-8.01   sec   110 MBytes   921 Mbits/sec
[  5]   8.01-9.01   sec   104 MBytes   876 Mbits/sec
[  5]   9.01-10.00  sec   106 MBytes   890 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth
[  5]   0.00-10.00  sec   939 MBytes   788 Mbits/sec                  sender
[  5]   0.00-10.00  sec  0.00 Bytes  0.00 bits/sec                  receiver
# client(Ubuntu)输出
Connecting to host 192.168.6.159, port 5201
Reverse mode, remote host 192.168.6.159 is sending
[  5] local 192.168.88.129 port 48874 connected to 192.168.6.159 port 5201
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-1.00   sec  73.7 MBytes   618 Mbits/sec
[  5]   1.00-2.00   sec  73.1 MBytes   613 Mbits/sec
[  5]   2.00-3.00   sec  91.8 MBytes   770 Mbits/sec
[  5]   3.00-4.00   sec  95.0 MBytes   797 Mbits/sec
[  5]   4.00-5.00   sec  95.1 MBytes   798 Mbits/sec
[  5]   5.00-6.00   sec  88.8 MBytes   745 Mbits/sec
[  5]   6.00-7.00   sec  99.4 MBytes   834 Mbits/sec
[  5]   7.00-8.00   sec   109 MBytes   910 Mbits/sec
[  5]   8.00-9.00   sec   106 MBytes   888 Mbits/sec
[  5]   9.00-10.00  sec   108 MBytes   904 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-10.00  sec   939 MBytes   788 Mbits/sec                  sender
[  5]   0.00-10.00  sec   939 MBytes   788 Mbits/sec                  receiver

由于是client从server下载数据,此时,sender代表client从server接收到的数据总和,receiver表示server向client发送的数据总和

2.3 UDP 上行测试
# Server(Windows) 输入
./iperf3.exe -s
# client(Ubuntu)输入
jiyun@ubuntu:~$ iperf3 -c 192.168.6.159 -u
# server(Windows)输出
Server listening on 5201
-----------------------------------------------------------
Accepted connection from 192.168.6.159, port 52219
[  5] local 192.168.6.159 port 5201 connected to 192.168.6.159 port 55542
[ ID] Interval           Transfer     Bandwidth       Jitter    Lost/Total Datagrams
[  5]   0.00-1.00   sec   128 KBytes  1.05 Mbits/sec  331534232.582 ms  0/90 (0%)
[  5]   1.00-2.00   sec   128 KBytes  1.05 Mbits/sec  995275.421 ms  0/90 (0%)
[  5]   2.00-3.00   sec   128 KBytes  1.05 Mbits/sec  2987.903 ms  0/90 (0%)
[  5]   3.00-4.00   sec   128 KBytes  1.05 Mbits/sec  9.023 ms  0/90 (0%)
[  5]   4.00-5.00   sec   128 KBytes  1.05 Mbits/sec  0.082 ms  0/90 (0%)
[  5]   5.00-6.00   sec   128 KBytes  1.05 Mbits/sec  0.051 ms  0/90 (0%)
[  5]   6.00-7.01   sec   128 KBytes  1.05 Mbits/sec  0.053 ms  0/90 (0%)
[  5]   7.01-8.00   sec   127 KBytes  1.04 Mbits/sec  0.065 ms  0/89 (0%)
[  5]   8.00-9.00   sec   128 KBytes  1.05 Mbits/sec  0.090 ms  0/90 (0%)
[  5]   9.00-10.00  sec   127 KBytes  1.04 Mbits/sec  0.064 ms  0/89 (0%)
[  5]  10.00-10.00  sec  0.00 Bytes  0.00 bits/sec  0.064 ms  0/0 (0%)
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Jitter    Lost/Total Datagrams
[  5]   0.00-10.00  sec  0.00 Bytes  0.00 bits/sec  0.064 ms  0/898 (0%)
# client(Ubuntu)输出
Connecting to host 192.168.6.159, port 5201
[  5] local 192.168.88.129 port 58572 connected to 192.168.6.159 port 5201
[ ID] Interval           Transfer     Bitrate         Total Datagrams
[  5]   0.00-1.00   sec   128 KBytes  1.05 Mbits/sec  90
[  5]   1.00-2.00   sec   128 KBytes  1.05 Mbits/sec  90
[  5]   2.00-3.00   sec   128 KBytes  1.05 Mbits/sec  90
[  5]   3.00-4.00   sec   128 KBytes  1.05 Mbits/sec  90
[  5]   4.00-5.00   sec   127 KBytes  1.04 Mbits/sec  89
[  5]   5.00-6.00   sec   128 KBytes  1.05 Mbits/sec  90
[  5]   6.00-7.00   sec   128 KBytes  1.05 Mbits/sec  90
[  5]   7.00-8.00   sec   127 KBytes  1.04 Mbits/sec  89
[  5]   8.00-9.00   sec   128 KBytes  1.05 Mbits/sec  90
[  5]   9.00-10.00  sec   128 KBytes  1.05 Mbits/sec  90
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Jitter    Lost/Total Datagrams
[  5]   0.00-10.00  sec  1.25 MBytes  1.05 Mbits/sec  0.000 ms  0/898 (0%)  sender
[  5]   0.00-10.00  sec  1.25 MBytes  1.05 Mbits/sec  0.064 ms  0/898 (0%)  receiver

此时多了一个lost数据,这项表示丢包数据

2.4 UDP 下行测试

这项和2.3 UDP 上行测试交换一下server和clinet即可以测试

3、参数介绍

命令行选项描述
客户端与服务器共用选项
-f, –format [bkmaBKMA]格式化带宽数输出。支持的格式有: ’b’ = bits/sec ‘B’ = Bytes/sec ’k’ = Kbits/sec ‘K’ = KBytes/sec ’m’ = Mbits/sec ‘M’ = MBytes/sec ’g’ = Gbits/sec ‘G’ = GBytes/sec ’a’ = adaptive bits/sec ‘A’ = adaptive Bytes/sec 自适应格式是kilo-和mega-二者之一。除了带宽之外的字段都输出为字节,除非指定输出的格式,默认的参数是a。 注意:在计算字节byte时,Kilo = 1024, Mega = 1024^2,Giga = 1024^3。通常,在网络中,Kilo = 1000, Mega = 1000^2, and Giga = 1000^3,所以,Iperf也按此来计算比特(位)。如果这些困扰了你,那么请使用-f b参数,然后亲自计算一下。
-i, –interval #设置每次报告之间的时间间隔,单位为秒。如果设置为非零值,就会按照此时间间隔输出测试报告。默认值为零。
-l, –len #[KM]设置读写缓冲区的长度。TCP方式默认为8KB,UDP方式默认为1470字节。
-m, –print_mss输出TCP MSS值(通过TCP_MAXSEG支持)。MSS值一般比MTU值小40字节。通常情况
-p, –port #设置端口,与服务器端的监听端口一致。默认是5001端口,与ttcp的一样。
-u, –udp使用UDP方式而不是TCP方式。参看-b选项。
-w, –window #[KM]设置套接字缓冲区为指定大小。对于TCP方式,此设置为TCP窗口大小。对于UDP方式,此设置为接受UDP数据包的缓冲区大小,限制可以接受数据包的最大值。
-B, –bind host绑定到主机的多个地址中的一个。对于客户端来说,这个参数设置了出栈接口。对于服务器端来说,这个参数设置入栈接口。这个参数只用于具有多网络接口的主机。在Iperf的UDP模式下,此参数用于绑定和加入一个多播组。使用范围在224.0.0.0至239.255.255.255的多播地址。参考-T参数。
-C, –compatibility与低版本的Iperf使用时,可以使用兼容模式。不需要两端同时使用兼容模式,但是强烈推荐两端同时使用兼容模式。某些情况下,使用某些数据流可以引起1.7版本的服务器端崩溃或引起非预期的连接尝试。
-M, –mss #[KM}通过TCP_MAXSEG选项尝试设置TCP最大信息段的值。MSS值的大小通常是TCP/IP头减去40字节。在以太网中,MSS值 为1460字节(MTU1500字节)。许多操作系统不支持此选项。
-N, –nodelay设置TCP无延迟选项,禁用Nagle’s运算法则。通常情况此选项对于交互程序,例如telnet,是禁用的。
-V (from v1.6 or higher)绑定一个IPv6地址。 服务端:$ iperf -s –V 客户端:$ iperf -c -V
服务器端专用选项
-s, –serverIperf服务器模式
-D (v1.2或更高版本)Unix平台下Iperf作为后台守护进程运行。在Win32平台下,Iperf将作为服务运行。
-R(v1.2或更高版本,仅用于Windows)卸载Iperf服务(如果它在运行)。
-o(v1.2或更高版本,仅用于Windows)重定向输出到指定文件
-c, –client host如果Iperf运行在服务器模式,并且用-c参数指定一个主机,那么Iperf将只接受指定主机的连接。此参数不能工作于UDP模式。
-P, –parallel #服务器关闭之前保持的连接数。默认是0,这意味着永远接受连接。
客户端专用选项
-b, –bandwidth #[KM]UDP模式使用的带宽,单位bits/sec。此选项与-u选项相关。默认值是1 Mbit/sec。
-c, –client host运行Iperf的客户端模式,连接到指定的Iperf服务器端。
-d, –dualtest运行双测试模式。这将使服务器端反向连接到客户端,使用-L 参数中指定的端口(或默认使用客户端连接到服务器端的端口)。这些在操作的同时就立即完成了。如果你想要一个交互的测试,请尝试-r参数。
-n, –num #[KM]传送的缓冲器数量。通常情况,Iperf按照10秒钟发送数据。-n参数跨越此限制,按照指定次数发送指定长度的数据,而不论该操作耗费多少时间。参考-l与-t选项。
-r, –tradeoff往复测试模式。当客户端到服务器端的测试结束时,服务器端通过-l选项指定的端口(或默认为客户端连接到服务器端的端口),反向连接至客户端。当客户端连接终止时,反向连接随即开始。如果需要同时进行双向测试,请尝试-d参数。
-t, –time #设置传输的总时间。Iperf在指定的时间内,重复的发送指定长度的数据包。默认是10秒钟。参考-l与-n选项。
-L, –listenport #指定服务端反向连接到客户端时使用的端口。默认使用客户端连接至服务端的端口。
-P, –parallel #线程数。指定客户端与服务端之间使用的线程数。默认是1线程。需要客户端与服务器端同时使用此参数。
-S, –tos #出栈数据包的服务类型。许多路由器忽略TOS字段。你可以指定这个值,使用以”0x”开始的16进制数,或以”0”开始的8进制数或10进制数。例如,16进制’0x10’ = 8进制’020’ = 十进制’16’。TOS值1349就是: IPTOS_LOWDELAY minimize delay 0x10 IPTOS_THROUGHPUT maximize throughput 0x08 IPTOS_RELIABILITY maximize reliability 0x04 IPTOS_LOWCOST minimize cost 0x02
-T, –ttl #出栈多播数据包的TTL值。这本质上就是数据通过路由器的跳数。默认是1,链接本地。
-F (from v1.2 or higher)使用特定的数据流测量带宽,例如指定的文件。 $ iperf -c -F
-I (from v1.2 or higher)与-F一样,由标准输入输出文件输入数据。
杂项
-h, –help显示命令行参考并退出 。
-v, –version显示版本信息和编译信息并退出。
  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值