1. 程式人生 > >Linux伺服器網路頻寬測試——iperf

Linux伺服器網路頻寬測試——iperf

0. iperf原理解析

  iperf工具可以用來測量TCP或者是UDP的網路吞吐量,即bandwidth(頻寬)測試。
  iPerf的主要目標是幫助調整特定路徑上的TCP連線。 眾所周知,TCP最基本的調整問題是調整TCP視窗大小,它控制在任何一點在網路中可以有多少資料。如果它太小,傳送者將會在一段時間內處於空閒狀態,從而影響傳送TCP的效能。TCP視窗大小的理論值是:瓶頸頻寬與往返延時的乘積,即:

bottleneck bandwidth * round trip time

  例如瓶頸鍊路是45 Mbit/sec,使用ping命令測量到的往返時延是42ms。那麼TCP視窗的理論值是

45 Mbit/sec * 42 ms = (45e6) * (42e-3) = 1890000 bits= 230 KByte

在實際測試中,可以以計算得到的TCP視窗為基準,在這個值(如上面為230KByte)的基礎上,升高或者降低TCP視窗大小,可以得到一個性能的提升。

   頻寬測試一般來說採用UDP模式測試,因為在UDP模式下能測出極限頻寬、路徑時延、丟包率,這些測試項會在頻寬測試報告中打印出來。在進行測試時,先以鏈路理論頻寬作為資料傳送速率進行測試,例如,從客戶端到伺服器之間的鏈路的理論頻寬為1000Mbps,先用 -b 1000M進行測試,然後根據測試結果(包括實際頻寬,時延抖動和丟包率),再以實際頻寬作為資料傳送速率進行測試,會發現時延抖動和丟包率比第一次好很多,重複測試幾次,就能得出穩定的實際頻寬。
  iperf是基於server-client模式工作的,因此,要使用iperf測試頻寬,需要建立一個服務端(用於丟棄流量)和一個客戶端(用於產生流量)。iperf服務端或者是客戶端,都是使用的同一個命令,不過是啟動命令的選項不同而已。

1. iperf服務啟動方式

先看下服務端和客戶端的啟動方式:

  • 服務端

iperf -s

  • 客戶端

iperf -c

注意:iperf預設測試的是TCP協議的頻寬,如果需要測試UDP的頻寬,則需要加上-u選項

2. iperf常用選項

 
  iperf選項分為 通用選項、服務端特定選項以及客戶端特定選項

  • 通用選項
-f <kmKM>    報告輸出格式。 [kmKM]   format to report: Kbits, Mbits, KBytes, MBytes
-i <sec>    在週期性報告頻寬之間暫停n秒。如週期是10
s,則-i指定為2,則每隔2秒報告一次頻寬測試情況,則共計報告5
-p 設定服務端監聽的埠,預設是5001 -u 使用UDP協議測試 -w n<K/M> 指定TCP視窗大小 -m 輸出MTU大小 -M 設定MTU大小 -o <filename> 結果輸出至檔案
  • 服務端選項
-s    iperf伺服器模式
-d    以後臺模式執行服務端
-U    執行一個單一執行緒的UDP模式
  • 客戶端選項
-b , --bandwidth n[KM]    指定客戶端通過UDP協議傳送資料的頻寬(bit/s)。預設是1Mbit/s
-c <ServerIP>    以客戶端模式執行iperf,並且連線至服務端主機ServerIPeg:  iperf -c <server_ip>
-d    雙向測試
-t    指定iperf頻寬測試時間,預設是10s。  eg:  iperf -c <server_ip> -t 20
-P    指定客戶端併發執行緒數,預設只執行一個執行緒。 eg,指定3個執行緒 : iperf -c <server_ip> -P 3
-T    指定TTL

3.例項

master 為服務端
minion 為客戶端
注意:必須先執行iperf server

  • 2秒返回一次頻寬測試報告
[[email protected] ~]# iperf -s -i 2
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
[  4] local 192.168.159.135 port 5001 connected with 192.168.159.136 port 57065
[ ID] Interval       Transfer     Bandwidth
[  4]  0.0- 2.0 sec   907 MBytes  3.80 Gbits/sec
[  4]  2.0- 4.0 sec   870 MBytes  3.65 Gbits/sec
[  4]  4.0- 6.0 sec   864 MBytes  3.62 Gbits/sec
[  4]  6.0- 8.0 sec   949 MBytes  3.98 Gbits/sec
[  4]  8.0-10.0 sec   813 MBytes  3.41 Gbits/sec
[  4]  0.0-10.0 sec  4.31 GBytes  3.69 Gbits/sec
[[email protected] ~]# iperf -c 192.168.159.135 -i 2
------------------------------------------------------------
Client connecting to 192.168.159.135, TCP port 5001
TCP window size: 19.3 KByte (default)
------------------------------------------------------------
[  3] local 192.168.159.136 port 57065 connected with 192.168.159.135 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0- 2.0 sec   912 MBytes  3.82 Gbits/sec
[  3]  2.0- 4.0 sec   872 MBytes  3.66 Gbits/sec
[  3]  4.0- 6.0 sec   863 MBytes  3.62 Gbits/sec
[  3]  6.0- 8.0 sec   949 MBytes  3.98 Gbits/sec
[  3]  8.0-10.0 sec   814 MBytes  3.41 Gbits/sec
[  3]  0.0-10.0 sec  4.31 GBytes  3.70 Gbits/sec

  上面兩個測試很簡單,但需要注意的是,以上測試都是客戶端到服務端的上行頻寬測試。如果還需要進行下行測試,我們可以直接使用雙向測試,測試如下:

  • 雙向測試
[[email protected] ~]# iperf -s
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
[  4] local 192.168.159.135 port 5001 connected with 192.168.159.136 port 56617
------------------------------------------------------------
Client connecting to 192.168.159.136, TCP port 5001
TCP window size: 19.3 KByte (default)
------------------------------------------------------------
[  5] local 192.168.159.135 port 48055 connected with 192.168.159.136 port 5001
[ ID] Interval       Transfer     Bandwidth
[  4]  0.0- 2.0 sec   528 MBytes  2.20 Gbits/sec
[  5]  0.0- 2.0 sec   425 MBytes  1.78 Gbits/sec
[[email protected] ~]# iperf -c 192.168.159.135 -t 2 -d
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
------------------------------------------------------------
Client connecting to 192.168.159.135, TCP port 5001
TCP window size:  174 KByte (default)
------------------------------------------------------------
[  5] local 192.168.159.136 port 56617 connected with 192.168.159.135 port 5001
[  4] local 192.168.159.136 port 5001 connected with 192.168.159.135 port 48055
[ ID] Interval       Transfer     Bandwidth
[  5]  0.0- 2.0 sec   528 MBytes  2.21 Gbits/sec
[  4]  0.0- 2.0 sec   425 MBytes  1.77 Gbits/sec

注意看下面兩行:

[  5] local 192.168.159.136 port 56617 connected with 192.168.159.135 port 5001
[  4] local 192.168.159.136 port 5001 connected with 192.168.159.135 port 48055

[5]標誌開頭的是上行測試,因為server端端口才是5001。相應的,[4]標誌開頭的是下行測試。後面的頻寬測試列印的時候,都是以[5]、[4]標記來區分是上行還是下行的。

  • UDP測試

      該測試中理論頻寬10000Mbits/s(內網,萬兆交換機,萬兆網絡卡)。因此測試時我先按照理論頻寬10000Mbits/sec來測試,然後根據測試報告,反覆測試,得到極限頻寬為815 Mbits/sec
      測試報告如下:

[[email protected] ~]# iperf -s -u 
------------------------------------------------------------
Server listening on UDP port 5001
Receiving 1470 byte datagrams
UDP buffer size:  122 KByte (default)
------------------------------------------------------------
[  3] local 10.65.14.43 port 5001 connected with 10.65.14.42 port 5586
[ ID] Interval       Transfer     Bandwidth        Jitter   Lost/Total Datagrams
[  3]  0.0-60.0 sec  4.11 GBytes   588 Mbits/sec   0.000 ms 1158071/4158943 (28%)
[  3]  0.0-60.0 sec  1 datagrams received out-of-order
[  4] local 10.65.14.43 port 5001 connected with 10.65.14.42 port 39851
[  4]  0.0-60.0 sec  5.33 GBytes   763 Mbits/sec   0.014 ms 264719/4158695 (6.4%)
[  4]  0.0-60.0 sec  1 datagrams received out-of-order
[  3] local 10.65.14.43 port 5001 connected with 10.65.14.42 port 56885
[  3]  0.0-60.0 sec  5.48 GBytes   784 Mbits/sec   0.017 ms   49/3999977 (0.0012%)
[  3]  0.0-60.0 sec  1 datagrams received out-of-order
[  4] local 10.65.14.43 port 5001 connected with 10.65.14.42 port 30343
[  4]  0.0-60.0 sec  5.69 GBytes   815 Mbits/sec   0.013 ms  727/4157413 (0.017%)
[  4]  0.0-60.0 sec  1 datagrams received out-of-order
[  3] local 10.65.14.43 port 5001 connected with 10.65.14.42 port 17417
[  3]  0.0-60.0 sec  5.69 GBytes   815 Mbits/sec   0.013 ms 2061/4158792 (0.05%)
[  3]  0.0-60.0 sec  1 datagrams received out-of-order
[[email protected] ~]# iperf -c 10.65.14.43 -u -m -t 60 -i 10 -b 10000M
------------------------------------------------------------
Client connecting to 10.65.14.43, UDP port 5001
Sending 1470 byte datagrams
UDP buffer size:  122 KByte (default)
------------------------------------------------------------
[  3] local 10.65.14.42 port 5586 connected with 10.65.14.43 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec   972 MBytes   815 Mbits/sec
[  3] 10.0-20.0 sec   972 MBytes   815 Mbits/sec
[  3] 20.0-30.0 sec   972 MBytes   815 Mbits/sec
[  3] 30.0-40.0 sec   972 MBytes   815 Mbits/sec
[  3] 40.0-50.0 sec   972 MBytes   815 Mbits/sec
[  3]  0.0-60.0 sec  5.69 GBytes   815 Mbits/sec
[  3] Sent 4158944 datagrams
[  3] Server Report:
[  3]  0.0-60.0 sec  4.11 GBytes   588 Mbits/sec   0.000 ms 1158071/4158943 (28%)
[  3]  0.0-60.0 sec  1 datagrams received out-of-order


[[email protected] ~]# iperf -c 10.65.14.43 -u -m -t 60 -i 10 -b 1000M 
------------------------------------------------------------
Client connecting to 10.65.14.43, UDP port 5001
Sending 1470 byte datagrams
UDP buffer size:  122 KByte (default)
------------------------------------------------------------
[  3] local 10.65.14.42 port 39851 connected with 10.65.14.43 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec   972 MBytes   815 Mbits/sec
[  3] 10.0-20.0 sec   972 MBytes   815 Mbits/sec
[  3] 20.0-30.0 sec   972 MBytes   815 Mbits/sec
[  3] 30.0-40.0 sec   972 MBytes   815 Mbits/sec
[  3] 40.0-50.0 sec   972 MBytes   815 Mbits/sec
[  3]  0.0-60.0 sec  5.69 GBytes   815 Mbits/sec
[  3] Sent 4158696 datagrams
[  3] Server Report:
[  3]  0.0-60.0 sec  5.33 GBytes   763 Mbits/sec   0.013 ms 264719/4158695 (6.4%)
[  3]  0.0-60.0 sec  1 datagrams received out-of-order


[[email protected] ~]# iperf -c 10.65.14.43 -u -m -t 60 -i 10 -b 763M 
------------------------------------------------------------
Client connecting to 10.65.14.43, UDP port 5001
Sending 1470 byte datagrams
UDP buffer size:  122 KByte (default)
------------------------------------------------------------
[  3] local 10.65.14.42 port 56885 connected with 10.65.14.43 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec   935 MBytes   784 Mbits/sec
[  3] 10.0-20.0 sec   935 MBytes   784 Mbits/sec
[  3] 20.0-30.0 sec   935 MBytes   784 Mbits/sec
[  3] 30.0-40.0 sec   935 MBytes   784 Mbits/sec
[  3] 40.0-50.0 sec   935 MBytes   784 Mbits/sec
[  3] 50.0-60.0 sec   935 MBytes   784 Mbits/sec
[  3]  0.0-60.0 sec  5.48 GBytes   784 Mbits/sec
[  3] Sent 3999978 datagrams
[  3] Server Report:
[  3]  0.0-60.0 sec  5.48 GBytes   784 Mbits/sec   0.017 ms   49/3999977 (0.0012%)
[  3]  0.0-60.0 sec  1 datagrams received out-of-order


[[email protected] ~]# iperf -c 10.65.14.43 -u -m -t 60 -i 10 -b 784M
------------------------------------------------------------
Client connecting to 10.65.14.43, UDP port 5001
Sending 1470 byte datagrams
UDP buffer size:  122 KByte (default)
------------------------------------------------------------
[  3] local 10.65.14.42 port 30343 connected with 10.65.14.43 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec   972 MBytes   815 Mbits/sec
[  3] 10.0-20.0 sec   971 MBytes   815 Mbits/sec
[  3] 20.0-30.0 sec   971 MBytes   815 Mbits/sec
[  3] 30.0-40.0 sec   971 MBytes   815 Mbits/sec
[  3] 40.0-50.0 sec   971 MBytes   815 Mbits/sec
[  3] 50.0-60.0 sec   971 MBytes   815 Mbits/sec
[  3]  0.0-60.0 sec  5.69 GBytes   815 Mbits/sec
[  3] Sent 4157414 datagrams
[  3] Server Report:
[  3]  0.0-60.0 sec  5.69 GBytes   815 Mbits/sec   0.013 ms  727/4157413 (0.017%)
[  3]  0.0-60.0 sec  1 datagrams received out-of-order


[[email protected] ~]# iperf -c 10.65.14.43 -u -m -t 60 -i 10 -b 815M
------------------------------------------------------------
Client connecting to 10.65.14.43, UDP port 5001
Sending 1470 byte datagrams
UDP buffer size:  122 KByte (default)
------------------------------------------------------------
[  3] local 10.65.14.42 port 17417 connected with 10.65.14.43 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec   972 MBytes   815 Mbits/sec
[  3] 10.0-20.0 sec   972 MBytes   815 Mbits/sec
[  3] 20.0-30.0 sec   972 MBytes   815 Mbits/sec
[  3] 30.0-40.0 sec   972 MBytes   815 Mbits/sec
[  3] 40.0-50.0 sec   972 MBytes   815 Mbits/sec
[  3] 50.0-60.0 sec   972 MBytes   815 Mbits/sec
[  3]  0.0-60.0 sec  5.69 GBytes   815 Mbits/sec
[  3] Sent 4158793 datagrams
[  3] Server Report:
[  3]  0.0-60.0 sec  5.69 GBytes   815 Mbits/sec   0.013 ms 2061/4158792 (0.05%)
[  3]  0.0-60.0 sec  1 datagrams received out-of-order

相關推薦

Linux伺服器網路頻寬測試——iperf

0. iperf原理解析   iperf工具可以用來測量TCP或者是UDP的網路吞吐量,即bandwidth(頻寬)測試。   iPerf的主要目標是幫助調整特定路徑上的TCP連線。 眾所周知,TCP最基本的調整問題是調整TCP視窗大小,它控制在任何一點在網

網路頻寬測試工具——iperf

一、iperf是什麼 iperf是一個基於Client/Server的網路效能測試工具,可以測試TCP、UDP和SCTP頻寬質量,能夠提供網路吞吐率資訊,以及震動、丟包率,最大段和最大傳輸單元大小等統計資訊,幫助我們測試網路效能,定位網路瓶頸。其中抖動和丟包率適應於UDP測試,二頻寬

linux / unix 網路效能測試工具iperf詳細使用圖文教程

Iperf是一個網路效能測試工具。Iperf可以測試TCP和UDP頻寬質量。Iperf可以測量最大TCP頻寬,具有多種引數和UDP特性。Iperf可以報告頻寬,延遲抖動和資料包丟失。利用Iperf這一特性,可以用來測試一些網路裝置如路由器,防火牆,交換機等的效能。 Iperf有兩種版本,windows版和

Linux網路效能測試工具 iperf 的安裝和使用

好久沒寫文章,iperf 也一直有用,感覺不錯就記錄一下 說明: OS :CentOS 6.4 x86_64 Server: 192.168.100.55 Client: 192.168.100.6 簡介: Iperf是一個網路效能測試工具。可以測試TCP和UDP頻寬質量,

深入進階02 - linux伺服器監控效能測試

               Linux 命令 man ls   man是檢視幫助命令      

Linux伺服器---網路配置

禁用ipv6 1、禁用ipv6很簡單,只需要在配置檔案“/etc/modprobe.d/disable-ipv6.conf”中寫入“install ipv6 /bin/true”,之後重啟系統 [[email protected] ~]# echo "ins

Linux伺服器---網路設定

禁用ipv6 1、禁用ipv6很簡單,只需要在配置檔案“/etc/modprobe.d/disable-ipv6.conf”中寫入“install ipv6 /bin/true”,之後重啟系統 [[email protected] ~]# ech

Linux 檢視網路頻寬是千兆還是萬兆

檢視機器網路埠 [trafodion@n12 ~]$ ifconfig eth1 Link encap:Ethernet HWaddr 5C:B9:01:9A:48:5D

Kali-Linux無線網路滲透測試-李亞偉-第3章-監聽WiFi網路--虛擬機器使用無線網絡卡

如果要管理無線網絡卡,則首先需要將該網絡卡插入到系統中。當用戶在物理機中使用無線網絡卡時,可能直接會被識別出來。如果是在虛擬機器中使用的話,可能無法直接連線到虛擬機器的作業系統中。這時候使用者需要斷開該網絡卡與物理機的連線,然後選擇連線到虛擬機器。在虛擬機器中只支援USB

提升linux tcp網路頻寬措施

要讓伺服器傳送更多的資料,比較容易想到的辦法就是開多個執行緒,向伺服器要求資料,這就類似於多個人一起搬運肯定比一個人拿的多。 另外一種方法,就是利用tcp的傳送視窗特性。傳送視窗可以看做tcp連線的一端,能夠一次傳送的最大資料。傳送視窗的大小取決於網路環境和對端的接收視窗。也就是說當網路環境確定的情況下,接

遠端訪問虛擬機器Linux伺服器網路配置

前提是電腦安裝了虛擬機器VMware,並且在虛擬機器中安裝了Linux系統,我安裝的是Ubuntu16.0

Linux伺服器上搭建測試環境(war包+tomcat)

> 悟空CRM專案環境部署(Java war專案) 1. 在/root目錄下建立一個資料夾(名字自取)。 ![](https://gitee.com/cai_hesheng/caituotuo-image/raw/master/img/20201215143731.png) 2. ls命令檢視一下

測試兩臺伺服器之間的網路頻寬

分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow 也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!        

Linux---基於命令列的Linux伺服器測試頻寬

對於影象介面,我們可以直接在瀏覽器輸入測速網址http://www.speedtest.net/ 就可以測試自己本地的上傳下載頻寬情況,操作非常簡單,點選Begin Test即可,但是對於純命令列的li

Linux伺服器上監控網路頻寬的18個常用命令

一些命令可以顯示單個程序所使用的頻寬。這樣一來,使用者很容易發現過度使用網路頻寬的某個程序。這些工具使用不同的機制來製作流量報告。nload等一些工具可以讀取"proc/net/dev"檔案,以獲得流量統計資訊;而一些工具使用pcap庫來捕獲所有資料包,然後計算總資料量,從而估計流量負載。下面是按功能劃分的命

LinuxiPerf網路效能測試

https://iperf.fr/iperf-download.php [[email protected] ~]# tar zxvf iperf-3.1.3-source.tar.gz [[email protected] ~]#&

即時通訊、線上教學、視訊會議——伺服器頻寬計算說明與網路品質測試

  對一個實時的網路語音視訊系統而言,網路的品質對該系統的使用者的體驗具有決定性的作用,所以,在正式部署系統之前,進行較全面的網路測試和網路調優工作是非常必要的。這將是一個複雜的系統工程,如果有專業的團隊來做這件事情是最好的。然而,一般的公司都是由開發人員或實施人員來做這些事情。比如需要進行如下分析:目標使用

簡談linux環境下網路效能測試工具iperf

通用引數  -f [kmKM] 分別表示以Kbits, Mbits, KBytes, MBytes顯示報告,預設以Mbits為單位,eg:iperf -c 222.35.11.23 -f K  -i sec 以秒為單位顯示報告間隔,eg:iperf -c 222.35.11.23 -i 2  -l 緩衝區大小

嵌入式linux網路效能測試工具iperf

       通常在某些應用中我們會乙太網作為高速傳輸媒介介面,在前期的驗證以及硬體完成以後都需要進行必要的效能測試。微控制器中由於RAM有限通常不會實現完整的TCP/IP協議棧,而採用諸如uIP/L

Linux高效能網路:協程系列09-協程效能測試

目錄 Linux高效能網路:協程系列01-前言 Linux高效能網路:協程系列02-協程的起源 Linux高效能網路:協程系列03-協程的案例 Linux高效能網路:協程系列04-協程實現之工作原理 Linux高效能網路:協程系列05-協程實現之原語操作 Linux高效能網路:協程