概述
Iperf是一个网络性能测试工具。可以测试TCP和UDP带宽质量,可以测量最大TCP带宽,具有多种参数和UDP特性,可以报告带宽,延迟抖动和数据包丢失。Iperf在linux和windows平台均有二进制版本供自由使用。
Iperf was developed by NLANRDAST as a modern alternative for measuring maximum TCP
and UDP bandwidth performance. Iperf allows the tuning of various parameters and UDP
characteristics. Iperf reports bandwidth, delay jitter, datagram loss.
本文HTML永久地址 doc
软件下载
yum 安装:
rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
yum -y install iperf
源码安装:
tar xvf iperf-xxx.tar #官方站:http://sourceforge.net/projects/iperf/
cd iperf
./configure
make
make install
windows版本
下载:http://www.noc.ucf.edu/Tools/Iperf/
Iperf使用方法与参数说明
参数说明
-s 以server模式启动,eg:iperf –s 。Server端为数据的接收端。
-c host以client模式启动,host是server端地址,eg:iperf -c 222.35.11.23 。Client端为数据的发出端。
通用参数
-f [kmKM] 分别表示以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 ciperflog.txt
-p 指定服务器端使用的端口或客户端所连接的端口eg:iperf -s -p 9999;iperf -c 222.35.11.23 -p 9999
-P 连接限制参数 例如-P 2 当两个连接建立后,服务器进程就会退出。如果这个参数设定为0,那么iperf 进程将持续监听端口,并且不限制连接数量
-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值
应用实例
实例一
使用 iperf -s 命令将 Iperf 启动为 server 模式,在客户机上使用 iperf -c启动client模式。
服务器端:
[root@18 ~]# iperf -s
- -----------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
- -----------------------------------------------------------
客户端:
[root@vps2 ~]# iperf -c 218.64.131.18
- -----------------------------------------------------------
Client connecting to 218.64.131.18, TCP port 5001
TCP window size: 16.0 KByte (default)
- -----------------------------------------------------------
[ 3] local 74.62.154.33 port 49896 connected with 218.64.131.18 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-10.1 sec 9.57 MBytes 7.92 Mbits/sec
[root@vps2 ~]#
上面可以测试到最大速度为7.92Mbits/sec
上面使用服务端和客户端的默认设置进行测试
实例二
服务器端设置
[root@18 ~]# iperf -s -w 300K
- -----------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 216 KByte (WARNING: requested 300 KByte)
- -----------------------------------------------------------
客户端设置
[root@vps2 ~]# iperf -c 218.64.131.18 -f K -i 2 -w 300K #设定报告间隔为2秒,服务器端和客户端的TCP窗口都开到300KB
------------------------------------------------------------
Client connecting to 218.64.131.18, TCP port 5001
TCP window size: 256 KByte (WARNING: requested 300 KByte)
------------------------------------------------------------
[ 3] local 74.62.154.33 port 57566 connected with 218.64.131.18 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0- 2.0 sec 624 KBytes 312 KBytes/sec
[ 3] 2.0- 4.0 sec 1184 KBytes 592 KBytes/sec
[ 3] 4.0- 6.0 sec 1208 KBytes 604 KBytes/sec
[ 3] 6.0- 8.0 sec 1304 KBytes 652 KBytes/sec
[ 3] 8.0-10.0 sec 1344 KBytes 672 KBytes/sec
[ 3] 0.0-10.1 sec 5672 KBytes 562 KBytes/sec
[root@vps2 ~]#
[root@vps2 ~]# iperf -c 218.64.131.18 -f K -i 2 -w 300K -n 1000000 #测试传输约1MB数据
- -----------------------------------------------------------
Client connecting to 218.64.131.18, TCP port 5001
TCP window size: 256 KByte (WARNING: requested 300 KByte)
- -----------------------------------------------------------
[ 3] local 74.62.154.33 port 58469 connected with 218.64.131.18 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0- 2.0 sec 824 KBytes 412 KBytes/sec
[ 3] 0.0- 2.2 sec 984 KBytes 449 KBytes/sec
[root@vps2 ~]#
[root@vps2 ~]# iperf -c 218.64.131.18 -f K -i 2 -w 300K -t 36 #测试持续36秒
- -----------------------------------------------------------
Client connecting to 218.64.131.18, TCP port 5001
TCP window size: 256 KByte (WARNING: requested 300 KByte)
- -----------------------------------------------------------
[ 3] local 74.62.154.33 port 58836 connected with 218.64.131.18 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0- 2.0 sec 744 KBytes 372 KBytes/sec
[ 3] 2.0- 4.0 sec 1280 KBytes 640 KBytes/sec
[ 3] 4.0- 6.0 sec 1304 KBytes 652 KBytes/sec
[ 3] 6.0- 8.0 sec 1312 KBytes 656 KBytes/sec
[ 3] 8.0-10.0 sec 1296 KBytes 648 KBytes/sec
[ 3] 10.0-12.0 sec 1296 KBytes 648 KBytes/sec
[ 3] 12.0-14.0 sec 1288 KBytes 644 KBytes/sec
[ 3] 14.0-16.0 sec 1168 KBytes 584 KBytes/sec
[ 3] 16.0-18.0 sec 1304 KBytes 652 KBytes/sec
[ 3] 18.0-20.0 sec 1248 KBytes 624 KBytes/sec
[ 3] 20.0-22.0 sec 392 KBytes 196 KBytes/sec
[ 3] 22.0-24.0 sec 712 KBytes 356 KBytes/sec
[ 3] 24.0-26.0 sec 808 KBytes 404 KBytes/sec
[ 3] 26.0-28.0 sec 888 KBytes 444 KBytes/sec
[ 3] 28.0-30.0 sec 888 KBytes 444 KBytes/sec
[ 3] 30.0-32.0 sec 896 KBytes 448 KBytes/sec
[ 3] 32.0-34.0 sec 992 KBytes 496 KBytes/sec
[ 3] 34.0-36.0 sec 960 KBytes 480 KBytes/sec
[ 3] 0.0-36.2 sec 18784 KBytes 520 KBytes/sec
[root@vps2 ~]#
[root@vps2 ~]# iperf -c 218.64.131.18 -f K -i 5 -w 300K -n 10400000 -d -t 60 #测试双向的传输
- -----------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 256 KByte (WARNING: requested 300 KByte)
- -----------------------------------------------------------
- -----------------------------------------------------------
Client connecting to 218.64.131.18, TCP port 5001
TCP window size: 256 KByte (WARNING: requested 300 KByte)
- -----------------------------------------------------------
[ 5] local 74.62.154.33 port 36184 connected with 218.64.131.18 port 5001
[ 4] local 74.62.154.33 port 5001 connected with 218.64.131.18 port 55946
[ ID] Interval Transfer Bandwidth
[ 5] 0.0- 5.0 sec 2720 KBytes 544 KBytes/sec
[ 5] 5.0-10.0 sec 3336 KBytes 667 KBytes/sec
[ 5] 10.0-15.0 sec 3256 KBytes 651 KBytes/sec
[ 5] 15.0-20.0 sec 3232 KBytes 646 KBytes/sec
[ 5] 20.0-25.0 sec 3032 KBytes 606 KBytes/sec
[ 5] 25.0-30.0 sec 1304 KBytes 261 KBytes/sec
[ 5] 30.0-35.0 sec 1536 KBytes 307 KBytes/sec
[ 5] 35.0-40.0 sec 1464 KBytes 293 KBytes/sec
[ 5] 40.0-45.0 sec 1704 KBytes 341 KBytes/sec
[ 5] 45.0-50.0 sec 1992 KBytes 398 KBytes/sec
[ 5] 50.0-55.0 sec 3408 KBytes 682 KBytes/sec
[ 5] 55.0-60.0 sec 3416 KBytes 683 KBytes/sec
[ 5] 0.0-60.2 sec 30408 KBytes 505 KBytes/sec
[ 4] 0.0- 5.0 sec 0.00 KBytes 0.00 KBytes/sec
[ 4] 5.0-10.0 sec 0.00 KBytes 0.00 KBytes/sec
[ 4] 10.0-15.0 sec 0.00 KBytes 0.00 KBytes/sec
[ 4] 15.0-20.0 sec 0.00 KBytes 0.00 KBytes/sec
[ 4] 20.0-25.0 sec 0.00 KBytes 0.00 KBytes/sec
[ 4] 25.0-30.0 sec 0.00 KBytes 0.00 KBytes/sec
[ 4] 30.0-35.0 sec 0.00 KBytes 0.00 KBytes/sec
[ 4] 35.0-40.0 sec 0.00 KBytes 0.00 KBytes/sec
[ 4] 40.0-45.0 sec 0.00 KBytes 0.00 KBytes/sec
[ 4] 45.0-50.0 sec 0.00 KBytes 0.00 KBytes/sec
[ 4] 50.0-55.0 sec 0.00 KBytes 0.00 KBytes/sec
[ 4] 0.0-60.0 sec 34952 KBytes 583 KBytes/sec
[root@vps2 ~]#
[root@vps2 ~]# iperf -c 218.64.131.18 -f K -i 2 -w 300K -u -t 10 #UDP测试
- -----------------------------------------------------------
Client connecting to 218.64.131.18, UDP port 5001
Sending 1470 byte datagrams
UDP buffer size: 256 KByte (WARNING: requested 300 KByte)
- -----------------------------------------------------------
[ 3] local 74.62.154.33 port 48551 connected with 218.64.131.18 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0- 2.0 sec 29360375 KBytes 14680187 KBytes/sec
[ 3] 2.0- 4.0 sec 8388861 KBytes 4194430 KBytes/sec
[ 3] 4.0- 6.0 sec 8388861 KBytes 4194430 KBytes/sec
[ 3] 6.0- 8.0 sec 8388862 KBytes 4194431 KBytes/sec
[ 3] 8.0-10.0 sec 8388861 KBytes 4194430 KBytes/sec
[ 3] 0.0-10.0 sec 62915820 KBytes 6281749 KBytes/sec
[ 3] Sent 893 datagrams
read failed: Connection refused
[ 3] WARNING: did not receive ack of last datagram after 2 tries.
[root@vps2 ~]#
实例三:windows 测试实例
服务器端设置:
C:\>iperf.exe -s
- -----------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 8.00 KByte (default)
- -----------------------------------------------------------
[1864] local 218.64.131.18 port 5001 connected with 59.42.207.131 port 18875
[ ID] Interval Transfer Bandwidth
[1864] 0.0-15.4 sec 800 KBytes 426 Kbits/sec
客户端连接
C:\>iperf.exe -c 218.64.131.18 -i 5 -t 15
- -----------------------------------------------------------
Client connecting to 218.64.131.18, TCP port 5001
TCP window size: 8.00 KByte (default)
- -----------------------------------------------------------
[1912] local 192.168.3.12 port 1901 connected with 218.64.131.18 port 5001
[ ID] Interval Transfer Bandwidth
[1912] 0.0- 5.0 sec 264 KBytes 433 Kbits/sec
[1912] 5.0-10.0 sec 264 KBytes 433 Kbits/sec
[1912] 10.0-15.0 sec 264 KBytes 433 Kbits/sec
[1912] 0.0-15.4 sec 800 KBytes 425 Kbits/sec
C:\>
从上面可以看到本机传输到服务器的最大速度为425 Kbits/sec,我本机使用的ADSL宽带,所以速度慢一点。