androidでiperfを使ってみた

バイナリ落ちてればいいのに、探してみたけど見当たらない。
iPerf for Androidというのがあったらしいけど、今は配布されていないのかな?
http://www.magicandroidapps.com/wiki//index.php?title=Using_iPerf_for_Android
しょうがないからソースからビルド。
http://sourceforge.net/projects/iperf/
なんかミラーへのリダイレクトリンクがめんどくさいな。

kinneko@BuildSV:~$ mkdir android-iperf
kinneko@BuildSV:~$ cd android-iperf/
kinneko@BuildSV:~/android-iperf$ wget http://jaist.dl.sourceforge.net/project/iperf/iperf-2.0.5.tar.gz


ビルドの手順はこのへんに。
https://groups.google.com/group/android-platform/browse_thread/thread/1ab11d2c3fbc5cad%29

kinneko@BuildSV:~/android-iperf$ tar zxvf iperf-2.0.5.tar.gz 
kinneko@BuildSV:~/android-iperf$ cd iperf-2.0.5/
kinneko@BuildSV:~/android-iperf/iperf-2.0.5$ export CROSS_COMPILE=arm-none-linux-gnueabi-
kinneko@BuildSV:~/android-iperf/iperf-2.0.5$ export PATH=/home/kinneko/panda/L27.12.1-P2/build_tools/arm-2010q1/bin:$PATH
kinneko@BuildSV:~/android-iperf/iperf-2.0.5$ ./configure --host="arm-linux" CXX="/home/kinneko/panda/L27.12.1-P2/build_tools/arm-2010q1/bin/arm-none-linux-gnueabi-g++" CXXFLAGS=-static CC="/home/kinneko/panda/L27.12.1-P2/build_tools/arm-2010q1/bin/arm-none-linux-gnueabi-gcc" CFLAGS=-static 
configure: WARNING: If you wanted to set the --build type, don't use --host.
    If a cross compiler is detected then cross compile mode will be used.
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking for arm-linux-strip... no
checking for strip... strip
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether /home/kinneko/panda/L27.12.1-P2/build_tools/arm-2010q1/bin/arm-none-linux-gnueabi-g++ accepts -g... yes
checking for style of include used by make... GNU
checking dependency style of /home/kinneko/panda/L27.12.1-P2/build_tools/arm-2010q1/bin/arm-none-linux-gnueabi-g++... gcc3
checking for arm-linux-gcc... /home/kinneko/panda/L27.12.1-P2/build_tools/arm-2010q1/bin/arm-none-linux-gnueabi-gcc
checking whether we are using the GNU C compiler... yes
checking whether /home/kinneko/panda/L27.12.1-P2/build_tools/arm-2010q1/bin/arm-none-linux-gnueabi-gcc accepts -g... yes
checking for /home/kinneko/panda/L27.12.1-P2/build_tools/arm-2010q1/bin/arm-none-linux-gnueabi-gcc option to accept ISO C89... none needed
checking dependency style of /home/kinneko/panda/L27.12.1-P2/build_tools/arm-2010q1/bin/arm-none-linux-gnueabi-gcc... gcc3
checking for library containing strerror... none required
checking whether make sets $(MAKE)... (cached) yes
checking for arm-linux-ranlib... no
checking for ranlib... ranlib
checking build system type... x86_64-unknown-linux-gnu
checking host system type... arm-unknown-linux-gnu
checking for the pthreads library -lpthreads... no
checking whether pthreads work without any flags... no
checking whether pthreads work with -Kthread... no
checking whether pthreads work with -kthread... no
checking for the pthreads library -llthread... no
checking whether pthreads work with -pthread... yes
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking if more special flags are required for pthreads... no
checking for cc_r... /home/kinneko/panda/L27.12.1-P2/build_tools/arm-2010q1/bin/arm-none-linux-gnueabi-gcc
checking for gethostbyname... yes
checking for socket... yes
checking how to run the C preprocessor... /home/kinneko/panda/L27.12.1-P2/build_tools/arm-2010q1/bin/arm-none-linux-gnueabi-gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking arpa/inet.h usability... yes
checking arpa/inet.h presence... yes
checking for arpa/inet.h... yes
checking libintl.h usability... yes
checking libintl.h presence... yes
checking for libintl.h... yes
checking netdb.h usability... yes
checking netdb.h presence... yes
checking for netdb.h... yes
checking netinet/in.h usability... yes
checking netinet/in.h presence... yes
checking for netinet/in.h... yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking for strings.h... (cached) yes
checking sys/socket.h usability... yes
checking sys/socket.h presence... yes
checking for sys/socket.h... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking syslog.h usability... yes
checking syslog.h presence... yes
checking for syslog.h... yes
checking for unistd.h... (cached) yes
checking for an ANSI C-conforming const... yes
checking for size_t... yes
checking for ssize_t... yes
checking whether time.h and sys/time.h may both be included... yes
checking whether struct tm is in sys/time.h or time.h... time.h
checking for stdint types... stdint.h (shortcircuit)
make use of stdint.h in include/iperf-int.h (assuming C99 compatible system)
checking 3rd argument of accept... socklen_t
checking for pid_t... yes
checking vfork.h usability... no
checking vfork.h presence... no
checking for vfork.h... no
checking for fork... yes
checking for vfork... yes
checking for working fork... yes
checking for working vfork... (cached) yes
checking for stdlib.h... (cached) yes
checking for GNU libc compatible malloc... yes
checking for working memcmp... yes
checking sys/select.h usability... yes
checking sys/select.h presence... yes
checking for sys/select.h... yes
checking for sys/socket.h... (cached) yes
checking types of arguments for select... int,fd_set *,struct timeval *
checking return type of signal handlers... void
checking for strftime... yes
checking for vprintf... yes
checking for _doprnt... no
checking for atexit... yes
checking for gettimeofday... yes
checking for memset... yes
checking for pthread_cancel... no
checking for select... yes
checking for strchr... yes
checking for strerror... yes
checking for strtol... yes
checking for usleep... yes
checking for snprintf... yes
checking for inet_pton... yes
checking for inet_ntop... yes
checking for gettimeofday... (cached) yes
checking *printf() support for %lld... yes
checking size of bool... 0
checking if true is defined... yes
checking whether byte ordering is bigendian... no
checking for struct ip_mreq... yes
checking whether IP_ADD_MEMBERSHIP is declared... yes
checking for multicast support... yes
checking for struct sockaddr_storage... yes
checking for struct sockaddr_in6... yes
checking whether AF_INET6 is declared... yes
checking for IPv6 headers and structures... yes
checking for struct ipv6_mreq... yes
checking whether IPV6_ADD_MEMBERSHIP is declared... yes
checking whether IPV6_MULTICAST_HOPS is declared... yes
checking for IPv6 multicast support... yes
checking whether make is GNU make... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating compat/Makefile
config.status: creating doc/Makefile
config.status: creating include/Makefile
config.status: creating src/Makefile
config.status: creating man/Makefile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing include/iperf-int.h commands
config.status: creating include/iperf-int.h : _IPERF_INCLUDE_IPERF_INT_H
kinneko@BuildSV:~/android-iperf/iperf-2.0.5$ vi config.h

"#define malloc rpl_malloc"のコメントアウトはいらないようだ。

kinneko@BuildSV:~/android-iperf/iperf-2.0.5$ make
(snip)

できた。

kinneko@BuildSV:~/android-iperf/iperf-2.0.5$ cd ..
kinneko@BuildSV:~/android-iperf$ 
kinneko@BuildSV:~/android-iperf$ file iperf     
iperf: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, for GNU/Linux 2.6.16, not stripped
kinneko@BuildSV:~/android-iperf$ ls -l
total 1176
-rwxr-xr-x 1 kinneko kinneko 948187 May 31 17:23 iperf
drwxr-xr-x 8 kinneko kinneko   4096 May 31 17:23 iperf-2.0.5
-rw-r--r-- 1 kinneko kinneko 248583 Jul  9  2010 iperf-2.0.5.tar.gz


Androidに転送してみる。

kinneko@BuildSV:~/android-sdks/platform-tools$ vi ~/.android/adb_usb.ini
0x1949
kinneko@BuildSV:~$ cd android-sdks/platform-tools/
kinneko@BuildSV:~/android-sdks/platform-tools$ ./adb kill-server
kinneko@BuildSV:~/android-sdks/platform-tools$ ./adb start-server
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
kinneko@BuildSV:~/android-sdks/platform-tools$ ./adb push ~/android-iperf/iperf /data/local
error: insufficient permissions for device

なんだよ。

kinneko@BuildSV:~/android-sdks/platform-tools$ ./adb devices
List of devices attached 
????????????	no permissions

をいをい。
shellアクセスもできないな。
ひどす。


adbdはroot権限で動いていないとダメだそう。
めんどくさ。

kinneko@BuildSV:~/android-sdks/platform-tools$ ./adb kill-server
kinneko@BuildSV:~/android-sdks/platform-tools$ sudo ./adb start-server
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
kinneko@BuildSV:~/android-sdks/platform-tools$ ./adb devices
List of devices attached 
5786000600000001	device
kinneko@BuildSV:~/android-sdks/platform-tools$ ./adb push ~/android-iperf/iperf /data/local
4981 KB/s (948187 bytes in 0.185s)
kinneko@BuildSV:~/android-sdks/platform-tools$ ./adb shell
$ cd /data/local
$ ls
tmp
BurritoRoot2.bin
iperf


鯖側の準備。

kinneko@BuildSV:~$ apt-cache search iperf
iperf - Internet Protocol bandwidth measuring tool
kinneko@BuildSV:~$ sudo apt-get install iperf 
(snip)
Setting up iperf (2.0.5-1) ...

鯖側。

kinneko@BuildSV:~$ iperf -s
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
[  4] local 192.168.1.102 port 5001 connected with 192.168.1.103 port 44308
[ ID] Interval       Transfer     Bandwidth
[  4]  0.0-10.2 sec  12.9 MBytes  10.6 Mbits/sec

Android側。

$ ./iperf -c 192.168.1.102
------------------------------------------------------------
Client connecting to 192.168.1.102, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[  3] local 192.168.1.103 port 44308 connected with 192.168.1.102 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.1 sec  12.9 MBytes  10.7 Mbits/sec

おそ〜。