Iperf was developed by NLANR/DAST 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.
一、軟件下載
Windows:http://www.noc.ucf.edu/Tools/Iperf/iperf.exe
Linux: http://sourceforge.net/projects/iperf/
二、以windows下的使用進行試驗
1、CP 測試,不能測試丟包率
以一臺機器上做爲服務端,啓動命令如下:
D:\>iperf.exe -s -i 5 -w 3M -m
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 3.00 MByte
------------------------------------------------------------
在另一臺機器上進行測試,命令臺下:
D:\tool>iperf.exe -c 10.1.95.68 -i 5 -t 20 -w 3M -m
------------------------------------------------------------
Client connecting to 10.1.95.68, TCP port 5001
TCP window size: 3.00 MByte
------------------------------------------------------------
[1868] local 10.1.95.65 port 1126 connected with 10.1.95.68 port 5001
[ ID] Interval Transfer Bandwidth
[1868] 0.0- 5.0 sec 59.2 MBytes 99.3 Mbits/sec
[1868] 5.0-10.0 sec 56.4 MBytes 94.6 Mbits/sec
[1868] 10.0-15.0 sec 56.3 MBytes 94.5 Mbits/sec
[1868] 15.0-20.0 sec 56.4 MBytes 94.6 Mbits/sec
[1868] 0.0-20.3 sec 228 MBytes 94.4 Mbits/sec
2、UDP測試
以一臺機器 10.1.95.68 上做爲服務端,啓動命令如下:
D:\>iperf.exe -s -i 5 -w 1M
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 1.00 MByte
------------------------------------------------------------
[1848] local 10.1.95.68 port 5001 connected with 10.1.95.65 port 1131
[ ID] Interval Transfer Bandwidth
[1848] 0.0- 5.0 sec 56.5 MBytes 94.7 Mbits/sec
[1848] 5.0-10.0 sec 56.1 MBytes 94.1 Mbits/sec
[1848] 10.0-15.0 sec 56.4 MBytes 94.6 Mbits/sec
[1848] 15.0-20.0 sec 56.2 MBytes 94.3 Mbits/sec
[1848] 0.0-20.1 sec 226 MBytes 94.5 Mbits/sec
在另一臺機器10.1.95.65上進行測試,命令臺下:
D:\tool>iperf.exe -c 10.1.95.68 -i 5 -t 20 -w 1M
------------------------------------------------------------
Client connecting to 10.1.95.68, TCP port 5001
TCP window size: 1.00 MByte
------------------------------------------------------------
[1868] local 10.1.95.65 port 1131 connected with 10.1.95.68 port 5001
[ ID] Interval Transfer Bandwidth
[1868] 0.0- 5.0 sec 57.4 MBytes 96.4 Mbits/sec
[1868] 5.0-10.0 sec 56.1 MBytes 94.1 Mbits/sec
[1868] 10.0-15.0 sec 56.4 MBytes 94.6 Mbits/sec
[1868] 15.0-20.0 sec 56.4 MBytes 94.6 Mbits/sec
[1868] 0.0-20.1 sec 226 MBytes 94.5 Mbits/sec
測試可得出,TCP傳輸的帶寬能達到90多Mb
2、UDP測試,能指定帶寬和觀察丟包率、延時
指定帶寬使用參數-b,不指定的情況默認是1Mb。
以一臺機器 10.1.95.68 上做爲服務端,啓動命令如下:
D:\>iperf.exe -s -i 5 -w 1M -u
------------------------------------------------------------
Server listening on UDP port 5001
Receiving 1470 byte datagrams
UDP buffer size: 1.00 MByte
------------------------------------------------------------
[1884] local 10.1.95.68 port 5001 connected with 10.1.95.65 port 1132
[ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams
[1884] 0.0- 5.0 sec 25.7 MBytes 43.1 Mbits/sec 0.113 ms 1398230852/18320 (7.
6e+006%)
[1884] 5.0-10.0 sec 26.9 MBytes 45.1 Mbits/sec 0.864 ms 0/19168 (0%)
[1884] 10.0-15.0 sec 29.6 MBytes 49.6 Mbits/sec 0.114 ms 0/21105 (0%)
[1884] 15.0-20.0 sec 26.4 MBytes 44.2 Mbits/sec 0.114 ms 0/18804 (0%)
[1884] 0.0-20.0 sec 109 MBytes 45.5 Mbits/sec 1.015 ms 0/77435 (0%)
在另一臺機器10.1.95.65上進行測試,命令臺下:
D:\tool>iperf.exe -c 10.1.95.68 -i 5 -t 20 -w 1M -u -b 100M
------------------------------------------------------------
Client connecting to 10.1.95.68, UDP port 5001
Sending 1470 byte datagrams
UDP buffer size: 1.00 MByte
------------------------------------------------------------
[1868] local 10.1.95.65 port 1132 connected with 10.1.95.68 port 5001
[ ID] Interval Transfer Bandwidth
[1868] 0.0- 5.0 sec 25.7 MBytes 43.2 Mbits/sec
[1868] 5.0-10.0 sec 26.8 MBytes 45.0 Mbits/sec
[1868] 10.0-15.0 sec 29.6 MBytes 49.7 Mbits/sec
[1868] 15.0-20.0 sec 26.4 MBytes 44.3 Mbits/sec
[1868] 0.0-20.0 sec 109 MBytes 45.5 Mbits/sec
[1868] Server Report:
[1868] 0.0-20.0 sec 109 MBytes 45.5 Mbits/sec 1.015 ms 0/77435 (0%)
[1868] Sent 77435 datagrams
測試可得出,UDP傳輸能達到45Mb,也直觀看到延時和丟包的情況。
三、參數說明
參數說明
-s 以server模式啓動,eg:iperf -s
-c host以client模式啓動,host是server端地址,eg:iperf -c 222.35.11.23
通用參數
-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
-u 使用udp協議
-w 指定TCP窗口大小,默認是8KB
-B 綁定一個主機地址或接口(當主機有多個地址或接口時使用該參數)
-C 兼容舊版本(當server端和client端版本不一樣時使用)
-M 設定TCP數據包的最大mtu值
-N 設定TCP不延時
-V 傳輸ipv6數據包
server專用參數
-D 以服務方式運行iperf,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值