?簡介
iPerf是一種命令行工具,它通過測量服務(wù)器可以處理的最大網(wǎng)絡(luò)吞吐量來測試網(wǎng)絡(luò)速度,因此在遇到網(wǎng)絡(luò)速度問題時(shí)特別有用,通過該工具可以確定哪臺服務(wù)器存在性能問題。
編譯和測試方式
1.選擇操作環(huán)境
本文選用華為鯤鵬云服務(wù)ECS KC1實(shí)例做測試
2.編譯源代碼
本文以“iperf-2.0.8”版本為例,下載源碼,并編譯安裝。
下載源代碼。
wget https://iperf.fr/download/source/iperf-2.0.8-source.tar.gz
1)安裝iPerf軟件依賴。
yum install gcc-c++ -y
2)解壓并安裝iPerf。
tar -xvf iperf-2.0.8-source.tar.gzcd iperf-2.0.8/./configure && make && make install
3.運(yùn)行和驗(yàn)證
iPerf由客戶端和服務(wù)端組成,客戶端連接到需要測試速度的服務(wù)端,且客戶端和服務(wù)端均需要運(yùn)行iPerf程序。
運(yùn)行iPerf時(shí),要求gcc的版本為4.8.5。
1)在服務(wù)端運(yùn)行iPerf程序。
iperf -s -p 1234 -i 1
參數(shù)說明:
− -s 表示以服務(wù)器模式運(yùn)行。
− -p 設(shè)置服務(wù)端監(jiān)聽端口。
− -i 設(shè)置每次報(bào)告之間的時(shí)間間隔,單位為秒。
服務(wù)端測試結(jié)果如下:
iperf -s -p 1234 -i 1
------------------------------------------------------------
Server listening on TCP port 1234
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
[ 4] local 192.168.1.25 port 1234 connected with XX.XX.XX.XX port 35632
[ ID] Interval Transfer Bandwidth
[ 4] 0.0- 1.0 sec 46.2 MBytes 387 Mbits/sec
[ 4] 1.0- 2.0 sec 30.9 MBytes 260 Mbits/sec
[ 4] 2.0- 3.0 sec 31.2 MBytes 261 Mbits/sec
[ 4] 3.0- 4.0 sec 31.0 MBytes 260 Mbits/sec
[ 4] 4.0- 5.0 sec 31.0 MBytes 260 Mbits/sec
[ 4] 5.0- 6.0 sec 31.1 MBytes 261 Mbits/sec
[ 4] 6.0- 7.0 sec 30.8 MBytes 258 Mbits/sec
[ 4] 7.0- 8.0 sec 30.9 MBytes 260 Mbits/sec
[ 4] 8.0- 9.0 sec 31.1 MBytes 261 Mbits/sec
[ 4] 9.0-10.0 sec 31.1 MBytes 261 Mbits/sec
[ 4] 0.0-10.1 sec 329 MBytes 273 Mbits/sec
2) 在客戶端運(yùn)行iPerf程序。
在一臺新的服務(wù)器上參照上述步驟安裝iPerf,然后啟動iPerf。
“XX.XX.XX.XX”是服務(wù)端的IP地址。
iperf -c XX.XX.XX.XX -p 1234 -i 1
參數(shù)說明:
− -c 表示要測試的服務(wù)端的IP地址,即運(yùn)行服務(wù)端iPerf程序所在主機(jī)的地址。
− -p 設(shè)置服務(wù)器端運(yùn)行iperf的端口號,示例中為“1234”。
− -i 設(shè)置每次報(bào)告之間的時(shí)間間隔,單位為秒。
客戶端測試結(jié)果如下:
iperf -c xx.xx.xx.xx -p 1234 -i 1
------------------------------------------------------------
Client connecting to XX.XX.XX.XX, TCP port 1234
TCP window size: 85.0 KByte (default)
------------------------------------------------------------
[ 3] local 192.168.1.140 port 35632 connected with XX.XX.XX.XX port 1234
[ ID] Interval Transfer Bandwidth
[ 3] 0.0- 1.0 sec 48.8 MBytes 409 Mbits/sec
[ 3] 1.0- 2.0 sec 31.8 MBytes 266 Mbits/sec
[ 3] 2.0- 3.0 sec 30.6 MBytes 257 Mbits/sec
[ 3] 3.0- 4.0 sec 31.8 MBytes 266 Mbits/sec
[ 3] 4.0- 5.0 sec 30.5 MBytes 256 Mbits/sec
[ 3] 5.0- 6.0 sec 31.9 MBytes 267 Mbits/sec
[ 3] 6.0- 7.0 sec 30.5 MBytes 256 Mbits/sec
[ 3] 7.0- 8.0 sec 30.2 MBytes 254 Mbits/sec
[ 3] 8.0- 9.0 sec 32.0 MBytes 268 Mbits/sec
[ 3] 9.0-10.0 sec 30.6 MBytes 257 Mbits/sec
[ 3] 0.0-10.0 sec 329 MBytes 275 Mbits/sec
已知問題匯總
問題描述:
使用EulerOS或CentOS安裝“iperf-2.0.8”版本,在編譯的時(shí)候,會出現(xiàn)如下問題:
cluded from /usr/include/c++/7.3.0/cmath:42:0,
from /usr/include/c++/7.3.0/math.h:36,
from ../include/headers.h:85,
from ../include/Timestamp.hpp:63,
from delay.cpp:55:
/usr/include/c++/7.3.0/bits/cpp_type_traits.h:205:12: error: redefinition of ‘struct std::__is_integer<int>’
struct __is_integer<int>
^~~~~~~~~~~
問題原因:如下鏈接所示
https://gitlab.flux.utah.edu/emulab/emulab-devel/issues/336

解決方法:對于Euler OS,請采用“iperf-2.0.9”版本源碼安裝,具體安裝步驟與2.0.8一致。