iperf使用方法簡易,先在某台機器上面先跑iperf service,其他的機器就可用iperf client去連線,測量兩者之間的網路頻寬。這server/client則都是整合在同一個程式,執行方法如下:
運行iperf service $ iperf -s
執行iperf client $ iperf -c ip_of_iperf_server
由於iperf使用簡便,如果在無線網路分享器上面跑service,不只可以測試無線的連線速度,而且也可以測量分享器對外連線速度,可惜AsusWRT上面沒有內建iperf,而且現在沒有可執行的可執行檔支援Asus RT-N66U的處理器,因此必須要自己弄一個出來。
N66U的處理器是Broadcom BCM4706,處理器架構是MIPS 74K,幸好有iperf有提供source code,才能夠cross compile出在N66U上面能運行的iperf。過程簡化成下面三步:
Step 1: 安裝支援MIPS的cross-compiler
編譯環境是Ubuntu Gnome 14.04,並參考了Sathish Kumar2的文章首先在/etc/apt/sources.list新增下面兩行
deb http://ftp.de.debian.org/debian squeeze main
deb http://www.emdebian.org/debian/ squeeze main
依序執行下面三個指令安裝mipsel cross compiler,這邊要注意是mipsel而不是mips(至於兩者說差別請參照Fred Chien的文章)
$ sudo apt-get update
$ sudo apt-get install emdebian-archive-keyring
$ sudo apt-get install linux-libc-dev-mipsel-cross libc6-mipsel-cross libc6-dev-mipsel-cross binutils-mipsel-linux-gnu gcc-4.4-mipsel-linux-gnu g++-4.4-mipsel-linux-gnu
驗證安裝結果
$ dpkg --get-selections | grep mipsel
binutils-mipsel-linux-gnu install
cpp-4.4-mipsel-linux-gnu install
g++-4.4-mipsel-linux-gnu install
gcc-4.4-mipsel-linux-gnu install
gcc-4.4-mipsel-linux-gnu-base install
libc-bin-mipsel-cross install
libc-dev-bin-mipsel-cross install
libc6-dev-mipsel-cross install
libc6-mipsel-cross install
libgcc1-mipsel-cross install
libgomp1-mipsel-cross install
libstdc++6-4.4-dev-mipsel-cross install
libstdc++6-mipsel-cross install
linux-libc-dev-mipsel-cross install
$ mipsel-linux-gnu-gcc -dumpmachine
mipsel-linux-gnu
Step 2: 下載原始碼,編譯出iperf執行檔
編譯過程參考Leed Salim的文章$ export CROSS_COMPILE=mipsel-linux-gnu-
$ export CC=${CROSS_COMPILE}gcc
$ export CPP=${CROSS_COMPILE}cpp
$ export CXX=${CROSS_COMPILE}g++
$ export LD=${CROSS_COMPILE}ld
$ export AR=${CROSS_COMPILE}ar
$ export ac_cv_func_malloc_0_nonnull=yes
$ ./configure --host=mipsel-linux
...
...
$ make CFLAGS=-static CXXFLAGS=-static
...
...
做完之後所需要的iperf executable就在目錄src/,確認是否有編譯成static executable
$ file src/iperf
iperf: ELF 32-bit LSB executable, MIPS, MIPS-I version 1 (SYSV), statically linked, for GNU/Linux 2.6.18, BuildID[sha1]=a76f56d5b9a6c2b239e62d2558e87c9333c47b47, not stripped
$ ldd src/iperf
not a dynamic executable
Step 3: 將iperf裝到N66U上面,開始運行
首先在分享器上面執行iperf service# nohup ./iperf -s -w 128k &
再來把防火牆上面iperf跑的5001 port打開,要注意放在第一行
# iptables -I INPUT 1 -p tcp --dport 5001 -j ACCEPT
在其他機器上面執行iperf client,每一秒回應一次連線速度
$ iperf -c 分享器的IP -i 1
------------------------------------------------------------
Client connecting to 分享器IP, TCP port 5001
TCP window size: 23.5 KByte (default)
------------------------------------------------------------
[ 3] local 本機的IP port 54952 connected with 分享器的IP port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0- 1.0 sec 25.9 MBytes 217 Mbits/sec
[ 3] 1.0- 2.0 sec 24.5 MBytes 206 Mbits/sec
[ 3] 2.0- 3.0 sec 24.9 MBytes 209 Mbits/sec
[ 3] 3.0- 4.0 sec 25.1 MBytes 211 Mbits/sec
[ 3] 4.0- 5.0 sec 24.2 MBytes 203 Mbits/sec
[ 3] 5.0- 6.0 sec 25.6 MBytes 215 Mbits/sec
[ 3] 6.0- 7.0 sec 24.5 MBytes 206 Mbits/sec
[ 3] 7.0- 8.0 sec 25.4 MBytes 213 Mbits/sec
[ 3] 8.0- 9.0 sec 24.5 MBytes 206 Mbits/sec
[ 3] 9.0-10.0 sec 23.4 MBytes 196 Mbits/sec
[ 3] 0.0-10.0 sec 248 MBytes 208 Mbits/sec
在執行的時候速度沒有到分享器網路頻寬上限,可能是iperf把分享器的CPU吃滿了
沒有留言:
張貼留言