https://linux.die.net/man/1/iperf
https://iperf.fr/iperf-doc.php
常用参数:
-i: 报告打印周期
-B: 单播的话,指定发包源IP地址,组播的话,加入组播组
-b:发包带宽
-t: 发包时间,如果想按照发包总量,使用-n 参数
-n: 发包总数,比如-n 100M
UDP测试举例
server端:./iperf -s -u -i 5
client端:./iperf -c 25.1.0.14 -u -i 5 -b 100M -t 100000 -B 192.168.100.1 -n 100000M
如果遇到丢包,可以尝试 -l 减少报文大小试一下,比如 -l 1200
TCP测试举例:
server端:./iperf -s -i 5
client端:./iperf -c 25.1.0.14 -i 5 -b 100M -t 100000 -B 192.168.100.1 -n 100000M
组播测试举例:
server端、加入组播组:./iperf -s -u -B 230.1.1.1
[root@TENCENT64 ~]# iperf -c 230.1.1.110 -u -b 10m -t 100000 -i 10 -T 64 -B 192.70.70.1
------------------------------------------------------------
Client connecting to 230.1.1.110, UDP port 5001
Binding to local address 192.70.70.1
Sending 1470 byte datagrams, IPG target: 1176.00 us (kalman adjust)
Setting multicast TTL to 64
UDP buffer size: 224 KByte (default)
------------------------------------------------------------
[ 3] local 192.70.70.1 port 41673 connected with 230.1.1.110 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-10.0 sec 11.9 MBytes 10.0 Mbits/sec # 只有单通通,即iperf server和client能够交互数据后,才开始发送组播包
[ 3] 10.0-20.0 sec 11.9 MBytes 10.0 Mbits/sec
client端、发送组播流:./iperf -c 230.1.1.1 -u -b 1m -i 5 -t 100 -B 192.168.100.1
[root@VM_0_14_centos ~]# iperf -s -u -i 5 -B 230.1.1.110
------------------------------------------------------------
Server listening on UDP port 5001
Binding to local address 230.1.1.110
Joining multicast group 230.1.1.110
Receiving 1470 byte datagrams
UDP buffer size: 208 KByte (default)
------------------------------------------------------------
[ 3] local 230.1.1.110 port 5001 connected with 192.70.70.1 port 41673
[ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams
[ 3] 0.0- 5.0 sec 5.96 MBytes 10.0 Mbits/sec 0.001 ms 365155/369407 (99%) # 当组播流量点播下来后,才开始打印。在单播通,组播不通的情况下,不会打印类似这行的信息
[ 3] 5.0-10.0 sec 5.96 MBytes 10.0 Mbits/sec 0.001 ms 0/ 4252 (0%)