Use iperf to benchmark the transfer speeds between two hosts.

--

Recently I had to estimate the practical transfer speeds between two hosts (As a benchmark for the real speeds I can expect for some file transfers from a JVM-based application). We can use the tool `iperf` to do the same.

The steps below are to estimate the max bandwidth availability between two machines say machine-01 and say machine-02. However, the max transfer speeds will be lesser depending on the protocol used (Eg. HTTPS will result in reduced bitrate to accommodate the initial asymmetric key handshake and the later symmetric encryption of the bits) Hence the experiment described below is a kind of a raw TCP streaming performance benchmarking.

On machine-01/source/server machine:

  1. Install iperf : https://iperf.fr/iperf-download.php

2. After installing iperf, Depending upon the firewall configuration of the machine, we might have to whitelist port 5201 (iperf port) for it to accept connections from other machines. The command for that is:

sudo iptables -A INPUT -p tcp --dport 5201 -j ACCEPT

3. Run iperf in server mode

iperf -s –i1

4. on machine-02 /destination/client machine, Run iperf in client mode:

iperf –c <machine-01-IP> –i1 –t60 -V

5. You might also want to reverse the above roles; i.e machine-02 becomes the server/source and machine-01 becomes the client.

6. Finally we can try to increase/tweak the TCP window size than what is the default (It is dynamic by default) in order to try to maximize the throughput.

To do this, note the output from the client above.

On my system:

root@sc2-10-186-100-157 [ ~ ]# iperf3 -c 10.193.60.130 -i1 -V
iperf 3.6
Linux sc2-10-186-100-157.eng.vmware.com 4.19.177-2.ph3 #1-photon SMP Fri Mar 5 02:24:52 UTC 2021 x86_64
Control connection MSS 1448
Time: Thu, 20 May 2021 14:09:50 GMT
Connecting to host 10.193.60.130, port 5201
Cookie: jokw2zpqeba3btnamtcequpk3hqvbjk6ssgp
TCP MSS: 1448 (default)
[ 5] local 10.186.100.157 port 36172 connected to 10.193.60.130 port 5201
Starting Test: protocol: TCP, 1 streams, 131072 byte blocks, omitting 0 seconds, 10 second test, tos 0

Notice the 131072-byte blocks.

This implies a 128KB TCP window size (131072/1024)

For you, it might be a different value. We can try to increase it by a factor and try the client command again like this:

iperf3 -c 10.193.60.130 -i1 -V -w256K

Note 1: 128K was the default in my case, I increased it to 256.

See that if this window size increase improves the performance.

Note 2: Increasing the TCP window size is not a shortcut to improving throughput. In fact, increasing it beyond a threshold will be detrimental. Since there is only so much physical bandwidth available and we cannot have a larger window size than that. You want to find out the sweet spot on your machine!

Cheers!

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response