close

 

Iperf 概覽
Iperf是一個TCP與UDP性能測試工具,可以提供網路吞吐率、丟包率最大組和最大傳輸單元大小等統計信息,通過這些信息可以分析網路的通信性能、定位網路瓶頸。
工作方式
先建立一個控制連結接,傳遞有關測試配置的信息,以及測試的結果;在控制連接建立並傳遞了測試配置信息以後,client與server會再建立一個測試連接用來回傳流量模式,以測試網絡的性能。
版本
Iperf分為兩種版本,unix/linux版本及window版本,linux版本更新較快。另外Jperf 是基於iperf基礎開發的GUI介面和新的功能

原始碼下載

http://iperf.fr/

 

交叉編譯 .. 請更改你使用的編譯器

make clean
./configure --host=arm-linux --prefix=`pwd`/iperf_install CC=/usr/local/arm-2009q3/bin/arm-none-linux-gnueabi-gcc CXX=/usr/local/arm-2009q3/bin/arm-none-linux-gnueabi-g++ ac_cv_func_malloc_0_nonnull=yes CFLAGS=-static CXXFLAGS=-static
make

 

加上 CFLAGS=-static CXXFLAGS=-static, 就不會用到 so 檔

但檔案大小差很多, 75770 byte 和 988377 byte 的差異。

 

 

網路上看到其他的編譯設定...參考用

方式2.(arm-linux)

export CXX=arm-none-linux-gnueabi-g++
export CC=arm-none-linux-gnueabi-gcc
export CPP=arm-none-linux-gnueabi-cpp
export ac_cv_func_malloc_0_nonnull=yes
./configure  --host=arm-linux --build=i686-linux
make CC=arm-none-linux-gnueabi-gcc


export CXX=arm-linux-g++
export CC=arm-linux-gcc
export CPP=arm-linux-cpp
export ac_cv_func_malloc_0_nonnull=yes
./configure  --host=arm-linux --build=i686-linux
make CC=arm-linux-gcc
 
 
 
 
 
 

 

 

基本參數命令
Client為Tx: iperf -c xxx.xxx.xxx.xxx -P 1 -i 1 -p 5001 -C -f m -t 60 -T 1
Server為Rx:iperf -s -P 0 -i 1 -p 5001 -C -f m
Tx與Rx: iperf -c xxx.xxx.xxx.xxx –d (等同iperf -c xxx.xxx.xxx.xxx -P 2 -i 1 -p 5001 -C -f m -t 60 -T 1)

 

 

※如何執行

IPERF的使用相當簡單,首先你必須準備兩台電腦(PC1,PC2)

其中一台設定為Server,一台設定為Client即可

範例

PC1:IPERF Server (10.10.10.1)

PC2:IPERF Client (192.168.1.2)

待測試物: 某廠牌分享器

┌────┐                                                 ┌────┐

 

│ PC2  │ -----LAN--- 待測試物 ----WAN---- │ PC1  │

 

└────┘                                                 └────┘

 

PC1啟動方式:

iperf -s

 

PC2啟動方式: 

iperf -c PC1的IP

 

example:

iperf -c 10.10.10.1

 

※如何變更tcp或是udp型態

iperf 的預設協定是tcp,如果要變更為udp,請下參數 -u

 

example:

iperf -c 10.10.10.1 -u

 

但是-u的預設值流量是1Mbit/s,如要提高請使用-b

 

example: 100Mbit/s

iperf -c 10.10.10.1 -u -b 1024000000

 

※如何增加IPERF connection數

TCP protocol有定義window size

這個東西形同網路封包的多工作業,如果同時間只處理一個封包串流,有可能無法享用所有頻寬

因此我們可以透過增加tcp的connection,來讓iperf榨出最多的效能

這個值受PC等級與待側物的性能影響,需要反覆測試才知道最佳數據會落在幾個session

參數為-P

 

example: 5個IPERF connection

iperf -c 10.10.10.1 -P 5

 

※如何設定測試時間

IPERF其實不是一個很穩定的測試工具,數據常有起落,建議測試時間至少要30秒

參數: -t

 

example: 30秒

iperf -c 10.10.10.1 -t 30

 

※如何讓他批次執行

 

IPERF這個工具除了數據不太穩定,長時間運行也可能自己就突然crash

改善的方式就是用批次檔,簡易的DOS 批次檔迴圈寫法如下:

 

example: client

:loop

iperf -c 10.10.10.1

goto loop

 

example: server

:loop

iperf -s

goto loop

 

 

Server端常用指令
iperf -s



iperf -s -w 300K
適當調整window size有助測試頻寬提升

Client端常用指令
iperf -c 192.168.254.205

以預設值測試頻寬


iperf -c 192.168.254.205 -w 300K -t 10 -i 2
適當調整window size有助測試頻寬提升

iperf -c 192.168.254.205 -w 300K -t 30 -P 4 -i 1
每1秒回報,測試30秒,同時4個session,win-size 300KByte

 

---------------------------------------------------------------------------------
Client/Server端共通參數:
-f, --format [kmKM] 以什麼方式顯示: Kbits, Mbits, KBytes, MBytes
-i, --interval # 每隔多少秒顯更新頻寬資訊
-l, --len #[KM] 設定讀寫的緩衝區長度 (預設 8 KB)
-m, --print_mss 顯示TCP/IP標頭的MTU(最大segment)大小
-o, --output 將report或錯誤訊息輸出到這個檔案裡
-p, --port # 設定server與client的溝通port
-u, --udp 使用UDP代替TCP測試
-w, --window #[KM] TCP的window大小(socket buffer size)
-B, --bind bind某,結合某介面或multicast的位址用
-C, --compatibility 與舊版本比較用,不送任何封包
-M, --mss # 設定TCP最大segment大小 (MTU - 40 bytes)
-N, --nodelay 設定無TCP延遲,取消Nagle's演算法
-V, --IPv6Version 設定為IPv6格式

Server:
-s, --server 執行Server模式
-D, --daemon 執行Server背景模式
-R, --remove 移除服務

Client:
-b, --bandwidth #[KM] UDP參數,以bits/sec傳送(預設 1 Mbit/sec, implies -u)
-c, --client 執行Client模式,並連線到Server的IP:
-d, --dualtest 同時執行雙向的模擬測試
-n, --num #[KM] 傳輸多少bytes封包 (取代-t)
-r, --tradeoff 單獨執行雙向的模擬測試
-t, --time # 每隔幾秒傳輸一次 (預設10 秒)
-F, --fileinput 選取某檔案傳輸測試
-I, --stdin 將鍵盤輸入的資料進行傳輸測試
-L, --listenport # 進行雙測試時,接收回應的port
-P, --parallel # 同時執行多少個Client連線
-T, --ttl # 進行Multicat的time-to-live(預設為 1)

其它參數:
-h, --help 顯示help 資訊
-v, --version 顯示版本

參考資料:
http://www.net130.com/CMS/Pub/special/special_fzjh/special_fzjh_yy/2010_07_27_40244.htm
http://www.microsoft.com/taiwan/technet/community/columns/cableguy/cg1105.mspx


相關測試工具

netperf
http://www.netperf.org/netperf/NetperfPage.html

ttcp
http://www.pcausa.com/Utilities/pcattcp.htm
http://sd.wareonearth.com/~phil/net/ttcp/
http://www.cisco.com/en/US/tech/tk801/tk36/technologies_tech_note09186a0080094694.shtml

http://iperf.fr/
http://blog.xuite.net/u870q217/blog/31513614-Iperf%E9%A0%BB%E5%AF%AC%E6%B8%AC%E8%A9%A6%E5%B7%A5%E5%85%B7

arrow
arrow
    全站熱搜

    立你斯 發表在 痞客邦 留言(0) 人氣()