Jamyy's Weblog

在 Linux CLI 進行網路頻寬測試

by Jamyy on 十一月.17, 2014, under Linux

  • iperf - 區域網路頻寬測試
  • speedtest-cli - 寬頻網路頻寬測試

操作環境: Ubuntu / CentOS

安裝 iperf

Debian / Ubuntu
$ sudo apt-get install iperf

Red Hat 6 / CentOS 6 (with EPEL repo)
$ su -c "yum install iperf"

Red Hat 7 / CentOS 7
$ su -c "rpm -Uvh ftp://rpmfind.net/linux/fedora/linux/updates/19/x86_64/iperf-2.0.5-11.fc19.x86_64.rpm"

iperf 基本操作

Server (192.168.1.1)
$ iperf -s

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

Client (192.168.1.100)
$ iperf -c 192.168.1.1

------------------------------------------------------------
Client connecting to 192.168.1.1, TCP port 5001
TCP window size: 85.0 KByte (default)
------------------------------------------------------------
[  3] local 192.168.1.100 port 55597 connected with 192.168.1.1 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec  1.09 GBytes   938 Mbits/sec


 
安裝 speedtest-cli

Debian / Ubuntu
$ sudo apt-get install python-pip
$ sudo pip install speedtest-cli

Red Hat / CentOS (with EPEL repo)
$ su -c "yum install python-pip"
$ su -c "pip install speedtest-cli"

speedtest-cli 基本操作

自動搜尋最近的 speedtest.net server 進行測速
$ speedtest-cli

Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from So-net Entertainment Taiwan Limited (27.105.153.4)...
Selecting best server based on latency...
Hosted by Asia Pacific Telecom (Taipei) [1.06 km]: 12.081 ms
Testing download speed........................................
Download: 19.20 Mbits/s
Testing upload speed..................................................
Upload: 4.92 Mbits/s

在 speedtest.net 產生 png 圖檔分享測速結果
$ speedtest-cli --share

Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from So-net Entertainment Taiwan Limited (27.105.153.4)...
Selecting best server based on latency...
Hosted by Chief Telecom (Taipei) [1.06 km]: 12.259 ms
Testing download speed........................................
Download: 19.23 Mbits/s
Testing upload speed..................................................
Upload: 4.91 Mbits/s
Share results: http://www.speedtest.net/result/3915036901.png

圖片連結: http://www.speedtest.net/result/3915036901.png

依距離排序列出 speedtest.net server 清單
$ speedtest-cli --list

Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
5008) Asia Pacific Telecom (Taipei, Taiwan) [1.06 km]
2327) Far Eastone Telecommunications Co., Ltd. (Taipei, Taiwan) [1.06 km]
2188) TFN Media Co., Ltd. (Taipei, Taiwan) [1.06 km]
2133) Taiwan Fixed Network (Taipei, Taiwan) [1.06 km]
5056) Taipei Fiber (Taipei, Taiwan) [1.06 km]
2181) kbro Co., Ltd. (Taipei, Taiwan) [1.06 km]
5315) Taiwan Star Telecom Co., Ltd. (Taipei, Taiwan) [1.06 km]
3967) Chief Telecom (Taipei, Taiwan) [1.06 km]
...
1657) NetCertto (Cascavel, Brazil) [19509.12 km]
4430) CLICKNETRS (Sao Paulo das Missoes, Brazil) [19531.52 km]
5126) Cabletel Mercedes (Mercedes, Argentina) [19550.81 km]
4461) OpcaoNet Telecom (Nova Santa Rosa, Brazil) [19554.21 km]
5494) PIPELINE (Ciudad del Este, Paraguay) [19623.54 km]
3773) Sol Internet (Santa Rita, Paraguay) [19646.11 km]
4885) Sur Multimedia SA (Encarnacion, Paraguay) [19653.05 km]
2830) Núcleo S.A., Personal (Asuncion, Paraguay) [19929.89 km]
2619) COPACO S.A. (Asuncion, Paraguay) [19929.89 km]
1480) Telecel SA (Asuncion, Paraguay) [19929.89 km]

指定 speedtest.net server 進行測速
$ speedtest-cli --server 1480

Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from So-net Entertainment Taiwan Limited (27.105.153.4)...
Hosted by Telecel SA (Asuncion) [19929.89 km]: 623.06 ms
Testing download speed........................................
Download: 10.19 Mbits/s
Testing upload speed..................................................
Upload: 3.36 Mbits/s


 
Ref:



:,