您的位置:首页 > 理论基础 > 计算机网络

iperf 测试网络性能

2013-05-02 09:59 507 查看
最近移植了Ralink的rt5370的USB wifi 驱动, ld要求测试一下性能,与先前的sdio wifi进行比较。

使用iperf工具。 ierf的用法如下所示:

Usage: iperf [-s|-c host] [options]

iperf [-h|--help] [-v|--version]

Client/Server:

-f, --format [kmKM] format to report: Kbits, Mbits, KBytes, MBytes

-i, --interval # seconds between periodic bandwidth reports

-l, --len #[KM] length of buffer to read or write (default 8 KB)

-m, --print_mss print TCP maximum segment size (MTU - TCP/IP header)

-o, --output <filename> output the report or error message to this specified file

-p, --port # server port to listen on/connect to

-u, --udp use UDP rather than TCP

-w, --window #[KM] TCP window size (socket buffer size)

-B, --bind <host> bind to <host>, an interface or multicast address

-C, --compatibility for use with older versions does not sent extra msgs

-M, --mss # set TCP maximum segment size (MTU - 40 bytes)

-N, --nodelay set TCP no delay, disabling Nagle's Algorithm

-V, --IPv6Version Set the domain to IPv6

Server specific:

-s, --server run in server mode

-U, --single_udp run in single threaded UDP mode

-D, --daemon run the server as a daemon

Client specific:

-b, --bandwidth #[KM] for UDP, bandwidth to send at in bits/sec

(default 1 Mbit/sec, implies -u)

-c, --client <host> run in client mode, connecting to <host>

-d, --dualtest Do a bidirectional test simultaneously

-n, --num #[KM] number of bytes to transmit (instead of -t)

-r, --tradeoff Do a bidirectional test individually

-t, --time # time in seconds to transmit for (default 10 secs)

-F, --fileinput <name> input the data to be transmitted from a file

-I, --stdin input the data to be transmitted from stdin

-L, --listenport # port to recieve bidirectional tests back on

-P, --parallel # number of parallel client threads to run

-T, --ttl # time-to-live, for multicast (default 1)

-Z, --linux-congestion <algo> set TCP congestion control algorithm (Linux only)

Miscellaneous:

-x, --reportexclude [CDMSV] exclude C(connection) D(data) M(multicast) S(settings) V(server) reports

-y, --reportstyle C report as a Comma-Separated Values

-h, --help print this message and quit

-v, --version print version information and quit

首先板子联网:

arm-linux$ mkdir /etc/Wireless

arm-linux$ mkdir /etc/Wireless/RT2870STA

arm-linux$ cp /mnt/RT2870STA.dat /etc/Wireless/RT2870STA/

arm-linux$ ifconfig ra0 inet 192.168.1.44 up

arm-linux$ iwpriv ra0 set SSID="NewNet"

arm-linux$ route add default gw 192.168.1.1

arm-linux$ ping 192.168.1.1

PING 192.168.1.1 (192.168.1.1): 56 data bytes

64 bytes from 192.168.1.1: seq=0 ttl=64 time=9.709 ms

64 bytes from 192.168.1.1: seq=1 ttl=64 time=5.316 ms

64 bytes from 192.168.1.1: seq=2 ttl=64 time=3.661 ms

64 bytes from 192.168.1.1: seq=3 ttl=64 time=3.526 ms

--- 192.168.1.1 ping statistics ---

4 packets transmitted, 4 packets received, 0% packet loss

round-trip min/avg/max = 3.526/5.553/9.709 ms

无线AP已经通过RJ45接到公司内网,尝试ping一下内网的linux服务器(11.7.16.108):

arm-linux$ ping 11.7.16.108

PING 11.7.16.108 (11.7.16.108): 56 data bytes

64 bytes from 11.7.16.108: seq=0 ttl=63 time=10.555 ms

64 bytes from 11.7.16.108: seq=1 ttl=63 time=3.249 ms

64 bytes from 11.7.16.108: seq=2 ttl=63 time=3.118 ms

64 bytes from 11.7.16.108: seq=3 ttl=63 time=3.641 ms

64 bytes from 11.7.16.108: seq=4 ttl=63 time=6.906 ms

^Z[7]+ Stopped ping 11.7.16.108

OK, 通了,可以使用iperf工具了:

1, 工作电脑(WIN7)通过putty登录11.7.16.108,

$ iperf -s

------------------------------------------------------------

Server listening on TCP port 5001

TCP window size: 85.3 KByte (default)

------------------------------------------------------------

2, 开发板

arm-linux$ iperf -c 11.7.16.108

------------------------------------------------------------

Client connecting to 11.7.16.108, TCP port 5001

TCP window size: 16.0 KByte (default)

------------------------------------------------------------

[ 3] local 192.168.1.44 port 42700 connected with 11.7.16.108 port 5001

[ ID] Interval Transfer Bandwidth

[ 3] 0.0-10.1 sec 10.8 MBytes 8.95 Mbits/sec

arm-linux$ iperf -c 11.7.16.108 -i 2

------------------------------------------------------------

Client connecting to 11.7.16.108, TCP port 5001

TCP window size: 16.0 KByte (default)

------------------------------------------------------------

[ 3] local 192.168.1.44 port 42701 connected with 11.7.16.108 port 5001

[ ID] Interval Transfer Bandwidth

[ 3] 0.0- 2.0 sec 2.12 MBytes 8.91 Mbits/sec

[ 3] 2.0- 4.0 sec 2.12 MBytes 8.91 Mbits/sec

[ 3] 4.0- 6.0 sec 2.00 MBytes 8.39 Mbits/sec

[ 3] 6.0- 8.0 sec 2.25 MBytes 9.44 Mbits/sec

[ 3] 8.0-10.0 sec 2.25 MBytes 9.44 Mbits/sec

[ 3] 0.0-10.1 sec 10.9 MBytes 9.08 Mbits/sec

测出来啦,带宽也就8-9M的样子。

上面测出来的是TCP的带宽,要测UDP带宽,在客户端要使用-b参数:

使用iperf的-b参数可以指定带宽大小,请注意这个指定的带宽大小并不是我们要测试的网络的带宽,我们测试的网络的带宽是最大值。

要获得带宽数据,需要通过-b不断在client端增加带宽值,直到server端出现轻微的丢包为止,此时server端显示的带宽就是被测系统的吞吐量。

不指定-b参数的话,默认是1M,所以测出来的结果会是1Mbps

例如: iperf -c 192.168.1.102 -u -b 5M 执行结果是,只有3Mbps

------------------------------------------------------------

Client connecting to 192.168.1.100, UDP port 5001

Sending 1470 byte datagrams

UDP buffer size: 32.0 KByte (default)

------------------------------------------------------------

[ 3] local 192.168.1.104 port 33027 connected with 192.168.1.100 port 5001

[ ID] Interval Transfer Bandwidth

[ 3] 0.0-10.0 sec 3.59 MBytes 3.00 Mbits/sec

[ 3] Sent 2561 datagrams

[ 3] Server Report:

[ 3] 0.0-10.1 sec 3.59 MBytes 2.99 Mbits/sec 7.435 ms 0/ 2560 (0%)

[ 3] 0.0-10.1 sec 1 datagrams received out-of-order

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

-------------------------------------------------------- More Infomation ----------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

perf是一个网络性能测试工具。可以测试TCP和UDP带宽质量,可以测量最大TCP带宽,具有多种参数和UDP特性,可以报告带宽,延迟抖动和数据包丢失。Iperf在linux和windows平台均有二进制版本供自由使用。

Iperf was developed by NLANRDAST as a modern alternative for measuring maximum TCP and UDP bandwidth performance. Iperf allows the tuning of various parameters and UDP characteristics. Iperf reports bandwidth, delay jitter, datagram loss.

Iperf使用方法与参数说明

参数说明

-s 以server模式启动,eg:iperf -s

-c host以client模式启动,host是server端地址,eg:iperf -c 222.35.11.23

通用参数

-f [kmKM] 分别表示以Kbits, Mbits, KBytes, MBytes显示报告,默认以Mbits为单位,eg:iperf -c 222.35.11.23 -f K

-i sec 以秒为单位显示报告间隔,eg:iperf -c 222.35.11.23 -i 2

-l 缓冲区大小,默认是8KB,eg:iperf -c 222.35.11.23 -l 16

-m 显示tcp最大mtu值

-o 将报告和错误信息输出到文件eg:iperf -c 222.35.11.23 -o ciperflog.txt

-p 指定服务器端使用的端口或客户端所连接的端口eg:iperf -s -p 9999;iperf -c 222.35.11.23 -p 9999

-u 使用udp协议

-w 指定TCP窗口大小,默认是8KB

-B 绑定一个主机地址或接口(当主机有多个地址或接口时使用该参数)

-C 兼容旧版本(当server端和client端版本不一样时使用)

-M 设定TCP数据包的最大mtu值

-N 设定TCP不延时

-V 传输ipv6数据包

server专用参数

-D 以服务方式运行iperf,eg:iperf -s -D

-R 停止iperf服务,针对-D,eg:iperf -s -R

client端专用参数

-d 同时进行双向传输测试

-n 指定传输的字节数,eg:iperf -c 222.35.11.23 -n 100000

-r 单独进行双向传输测试

-t 测试时间,默认10秒,eg:iperf -c 222.35.11.23 -t 5

-F 指定需要传输的文件

-T 指定ttl值

应用实例

使用 iperf -s 命令将 Iperf 启动为 server 模式,在客户机上使用 iperf -c启动client模式。

iperf –s

————————————————————

Server listening on TCP port 5001

TCP window size: 8.00 KByte (default)

————————————————————

iperf -c 59.128.103.56

上面使用服务端和客户端的默认设置进行测试

iperf -s -w 300K

————————————————————

Server listening on TCP port 5001

TCP window size: 300 KByte

————————————————————

iperf -c 59.128.103.56 -f K -i 2 -w 300K

设定报告间隔为2秒,服务器端和客户端的TCP窗口都开到300KB

iperf -c 59.128.103.56 -f K -i 2 -w 300K –n 1000000

测试传输约1MB数据

iperf -c 59.128.103.56 -f K -i 2 -w 300K –t 36

测试持续36秒

iperf -c 59.128.103.56 -f K -i 2 -w 300K -n 10400000 –d

测试双向的传输

iperf -c 59.128.103.56 -f K -i 2 -w 300K –u

UDP测试

其中 -i 参数的含义是周期性报告的时间间隔(interval),单位为秒;在上面的例子中,表示每隔2秒报告一次带宽等信息。

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: