1. 程式人生 > >網路頻寬測試工具——iperf

網路頻寬測試工具——iperf

一、iperf是什麼

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

iperf的好處是純粹發包和接收,防止硬碟拖後腿,影響測試結果。對於時延,iperf無能無力。但是iperf能夠計算抖動。在iperf測試中需要傳送大量的包,因此計算出來的抖動值,就是連續傳送時延差值的平均值。

二、iperf安裝

1、獲取iperf原始碼安裝包(iperf-3.0.5.tar.gz)

https://iperf.fr/iperf-download.php#opensuse
2、將iperf安裝包上傳到伺服器/tmp/目錄並解壓

[[email protected] /]#cd /tmp/
[[email protected] tmp]#tar –zxvf iperf-3.0.5.tar.gz

3、編譯並安裝iperf

[[email protected] tmp]# cd iperf-3.0.5
[[email protected] iperf-3.0.5]#./configure
[[email protected] stress-1.0.4]# make
[
[email protected]
stress-1.0.4]#make install

4、編譯安裝成功後,可以在系統命令中找到iperf命令

[[email protected] iperf-3.0.5]# iperf
iperf3 
[[email protected] bin]# find /usr/local/|grep iperf
/usr/local/bin/iperf3

三、錯誤及解決方法:

[[email protected] bin]# iperf3 -s
iperf3: error while loading shared libraries: libiperf.so.0:
cannot open shared object file: No such file or directory

問題原因

Linux系統中找不到libiperf.so.0 庫檔案,導致執行iperf3 –s時提示缺少相關lib庫。
通過find /usr/local/lib/ |grep iperf查詢其他伺服器上是否存在該lib庫檔案,而庫檔案就在當前目錄中。ld提示找不到庫檔案,是由於連結器ld預設的目錄是/lib和/usr/lib,如果放在其他路徑也可以,需要讓ld知道庫檔案在哪裡。

解決方法:

方法1:
編輯/etc/ld.so.conf檔案,在新的一行中加入庫檔案所在目錄;
執行ldconfig,以更新/etc/ld.so.cache檔案;
方法2:
在/etc/ld.so.conf.d/目錄下新建任何以.conf為字尾的檔案,在該檔案中加入庫檔案所在的目錄;
執行ldconfig,以更新/etc/ld.so.cache檔案;
方法3:
ln -s /usr/local/lib/libiperf.so.0.0.0 /usr/lib/iperf.so.0
說明:本質與方法1、2思路相同,但是這裡沒有生效,最後用1、2都可以解決。

四、啟動測試

服務端
命令:iperf3 -s

[[email protected] bin]# iperf3 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------

客戶端
命令:iperf3 -c ip

[[email protected] iperf-3.0.5]# iperf3 -c 192.168.0.1

該Ip為伺服器端IP

四、其它內容

windows端執行

對於windows版的Iperf,直接將解壓出來的iperf.exe和cygwin1.dll複製到%systemroot%目錄即可在WinXP 或者Win7的日常使用中,經常可以看到%SystemRoot%這個名詞,但是很多人也搞不清楚它是什麼意思。其實很簡單,它就是系統的目錄的縮寫。直接在檔案位址列中輸入%SystemRoot%。

之後進入cmd命令視窗執行

在這裡插入圖片描述
更多詳細操作,可以參考其它相關文件
網路頻寬和速度測試windows和linux用iperf工具
Linux系統中效能測試中如何分析檢視網路頻寬佔用情況

參考:
1、解決錯誤:
Iperf3移植到ARM Linux及使用教程
錯誤解決error while loading shared libraries: libXXX.so.X: cannot open shared object file: No such file
2、部署啟動
iperf測試工具