一、安裝方式
1,從官網下載相應版本。用 rpm包安裝
https://iperf.fr/iperf-download.php
centos7 安裝
rpm -i iperf3-3.1.3-1.fc24.x86_64.rpm
2,執行yum install -y iperf3 安裝
二、測試方式
網絡帶寬測試
在使用iperf3測試時,要同時在server端與client端都各執行一個程序,讓它們互相傳送報文進行測試。下面的例子是在CentOS7上進行的測試。
首先在10.23.5.66機器啟動server端的程序:
iperf3 -s
接着在10.23.5.65服務器上執行client 端的程序:
iperf3 -c 10.23.5.66
在測試時server端與client端都會出現測試的數據,client端以下是測試的結果:
[jinguang1@localhost ~]$ iperf3 -c 10.23.5.66
Connecting to host 10.23.5.66, port 5201
[ 4] local 10.23.5.65 port 10412 connected to 10.23.5.66 port 5201
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-1.00 sec 114 MBytes 953 Mbits/sec 0 95.5 KBytes
[ 4] 1.00-2.00 sec 113 MBytes 948 Mbits/sec 0 95.5 KBytes
[ 4] 2.00-3.00 sec 113 MBytes 950 Mbits/sec 0 95.5 KBytes
[ 4] 3.00-4.00 sec 113 MBytes 948 Mbits/sec 0 95.5 KBytes
[ 4] 4.00-5.00 sec 113 MBytes 950 Mbits/sec 0 95.5 KBytes
[ 4] 5.00-6.00 sec 113 MBytes 948 Mbits/sec 0 95.5 KBytes
[ 4] 6.00-7.00 sec 113 MBytes 948 Mbits/sec 0 95.5 KBytes
[ 4] 7.00-8.00 sec 113 MBytes 950 Mbits/sec 0 95.5 KBytes
[ 4] 8.00-9.00 sec 113 MBytes 948 Mbits/sec 0 95.5 KBytes
[ 4] 9.00-10.00 sec 113 MBytes 950 Mbits/sec 0 95.5 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-10.00 sec 1.10 GBytes 949 Mbits/sec 0 sender
[ 4] 0.00-10.00 sec 1.10 GBytes 949 Mbits/sec receiver
iperf Done.
從打印的內容看,缺省參數下,Client將連接Server端的5201端口,持續向Server端發送數據,並統計出每秒傳輸的字節數、帶寬、出現報文重傳的次數、擁塞窗口(Congestion Window)大小,整個測試將持續10秒鍾;最后將匯總10秒的平均數據,並給出發送和接收端的統計。
接下來分析一下Server的測試輸出結果:
[jinguang1@localhost ~]$ iperf3 -s
warning: this system does not seem to support IPv6 - trying IPv4
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Accepted connection from 10.23.5.65, port 10410
[ 5] local 10.23.5.66 port 5201 connected to 10.23.5.65 port 10412
[ ID] Interval Transfer Bandwidth
[ 5] 0.00-1.00 sec 109 MBytes 913 Mbits/sec
[ 5] 1.00-2.00 sec 113 MBytes 948 Mbits/sec
[ 5] 2.00-3.00 sec 113 MBytes 949 Mbits/sec
[ 5] 3.00-4.00 sec 113 MBytes 949 Mbits/sec
[ 5] 4.00-5.00 sec 113 MBytes 949 Mbits/sec
[ 5] 5.00-6.00 sec 113 MBytes 949 Mbits/sec
[ 5] 6.00-7.00 sec 113 MBytes 949 Mbits/sec
[ 5] 7.00-8.00 sec 113 MBytes 949 Mbits/sec
[ 5] 8.00-9.00 sec 113 MBytes 949 Mbits/sec
[ 5] 9.00-10.00 sec 113 MBytes 949 Mbits/sec
[ 5] 10.00-10.04 sec 4.29 MBytes 947 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth
[ 5] 0.00-10.04 sec 0.00 Bytes 0.00 bits/sec sender
[ 5] 0.00-10.04 sec 1.10 GBytes 945 Mbits/sec receiver
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Server端缺省監聽IPv6地址和端口,如果未配置IPv6,會嘗試IPv4。日志顯示接收了來自10.23.5.65,源端口未10410的測試請求。Client端連續進行了10秒的測試,並顯示了每秒傳輸的字節數,帶寬信息;測試結束后會匯總發送和接收的統計信息。在Client連接關閉之后會繼續偵聽5201端口。