How to Test Network Throughput Using iperf3 Tool in Linux

[‘

n

iperf3 is a free open source, cross-platform command-line based program for performing real-time network throughput measurements. It is one of the powerful tools for testing the maximum achievable bandwidth in IP networks (supports IPv4 and IPv6).

n

Read Also: 16 Bandwidth Monitoring Tools to Analyze Network Usage in Linux

n

With iperf, you can tune several parameters associated with timing, buffers, and protocols such as TCP, UDP, SCTP. It comes in handy for network performance tuning operations.

n

In order to acquire maximum or rather improved network performance, you need to increase the throughput as well as the latency of your network’s receiving and sending capabilities. However, before you can go into actual tuning, you need to perform some tests to gather overall network performance statistics that will guide your tuning process.

n

Its results include time interval in seconds, data transferred, bandwidth (transfer rate), loss, and other useful network performance parameters. It is primarily intended to assist in tuning TCP connections over a particular path and this is what we will focus on in this guide.

n

Requirements:

n

    n

  • Two networked computers which both have iperf3 installed.
  • n

n

How to Install iperf3 in Linux Systems

n

Before you start using iperf3, you need to install it on the two machines you will use for benchmarking. Since iperf3 is available in the official software repositories of most common Linux distributions, installing it should be easy, using a package manager as shown.

n

$ sudo apt install iperf3t#Debian/Ubunturn$ sudo yum install iperf3t#RHEL/CentOSrn$ sudo dnf install iperf3t#Fedora 22+ rn

n

Once you have iperf3 installed on both machines, you can start testing network throughput.

n

How to Test Network Throughput Between Linux Servers

n

First connect to the remote machine which you will use as the server and fire up iperf3 in server mode using -s flag, it will listen on port 5201 by default.

n

You can specify the format (k, m, g for Kbits, Mbits, Gbits or K, M, G for KBytes, Mbytes, Gbytes) to report in, using the -f switch as shown.

n

$ iperf3 -s -f K rn

n

If port 5201 is being used by another program on your server, you can specify a different port (e.g 3000) using the -p switch as shown.

n

$ iperf3 -s -p 3000rn

n

Optionally, you can run the server as a daemon, using the -D flag and write server messages to a log file, as follows.

n

$ iperf3 -s -D > iperf3log rn

n

Then on your local machine which we will treat as the client (where the actual benchmarking takes place), run iperf3 in client mode using -c flag and specify the host on which the server is running on (either using its IP address or domain or hostname).

n

$ iperf3 -c 192.168.10.1 -f Krn

n

After about 18 to 20 seconds, the client should terminate and produce results indicating the average throughput for the benchmark, as shown in the following screenshot.

n

Test Network Throughput Between Servers
Test Network Throughput Between Servers

n

Important: From the benchmark results, as shown in the above screenshot, there is a variation in values from the server and client. But, you should always consider using the results obtained from the iperf client machine in every test you carry out.

n

How to Perform Advanced Network Test Throughput in Linux

n

There are a number of client-specific options for performing an advanced test, as explained below.

n

One of the important factors that determine the amount of data in the network a given time is the TCP window size – it is important in tuning TCP connections. You can set the window size/socket buffer size using the -w flag as shown.

n

$ iperf3 -c 192.168.10.1 -f K -w 500Ktrn

n

To run it in reverse mode where the server sends and the client receives, add the -R switch.

n

$ iperf3 -c 192.168.10.1 -f K -w 500K -Rtrn

n

To run a bi-directional test, meaning you measure bandwidth in both directions simultaneously, use the -d option.

n

$ iperf3 -c 192.168.10.1 -f K -w 500K -drn

n

If you want to get server results in the client output, use the --get-server-output option.

n

$ iperf3 -c 192.168.10.1 -f K -w 500K -R --get-server-outputrn

n

Get Server Network Results in Client
Get Server Network Results in Client

n

It is also possible to set the number of parallel client streams (two in this example), which run at the same time, using the -P options.

n

$ iperf3 -c 192.168.10.1 -f K -w 500K -P 2rn

n

For more information, see the iperf3 man page.

n

$ man iperf3rn

n

iperf3 Homepage: https://iperf.fr/

n

That’s all! Remember to always perform network performance tests before going for actual network performance tuning. iperf3 is a powerful tool, that comes in handy for running network throughput tests. Do you have any thoughts to share or questions to ask, use the comment form below.

n

‘]