通常在 Linux 環境下會使用 iperf – https://benjr.tw/462 來當作測試網路效能工具,在 Windows 環境下 iperf 也有提供相對應的版本.
不過在 Microsoft 網站提到在 Azure 下建議使用 NTttcp 當作網路頻寬測試工具.
https://docs.microsoft.com/zh-tw/azure/virtual-network/virtual-network-bandwidth-testing
Amazon 的 AWS 文章也是建議使用 NTttcp.
https://aws.amazon.com/tw/premiumsupport/knowledge-center/network-throughput-benchmark-windows-ec2/
來看看這 NTttcp 如何使用.
測試環境 (虛擬機)
- Windows 2012 R2 x86_64 – IP : 192.168.95.149
- Ubuntu 16.04 x86_64 – IP 192.168.95.151
Windows
下載點 https://gallery.technet.microsoft.com/NTttcp-Version-528-Now-f8b12769 安裝就不說明了.
解開後建議存放在 c:\NTttcp” 資料夾,如果有設定 Windows 防火牆,需打開 NTttcp 權限.
下面設定防火牆指令需要有 administrator 權限,可以透過 command prompt (admin).
C:\Windows\system32>netsh advfirewall firewall add rule program=c:\NTttcp\amd64fre\ntttcp.exe name= "ntttcp" protocol=any dir=in action=allow enable=yes profile=ANY Ok. |
Linux
NTttcp 屬於 opensource 由 Windows 開發,透過 clone 就可以從 https://github.com 下載.
root@ubuntu:~# apt-get -y install build-essential root@ubuntu:~# apt-get -y install git root@ubuntu:~# git clone https: //github.com/Microsoft/ntttcp-for-linux root@ubuntu:~# cd ntttcp- for -linux/src root@ubuntu:~/ntttcp- for -linux/src# make && make install |
如果是 CentOS 則需要透過 yum 下載 gcc 與 git 套件才能安裝.
Windows < Linux
Windows (Receiver)
c:\NTttcp\amd64fre>NTttcp.exe -r -m 1,0,192.168.95.149 Copyright Version 5.33 |
使用參數:
- -r
當作接收端 (receiver). - -m <mappings>
mapping 需要三個參數 1. session count (連線數), 2. processor number(指定使用哪一個處理器來進行封包處理), 3. receiver address or name (接收端的 IP)
範例: -m 4,0,1.2.3.4 表示為- 4 – 表示使用 4 個連線數 (sessions).
- 0 – 表示使用所有的處理器.
- 1.2.3.4 – 表示接收端的 IP.
Linux (Sender)
root@ubuntu:~# ntttcp -s -m 1,0,192.168.95.149 -N -t 30 NTTTCP for Linux 1.3.4 --------------------------------------------------------- 12:15:49 INFO: main: set cpu affinity 12:15:49 INFO: Starting sender activity (no sync) ... 12:15:49 INFO: 1 threads created 12:16:19 INFO: Test run completed. 12:16:19 INFO: Test cycle finished. 12:16:20 INFO: 1 connections tested 12:16:20 INFO: ##### Totals: ##### 12:16:20 INFO: test duration :30.01 seconds 12:16:20 INFO: total bytes :303584 12:16:20 INFO: throughput :80.93Kbps 12:16:20 INFO: cpu cores :2 12:16:20 INFO: cpu speed :2294.870MHz 12:16:20 INFO: user :0.41% 12:16:20 INFO: system :0.68% 12:16:20 INFO: idle :98.89% 12:16:20 INFO: iowait :0.00% 12:16:20 INFO: softirq :0.02% 12:16:20 INFO: cycles/byte :5028.13 12:16:20 INFO: cpu busy (all) :4.11% --------------------------------------------------------- |
使用參數:
- -s
當作傳送端 (Sender). - -m <mappings>
mapping 需要三個參數 1. session count (連線數), 2. processor number(指定使用哪一個處理器來進行封包處理), 3. receiver address or name (接收端的 IP) - -t <Runtime>
測試時間(單位為秒) - -N
啟用非同步模式, Linux 使用 -N 而 Windows 使用 -ns 參數.
Windows > Linux
和剛剛測試差不多,需要注意的是 IP 變成 Linux (Receiver) , Windows 需要加 -ns (非同步模式).
Linux (Receiver)
root@ubuntu:~# ntttcp -r -m 1,0,192.168.95.151 NTTTCP for Linux 1.3.4 --------------------------------------------------------- 16:30:43 INFO: main: set cpu affinity 16:30:43 INFO: 2 threads created |
Windows (Sender)
c:\NTttcp\amd64fre>NTttcp.exe -s -m 1,0,192.168.95.151 -ns -t 30 Copyright Version 5.33 Network activity progressing... Thread Time(s) Throughput(KB/s) Avg B / Compl ====== ======= ================ ============= 0 30.005 92340.877 65536.000 ##### Totals: ##### Bytes(MEG) realtime(s) Avg Frame Size Throughput(MB/s) ================ =========== ============== ================ 2705.750000 30.005 1456.356 90.177 Throughput(Buffers/s) Cycles/Byte Buffers ===================== =========== ============= 1442.826 22.975 43292.000 DPCs( count /s) Pkts(num/DPC) Intr( count /s) Pkts(num/intr) ============= ============= =============== ============== 2223.829 1.347 3955.174 0.758 Packets Sent Packets Received Retransmits Errors Avg. CPU % ============ ================ =========== ====== ========== 1948140 89900 0 0 94.620 |
其他參數:
-l <Length of buffer> [default TCP: 64K, UDP: 128]
-n <Number of buffers> [default: 20K]
-p <port base> [default: 5001]
-sp Synchronize data ports, if used -p must be same on every instance.
-to <timeout> in milliseconds. [default: 600000]
-a <outstanding I/O> [default: 2]
-rb <Receive buffer size> [default: -1]
-sb <Send buffer size> , default: 0 with -a; 8K otherwise
-ndl set TCP_NODELAY socket option
-u UDP send / recv
-w WSARecv / WSASend
-d Verify Flag
-cd <Cool-down> in seconds
-wu <Warm-up> in seconds
-v enable verbose mode
-6 enable IPv6 mode
-wa Sets the WAIT_ALL flag when using recv or WSARecv functions
-nic <NIC IP> Use NIC with <NIC IP> for sending data (sender only).
-xml [filename] save XML output to a file, by default saves to xml.txt