Think before you speak, read before you think.

使用iperf测试网络的性能

准备工作:

安装epel源

rpm -ivh http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm

更新本地cache安装iperf

yum makecache -y
yum install iperf -y

 

测试工作:

192.168.0.244为server端,192.168.0.236为client端

在server端和client端可以查看到传输的情况,还可以通过ifstat, iptraf查看网卡的流量

TCP测试

server(0.244)

iperf -s -i 1

-s 服务器模式

-i 报告显示间隔秒数

client(0.236)

iperf -t 20 -i 1 -c 192.168.0.244

-t 测试用时的秒数

-c 客户端模式,后面接要连接的服务器

服务端显示:

------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 32.0 KByte (default)
------------------------------------------------------------
[ 4] local 192.168.0.244 port 5001 connected with 192.168.0.236 port 54921
[ ID] Interval Transfer Bandwidth
[ 4] 0.0- 1.0 sec 112 MBytes 938 Mbits/sec
[ 4] 1.0- 2.0 sec 112 MBytes 942 Mbits/sec
[ 4] 2.0- 3.0 sec 112 MBytes 942 Mbits/sec
[ 4] 3.0- 4.0 sec 112 MBytes 941 Mbits/sec
[ 4] 4.0- 5.0 sec 112 MBytes 942 Mbits/sec
[ 4] 5.0- 6.0 sec 112 MBytes 942 Mbits/sec
[ 4] 6.0- 7.0 sec 112 MBytes 942 Mbits/sec
[ 4] 7.0- 8.0 sec 112 MBytes 941 Mbits/sec
[ 4] 8.0- 9.0 sec 112 MBytes 942 Mbits/sec
[ 4] 9.0-10.0 sec 112 MBytes 942 Mbits/sec
[ 4] 10.0-11.0 sec 112 MBytes 942 Mbits/sec
[ 4] 11.0-12.0 sec 112 MBytes 941 Mbits/sec
[ 4] 12.0-13.0 sec 112 MBytes 942 Mbits/sec
[ 4] 13.0-14.0 sec 112 MBytes 942 Mbits/sec
[ 4] 14.0-15.0 sec 112 MBytes 942 Mbits/sec
[ 4] 15.0-16.0 sec 112 MBytes 941 Mbits/sec
[ 4] 16.0-17.0 sec 112 MBytes 941 Mbits/sec
[ 4] 17.0-18.0 sec 112 MBytes 941 Mbits/sec
[ 4] 18.0-19.0 sec 112 MBytes 942 Mbits/sec
[ 4] 19.0-20.0 sec 112 MBytes 942 Mbits/sec
[ 4] 0.0-20.0 sec 2.20 GBytes 941 Mbits/sec

客户端显示:

------------------------------------------------------------
Client connecting to 192.168.0.244, TCP port 5001
TCP window size: 23.2 KByte (default)
------------------------------------------------------------
[ 3] local 192.168.0.236 port 54921 connected with 192.168.0.244 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0- 1.0 sec 115 MBytes 965 Mbits/sec
[ 3] 1.0- 2.0 sec 112 MBytes 937 Mbits/sec
[ 3] 2.0- 3.0 sec 113 MBytes 946 Mbits/sec
[ 3] 3.0- 4.0 sec 113 MBytes 946 Mbits/sec
[ 3] 4.0- 5.0 sec 112 MBytes 935 Mbits/sec
[ 3] 5.0- 6.0 sec 113 MBytes 946 Mbits/sec
[ 3] 6.0- 7.0 sec 112 MBytes 935 Mbits/sec
[ 3] 7.0- 8.0 sec 113 MBytes 946 Mbits/sec
[ 3] 8.0- 9.0 sec 113 MBytes 946 Mbits/sec
[ 3] 9.0-10.0 sec 111 MBytes 934 Mbits/sec
[ 3] 10.0-11.0 sec 113 MBytes 946 Mbits/sec
[ 3] 11.0-12.0 sec 111 MBytes 934 Mbits/sec
[ 3] 12.0-13.0 sec 113 MBytes 945 Mbits/sec
[ 3] 13.0-14.0 sec 113 MBytes 945 Mbits/sec
[ 3] 14.0-15.0 sec 113 MBytes 946 Mbits/sec
[ 3] 15.0-16.0 sec 111 MBytes 931 Mbits/sec
[ 3] 16.0-17.0 sec 113 MBytes 948 Mbits/sec
[ 3] 17.0-18.0 sec 111 MBytes 934 Mbits/sec
[ 3] 18.0-19.0 sec 113 MBytes 945 Mbits/sec
[ 3] 19.0-20.0 sec 113 MBytes 948 Mbits/sec
[ 3] 0.0-20.0 sec 2.20 GBytes 942 Mbits/sec

UDP 测试

 

server(0.244): iperf -u -s -i 1

client(0.236): iperf -t 20 -i 1 -u -b 1000M -c 192.168.0.244

 

-u 使用udp协议

-b 后面接每秒带宽发送量(udp下适用)

 

服务器显示

------------------------------------------------------------
Server listening on UDP port 5001
Receiving 1470 byte datagrams
UDP buffer size: 224 KByte (default)
------------------------------------------------------------
[ 3] local 192.168.0.244 port 5001 connected with 192.168.0.236 port 34489
[ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams
[ 3] 0.0- 1.0 sec 128 KBytes 1.05 Mbits/sec 0.013 ms 0/ 89 (0%)
[ 3] 1.0- 2.0 sec 128 KBytes 1.05 Mbits/sec 0.010 ms 0/ 89 (0%)
[ 3] 2.0- 3.0 sec 128 KBytes 1.05 Mbits/sec 0.015 ms 0/ 89 (0%)
[ 3] 3.0- 4.0 sec 128 KBytes 1.05 Mbits/sec 0.012 ms 0/ 89 (0%)
[ 3] 4.0- 5.0 sec 128 KBytes 1.05 Mbits/sec 0.008 ms 0/ 89 (0%)
[ 3] 5.0- 6.0 sec 129 KBytes 1.06 Mbits/sec 0.008 ms 0/ 90 (0%)
[ 3] 6.0- 7.0 sec 128 KBytes 1.05 Mbits/sec 0.009 ms 0/ 89 (0%)
[ 3] 7.0- 8.0 sec 128 KBytes 1.05 Mbits/sec 0.019 ms 0/ 89 (0%)
[ 3] 8.0- 9.0 sec 128 KBytes 1.05 Mbits/sec 0.011 ms 0/ 89 (0%)
[ 3] 9.0-10.0 sec 128 KBytes 1.05 Mbits/sec 0.009 ms 0/ 89 (0%)
[ 3] 10.0-11.0 sec 128 KBytes 1.05 Mbits/sec 0.014 ms 0/ 89 (0%)
[ 3] 11.0-12.0 sec 129 KBytes 1.06 Mbits/sec 0.014 ms 0/ 90 (0%)
[ 3] 12.0-13.0 sec 128 KBytes 1.05 Mbits/sec 0.009 ms 0/ 89 (0%)
[ 3] 13.0-14.0 sec 128 KBytes 1.05 Mbits/sec 0.017 ms 0/ 89 (0%)
[ 3] 14.0-15.0 sec 128 KBytes 1.05 Mbits/sec 0.016 ms 0/ 89 (0%)
[ 3] 15.0-16.0 sec 128 KBytes 1.05 Mbits/sec 0.011 ms 0/ 89 (0%)
[ 3] 16.0-17.0 sec 128 KBytes 1.05 Mbits/sec 0.012 ms 0/ 89 (0%)
[ 3] 17.0-18.0 sec 129 KBytes 1.06 Mbits/sec 0.017 ms 0/ 90 (0%)
[ 3] 18.0-19.0 sec 128 KBytes 1.05 Mbits/sec 0.018 ms 0/ 89 (0%)
[ 3] 19.0-20.0 sec 128 KBytes 1.05 Mbits/sec 0.012 ms 0/ 89 (0%)
[ 3] 0.0-20.0 sec 2.50 MBytes 1.05 Mbits/sec 0.013 ms 0/ 1785 (0%)

客户端显示

------------------------------------------------------------
Client connecting to 192.168.0.244, UDP port 5001
Sending 1470 byte datagrams
UDP buffer size: 224 KByte (default)
------------------------------------------------------------
[ 3] local 192.168.0.236 port 34489 connected with 192.168.0.244 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0- 1.0 sec 129 KBytes 1.06 Mbits/sec
[ 3] 1.0- 2.0 sec 128 KBytes 1.05 Mbits/sec
[ 3] 2.0- 3.0 sec 128 KBytes 1.05 Mbits/sec
[ 3] 3.0- 4.0 sec 128 KBytes 1.05 Mbits/sec
[ 3] 4.0- 5.0 sec 128 KBytes 1.05 Mbits/sec
[ 3] 5.0- 6.0 sec 128 KBytes 1.05 Mbits/sec
[ 3] 6.0- 7.0 sec 129 KBytes 1.06 Mbits/sec
[ 3] 7.0- 8.0 sec 128 KBytes 1.05 Mbits/sec
[ 3] 8.0- 9.0 sec 128 KBytes 1.05 Mbits/sec
[ 3] 9.0-10.0 sec 128 KBytes 1.05 Mbits/sec
[ 3] 10.0-11.0 sec 128 KBytes 1.05 Mbits/sec
[ 3] 11.0-12.0 sec 128 KBytes 1.05 Mbits/sec
[ 3] 12.0-13.0 sec 129 KBytes 1.06 Mbits/sec
[ 3] 13.0-14.0 sec 128 KBytes 1.05 Mbits/sec
[ 3] 14.0-15.0 sec 128 KBytes 1.05 Mbits/sec
[ 3] 15.0-16.0 sec 128 KBytes 1.05 Mbits/sec
[ 3] 16.0-17.0 sec 128 KBytes 1.05 Mbits/sec
[ 3] 17.0-18.0 sec 128 KBytes 1.05 Mbits/sec
[ 3] 18.0-19.0 sec 129 KBytes 1.06 Mbits/sec
[ 3] 19.0-20.0 sec 128 KBytes 1.05 Mbits/sec
[ 3] 0.0-20.0 sec 2.50 MBytes 1.05 Mbits/sec
[ 3] Sent 1785 datagrams
[ 3] Server Report:
[ 3] 0.0-20.0 sec 2.50 MBytes 1.05 Mbits/sec 0.013 ms 0/ 1785 (0%)

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *