利用netperf、iperf、mtr測試網絡

一、netperf安裝和使用服務器

  netperf安裝網絡

 

 # tar -xzvf netperf-2.7.0.tar.gz
# cd netperf-2.7.0
# ./configure
# make
# make install

在客戶端和服務器上都安裝好。工具

  netperf使用 測試

  首先在服務器端運行netserver.spa

#./netserver -p 49152 -L 172.18.0.14

Starting netserver with host '172.18.0.14' port '49152' and family AF_UNSPEC
命令行

  在client端利用netperf經過命令行來測試code

  -H:服務器的ip地址server

  -p:端口號blog

  -L:本地ip地址ip

  -m:發送數據大小

  -l:運行時間

  TCP_STREAM批量傳輸

./netperf -H 172.18.0.14 -p 49152 -L 172.18.0.13 -l 60 -- -m 32768

  

#./netperf -H 172.16.0.14 -p 49152 -l 60 -- -m 4
Recv   Send    Send                          
Socket Socket  Message  Elapsed              
Size   Size    Size     Time     Throughput  
bytes  bytes   bytes    secs.    10^6bits/sec 
 
87380  65536      4    60.00      27.14
[root@cn13 src]# ./netperf -H 172.18.0.14 -p 49152 -L 172.18.0.13 -l 60 -- -m 32768
MIGRATED TCP STREAM TEST from 172.18.0.13 () port 0 AF_INET to 172.18.0.14 () port 0 AF_INET
Recv   Send    Send                          
Socket Socket  Message  Elapsed              
Size   Size    Size     Time     Throughput  
bytes  bytes   bytes    secs.    10^6bits/sec  

 87380  65536  32768    60.00    7714.07 

  測試TCP_RR

  -r 4,4:請求大小,響應大小

若是隻有一個參數-r 4,那麼請求和響應大小就是4.

[root@cn13 src]# ./netperf -t TCP_RR -H 172.16.0.14 -p 49152 -L 172.16.0.13 -l 60 -- -r 4
MIGRATED TCP REQUEST/RESPONSE TEST from 172.16.0.13 () port 0 AF_INET to 172.16.0.14 () port 0 AF_INET : first burst 0
Local /Remote
Socket Size   Request  Resp.   Elapsed  Trans.
Send   Recv   Size     Size    Time     Rate         
bytes  Bytes  bytes    bytes   secs.    per sec   

65536  87380  4        4       60.00    14082.09  

二、iperf的安裝和使用

  iperf安裝

tar -xzvf iperf-3.0b5.tar.gz
[root@cn14 tangwh]# cd iperf-3.0b5
[root@cn14 iperf-3.0b5]# ./configure
[root@cn14 iperf-3.0b5]# make
[root@cn14 iperf-3.0b5]# make install

  iperf使用  

  服務器端:

  啓動服務器

[root@cn14 src]# iperf3 -s -p 12345 -i 1

  客戶端:

  -c:服務端的IP

  -p:端口號

  -t:傳輸的總時間

  -i:每次報告之間的時間間隔

[root@cn13 src]# iperf3 -c 172.16.0.14 -p 12345 -i 1 -t 10
Connecting to host 172.16.0.14, port 12345
[  4] local 172.16.0.13 port 46587 connected to 172.16.0.14 port 12345
[ ID] Interval           Transfer     Bandwidth       Retransmits
[  4]   0.00-1.01   sec   115 MBytes   956 Mbits/sec  0
[  4]   1.01-2.00   sec   112 MBytes   949 Mbits/sec  0
[  4]   2.00-3.02   sec   115 MBytes   952 Mbits/sec  0
[  4]   3.02-4.01   sec   112 MBytes   949 Mbits/sec  0
[  4]   4.01-5.01   sec   112 MBytes   950 Mbits/sec  0
[  4]   5.01-6.00   sec   112 MBytes   949 Mbits/sec  0
[  4]   6.00-7.02   sec   115 MBytes   949 Mbits/sec  0
[  4]   7.02-8.01   sec   112 MBytes   950 Mbits/sec  0
[  4]   8.01-9.01   sec   112 MBytes   947 Mbits/sec  0
[  4]   9.01-10.00  sec   112 MBytes   949 Mbits/sec  0
[ ID] Interval           Transfer     Bandwidth       Retransmits
      Sent
[  4]   0.00-10.00  sec  1.11 GBytes   950 Mbits/sec  0
      Received
[  4]   0.00-10.00  sec  1.11 GBytes   949 Mbits/sec

iperf Done.

三、Mtr是 Linux中有一個很是棒的網絡連通性判斷工具。

  -c:發送多少個數據包

  -s:發送的ping數據包的大小

  -a:設置發送數據包的IP地址

  --report:顯示結果在終端上

  172.16.0.14指的是要ping的ip地址

[root@cn13 tangwh]# mtr -c 10 -s 2 -a 172.16.0.13 --report 172.16.0.14
HOST: cn13                        Loss%   Snt   Last   Avg  Best  Wrst StDev
  1. mn14                          0.0%    10    0.2   0.4   0.2   1.5   0.4

  其中host後是本機域名。

  第一列指的是IP地址

  第二列是每一個對應ip的丟包率

  第三列是每秒發送數據包的數量,默認爲10,用-c來設置

  第四列是最近一次的返回時延

  第五列是平均時延

  第六列是最短時延

  第七列是最長時延

  第八列是時延抖動

相關文章
相關標籤/搜索