(转)WIFI 无线传输速率测试-iperf
Iperf是一个TCP/IP和UDP/IP的性能测量工具,能够提供网络吞吐率信息,以及震动、丢包率、最大段和最大传输单元大小等统计信息;从而能够帮助我们测试网络性能,定位网络瓶颈。现在ubuntu单虚拟机不同终端以及不同虚拟机之间的测试为例说明如何安装以及使用,然后提供MT7688openwrt平台交叉编译的方法。使用这个工具的目的是为了测试MTK7688开发板上面的wifi性能,所以后面还需要对其进行交叉编译!ubuntu下iperf的安装Iperf 安装
linux@ubuntu:~$ sudo apt-get install iperf
password for linux:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
iperf
0 upgraded, 1 newly installed, 0 to remove and 615 not upgraded.
Need to get 54.0 kB of archives.
After this operation, 169 kB of additional disk space will be used.
Get:1 http://cn.archive.ubuntu.com/ubuntu/ precise/universe iperf i386 2.0.5-2.1
Fetched 54.0 kB in 0s (71.7 kB/s)
Selecting previously unselected package iperf.
(Reading database ... 149737 files and directories currently installed.)
Unpacking iperf (from .../iperf_2.0.5-2.1_i386.deb) ...
Processing triggers for doc-base ...
Processing 1 added doc-base file...
Processing triggers for man-db ...
Setting up iperf (2.0.5-2.1) ...
linux@ubuntu:~$ iperf -V
Usage: iperf [-s|-c host]
Try `iperf --help' for more information.
linux@ubuntu:~$ iperf -v
iperf version 2.0.5 (08 Jul 2010) pthreads
1.同一虚拟机,不同终端
终端1
linux@ubuntu:~$ iperf -s
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
local 192.168.0.127 port 5001 connected with 192.168.0.127 port 34052
[ ID] Interval Transfer Bandwidth
0.0-10.0 sec38.9 GBytes33.4 Gbits/sec
终端2
linux@ubuntu:~$ iperf -c 192.168.0.127
------------------------------------------------------------
Client connecting to 192.168.0.127, TCP port 5001
TCP window size:334 KByte (default)
------------------------------------------------------------
local 192.168.0.127 port 34052 connected with 192.168.0.127 port 5001
[ ID] Interval Transfer Bandwidth
0.0-10.0 sec38.9 GBytes33.4 Gbits/sec
2.不同虚拟机 TCP iperf测试
虚拟机1
linux@ubuntu:~$ iperf -s
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
local 192.168.0.160 port 5001 connected with 192.168.0.127 port 60192
[ ID] Interval Transfer Bandwidth
0.0-10.0 sec4.80 GBytes4.12 Gbits/sec
虚拟机2
linux@ubuntu:~$ iperf -c 192.168.0.160
------------------------------------------------------------
Client connecting to 192.168.0.160, TCP port 5001
TCP window size: 21.0 KByte (default)
------------------------------------------------------------
local 192.168.0.127 port 60192 connected with 192.168.0.160 port 5001
[ ID] Interval Transfer Bandwidth
0.0-10.0 sec4.80 GBytes4.13 Gbits/sec
3.不同虚拟机 udp iperf测试
虚拟机1
^Clinux@ubuntu:~$ iperf -s -u
------------------------------------------------------------
Server listening on UDP port 5001
Receiving 1470 byte datagrams
UDP buffer size:160 KByte (default)
------------------------------------------------------------
local 192.168.0.160 port 5001 connected with 192.168.0.127 port 39359
[ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams
0.0-10.0 sec1.25 MBytes1.05 Mbits/sec 0.044 ms 0/893 (0%)
虚拟机2
linux@ubuntu:~$ iperf -c 192.168.0.160 -u
------------------------------------------------------------
Client connecting to 192.168.0.160, UDP port 5001
Sending 1470 byte datagrams
UDP buffer size:160 KByte (default)
------------------------------------------------------------
local 192.168.0.127 port 39359 connected with 192.168.0.160 port 5001
[ ID] Interval Transfer Bandwidth
0.0-10.0 sec1.25 MBytes1.05 Mbits/sec
Sent 893 datagrams
Server Report:
0.0-10.0 sec1.25 MBytes1.05 Mbits/sec 0.043 ms 0/893 (0%)
-i制定输出间隔
linux@ubuntu:~$ iperf -c 192.168.0.160 -u -i 2
------------------------------------------------------------
Client connecting to 192.168.0.160, UDP port 5001
Sending 1470 byte datagrams
UDP buffer size:160 KByte (default)
------------------------------------------------------------
local 192.168.0.127 port 35034 connected with 192.168.0.160 port 5001
[ ID] Interval Transfer Bandwidth
0.0- 2.0 sec 257 KBytes1.05 Mbits/sec
2.0- 4.0 sec 256 KBytes1.05 Mbits/sec
4.0- 6.0 sec 256 KBytes1.05 Mbits/sec
6.0- 8.0 sec 257 KBytes1.05 Mbits/sec
8.0-10.0 sec 256 KBytes1.05 Mbits/sec
0.0-10.0 sec1.25 MBytes1.05 Mbits/sec
Sent 893 datagrams
Server Report:
0.0-10.0 sec1.25 MBytes1.05 Mbits/sec 0.056 ms 0/893 (0%)
-b制定带宽
linux@ubuntu:~$ iperf -c 192.168.0.160 -u -i 2 -b 2M
------------------------------------------------------------
Client connecting to 192.168.0.160, UDP port 5001
Sending 1470 byte datagrams
UDP buffer size:160 KByte (default)
------------------------------------------------------------
local 192.168.0.127 port 39060 connected with 192.168.0.160 port 5001
[ ID] Interval Transfer Bandwidth
0.0- 2.0 sec 490 KBytes2.01 Mbits/sec
2.0- 4.0 sec 488 KBytes2.00 Mbits/sec
4.0- 6.0 sec 488 KBytes2.00 Mbits/sec
6.0- 8.0 sec 488 KBytes2.00 Mbits/sec
8.0-10.0 sec 488 KBytes2.00 Mbits/sec
0.0-10.0 sec2.39 MBytes2.00 Mbits/sec
Sent 1702 datagrams
Server Report:
0.0-10.0 sec2.39 MBytes2.00 Mbits/sec 0.099 ms 0/ 1702 (0%)
-t指定测试时间
linux@ubuntu:~$ iperf -c 192.168.0.160 -u -i 2 -b 2M -t 30
------------------------------------------------------------
Client connecting to 192.168.0.160, UDP port 5001
Sending 1470 byte datagrams
UDP buffer size:160 KByte (default)
------------------------------------------------------------
local 192.168.0.127 port 37215 connected with 192.168.0.160 port 5001
[ ID] Interval Transfer Bandwidth
0.0- 2.0 sec 488 KBytes2.00 Mbits/sec
2.0- 4.0 sec 490 KBytes2.01 Mbits/sec
4.0- 6.0 sec 488 KBytes2.00 Mbits/sec
6.0- 8.0 sec 488 KBytes2.00 Mbits/sec
8.0-10.0 sec 488 KBytes2.00 Mbits/sec
10.0-12.0 sec 488 KBytes2.00 Mbits/sec
12.0-14.0 sec 488 KBytes2.00 Mbits/sec
14.0-16.0 sec 490 KBytes2.01 Mbits/sec
16.0-18.0 sec 488 KBytes2.00 Mbits/sec
18.0-20.0 sec 488 KBytes2.00 Mbits/sec
20.0-22.0 sec 488 KBytes2.00 Mbits/sec
22.0-24.0 sec 488 KBytes2.00 Mbits/sec
24.0-26.0 sec 488 KBytes2.00 Mbits/sec
26.0-28.0 sec 488 KBytes2.00 Mbits/sec
28.0-30.0 sec 488 KBytes2.00 Mbits/sec
0.0-30.0 sec7.15 MBytes2.00 Mbits/sec
Sent 5103 datagrams
Server Report:
0.0-30.0 sec7.15 MBytes2.00 Mbits/sec 0.036 ms 0/ 5102 (0%)
0.0-30.0 sec1 datagrams received out-of-order
5. 交叉编译iperf1)下载iperf-2.0.5-source.tar.gzhttps://iperf.fr/iperf-download.php2)解压,并进行编译配置
./configure --host=mipsel-openwrt-linux CC=mipsel-openwrt-linux-gcc LD=mipsel-openwrt-linux-ld ac_cv_func_malloc_0_nonnull=yes
echo "ac_cv_func_malloc_0_nonnull=yes" > arm-linux.cache
./configure --host=mipsel-openwrt-linux CC=mipsel-openwrt-linux-gcc LD=mipsel-openwrt-linux-ld -cache-file=arm-linux.cache
3)编译出现的错误以及警告解决方法:a. mips-openwrt-linux-gcc: warning: environment variable'STAGING_DIR' not defined解决办法是在命令行输入:export STAGING_DIR=(你的OpenWrt目录的绝对路径)/staging_direxportSTAGING_DIR=/home/linux/mt7688/openwrt-3.10.14/staging_dir
b.undefinedreference to `rpl_malloc'必须添加ac_cv_func_malloc_0_nonnull=yes,否则编译时会报错undefined reference to `rpl_malloc'
./configure --host=mipsel-openwrt-linux CC=mipsel-openwrt-linux-gcc LD=mipsel-openwrt-linux-ldac_cv_func_malloc_0_nonnull=yes
echo "ac_cv_func_malloc_0_nonnull=yes" > arm-linux.cache
./configure --host=mipsel-openwrt-linux CC=mipsel-openwrt-linux-gcc LD=mipsel-openwrt-linux-ld -cache-file=arm-linux.cache
linux@ubuntu:~/linux_c/iperf-2.0.5/src$ file iperfiperf: ELF 32-bit LSB executable, MIPS,MIPS32 rel2 version 1, dynamically linked (usesshared libs), with unknown capability 0xf41 = 0x756e6700, with unknowncapability 0x70100 = 0x3040000, not stripped发现默认是动态文件,最好可以编译成静态,可惜无法编译成功,看信息是因为libstdc++.so.6缺乏部分函数定义
linux@ubuntu:~/linux_c/iperf-2.0.5/src$ cd../linux@ubuntu:~/linux_c/iperf-2.0.5$./configure --host=mipsel-openwrt-linux CC=mipsel-openwrt-linux-gccLD=mipsel-openwrt-linux-ld ac_cv_func_malloc_0_nonnull=yes CFLAGS=-static –无法编译成功,注意要先make clean4)下载到开发板进行 测试
./iperf: can't load library 'libstdc++.so.6'
交叉编译工具链有的这个库,需要把工具链中的文件拷贝进开发板的/usr/lib
root@OpenWrt:/tmp# ./iperf -c 192.168.0.107
------------------------------------------------------------
Client connecting to 192.168.0.107, TCP port 5001
TCP window size: 20.5 KByte (default)
------------------------------------------------------------
local 192.168.0.143 port 44193 connected with 192.168.0.107 port 5001
[ ID] Interval Transfer Bandwidth
0.0-10.0 sec94.8 MBytes79.3 Mbits/sec
root@OpenWrt:/tmp# ./iperf -l 2048 -c 192.168.0.107
------------------------------------------------------------
Client connecting to 192.168.0.107, TCP port 5001
TCP window size: 20.5 KByte (default)
------------------------------------------------------------
local 192.168.0.143 port 44194 connected with 192.168.0.107 port 5001
[ ID] Interval Transfer Bandwidth
0.0-10.0 sec78.7 MBytes66.1 Mbits/sec
6. ixcharit测试工具
用的无线网卡测试 ;无线对有线,无线对无线转自:http://blog.csdn.net/xushx_bigbear/article/details/47997995
页:
[1]