What is iPerf / iPerf3 ?

iPerf3 is a tool for active measurements of the maximum achievable bandwidth on IP networks. It supports tuning of various parameters related to timing, buffers and protocols (TCP, UDP, SCTP with IPv4 and IPv6). For each test it reports the bandwidth, loss, and other parameters. This is a new implementation that shares no code with the original iPerf and also is not backwards compatible. iPerf was orginally developed by NLANR/DAST. iPerf3 is principally developed by ESnet / Lawrence Berkeley National Laboratory. It is released under a three-clause BSD license.

iperf3是一款测量IP网络上两台设备之间最大带宽的工具。支持TCP和UDP。

官方下载地址

  • iPerf 3.1.3 (8 jun 2016 - 1.3 MiB for Windows Vista 64bits to Windows 10 64bits)

1. 安装

图简单,下载后解压缩放入C:\Windows\System32

2. 测试

2.1. 例子1-测试TCP流量

打开命令行

  • 服务器端命令:iperf3 -s
  • 客户端命令:iperf3 -c 192.168.8.28 -t 1000 -f M

参数解释

命令 功能 备注
-s 作为服务器运行  
-c 作为客户端运行,并指明服务器IP地址  
-t 客户端测试运行时间,秒为单位  
-f M表示显示MB/s单位流量  

详细使用说明请参考iperf3 -h官方资料

服务器端提示

-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Accepted connection from 192.168.8.28, port 16773
[  5] local 192.168.8.28 port 5201 connected to 192.168.8.28 port 16774
[ ID] Interval           Transfer     Bandwidth
[  5]   0.00-1.00   sec  1.08 GBytes  9.29 Gbits/sec
[  5]   1.00-2.00   sec  1.29 GBytes  11.1 Gbits/sec
[  5]   2.00-3.00   sec  1.29 GBytes  11.0 Gbits/sec
[  5]   3.00-4.00   sec  1.32 GBytes  11.3 Gbits/sec
[  5]   4.00-5.00   sec  1.41 GBytes  12.1 Gbits/sec

客户端提示

[  4] local 192.168.8.28 port 16774 connected to 192.168.8.28 port 5201
[ ID] Interval           Transfer     Bandwidth
[  4]   0.00-1.00   sec  1.08 GBytes  1108 MBytes/sec
[  4]   1.00-2.00   sec  1.29 GBytes  1321 MBytes/sec
[  4]   2.00-3.00   sec  1.29 GBytes  1317 MBytes/sec
[  4]   3.00-4.00   sec  1.32 GBytes  1347 MBytes/sec
[  4]   4.00-5.00   sec  1.41 GBytes  1448 MBytes/sec

结果分析

  • 服务器和客户端之间TCP流量达到万兆以上
  • 这么高的带宽,应该是在本地机器上测试

2.2 例子2-测试UDP流量

打开命令行

  • 服务器端命令:iperf3 -s
  • 客户端命令:iperf3 -u -c 192.168.8.88 -t 10 -b 400m

参数解释

命令 功能 备注
-u 测试UDP协议  
-c 指定服务器所在地址  
-t 60表示测试60秒  
-b 待测试带框上限,TCP默认是没有上限,UDP是1Mb/s。400m表示400Mbits/sec  

服务器端提示

Accepted connection from 192.168.8.28, port 32608

[  5] local 192.168.8.88 port 5201 connected to 192.168.8.28 port 51840

[ ID] Interval           Transfer     Bandwidth       Jitter    Lost/Total Datagrams

[  5]   0.00-1.00   sec  29.6 MBytes   249 Mbits/sec  0.372 ms  0/3795 (0%)
[  5]   1.00-2.00   sec  41.6 MBytes   349 Mbits/sec  0.408 ms  0/5320 (0%)
[  5]   2.00-3.00   sec  41.5 MBytes   349 Mbits/sec  0.418 ms  0/5318 (0%)
[  5]   3.00-4.00   sec  41.6 MBytes   349 Mbits/sec  0.391 ms  0/5323 (0%)
[  5]   4.00-5.00   sec  41.5 MBytes   348 Mbits/sec  0.360 ms  0/5314 (0%)
[  5]   5.00-6.00   sec  41.5 MBytes   349 Mbits/sec  0.354 ms  0/5318 (0%)
[  5]   6.00-7.00   sec  41.6 MBytes   349 Mbits/sec  0.343 ms  0/5322 (0%)
[  5]   7.00-8.00   sec  41.5 MBytes   349 Mbits/sec  0.339 ms  0/5318 (0%)
[  5]   8.00-9.00   sec  41.6 MBytes   349 Mbits/sec  0.340 ms  0/5322 (0%)
[  5]   9.00-10.00  sec  41.5 MBytes   349 Mbits/sec  0.113 ms  0/5318 (0%)
[  5]  10.00-10.20  sec  8.14 MBytes   348 Mbits/sec  0.215 ms  0/1042 (0%)
- - - - - - - - - - - - - - - - - - - - - - - - -

[ ID] Interval           Transfer     Bandwidth       Jitter    Lost/Total Datagrams
[  5]   0.00-10.20  sec  0.00 Bytes  0.00 bits/sec  0.215 ms  0/52710 (0%)

客户端提示


Connecting to host 192.168.8.88, port 5201

[  4] local 192.168.8.28 port 51840 connected to 192.168.8.88 port 5201
[ ID] Interval           Transfer     Bandwidth       Total Datagrams
[  4]   0.00-1.00   sec  37.8 MBytes   317 Mbits/sec  4840
[  4]   1.00-2.00   sec  41.6 MBytes   349 Mbits/sec  5320
[  4]   2.00-3.00   sec  41.6 MBytes   349 Mbits/sec  5319
[  4]   3.00-4.00   sec  41.6 MBytes   349 Mbits/sec  5320
[  4]   4.00-5.00   sec  41.5 MBytes   348 Mbits/sec  5317
[  4]   5.00-6.00   sec  41.5 MBytes   349 Mbits/sec  5318
[  4]   6.00-7.00   sec  41.6 MBytes   349 Mbits/sec  5319
[  4]   7.00-8.00   sec  41.6 MBytes   349 Mbits/sec  5320
[  4]   8.00-9.00   sec  41.6 MBytes   349 Mbits/sec  5320
[  4]   9.00-10.00  sec  41.5 MBytes   349 Mbits/sec  5318
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Jitter    Lost/Total Datagrams
[  4]   0.00-10.00  sec   412 MBytes   345 Mbits/sec  0.215 ms  0/52710 (0%)
[  4] Sent 52710 datagrams

iperf Done.

结果分析

  • 客户端192.168.8.28和服务器192.168.8.88之间最大UDP带宽达到345 Mbits/sec,Jitter抖动0.215ms,丢包率为0/52710 (0%)。无法达到期望的400Mbits/sec

3. 测试RTSP流媒体带宽

3.1 由于音视频数据以UDP为主,所以在测试UDP时,-b参数后面可从下面中选择,逐个递减来探测网络中实际UDP带宽

  1. 100m
  2. 50m
  3. 20m
  4. 10m
  5. 8m
  6. 4m
  7. 2m
  8. 1m

3.2 测试时间-t 10可以加大到60即1分钟

分析测试结果时以服务端提示Lost/Total Datagrams列不出现大于0%的丢包率为判断条件。

4. 参考

  1. NTTTCP