How to perform throughput testing using iPerf3 on Ubuntu 18.04 CLI

This is a detailed guide on how to perform throughput testing using IPERF on Linux Based Operating Systems.

1. Install iPerf3

You will need to have iPerf3 installed on both endpoints. iPerf3 works using a client and server model.

apt install iperf3

2. iPerf3 Server

Once installed you will need one end point to listen for iPerf traffic. By default this will listen on port 5201.

2.1 iperf3 -s

This command will start the iPerf server

root@FTP:/etc/conf.d# iperf3 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------

2.2 iperf3 -s -p

This will specify which port to listen on. You will need to ensure that this is specified on both client and server.

root@FTP:/etc/conf.d# iperf3 -s -p 5002
-----------------------------------------------------------
Server listening on 5002
-----------------------------------------------------------

3. iPerf3 Client

Command examples:

Replace 10.0.x.x with the server IP address.

iperf3 -c 10.0.x.x -t 5 -l 1000k
iperf3 -c 10.0.x.x -t 5 -l 1000k -w 2.5m
iperf3 -c 10.0.x.x -t 5 -l 1000k -w 2.5m -P 5
iperf3 -c 10.0.x x -t 60 -l 1000k -w 2.5m -P 5
iperf3 -c 10.0.x.x -t 60 -l 1000k -w 2.5m -P 10 
iperf3 -c 10.0.x.x -t 5 -l 1000k -R
-t, –time nThe time in seconds to transmit for. iPerf normally works by repeatedly sending an array of len bytes for time seconds. Default is 10 seconds.
-l, –length n[KM]The length of buffers to read or write. iPerf works by writing an array of len bytes a number of times. Default is 128 KB for TCP, 8 KB for UDP
-w, –window n[KM]Sets the socket buffer sizes to the specified value. For TCP, this sets the TCP window size. (this gets sent to the server and used on that side too)
-R, –reverseRun in reverse mode (server sends, client receives).

4. Testing using Wondershaper (Traffic Shaper)

You can install wondershaper to shape the client or servers interface bandwidth.

4.1 Install Wondershaper

apt install wondershaper

IMPORTANT: The following installation will create the directory for where the traffic shaping configuration will go.

cd bin
git clone https://github.com/magnific0/wondershaper.git
cd wondershaper
make install

4.2 Edit /etc/conf.d/wondershaper.conf

nano /etc/conf.d/wondershaper.conf

Example configuration:

You will need to specify which interface and what the bandwidth is restricted to in kbps.

[wondershaper]
# Adapter
#
IFACE="eth0"

# Download rate in Kbps
#
DSPEED="10240"

# Upload rate in Kbps
#
USPEED="10240"

4.3 Restart Wondershaper

service wondershaper restart

5. iPerf Before and after Wondershaper.

root@FTP:~# iperf3 -c 10.0.125.14
Connecting to host 10.0.125.14, port 5201
[  4] local 10.0.125.11 port 38860 connected to 10.0.125.14 port 5201
[ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
[  4]   0.00-1.00   sec   115 MBytes   968 Mbits/sec    0   3.03 MBytes
[  4]   1.00-2.00   sec   112 MBytes   939 Mbits/sec    0   3.03 MBytes
[  4]   2.00-3.00   sec   112 MBytes   939 Mbits/sec    0   3.03 MBytes
[  4]   3.00-4.00   sec   112 MBytes   939 Mbits/sec    0   3.03 MBytes
[  4]   4.00-5.00   sec   112 MBytes   939 Mbits/sec    0   3.03 MBytes
[  4]   5.00-6.00   sec   112 MBytes   939 Mbits/sec    0   3.03 MBytes
[  4]   6.00-7.00   sec   112 MBytes   939 Mbits/sec    0   3.03 MBytes
[  4]   7.00-8.00   sec   112 MBytes   939 Mbits/sec    0   3.03 MBytes
[  4]   8.00-9.00   sec   112 MBytes   939 Mbits/sec    0   3.03 MBytes
[  4]   9.00-10.00  sec   112 MBytes   939 Mbits/sec    0   3.03 MBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-10.00  sec  1.10 GBytes   942 Mbits/sec    0             sender
[  4]   0.00-10.00  sec  1.09 GBytes   939 Mbits/sec                  receiver

iperf Done.
root@FTP:~# service wondershaper start
root@FTP:~# iperf3 -c 10.0.125.14
Connecting to host 10.0.125.14, port 5201
[  4] local 10.0.125.11 port 38864 connected to 10.0.125.14 port 5201
[ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
[  4]   0.00-1.00   sec  1.71 MBytes  14.3 Mbits/sec    0    102 KBytes
[  4]   1.00-2.00   sec  1.12 MBytes  9.38 Mbits/sec    0    102 KBytes
[  4]   2.00-3.00   sec  1.12 MBytes  9.38 Mbits/sec    0    102 KBytes
[  4]   3.00-4.00   sec  1.12 MBytes  9.38 Mbits/sec    0    102 KBytes
[  4]   4.00-5.00   sec  1.12 MBytes  9.38 Mbits/sec    0    102 KBytes
[  4]   5.00-6.00   sec  1.12 MBytes  9.38 Mbits/sec    0    102 KBytes
[  4]   6.00-7.00   sec  1.06 MBytes  8.86 Mbits/sec    0    102 KBytes
[  4]   7.00-8.00   sec  1.12 MBytes  9.38 Mbits/sec    0    102 KBytes
[  4]   8.00-9.00   sec  1.12 MBytes  9.38 Mbits/sec    0    102 KBytes
[  4]   9.00-10.00  sec  1.12 MBytes  9.38 Mbits/sec    0    102 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-10.00  sec  11.7 MBytes  9.83 Mbits/sec    0             sender
[  4]   0.00-10.00  sec  11.1 MBytes  9.31 Mbits/sec                  receiver

iperf Done.

Thank you for reading and please feel free to leave any feedback.

Leave a Reply

Discover more from Secnetlinux

Subscribe now to keep reading and get access to the full archive.

Continue reading

Discover more from Secnetlinux

Subscribe now to keep reading and get access to the full archive.

Continue reading

Scroll to Top