iperf

最後更新: 2016-12-22

介紹

 

iperf 是用來測試 Server 與 Client 之間的連線速度工具來

它分別能夠測試 TCP 及 UDP 的來回速度

 * iperf3 與 iperf2 是不相容的

目錄

 

 


用法

iperf [-u] [-s|-c host] [options]

 


Server

 

Opts:

  • -s                        # server mode
  • -D, --daemon
  • -P N                     # listen 那個 port ( Default: 5001 )
  • -B IP                    # listen 那個 interface
  • -u                        # 用 UDP 去 test speed ( Default: TCP )

i.e.

# 所有都用 Default Setting 來行 Server

iperf -s

# 未有 connection 時

------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------

# 改用 UDP 及 Port 8888 並 bind 其中一個 Interface

iperf -s -u -P 5001 -B 192.168.123.254

更改 TCP window size ( socket buffer size )

-w, --window n[KM]

more info

 


Client

 

Opts

  • -c                        # client mode
  • -t t                      # 測試幾多秒 ( Default 10 secs )
  • -f [kmKM]           # 顯示的單位 ( Kbits, Mbits, KBytes, MBytes )
  • -i  s                     # 多久有一次 report
  • -p p                     # server port, default port 5001
  • -P, --parallel n      # number of parallel client threads to run

P.S.

Default Upload Test Only !! ( C -> S )

Example1: 測試 20 秒, Unit: Mbit, 每 5 秒 report 一次

iperf.exe -c 192.168.123.254 -t 20 -f M -i 5

------------------------------------------------------------
Client connecting to 192.168.88.150, TCP port 5001
TCP window size: 0.04 MByte (default)
------------------------------------------------------------
[  3] local 192.168.8.231 port 58852 connected with 192.168.88.150 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0- 5.0 sec  33.8 MBytes  6.75 MBytes/sec
[  3]  5.0-10.0 sec  33.6 MBytes  6.72 MBytes/sec
[  3] 10.0-15.0 sec  33.6 MBytes  6.72 MBytes/sec
[  3] 15.0-20.0 sec  33.6 MBytes  6.72 MBytes/sec
[  3]  0.0-20.0 sec   135 MBytes  6.73 MBytes/sec

Example2: Parallel

[  6] local 10.0.0.1 port 56679 connected with 10.0.0.2 port 5001
[  4] local 10.0.0.1 port 56676 connected with 10.0.0.2 port 5001
[  5] local 10.0.0.1 port 56677 connected with 10.0.0.2 port 5001
[  3] local 10.0.0.1 port 56678 connected with 10.0.0.2 port 5001
[ ID] Interval       Transfer     Bandwidth
[  4]  0.0- 3.0 sec  82.0 MBytes   229 Mbits/sec
[  5]  0.0- 3.0 sec  86.8 MBytes   243 Mbits/sec
[  3]  0.0- 3.0 sec  88.8 MBytes   248 Mbits/sec
[  6]  0.0- 3.0 sec  80.1 MBytes   224 Mbits/sec
[SUM]  0.0- 3.0 sec   338 MBytes   944 Mbits/sec

 


UDP 測試

 

iperf uses a default of 1Mb/sec for UDP tests.

Use the -b flag on the iperf client to specify the UDP bandwidth you want to transmit at

opts

-u                        # 使用 udp 測試 (Default 是用 tcp 的)

-b                        # 限制 bandwidth. --bandwidth n[k/m](bit/sec) requires UDP (-u)

e.g.

# options 一定要放在最尾

iperf -c 192.168.88.150  -t 20 -i 5 -u -b 100m

------------------------------------------------------------
Client connecting to 192.168.88.150, UDP port 5001
Sending 1470 byte datagrams
UDP buffer size:  160 KByte (default)
------------------------------------------------------------
[  3] local 192.168.8.231 port 46373 connected with 192.168.88.150 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0- 5.0 sec  47.7 MBytes  80.1 Mbits/sec
[  3]  5.0-10.0 sec  47.6 MBytes  79.9 Mbits/sec
[  3] 10.0-15.0 sec  47.6 MBytes  79.8 Mbits/sec
[  3] 15.0-20.0 sec  47.6 MBytes  79.9 Mbits/sec
[  3]  0.0-20.0 sec   191 MBytes  79.9 Mbits/sec
[  3] Sent 135911 datagrams
[  3] Server Report:
[  3]  0.0-20.0 sec   191 MBytes  79.9 Mbits/sec   0.132 ms    0/135910 (0%)
[  3]  0.0-20.0 sec  1 datagrams received out-of-order

 


來回測試 (-r / -d)

 

Example:

iperf.exe -c 192.168.123.254 -f K  -r

  • -L N                # 是指要 Server send data 到 client 的那一個 port (client local port)
  • -r                   # --tradeoff, 是指先 client upload 完後, server 才再 send data 過來 Client
  • -d                   # --dualtest, 同時互相傳遞資料 ( duplex )

其他測試

-w N                              # 是用來加大 TCP Window Size ( defealt 8 KByte )

-N, --nodelay                 # Disabling Nagle's Algorithm

P.S.

當測試時要關 firewall, 因為效果會差很遠 (當開了 fw 後得 457 Mbits/sec )

測試時當速度有 740 Mbits/sec , CPU 大約佔用了 56-60% 左右 ( CPU: intel_e7200 )

另外當 "-d" 時, 在 xp 會很 lag