wjoyxt

iperf点对点网络性能测试工具

Iperf 是一个 TCP/IP 和 UDP/IP 的性能测量工具,能够提供网络吞吐率信息,以及震动、丢包率、最大段和最大传输单元大小等统计信息;从而能够帮助我们测试网络性能,定位网络瓶颈。

1.服务端

iperf -s -w 1m

2.客户端

iperf -c 192.168.43.1 -t 60 -i 2 -P 5 -w 1m

参数的含义:

-s  (server) 开启服务器

-c  (client)  指定服务端主机IP

-t  测试时长。默认10秒

-i  数据统计间隔,以秒为单位。          client 显示的是发送速率 , server端显示的是接收速率,最好加 i 参数进行速率跟踪

-p (小写)指定服务器端使用的端口或客户端所连接的端口

-P (大写)发包并发线程数

-w 设置TCP窗口大小,默认是8KB。如果窗口太小,有可能丢包

-u 使用udp协议。测试htb的时候最好用udp,udp通信开销小,测试的带宽更准确

-b 指定发送带宽,默认是1Mbit/s。与-u 选项相关,千兆链路使用90%容量进行测试就可以了: -u  -b 900M在测试qos的时候,这是最有用的参数

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

 

一般来说,我们在做性能测试的时候需要指定包长,不同的包长会得到不同的吞吐量,通过 -l 指定,而使用 -b 指定带宽 

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

使用 iperf 测试两台机器间的最大带宽

如果在测试中想知道两台机器见最大的连接速度。用scp拷一个文件应该是最容易的方法。但是不准确。 iperf 这个小工具就是专门用来干这个的。结果相对来说准确一些。使用起来也很方便。

首先在两台机器上都安装iperf

$ sudo apt-get install iperf

然后在需要测试的一台机器上 启动 iperf 监听

$ iperf -s
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------

然后在另外一台机器上连接过去

$ iperf -c 192.168.1.10
------------------------------------------------------------
Client connecting to 192.168.1.10, TCP port 5001
TCP window size: 18.6 KByte (default)
------------------------------------------------------------
[  3] local 192.168.1.9 port 60611 connected with 192.168.1.10 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec   112 MBytes  93.5 Mbits/sec

可以看到 连接速率是 93.5Mbps 局域网一般达不到全速。

另外还有个小工具 用来查看实时的传输速率 httperf

$ sudo apt-get install httperf
$ httperf
httperf --client=0/1 --server=localhost --port=80 --uri=/ --send-buffer=4096 --recv-buffer=16384 --num-conns=1 --num-calls=1
httperf: warning: open file limit > FD_SETSIZE; limiting max. # of open files to FD_SETSIZE
Maximum connect burst length: 0

Total: connections 1 requests 1 replies 1 test-duration 0.001 s

Connection rate: 1081.0 conn/s (0.9 ms/conn, <=1 concurrent connections)
Connection time [ms]: min 0.9 avg 0.9 max 0.9 median 0.5 stddev 0.0
Connection time [ms]: connect 0.2
Connection length [replies/conn]: 1.000

Request rate: 1081.0 req/s (0.9 ms/req)
Request size [B]: 62.0

Reply rate [replies/s]: min 0.0 avg 0.0 max 0.0 stddev 0.0 (0 samples)
Reply time [ms]: response 0.7 transfer 0.0
Reply size [B]: header 284.0 content 177.0 footer 0.0 (total 461.0)
Reply status: 1xx=0 2xx=1 3xx=0 4xx=0 5xx=0

CPU time [s]: user 0.00 system 0.00 (user 0.0% system 432.4% total 432.4%)
Net I/O: 552.1 KB/s (4.5*10^6 bps)

Errors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0
Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0

可以看到目前的网络IO 是 552.1KB/s 大约等于 4.5Mbps

 

分类:

技术点:

相关文章: