http://blog.163.com/frank_spr/blog/static/22926500520159253346691/
iperf的主要功能:
1)TCP方面
测试网络带宽
支持多线程,在客户端和服务端支持多重连接
报告MSS/MTU值的大小
支持TCP窗口值自定义并可通过套接字缓冲
2)UDP方面
可设置指定带宽的UDP数据流
可以测试网络抖动值、丢包数
支持多播 测试
支持多线程,在客户端和服务端支持多重连接
安装:
tar -xzvf iperf-3.1b3.tar.gz
cd iperf-3.1b3/
./configure
make
make install
应用实例:
1)测试TCP吞吐量
服务端:
iperf3 -s
suse11-2:/soft/iperf-3.1b3 # iperf3 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
客户端:
SUSE01:/soft # iperf3 -c 192.168.17.142
Connecting to host 192.168.17.142, port 5201
[ 4] local 192.168.17.141 port 48107 connected to 192.168.17.142 port 5201
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-1.00 sec 51.1 MBytes 428 Mbits/sec 5 151 KBytes
[ 4] 1.00-2.00 sec 86.1 MBytes 723 Mbits/sec 0 175 KBytes
[ 4] 2.00-3.00 sec 72.8 MBytes 611 Mbits/sec 1 102 KBytes
[ 4] 3.00-4.00 sec 84.8 MBytes 712 Mbits/sec 0 112 KBytes
[ 4] 4.00-5.00 sec 76.5 MBytes 641 Mbits/sec 0 124 KBytes
[ 4] 5.00-6.00 sec 79.9 MBytes 671 Mbits/sec 0 132 KBytes
[ 4] 6.00-7.00 sec 82.0 MBytes 688 Mbits/sec 0 137 KBytes
[ 4] 7.00-8.00 sec 84.5 MBytes 709 Mbits/sec 0 144 KBytes
[ 4] 8.00-9.00 sec 72.8 MBytes 608 Mbits/sec 0 153 KBytes
[ 4] 9.00-10.00 sec 79.6 MBytes 670 Mbits/sec 0 158 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-10.00 sec 770 MBytes 646 Mbits/sec 6 sender
[ 4] 0.00-10.00 sec 769 MBytes 645 Mbits/sec receiver
iperf Done.
SUSE01:/soft #
iperf默认运行时间10s,每隔1s输出一次传输状态,同时还可以看到每秒传输的数据量在50~80M之间(我的是虚拟机环境)
刚好与Bandwidth列的值对应起来,网卡的带宽平均速率维持在500Mbits/sec
改变iperf运行时间和输出频率:
-t 和-i 参数来实现
SUSE01:/soft # iperf3 -c 192.168.17.142 -t 20 -i 5
Connecting to host 192.168.17.142, port 5201
[ 4] local 192.168.17.141 port 48109 connected to 192.168.17.142 port 5201
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-5.01 sec 301 MBytes 504 Mbits/sec 52 124 KBytes
[ 4] 5.01-10.00 sec 344 MBytes 578 Mbits/sec 0 168 KBytes
[ 4] 10.00-15.01 sec 369 MBytes 618 Mbits/sec 5 158 KBytes
[ 4] 15.01-20.00 sec 355 MBytes 596 Mbits/sec 90 129 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-20.00 sec 1.34 GBytes 574 Mbits/sec 147 sender
[ 4] 0.00-20.00 sec 1.34 GBytes 574 Mbits/sec receiver
iperf Done.
SUSE01:/soft #
模拟大量数据传输:-n指定传输的数据量
SUSE01:/soft # iperf3 -c 192.168.17.142 -i 10 -n 5000000000
Connecting to host 192.168.17.142, port 5201
[ 4] local 192.168.17.141 port 48111 connected to 192.168.17.142 port 5201
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-10.00 sec 652 MBytes 547 Mbits/sec 11 150 KBytes
[ 4] 10.00-20.00 sec 582 MBytes 488 Mbits/sec 8 160 KBytes
[ 4] 20.00-30.00 sec 671 MBytes 562 Mbits/sec 6 148 KBytes
[ 4] 30.00-40.00 sec 494 MBytes 414 Mbits/sec 3 137 KBytes
[ 4] 40.00-50.01 sec 683 MBytes 573 Mbits/sec 46 140 KBytes
[ 4] 50.01-60.00 sec 591 MBytes 496 Mbits/sec 3 144 KBytes
[ 4] 60.00-70.00 sec 660 MBytes 554 Mbits/sec 45 180 KBytes
[ 4] 70.00-77.90 sec 436 MBytes 463 Mbits/sec 46 180 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-77.90 sec 4.66 GBytes 513 Mbits/sec 168 sender
[ 4] 0.00-77.90 sec 4.66 GBytes 513 Mbits/sec receiver
iperf Done.
模拟TCP一个特定文件发送数据:-F
SUSE01:/soft # iperf3 -c 192.168.17.142 -F test.dbf -i 5 -t 40
Connecting to host 192.168.17.142, port 5201
[ 4] local 192.168.17.141 port 48115 connected to 192.168.17.142 port 5201
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-5.01 sec 82.7 MBytes 139 Mbits/sec 8 117 KBytes
[ 4] 5.01-10.02 sec 117 MBytes 195 Mbits/sec 0 168 KBytes
[ 4] 10.02-15.00 sec 84.7 MBytes 143 Mbits/sec 7 110 KBytes
[ 4] 15.00-20.04 sec 106 MBytes 177 Mbits/sec 0 158 KBytes
[ 4] 20.04-25.00 sec 105 MBytes 177 Mbits/sec 12 140 KBytes
[ 4] 25.00-30.00 sec 126 MBytes 212 Mbits/sec 0 174 KBytes
[ 4] 30.00-35.03 sec 129 MBytes 215 Mbits/sec 1 148 KBytes
[ 4] 35.03-40.00 sec 105 MBytes 178 Mbits/sec 6 32.5 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-40.00 sec 856 MBytes 179 Mbits/sec 34 sender
Sent 856 MByte / 1000 MByte (85%) of test.dbf
[ 4] 0.00-40.00 sec 855 MBytes 179 Mbits/sec receiver
iperf Done.
将结果输出都以MBytes/sec来显示: -f M
SUSE01:/soft # iperf3 -c 192.168.17.142 -n 2000000000 -i 5 -f M
Connecting to host 192.168.17.142, port 5201
[ 4] local 192.168.17.141 port 48117 connected to 192.168.17.142 port 5201
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-5.00 sec 388 MBytes 77.6 MBytes/sec 6 115 KBytes
[ 4] 5.00-10.03 sec 283 MBytes 56.2 MBytes/sec 0 165 KBytes
[ 4] 10.03-15.00 sec 181 MBytes 36.4 MBytes/sec 9 151 KBytes
[ 4] 15.00-20.01 sec 229 MBytes 45.7 MBytes/sec 0 181 KBytes
[ 4] 20.01-25.00 sec 379 MBytes 75.9 MBytes/sec 47 146 KBytes
[ 4] 25.00-30.00 sec 333 MBytes 66.5 MBytes/sec 2 134 KBytes
[ 4] 30.00-31.71 sec 116 MBytes 67.8 MBytes/sec 0 174 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-31.71 sec 1.86 GBytes 60.2 MBytes/sec 64 sender
[ 4] 0.00-31.71 sec 1.86 GBytes 60.1 MBytes/sec receiver
iperf Done.
多线程:-P
SUSE01:/soft # iperf3 -c 192.168.17.142 -n 2000000000 -i 5 -f M -P 2
Connecting to host 192.168.17.142, port 5201
[ 4] local 192.168.17.141 port 48119 connected to 192.168.17.142 port 5201
[ 6] local 192.168.17.141 port 48120 connected to 192.168.17.142 port 5201
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-5.09 sec 126 MBytes 24.7 MBytes/sec 46 117 KBytes
[ 6] 0.00-5.09 sec 104 MBytes 20.4 MBytes/sec 102 99.0 KBytes
[SUM] 0.00-5.09 sec 229 MBytes 45.1 MBytes/sec 148
- - - - - - - - - - - - - - - - - - - - - - - - -
[ 4] 5.09-10.00 sec 139 MBytes 28.3 MBytes/sec 31 93.3 KBytes
[ 6] 5.09-10.00 sec 141 MBytes 28.7 MBytes/sec 16 115 KBytes
[SUM] 5.09-10.00 sec 280 MBytes 57.0 MBytes/sec 47
- - - - - - - - - - - - - - - - - - - - - - - - -
[ 4] 10.00-15.06 sec 108 MBytes 21.4 MBytes/sec 0 158 KBytes
[ 6] 10.00-15.06 sec 98.2 MBytes 19.4 MBytes/sec 60 2.83 KBytes
[SUM] 10.00-15.06 sec 206 MBytes 40.8 MBytes/sec 60
- - - - - - - - - - - - - - - - - - - - - - - - -
[ 4] 15.06-20.00 sec 126 MBytes 25.6 MBytes/sec 38 70.7 KBytes
[ 6] 15.06-20.00 sec 141 MBytes 28.5 MBytes/sec 0 117 KBytes
[SUM] 15.06-20.00 sec 267 MBytes 54.0 MBytes/sec 38
- - - - - - - - - - - - - - - - - - - - - - - - -
[ 4] 20.00-25.00 sec 131 MBytes 26.2 MBytes/sec 11 96.2 KBytes
[ 6] 20.00-25.00 sec 141 MBytes 28.1 MBytes/sec 2 113 KBytes
[SUM] 20.00-25.00 sec 272 MBytes 54.3 MBytes/sec 13
- - - - - - - - - - - - - - - - - - - - - - - - -
[ 4] 25.00-30.11 sec 129 MBytes 25.2 MBytes/sec 24 67.9 KBytes
[ 6] 25.00-30.11 sec 146 MBytes 28.6 MBytes/sec 19 126 KBytes
[SUM] 25.00-30.11 sec 275 MBytes 53.7 MBytes/sec 43
- - - - - - - - - - - - - - - - - - - - - - - - -
[ 4] 30.11-35.01 sec 107 MBytes 21.9 MBytes/sec 32 74.9 KBytes
[ 6] 30.11-35.01 sec 99.6 MBytes 20.3 MBytes/sec 41 105 KBytes
[SUM] 30.11-35.01 sec 207 MBytes 42.2 MBytes/sec 73
- - - - - - - - - - - - - - - - - - - - - - - - -
[ 4] 35.01-38.33 sec 84.9 MBytes 25.6 MBytes/sec 22 83.4 KBytes
[ 6] 35.01-38.33 sec 86.4 MBytes 26.0 MBytes/sec 3 113 KBytes
[SUM] 35.01-38.33 sec 171 MBytes 51.6 MBytes/sec 25
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-38.33 sec 951 MBytes 24.8 MBytes/sec 204 sender
[ 4] 0.00-38.33 sec 950 MBytes 24.8 MBytes/sec receiver
[ 6] 0.00-38.33 sec 956 MBytes 24.9 MBytes/sec 243 sender
[ 6] 0.00-38.33 sec 956 MBytes 24.9 MBytes/sec receiver
[SUM] 0.00-38.33 sec 1.86 GBytes 49.8 MBytes/sec 447 sender
[SUM] 0.00-38.33 sec 1.86 GBytes 49.7 MBytes/sec receiver
iperf Done.
SUSE01:/soft #
测试UDP丢包和延迟
SUSE01:/soft # iperf3 -c 192.168.17.142 -u -b 100M -f M -i 3
Connecting to host 192.168.17.142, port 5201
[ 4] local 192.168.17.141 port 44195 connected to 192.168.17.142 port 5201
[ ID] Interval Transfer Bandwidth Total Datagrams
[ 4] 0.00-3.00 sec 34.6 MBytes 11.5 MBytes/sec 4428
[ 4] 3.00-6.00 sec 36.1 MBytes 12.0 MBytes/sec 4625
[ 4] 6.00-9.00 sec 35.7 MBytes 11.9 MBytes/sec 4564
[ 4] 9.00-10.00 sec 12.4 MBytes 12.4 MBytes/sec 1589
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams
[ 4] 0.00-10.00 sec 119 MBytes 11.9 MBytes/sec 0.340 ms 357/15206 (2.3%)
[ 4] Sent 15206 datagrams
iperf Done.