iperf
是美国伊利诺斯大学(University of Illinois
)开发的一种开源的网络性能测试工具。可以用来测试网络节点间(包括回环)TCP
或UDP
连接的性能,包括带宽、抖动以及丢包率,其中抖动和丢包率适应于UDP
测试,而带宽测试适应于TCP
和UDP
。利用iperf
这一特性,可以用来测试一些网络设备,如路由器、防火墙、交换机等的性能。
网络的主要性能参数包括带宽、时延、抖动和丢包率,这些用一个名词代替,就是QOS
(服务质量)。对于时延,iperf
无能为力。但是iperf
能够计算抖动,测试时需要发送大量的包,因此计算出来的抖动值就是连续发送时延差值的平均值。
带宽测试通常采用UDP
模式,因为能测出极限带宽、时延抖动、丢包率。在进行测试时,首先以链路理论带宽作为数据发送速率进行测试,例如,从客户端到服务器之间的链路的理论带宽为100Mbps
,先用-b 100M
进行测试,然后根据测试结果(包括实际带宽,时延抖动和丢包率),再以实际带宽作为数据发送速率进行测试,会发现时延抖动和丢包率比第一次好很多,重复测试几次,就能得出稳定的实际带宽。
iperf
编译安装
执行make menuconfig
,按照如下方式配置:
Network --->
<M> iperf3.............. Internet Protocol bandwidth measuring tool
执行make -j8 V=99
编译,拷贝到设备后安装:
# mount -t nfs -o nolock 192.168.0.103:/opt/nfs /mnt/nfs
# opkg install /mnt/nfs/iperf3_3.0.11-1_ramips_24kec.ipk
Installing iperf3 (3.0.11-1) to root...
Configuring iperf3.
UDP模式
服务器端:
$ iperf3 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Accepted connection from 192.168.0.102, port 36420
[ 5] local 192.168.0.103 port 5201 connected to 192.168.0.102 port 47568
[ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams
[ 5] 0.00-1.00 sec 192 KBytes 1.57 Mbits/sec 11.425 ms 39/63 (62%)
[ 5] 1.00-2.00 sec 2.73 MBytes 22.9 Mbits/sec 6.296 ms 0/350 (0%)
[ 5] 2.00-3.00 sec 3.03 MBytes 25.4 Mbits/sec 3.376 ms 0/388 (0%)
[ 5] 3.00-4.00 sec 3.11 MBytes 26.1 Mbits/sec 2.895 ms 0/398 (0%)
[ 5] 4.00-5.00 sec 2.90 MBytes 24.3 Mbits/sec 3.027 ms 0/371 (0%)
[ 5] 5.00-6.00 sec 3.07 MBytes 25.8 Mbits/sec 3.963 ms 0/393 (0%)
[ 5] 6.00-7.00 sec 3.19 MBytes 26.7 Mbits/sec 4.895 ms 0/408 (0%)
[ 5] 7.00-8.00 sec 3.11 MBytes 26.1 Mbits/sec 2.836 ms 0/398 (0%)
[ 5] 8.00-9.00 sec 3.10 MBytes 26.0 Mbits/sec 3.510 ms 0/397 (0%)
[ 5] 9.00-10.00 sec 1.74 MBytes 14.6 Mbits/sec 6.831 ms 171/394 (43%)
[ 5] 10.00-10.06 sec 160 KBytes 21.3 Mbits/sec 5.124 ms 0/20 (0%)
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams
[ 5] 0.00-10.06 sec 0.00 Bytes 0.00 bits/sec 5.124 ms 210/3580 (5.9%)
客户端:
# iperf3 -u -c 192.168.0.103 -b 50M -t 10
Connecting to host 192.168.0.103, port 5201
[ 4] local 192.168.0.102 port 47568 connected to 192.168.0.103 port 5201
[ ID] Interval Transfer Bandwidth Total Datagrams
[ 4] 0.00-1.00 sec 704 KBytes 5.77 Mbits/sec 88
[ 4] 1.00-2.00 sec 2.77 MBytes 23.2 Mbits/sec 354
[ 4] 2.00-3.00 sec 3.03 MBytes 25.4 Mbits/sec 388
[ 4] 3.00-4.00 sec 3.09 MBytes 25.9 Mbits/sec 395
[ 4] 4.00-5.00 sec 2.92 MBytes 24.5 Mbits/sec 374
[ 4] 5.00-6.00 sec 3.09 MBytes 25.9 Mbits/sec 395
[ 4] 6.00-7.00 sec 3.20 MBytes 26.9 Mbits/sec 410
[ 4] 7.00-8.00 sec 3.08 MBytes 25.8 Mbits/sec 394
[ 4] 8.00-9.00 sec 3.09 MBytes 26.0 Mbits/sec 396
[ 4] 9.00-10.00 sec 3.04 MBytes 25.5 Mbits/sec 389
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams
[ 4] 0.00-10.00 sec 28.0 MBytes 23.5 Mbits/sec 5.124 ms 210/3580 (5.9%)
[ 4] Sent 3580 datagrams
iperf Done.
在udp
模式下,以50Mbps
为数据发送速率,客户端到服务器192.168.0.103
上传带宽测试,测试时间为10
秒。
# iperf3 -u -c 192.168.0.103 -b 5M -P 10 -t 10
客户端同时向服务器端发起10
个连接线程,以5Mbps
为数据发送速率。
# iperf3 -u -c 192.168.0.103 -b 50M -d -t 10
以50M
为数据发送速率,进行上下行带宽测试。
TCP模式
服务器端:
$ iperf3 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Accepted connection from 192.168.0.102, port 36424
[ 5] local 192.168.0.103 port 5201 connected to 192.168.0.102 port 36425
[ ID] Interval Transfer Bandwidth
[ 5] 0.00-1.00 sec 116 KBytes 949 Kbits/sec
[ 5] 1.00-2.00 sec 642 KBytes 5.26 Mbits/sec
[ 5] 2.00-3.00 sec 2.25 MBytes 18.9 Mbits/sec
[ 5] 3.00-4.00 sec 2.61 MBytes 21.9 Mbits/sec
[ 5] 4.00-5.00 sec 2.74 MBytes 23.0 Mbits/sec
[ 5] 5.00-6.00 sec 2.94 MBytes 24.7 Mbits/sec
[ 5] 6.00-7.00 sec 2.77 MBytes 23.3 Mbits/sec
[ 5] 7.00-8.00 sec 2.97 MBytes 24.9 Mbits/sec
[ 5] 8.00-9.00 sec 3.29 MBytes 27.6 Mbits/sec
[ 5] 9.00-10.00 sec 3.11 MBytes 26.1 Mbits/sec
[ 5] 10.00-10.15 sec 369 KBytes 20.9 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth
[ 5] 0.00-10.15 sec 0.00 Bytes 0.00 bits/sec sender
[ 5] 0.00-10.15 sec 23.8 MBytes 19.7 Mbits/sec receiver
-----------------------------------------------------------
客户端:
# iperf3 -c 192.168.0.103 -t 10
Connecting to host 192.168.0.103, port 5201
[ 4] local 192.168.0.102 port 36425 connected to 192.168.0.103 port 5201
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-1.00 sec 184 KBytes 1.51 Mbits/sec 20 24.0 KBytes
[ 4] 1.00-2.00 sec 735 KBytes 6.02 Mbits/sec 17 43.8 KBytes
[ 4] 2.00-3.00 sec 2.29 MBytes 19.2 Mbits/sec 0 76.4 KBytes
[ 4] 3.00-4.00 sec 2.69 MBytes 22.5 Mbits/sec 0 123 KBytes
[ 4] 4.00-5.00 sec 2.88 MBytes 24.2 Mbits/sec 0 215 KBytes
[ 4] 5.00-6.00 sec 3.04 MBytes 25.5 Mbits/sec 0 338 KBytes
[ 4] 6.00-7.00 sec 2.75 MBytes 23.1 Mbits/sec 0 417 KBytes
[ 4] 7.00-8.00 sec 3.03 MBytes 25.4 Mbits/sec 0 457 KBytes
[ 4] 8.00-9.00 sec 3.36 MBytes 28.2 Mbits/sec 0 499 KBytes
[ 4] 9.00-10.00 sec 3.14 MBytes 26.3 Mbits/sec 0 522 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-10.00 sec 24.1 MBytes 20.2 Mbits/sec 37 sender
[ 4] 0.00-10.00 sec 23.8 MBytes 20.0 Mbits/sec receiver
iperf Done.
在tcp
模式下,客户端到服务器192.168.0.103
上传带宽测试,测试时间为10
秒。
# iperf3 -c 192.168.0.103 -P 10 -t 10
客户端同时向服务器端发起10
个连接线程。
# iperf3 -c 192.168.0.103 -d -t 10
进行上下行带宽测试。
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。