iperf测试TCP、UDP端口连通性与丢包率

文章目录

      • 一、安装iperf命令
      • 二、常用选项
      • 三、测试
        • 1.测试tcp
        • 2.测试UDP

一、安装iperf命令

Iperf是一个网络性能测试工具。可以测试TCP和UDP带宽吞吐,可以报告带宽,延迟抖动和数据包丢失。
下载地址:https://sourceforge.net/projects/iperf/
官方操作文档:https://pirlwww.lpl.arizona.edu/resources/guide/software/iperf/

[root@liang /server/Package 05:49:07]#ll iperf-2.0.5.tar.gz
-rw-r–r-- 1 root root 248583 Jul 22 05:48 iperf-2.0.5.tar.gz
[root@liang /server/Package 05:50:34]#tar zxf iperf-2.0.5.tar.gz
[root@liang /server/Package 05:51:12]#cd iperf-2.0.5
[root@liang /server/Package/iperf-2.0.5 05:52:19]#./configure --prefix=/usr/local/iperf-2.0.5
[root@liang /server/Package/iperf-2.0.5 05:52:26]#make && make install
[root@liang /server/Package/iperf-2.0.5 05:52:36]#ln -s /usr/local/iperf-2.0.5/bin/iperf /usr/local/bin/

二、常用选项

-u 使用UDP协议测试
-o 结果输出至文件
-b , --bandwidth n[KM] 指定客户端通过UDP协议发送数据的带宽(bit/s),默认是1Mbit/s。
-c 以客户端模式运行iperf,并且连接至服务端主机ServerIP。
-t 指定iperf带宽测试时间,默认是10s。
-P 指定客户端并发线程数,默认只运行一个线程。
-T 指定TTL值

三、测试

1.测试tcp

[root@liang /server/Package/iperf-2.0.5 06:04:40]#iperf -c 129.204.105.215 -p 80 -t 30 -b 2M
WARNING: option -b implies udp testing
------------------------------------------------------------
Client connecting to 129.204.105.215, UDP port 80
Sending 1470 byte datagrams
UDP buffer size: 208 KByte (default)
------------------------------------------------------------
[ 3] local 10.0.0.66 port 50955 connected with 129.204.105.215 port 80
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-30.0 sec 7.15 MBytes 2.00 Mbits/sec

.输出结果解释:
Interval表示连接测试的时间范围,通常为10s。
Transfer为在这个时间段内,客户端和服务器传输的数据总量。
Bandwidth是我们最关注的就是网络传输速率,也就是带宽。

2.测试UDP

[root@liang /server/Package/iperf-2.0.5 05:55:36]#iperf -uc 129.204.105.215 -p 8888 -t 30 -b 2M
------------------------------------------------------------
Client connecting to 129.204.105.215, UDP port 8888
Sending 1470 byte datagrams
UDP buffer size: 208 KByte (default)
------------------------------------------------------------
[ 3] local 10.0.0.66 port 40690 connected with 129.204.105.215 port 8888
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-30.0 sec 7.15 MBytes 2.00 Mbits/sec
[ 3] Sent 5103 datagrams
[ 3] WARNING: did not receive ack of last datagram after 10 tries.

你可能感兴趣的:(Linux运维,测试工具,网络)