iperf3 tutorial


Simple usage example of iperfs3

Introduction

iPerf3 is a tool for actively testing the maximum available bandwidth on an IP network. It supports timing, buffer, protocol (TCP, UDP, SCTP and IPv4 and IPv6) related parameters. For each test, it reports detailed bandwidth, latency jitter and packet loss.

It shares no code with the original iPerf and is not backward compatible.

It is a testing tool of C/S architecture and needs to be run on both the server and the client.

Supported platforms: Windows, Linux, Android, MacOS X, FreeBSD, OpenBSD, iPhone/iPad, etc.

1. Download

  • manual download
sudo wget -O /usr/lib/libiperf.so.0 https://iperf.fr/download/ubuntu/libiperf.so.0_3.1.3

insert image description here

[root@gaussdb01 rpm]# sudo wget -o /usr/bin/iperf3 https://iperf.fr/download/ubuntu/iperf3_3.1.3
[root@gaussdb01 rpm]# sudo chmod +x /usr/bin/iperf3
  • yum download

yum -y install iperf3 

2. use

When using, you can enter iperf3 -h to view the details.
Example:
1. Open the service first on the server side

[root@gaussdb01 ~]# iperf3 -s -i 1 -p 5201
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
# 作为服务端运行,报告回显间隔时间1s,服务端不区分tcp或udp

-s : server

-i : sec display report interval in seconds

-p: port

2. Client connection service

[root@gaussdb02 ~]# iperf3 -c 192.168.0.83 -i 1 -t 5 -p 5201
Connecting to host 192.168.0.83, port 5201
[  5] local 192.168.0.84 port 59274 connected to 192.168.0.83 port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec  3.43 GBytes  29.5 Gbits/sec    0   3.69 MBytes       
[  5]   1.00-2.00   sec  3.61 GBytes  31.0 Gbits/sec    0   3.69 MBytes       
[  5]   2.00-3.00   sec  3.30 GBytes  28.4 Gbits/sec    0   3.69 MBytes       
[  5]   3.00-4.00   sec  3.28 GBytes  28.2 Gbits/sec    0   3.69 MBytes       
[  5]   4.00-5.00   sec  3.08 GBytes  26.5 Gbits/sec    0   3.69 MBytes       
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-5.00   sec  16.7 GBytes  28.7 Gbits/sec    0             sender
[  5]   0.00-5.04   sec  16.7 GBytes  28.4 Gbits/sec                  receiver

iperf Done.

-c: The client host is the address of the server

-i:sec show report interval in seconds

-t: test time, default 10 seconds

-p: port

3. The server receives information

[root@gaussdb01 ~]# iperf3 -s -i 1 -p 5201
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Accepted connection from 192.168.0.84, port 59272
[  5] local 192.168.0.83 port 5201 connected to 192.168.0.84 port 59274
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-1.00   sec  3.25 GBytes  27.9 Gbits/sec                  
[  5]   1.00-2.00   sec  3.65 GBytes  31.4 Gbits/sec                  
[  5]   2.00-3.00   sec  3.27 GBytes  28.1 Gbits/sec                  
[  5]   3.00-4.00   sec  3.29 GBytes  28.2 Gbits/sec                  
[  5]   4.00-5.00   sec  3.12 GBytes  26.8 Gbits/sec                  
[  5]   5.00-5.04   sec   112 MBytes  22.1 Gbits/sec                  
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-5.04   sec  16.7 GBytes  28.4 Gbits/sec                  receiver
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------

iperf main parameters

There are many optional parameters in iperf, please refer to its user manual for details.

http://webfolder.wirelessleiden.nl/iperf/

Generally speaking, we need to specify the packet length when doing performance testing. Different packet lengths will result in different throughputs, which can be specified by -l and bandwidth by -b.

  • Test throughput, jitter and packet loss

If the above three parameters need to be tested at the same time, they can only be obtained through UDP. Use the -u parameter for UDP testing (iperf defaults to TCP).

At the end of the test server will give a report.

To obtain bandwidth data, it is necessary to continuously increase the bandwidth value on the client side until slight packet loss occurs on the server side. At this time, the bandwidth displayed on the server side is the throughput of the system under test.

Problems that should be paid attention to when using TPC to test bandwidth

Sometimes, we need to use TCP to test network bandwidth. There is a parameter here that needs special attention, that is, the TCP window size, which can be specified with the -w parameter.

The capacity of the network channel capacity = bandwidth * round-trip time

The size of the theoretical TCP window is the capacity of the network channel.

For example, the network bandwidth is 40Mbit/s, and the loopback path consumes 2ms, then the TCP window size is not less than 40Mbit/s×2ms = 80kbit = 10Kbytes

At this point, we can query the default TCP window size of iperf to determine whether to set this parameter. In this example, the window size should be designed to be larger than 10Kbytes. Of course, this is only a theoretical value, and may need to be adjusted in actual tests.

Test instance:

This software needs to be installed on the machines where both ends need to test each other, and then one end is used as the server to monitor, and the other end is used as the client to connect. Specific commands can be viewed under iperf -h.

Server:
iperf -s -u
-s marks this end as a server
-u marks itself as a UDP listener
-p specifies its own listening port

Client:
iperf -c 1.1.1.1 -i 1 -u -t 60 -F /root/a.zip -P 5
-c mark yourself as client
-i set output value interval
-u use transport protocol as UDP
- t Set the test time to 60 seconds
-F specifies the transfer file (this item is optional)
-P specifies the number of processes, if it is set to 5, then it is equivalent to establishing five connections with the peer

Note:
1. The packet sending test needs to be divided into UDP test and TCP test, and the server needs to use the -u command to distinguish the listening protocol.
2. The TCP protocol test cannot calculate the delay and packet loss rate, and cannot specify the sending bandwidth.

Case 1 TCP communication test

Server:

[root@gaussdb01 ~]# iperf3 -s -i 1  -p 5201 
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
# 作为服务端运行,报告回显间隔时间1s,服务端不区分tcp或udp

The effect is as follows:

insert image description here

client

[root@gaussdb02 ~]# iperf3 -c 192.168.0.83 -i 1 -t 10 -b 5M
#作为客户端,连接服务端ip地址192.168.3.250,报告回显间隔1s,测试时间10s,带宽限制为5M

insert image description here

Server:

insert image description here

The result of our test throughput here is about Bitrate 5.01M, because we limited the bandwidth of the test data to 5M, indicating that the actual throughput should be larger than this. During the test, if the test bandwidth is found to be close to the limited bandwidth, It means that the limit setting is too small, you need to adjust the -b parameter appropriately, or refer to the index test given by the hardware manufacturer.

Then we adjust the -b parameter to 50M, and the test results are as follows

insert image description here

It can be seen that our actual TCP uplink speed test is 49.8M/sec, and we can also increase the test time to improve test accuracy.

Another point here is that the sender result is 0bits/sec, because we only tested the uplink data, so how to test the downlink communication speed?

TCP downlink test : Start a shell window on the A (client) device and enter commands

[root@gaussdb02 ~]# iperf3 -c 192.168.0.83 -i 1 -t 10 -b 5M -R
#作为客户端,连接服务端ip地址192.168.0.83,报告回显间隔1s,测试时间10s,带宽限制为7M,-R为反向测试,这个参数也是iperf3的主要亮点,支持直接转换数据发送方向

insert image description here

The result of our test of TCP downlink throughput here is about 5.01M.

Case 2: UDP test

You can continue to use the server in Case 1. If it is not opened, refer to the server opening method in Case 1. Be careful not to open multiple servers at the same time

Start the shell window on device B (server) and enter commands

[root@gaussdb01 ~]# iperf3 -s -i 1  -p 5201 
# 作为服务端运行,报告回显间隔时间1s,服务端不区分tcp或udp

client

[root@gaussdb02 ~]# iperf3 -u -c 192.168.0.83 -i 1 -t 10 -b 50M -i 1 -t 10
#作为客户端运行,限制带宽50M,报告回显间隔1s,测试时间10s

insert image description here

UDP downlink test : Start the shell window on the A (client) device, enter the command and add - R

We tested the UDP uplink throughput to be 50M/s, the delay jitter (Jitter) to be 0.000ms, and the packet loss rate to be 0%.

Case 3 Transfer things for testing

[root@gaussdb02 ~]# du -sh a.txt 
4.0K	a.txt        
[root@gaussdb02 ~]# iperf3 -u -c 192.168.0.83 -i 1 -t 10 -b 50M -i 1 -t 10 -F /root/a.txt 

insert image description here

insert image description here

Guess you like

Origin blog.csdn.net/m0_46400195/article/details/130379876