很多时候,我们为了排查问题,往往需要了解对方网络带宽,下面给出几种方法:

  • 方法1:登录speedtest测速网,点击开始测速

  • 方法2:使用speedtest-cli
root:~ $ speedtest-cli
Retrieving speedtest.net configuration...
Testing from China Telecom fujian (59.61.184.111)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by China Unicom FuJian (Fuzhou) [1.63 km]: 25.097 ms
Testing download speed................................................................................
Download: 35.41 Mbit/s
Testing upload speed................................................................................................
Upload: 47.07 Mbit/s
  • 方法3:采用iperf

以上方法都要依赖speedtest,而最近发现speedtest不给力,因此找到了iperf。iperf是一个非常好用的命令,分服务端工作模式和客户端工作模式

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

-i 时间间隔
-p 指定端口
-u UDP
-d 双向
-s 服务端
-c 客户端
-t 测试时间
-b 指定发送速率

样例

# 服务端
root:~ $ iperf -s -i 1 -u
------------------------------------------------------------
Server listening on UDP port 5001
Receiving 1470 byte datagrams
UDP buffer size:  208 KByte (default)

# 客户端
smou:~ $ iperf -c 192.168.12.200 -i 1 -t 10 -b 30M
WARNING: option -b implies udp testing
------------------------------------------------------------
Client connecting to 192.168.12.200, UDP port 5001
Sending 1470 byte datagrams
UDP buffer size: 9.00 KByte (default)
------------------------------------------------------------
[  4] local 192.168.12.101 port 60797 connected with 192.168.12.200 port 5001
[ ID] Interval       Transfer     Bandwidth
[  4]  0.0- 1.0 sec  3.58 MBytes  30.0 Mbits/sec
[  4]  1.0- 2.0 sec  3.58 MBytes  30.0 Mbits/sec
[  4]  2.0- 3.0 sec  3.58 MBytes  30.0 Mbits/sec
[  4]  3.0- 4.0 sec  3.58 MBytes  30.0 Mbits/sec
[  4]  4.0- 5.0 sec  3.58 MBytes  30.0 Mbits/sec
[  4]  5.0- 6.0 sec  3.58 MBytes  30.0 Mbits/sec
[  4]  6.0- 7.0 sec  3.58 MBytes  30.0 Mbits/sec
[  4]  7.0- 8.0 sec  3.57 MBytes  30.0 Mbits/sec
[  4]  8.0- 9.0 sec  3.58 MBytes  30.0 Mbits/sec
[  4]  9.0-10.0 sec  3.58 MBytes  30.0 Mbits/sec
[  4]  0.0-10.0 sec  35.8 MBytes  30.0 Mbits/sec
[  4] Sent 25510 datagrams
[  4] Server Report:
[  4]  0.0- 9.9 sec  35.4 MBytes  29.9 Mbits/sec   0.393 ms  233/25509 (0.91%)
[  4]  0.0- 9.9 sec  1 datagrams received out-of-order