如果在测试中想知道两台机器见最大的连接速度。用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