簡單測試 bandwidth 方法

公司需要在北京找一個 data center 放 server,最後通過 agent 決定在位於中關村科技發展大廈的電信通數據中心(前身中關村數據)租了一個 2U 100M shared 的地方。Agent 說能保證 bandwidth 最少 1Mbps,最多也不會超過 1.2Mbps。但基於 sales 的不可信性,還是有自己去測試一下 bandwidth 的必要的。這裡給大家一個簡單的 poor man’s way 來測試 bandwidth,一般人會用 HTTP/FTP 傳送 file 的方法來看一下速度有多快,但是需要先裝好 HTTP 或 FTP daemon。我喜歡用 netcat,因為使用非常簡單。除了 netcat,你亦需要一個用來 monitor network bandwidth usage 的軟件,用來查看實際的網絡流量,推薦使用 muninntop

netcat 的使用方法非常簡單,步驟如下:

  1. 假設我的 server 叫電腦 A,你需要再多找一台電腦,叫電腦 B(我就找了一台在香港 data center 的 server)
  2. 在電腦 B 執行命令:netcat -l -p 10000 > /dev/null。意思就是用 netcat 監聽 port 10000,而且接收到的所有 data 都當成是垃圾扔到 /dev/null 這個黑洞裡。
  3. 在電腦 A 執行命令:netcat [電腦 B 的 IP] 10000 < /dev/urandom。意思就是連接到電腦 B 的 port 10000, 並且不斷 send data。 Linux 會為 /dev/urandom 不斷的供應一些隨機的 data。

就這樣,便可以測試電腦 A 的 outbound bandwidth 了。再多找兩三台電腦(當然是在不同的 network 的)同時 send 和 receive,差不多就能把可用的 bandwidth 用盡了。如果要測試 inbound bandwidth,把 A 和 B 的身份對換就可以了。

P.S. 測試後發現,bandwidth 比想像中的要好,深夜的時候可以達到 3Mbps,連到國內的 server 更可以達到 10Mbps!到白天基本上 bandwidth 就回落了。

Network bandwidth testing for Beijing server using munin

9 thoughts on “簡單測試 bandwidth 方法”

  1. 請問如果不是linux的主機,而是windows的主機,有相關軟體可以測嗎?希望能與你深入研究唷!交個朋友吧!@@~好嗎?你有msn嗎?寄信給我唷..

  2. Windows 下就不行了,有什麼軟件可用我也不太清楚,可能用 cygwin 可以,因為 cygwin 裡面有 netcat 的程序。你還是找個 Windows 的高人指點迷津吧 :)

    我的 email 在右邊能找到,你可以 send email 給我。

  3. I have the same problem before, which i need to test the b/w and ping time.

    there is one more command in windows which can be useful: pingpath and that will gives you the ping time of the path, so you can then find the bottle-neck.

    HTH.

Leave a Reply

Your email address will not be published.


eight − 2 =

This site uses Akismet to reduce spam. Learn how your comment data is processed.