网络性能测试之iperf的安装使用
Iperf 是一个网络性能测试工具。Iperf可以测试TCP和UDP带宽质量。Iperf可以测量最大TCP带宽,具有多种参数和UDP特性。Iperf可以报告带宽,延迟抖动和数据包丢失。

Iperf使用方法与参数说明

参数说明
-s 以server模式启动,eg:iperf -s
-c host以client模式启动,host是server端地址,eg:iperf -c 222.35.11.23
通用参数
-f [k|m|K|M] 分别表示以Kbits, Mbits, KBytes, MBytes显示报告,默认以Mbits为单位,eg:iperf -c 222.35.11.23 -f K
-i sec 以秒为单位显示报告间隔,eg:iperf -c 222.35.11.23 -i 2
-l 缓冲区大小,默认是8KB,eg:iperf -c 222.35.11.23 -l 16
-m 显示tcp最大mtu值
-o 将报告和错误信息输出到文件eg:iperf -c 222.35.11.23 -o c:\iperflog.txt
-p 指定服务器端使用的端口或客户端所连接的端口eg:iperf -s -p 9999;iperf -c 222.35.11.23 -p 9999
-u 使用udp协议
-w 指定TCP窗口大小,默认是8KB
-B 绑定一个主机地址或接口(当主机有多个地址或接口时使用该参数)
-C 兼容旧版本(当server端和client端版本不一样时使用)
-M 设定TCP数据包的最大mtu值
-N 设定TCP不延时
-V 传输ipv6数据包

server专用参数
-D 以服务方式运行ipserf,eg:iperf -s -D
-R 停止iperf服务,针对-D,eg:iperf -s -R

client端专用参数
-d 同时进行双向传输测试
-n 指定传输的字节数,eg:iperf -c 222.35.11.23 -n 100000
-r 单独进行双向传输测试
-t 测试时间,默认10秒,eg:iperf -c 222.35.11.23 -t 5
-F 指定需要传输的文件
-T 指定ttl值

[root@server1 opt]# tar -xzvf iperf-2.0.4.tar.gz 
[root@server1 opt]# cd iperf-2.0.4
[root@server1 iperf-2.0.4]# ./configure
[root@server1 iperf-2.0.4]# make && make install

同样分为服务端和客户端
按照以上方法分别安装于两台linux服务器
在其中一台启动iperf

[root@server1 iperf-2.0.4]#iperf -s -D
Running Iperf Server as a daemon
The Iperf daemon process ID : 12091
从另外一台连接过来

[root@server2 iperf-2.0.4]# iperf -c 10.10.10.130 -i 1
------------------------------------------------------------
Client connecting to 10.10.10.130, TCP port 5001
TCP window size: 40.2 KByte (default)
------------------------------------------------------------
[  3] local 10.10.10.131 port 33745 connected with 10.10.10.130 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0- 1.0 sec  21.8 MBytes    183 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  1.0- 2.0 sec  22.1 MBytes    185 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  2.0- 3.0 sec  18.3 MBytes    154 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  3.0- 4.0 sec  21.7 MBytes    182 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  4.0- 5.0 sec  21.1 MBytes    177 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  5.0- 6.0 sec  21.1 MBytes    177 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  6.0- 7.0 sec  21.1 MBytes    177 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  7.0- 8.0 sec  20.9 MBytes    176 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  8.0- 9.0 sec  21.8 MBytes    183 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  9.0-10.0 sec  21.5 MBytes    181 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec    212 MBytes    177 Mbits/sec
[root@server2 iperf-2.0.4]# iperf -c 10.10.10.130 -M -i 1
iperf: ignoring extra argument -- 1
------------------------------------------------------------
Client connecting to 10.10.10.130, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[  3] local 10.10.10.131 port 33746 connected with 10.10.10.130 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec    319 MBytes    267 Mbits/sec
[root@server2 iperf-2.0.4]# iperf -c 10.10.10.130 -f M -i 1
------------------------------------------------------------
Client connecting to 10.10.10.130, TCP port 5001
TCP window size: 0.03 MByte (default)
------------------------------------------------------------
[  3] local 10.10.10.131 port 33747 connected with 10.10.10.130 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0- 1.0 sec  23.6 MBytes  23.6 MBytes/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  1.0- 2.0 sec  21.9 MBytes  21.9 MBytes/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  2.0- 3.0 sec  22.8 MBytes  22.8 MBytes/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  3.0- 4.0 sec  22.7 MBytes  22.7 MBytes/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  4.0- 5.0 sec  22.4 MBytes  22.4 MBytes/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  5.0- 6.0 sec  22.9 MBytes  22.9 MBytes/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  6.0- 7.0 sec  22.2 MBytes  22.2 MBytes/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  7.0- 8.0 sec  22.4 MBytes  22.4 MBytes/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  8.0- 9.0 sec  22.7 MBytes  22.7 MBytes/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  9.0-10.0 sec  22.5 MBytes  22.5 MBytes/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec    226 MBytes  22.6 MBytes/sec
[root@server2 iperf-2.0.4]# iperf -c 10.10.10.130 -f M -u -i 1
------------------------------------------------------------
Client connecting to 10.10.10.130, UDP port 5001
Sending 1470 byte datagrams
UDP buffer size: 0.10 MByte (default)
------------------------------------------------------------
[  3] local 10.10.10.131 port 36631 connected with 10.10.10.130 port 5001
write2 failed: Connection refused
[ ID] Interval       Transfer     Bandwidth
read failed: Connection refused
[  3] WARNING: did not receive ack of last datagram after 1 tries.
[  3]  0.0- 0.1 sec  0.00 MBytes  0.01 MBytes/sec
[  3] Sent 1 datagrams
[root@server2 iperf-2.0.4]# iperf -c 10.10.10.130 -f M u -i 1
iperf: ignoring extra argument -- u
------------------------------------------------------------
Client connecting to 10.10.10.130, TCP port 5001
TCP window size: 0.03 MByte (default)
------------------------------------------------------------
[  3] local 10.10.10.131 port 56851 connected with 10.10.10.130 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0- 1.0 sec  24.0 MBytes  24.0 MBytes/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  1.0- 2.0 sec  22.2 MBytes  22.2 MBytes/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  2.0- 3.0 sec  22.8 MBytes  22.8 MBytes/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  3.0- 4.0 sec  22.4 MBytes  22.4 MBytes/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  4.0- 5.0 sec  22.2 MBytes  22.2 MBytes/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  5.0- 6.0 sec  22.9 MBytes  22.9 MBytes/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  6.0- 7.0 sec  22.3 MBytes  22.3 MBytes/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  7.0- 8.0 sec  22.8 MBytes  22.8 MBytes/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  8.0- 9.0 sec  22.8 MBytes  22.8 MBytes/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  9.0-10.0 sec  22.6 MBytes  22.6 MBytes/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec    227 MBytes  22.7 MBytes/sec
[root@server2 iperf-2.0.4]# 

[root@server2 iperf-2.0.4]# iperf -c 10.10.10.130 -i 1 -w 2048
------------------------------------------------------------
Client connecting to 10.10.10.130, TCP port 5001
TCP window size: 4.00 KByte (WARNING: requested 2.00 KByte)
------------------------------------------------------------
[  3] local 10.10.10.131 port 56582 connected with 10.10.10.130 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0- 1.0 sec  2.09 MBytes  17.6 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  1.0- 2.0 sec  2.05 MBytes  17.2 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  2.0- 3.0 sec  2.02 MBytes  16.9 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  3.0- 4.0 sec  2.12 MBytes  17.8 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  4.0- 5.0 sec  2.07 MBytes  17.4 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  5.0- 6.0 sec  1.82 MBytes  15.3 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  6.0- 7.0 sec  1.93 MBytes  16.2 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  7.0- 8.0 sec  2.06 MBytes  17.3 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  8.0- 9.0 sec  2.12 MBytes  17.8 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  9.0-10.0 sec  2.12 MBytes  17.8 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec  20.4 MBytes  17.1 Mbits/sec
[root@server2 iperf-2.0.4]# iperf -c 10.10.10.130 -i 1 -w 20480
------------------------------------------------------------
Client connecting to 10.10.10.130, TCP port 5001
TCP window size: 40.0 KByte (WARNING: requested 20.0 KByte)
------------------------------------------------------------
[  3] local 10.10.10.131 port 56583 connected with 10.10.10.130 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0- 1.0 sec  8.56 MBytes  71.8 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  1.0- 2.0 sec  7.51 MBytes  63.0 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  2.0- 3.0 sec  7.24 MBytes  60.8 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  3.0- 4.0 sec  6.79 MBytes  57.0 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  4.0- 5.0 sec  7.85 MBytes  65.9 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  5.0- 6.0 sec  6.16 MBytes  51.7 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  6.0- 7.0 sec  8.26 MBytes  69.3 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  7.0- 8.0 sec  8.36 MBytes  70.1 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  8.0- 9.0 sec  8.59 MBytes  72.0 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  9.0-10.0 sec  8.14 MBytes  68.3 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec  77.5 MBytes  65.0 Mbits/sec
[root@server2 iperf-2.0.4]# iperf -c 10.10.10.130 -i 1 -w 204800
------------------------------------------------------------
Client connecting to 10.10.10.130, TCP port 5001
TCP window size:   256 KByte (WARNING: requested   200 KByte)
------------------------------------------------------------
[  3] local 10.10.10.131 port 56584 connected with 10.10.10.130 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0- 1.0 sec  23.2 MBytes    194 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  1.0- 2.0 sec  22.0 MBytes    185 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  2.0- 3.0 sec  22.2 MBytes    187 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  3.0- 4.0 sec  22.5 MBytes    189 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  4.0- 5.0 sec  22.3 MBytes    187 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  5.0- 6.0 sec  22.6 MBytes    190 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  6.0- 7.0 sec  22.1 MBytes    185 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  7.0- 8.0 sec  22.3 MBytes    187 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  8.0- 9.0 sec  22.6 MBytes    190 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  9.0-10.0 sec  22.4 MBytes    188 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec    224 MBytes    188 Mbits/sec
[root@server2 iperf-2.0.4]# iperf -c 10.10.10.130 -i 1 -w 2048000
------------------------------------------------------------
Client connecting to 10.10.10.130, TCP port 5001
TCP window size:   256 KByte (WARNING: requested 1.95 MByte)
------------------------------------------------------------
[  3] local 10.10.10.131 port 56585 connected with 10.10.10.130 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0- 1.0 sec  24.5 MBytes    205 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  1.0- 2.0 sec  21.9 MBytes    184 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  2.0- 3.0 sec  22.8 MBytes    191 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  3.0- 4.0 sec  22.4 MBytes    188 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  4.0- 5.0 sec  22.8 MBytes    191 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  5.0- 6.0 sec  22.6 MBytes    190 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  6.0- 7.0 sec  22.1 MBytes    185 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  7.0- 8.0 sec  22.8 MBytes    191 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  8.0- 9.0 sec  22.4 MBytes    188 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  9.0-10.0 sec  22.6 MBytes    190 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec    227 MBytes    190 Mbits/sec
[root@server2 iperf-2.0.4]# iperf -c 10.10.10.130 -i 1 -w 20480000
------------------------------------------------------------
Client connecting to 10.10.10.130, TCP port 5001
TCP window size:   256 KByte (WARNING: requested 19.5 MByte)
------------------------------------------------------------
[  3] local 10.10.10.131 port 56586 connected with 10.10.10.130 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0- 1.0 sec  22.8 MBytes    191 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  1.0- 2.0 sec  22.4 MBytes    188 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  2.0- 3.0 sec  22.9 MBytes    192 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  3.0- 4.0 sec  22.5 MBytes    188 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  4.0- 5.0 sec  22.5 MBytes    189 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  5.0- 6.0 sec  22.5 MBytes    189 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  6.0- 7.0 sec  22.4 MBytes    188 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  7.0- 8.0 sec  22.7 MBytes    190 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  8.0- 9.0 sec  22.3 MBytes    187 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  9.0-10.0 sec  22.4 MBytes    188 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec    225 MBytes    189 Mbits/sec
[root@server2 iperf-2.0.4]#

发表评论

电子邮件地址不会被公开。 必填项已用*标注