wget を使ってネットワーク性能(転送速度)を検証する方法

僕がネットワーク性能を検証するなら、いつもは netperf を使います。今回も Android の WiFi の性能を調べるお仕事があったので、先日構築した Android ビルド環境にて、Android ソースに入っている netperf をコンパイルして検証を試みるも、どうにも netperf サーバと通信がうまくいかず数日費やしてしまいました。

ネットワーク構成的には単純です。Gbit有線で接続されたサーバに WiFi 接続する Android という構成です。

Android(nerperf) --[WiFi]--> WiFi Router --[Gigabit 有線]--> Server(nerserver)

出力されるのは no response received です。netserver には接続メッセージが出力されるのでパケットは飛んでるはずなんですけど・・・謎です。

c:\temp>adb shell /data/local/tmp/netperf -H 192.168.1.94
TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.1.94 (192.168.1.94) port 0 AF_INET
netperf: receive_response: no response received. errno 0 counter 0

時間をかけても無駄と判断し、wget を代用して転送速度検証を行うこととしました。

- スポンサーリンク -

wget を使ってネットワーク性能(転送速度)を検証する方法

手順1.Android 用の wget を手に入れます。
android wget で検索すればすぐに出てきますが、wget に android 向けの patch を作って binary を提供している人がいます。有り難く下記 wget binary からバイナリをいただきます。

http://jacob.hoffman-andrews.com/android/wget/

I spent some time hacking wget to build under the NDK. It works pretty well, though it's not really in a condition to submit back to mainline. If you'd like to take a look, though, here's the patch:

http://hoffman-andrews.com/android/wget/wget-android.patch

To build, get wget from http://ftp.gnu.org/gnu/wget/wget-1.11.4.tar.gz
and unpack it to android-ndk-1.5_r1/sources/wget. In the wget directory, run:

./configure --without-ssl --disable-nls --build=arm-eabi

Create android-ndk-1.5_r1/apps/wget/Application.mk:
APP_PROJECT_PATH := $(call my-dir)/project
APP_MODULES := wget

Change back to android-ndk-1.5_r1 and run:
make APP=wget V=1

And here's the binary if you want to skip all that trouble:

wget binary

Enjoy!

手順2.Gbit有線LANで接続されたサーバ上に apache なりで http サーバを起動します。
この記事を見ている方であれば、yum や apt-get で問題なく構築できることでしょうから説明を割愛します。検証でダウンロードさせるファイルとしてある程度のサイズが必要となるため、50MByte 程度のファイルを DocumentRoot 配下に設置しておきます。
つまり、http://192.168.1.10/a.zip などのような形でアクセスできる状態を作ります。

手順3.wget を Android 端末へ送り込み、wget を起動して検証ファイルを DL します。
ここでは、下記条件配下で赤色の文字のように命令を実行します。
・ wget を c:\temp\ 配下に置いたと仮定します。
・ コマンドを叩く端末には Android SDK の環境が整っていることを前提としています。

C:\Users\drk>cd c:\temp

c:\temp>adb push wget /data/local/tmp/wget
561 KB/s (241974 bytes in 0.420s)

c:\temp>adb shell chmod 700 /data/local/tmp/wget

c:\temp>adb shell /data/local/tmp/wget --output-document=/dev/null http://192.168.1.10/a.zip
--2012-10-05 18:49:47--  http://192.168.1.10/a.zip
Connecting to 192.168.1.10:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 135820340 (130M) [application/zip]
Saving to: `/dev/null'

100%[======================================>] 135,820,340 1.32M/s   in 95s

2012-10-05 18:51:22 (1.36 MB/s) - `/dev/null' saved [135820340/135820340]

手順4.検証結果の考察。
上記の結果から、Android の WiFi 性能は概ね 1.32MB/s であることがわかりました。単位が Byte なので bit に変換すると8倍して、約 11Mbps 出ていることがわかりました。他の高性能な PC の 11n で実測すると 90Mbps 近い数値が出ていることが確認されているので、Android 実機は計測した環境下では、思ったほどパフォーマンスが出ていないことが確認されました。

いろいろ複数機種の速度を計測していますが、端末によって随分と WiFi の速度が違うようです。
今回の検証手順はあくまでも代替手段で正確な数値測定には向きませんが、数回実行して、概ねの傾向と数値を把握する用途には使えるかと思います。

- スポンサーリンク -

関連する記事&スポンサーリンク