Skip to Content

回覆回應

Linux - 網路效能測試工具 "iperf"

Step 1.下載程式
Step 2.安裝 iperf(Server端)
Step 3.安裝 iperf(client端)
Step 4.看 iperf 結果
Step 5.iperf 參數
Step 6.jperf 圖形(GUI) 介面的 iperf

Step 1.下載程式

通常我們在 Linux 下面可以透過 Iometer 去測試硬碟的效能速度,那網路呢!!要以免費最簡單使用的就算是 iperf 了.Iperf 是由 NLANR( National Laboratory for Applied Network Research)所開發出來的工具,主要 iperf 可以用來量測網路的最大的 TCP / UDP  網路頻寬/效能,但僅僅如此如果你需要更精準的網路效能或是穩定度那建議使用 另外一套專業級的網路效能測試工具 - IxChariot (http://benjr.tw/?q=node/433).不過我們先來看看 iperf 如何使用, iperf 並不是 Linux 系統預設套件,可以從 sourceforge 中下載. http://sourceforge.net/projects/iperf 它支援的作業系統包括了  linux, unix 和 window,採用 Server / Client 模式進行量測.

測試環境如下:

基本上只要兩台 Linux 機台就可以做網路效能測試,當然兩張網卡速度要一致,並同時將這個程式安裝在 Server 和 Client 上面.

Step 2.安裝 iperf(Server端 IP:192.12.1.2)

[root@Server ~]# tar iperf

[root@Server ~]# cd iperf

#configure for your machine

[root@Server iperf]# ./configure

#compile Iperf

[root@Server iperf]# make

#install Iperf, if desired

[root@Server iperf]# make install

[root@Server iperf]# iperf -s

Server 端的程式要先開,去監看 Client 端的封包!預設使用 TCP port 5001.TCP read/write buffer 預設是 8KB

Step 3.安裝 iperf(client端 IP:192.12.1.1)

[root@benjr ~]# tar iperf

[root@benjr ~]# cd iperf

#configure for your machine

[root@benjr iperf]# ./configure

#compile Iperf

[root@benjr iperf]# make

#install Iperf, if desired

[root@benjr iperf]# make install

[root@benjr iperf]# iperf -c 192.12.1.2  -t 60 -i 30

#-c : server IP
#-t : 測量時間間隔為60秒
#-i : 每隔 x 秒將測量結果顯示出來,最後再算出平均值.

Step 4.看 iperf 結果

Server端 IP:192.12.1.2

[root@Server ~]# iperf -s
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
[  4] local 192.12.1.2 port 5001 connected with 192.12.1.1 port 37994
[ ID] Interval       Transfer     Bandwidth
[  4]  0.0-60.0 sec  6.58 GBytes    941 Mbits/sec

顯示結果依序為1.執行時間  2.時間內所傳輸的總資料量. 3.頻寬為  941 Mbits/sec,跟我們實際 1G 頻寬差不多了.

client端 IP:192.12.1.1

[root@benjr ~]# iperf -c 192.12.1.2 -t 60 -i 30
------------------------------------------------------------
Client connecting to 192.12.1.2, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[  3] local 192.12.1.1 port 37994 connected with 192.12.1.2 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0- 30.0 sec    3.3 GBytes    941 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  30.0-60.0 sec    3.28 GBytes    942 Mbits/sec
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-60.0 sec  6.58 GBytes    942 Mbits/sec

Step 5.iperf 參數

-w n[KM]  指定 TCP window size
-l n[KM] 指定 read/write buffer 大小(預設為 8k)
-Pn (大寫的P) client 端指定同時 (parallel) 跑幾個的 threads

[root@Server ~]# iperf -s -w 2M -l 64k
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size:   256 KByte (WARNING: requested 2.00 MByte)
------------------------------------------------------------
[  4] local 192.7.1.2 port 5001 connected with 192.7.1.1 port 41278
[  5] local 192.7.1.2 port 5001 connected with 192.7.1.1 port 41279
[  6] local 192.7.1.2 port 5001 connected with 192.7.1.1 port 41280
[  7] local 192.7.1.2 port 5001 connected with 192.7.1.1 port 41281
[ ID] Interval       Transfer     Bandwidth
[  5]  0.0-120.0 sec  32.1 GBytes  2.30 Gbits/sec
[ ID] Interval       Transfer     Bandwidth
[  6]  0.0-120.0 sec  33.4 GBytes  2.39 Gbits/sec
[ ID] Interval       Transfer     Bandwidth
[  4]  0.0-120.0 sec  32.2 GBytes  2.31 Gbits/sec
[ ID] Interval       Transfer     Bandwidth
[  7]  0.0-120.0 sec  33.3 GBytes  2.38 Gbits/sec
[SUM]  0.0-120.0 sec    131 GBytes  9.38 Gbits/sec

Server 和 Client 需要用相同的參數才可以跑!

[root@benjr ~]#  iperf -c 192.12.1.2  -t 60 -i 5 -w 2M -l 64k -P4

Step 6.jperf 圖形(GUI) 介面的 iperf

xjperf 是有圖形 GUI 介面的 iperf,不過他是架構在 iperf 必須先安裝過 iperf 才可以使用.下載點在 http://code.google.com/p/xjperf/downloads/list 方式也很簡單,先行安裝完 iperf  再解開 xjperf 即可執行

[root@benjr ~]# unzip jperf2.0.0.zip
Archive:  jperf2.0.0.zip
   creating: bin/
   creating: lib/
  inflating: bin/iperf.exe          
  inflating: jperf.bat              
  inflating: jperf.sh               
  inflating: jperf2.0.0.jar         
  inflating: lib/forms-1.1.0.jar    
  inflating: lib/jcommon-1.0.10.jar 
  inflating: lib/jfreechart-1.0.6.jar 
  inflating: lib/swingx-2008_02_03.jar 

[root@benjr ~]# sh jperf.sh

相對應的指令參數會顯示在最上面,就如圖我們在使用 iperf 時一樣.不過我在 RHEL5 Update 2 上面使用時這一隻程式倒是常常當掉.

回應

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
圖片的 CAPTCHA
Enter the characters shown in the image.