Test Bandwidth Between Two Machines

Post Reply
User avatar
LHammonds
Site Admin
Site Admin
Posts: 942
Joined: Fri Jul 31, 2009 6:27 pm
Are you a filthy spam bot?: No
Location: Behind You
Contact:

Test Bandwidth Between Two Machines

Post: # 941Post LHammonds »

Utilities such as speedtest.net are great if you want to test the bandwidth / latency from your PC to a location on the Internet. However, if you want to test between 2 machines on your LAN or WAN, those types of sites will not be helpful.

For Linux machines, you can install and use a utility called iperf3 and this is how you can utilize it.

On each machine, install iperf3:

Code: Select all

sudo apt install iperf3
On the destination (or server), make sure you open a port on your software firewall that you intend to use. In this example, let's use 5201.

Code: Select all

sudo ufw allow 5201 comment 'iperf3'
Now run iperf3 in server mode and make it listen to the port we just opened up:

Code: Select all

iperf3 --server --port 5201
Let's assume this server's IP address is 10.10.10.20

On a client PC, run iperf3 to test upload speed:

Code: Select all

iperf3 --client 10.10.10.20 --port 5201
Output of the above command:

Code: Select all

Connecting to host 10.10.10.20, port 5201
[  5] local 10.10.10.25 port 53488 connected to 10.10.10.20 port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec  1.08 GBytes  9.31 Gbits/sec    0   1.89 MBytes
[  5]   1.00-2.00   sec  1.09 GBytes  9.35 Gbits/sec    0   2.10 MBytes
[  5]   2.00-3.00   sec  1.09 GBytes  9.36 Gbits/sec    0   2.10 MBytes
[  5]   3.00-4.00   sec  1.08 GBytes  9.28 Gbits/sec  513   1.27 MBytes
[  5]   4.00-5.00   sec  1.04 GBytes  8.89 Gbits/sec  198    901 KBytes
[  5]   5.00-6.00   sec  1.08 GBytes  9.31 Gbits/sec    8   1.19 MBytes
[  5]   6.00-7.00   sec  1.08 GBytes  9.24 Gbits/sec   30   1.08 MBytes
[  5]   7.00-8.00   sec  1.09 GBytes  9.37 Gbits/sec    0   1.43 MBytes
[  5]   8.00-9.00   sec  1.08 GBytes  9.31 Gbits/sec  269   1.12 MBytes
[  5]   9.00-10.00  sec  1.09 GBytes  9.36 Gbits/sec    0   1.45 MBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec  10.8 GBytes  9.28 Gbits/sec  1018             sender
[  5]   0.00-10.00  sec  10.8 GBytes  9.28 Gbits/sec                  receiver

iperf Done.
Now run iperf3 to test download speed:

Code: Select all

iperf3 --client 10.10.10.20 --port 5201 --reverse
Output of the above command:

Code: Select all

Connecting to host 10.10.10.20, port 5201
Reverse mode, remote host 10.10.10.20 is sending
[  5] local 10.10.10.25 port 53522 connected to 10.10.10.20 port 5201
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-1.00   sec   717 MBytes  6.02 Gbits/sec
[  5]   1.00-2.00   sec   877 MBytes  7.36 Gbits/sec
[  5]   2.00-3.00   sec   871 MBytes  7.31 Gbits/sec
[  5]   3.00-4.00   sec   836 MBytes  7.01 Gbits/sec
[  5]   4.00-5.00   sec   809 MBytes  6.79 Gbits/sec
[  5]   5.00-6.00   sec   876 MBytes  7.35 Gbits/sec
[  5]   6.00-7.00   sec   820 MBytes  6.88 Gbits/sec
[  5]   7.00-8.00   sec   783 MBytes  6.56 Gbits/sec
[  5]   8.00-9.00   sec   854 MBytes  7.16 Gbits/sec
[  5]   9.00-10.00  sec   870 MBytes  7.30 Gbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec  8.12 GBytes  6.98 Gbits/sec  6379             sender
[  5]   0.00-10.00  sec  8.12 GBytes  6.97 Gbits/sec                  receiver

iperf Done.
Now let's add some more options such as increasing the log level, setting the format to MBytes, setting the title prefix for each line and log the results to a file:

Code: Select all

iperf3 --client 10.10.10.20 --port 5201 --time 10 --verbose --format M --reverse --title $HOSTNAME --logfile /tmp/iperf-down.out
Contents of /tmp/perf-down.out:

Code: Select all

ubuntu2004:  iperf 3.7
ubuntu2004:  ubuntu2004:  Linux ubuntu2004 5.4.0-70-generic #78-Ubuntu SMP Fri Mar 19 13:29:52 UTC 2021 x86_64
ubuntu2004:  Time: Wed, 07 Apr 2021 20:13:48 GMT
ubuntu2004:  Connecting to host 10.10.10.20, port 5201
ubuntu2004:  Reverse mode, remote host 10.10.10.20 is sending
ubuntu2004:        Cookie: vpareqifxp4zoyxfr66bymsa4iqphckf2btp
ubuntu2004:        TCP MSS: 1448 (default)
ubuntu2004:  [  6] local 10.10.10.25 port 53628 connected to 10.10.10.20 port 5201
ubuntu2004:  Starting Test: protocol: TCP, 1 streams, 131072 byte blocks, omitting 0 seconds, 10 second test, tos 0
ubuntu2004:  [ ID] Interval           Transfer     Bitrate
ubuntu2004:  [  6]   0.00-1.00   sec   755 MBytes   755 MBytes/sec             
ubuntu2004:  [  6]   1.00-2.00   sec   784 MBytes   784 MBytes/sec             
ubuntu2004:  [  6]   2.00-3.00   sec   851 MBytes   851 MBytes/sec             
ubuntu2004:  [  6]   3.00-4.00   sec   897 MBytes   897 MBytes/sec             
ubuntu2004:  [  6]   4.00-5.00   sec   759 MBytes   759 MBytes/sec
ubuntu2004:  [  6]   5.00-6.00   sec   825 MBytes   825 MBytes/sec             
ubuntu2004:  [  6]   6.00-7.00   sec   761 MBytes   761 MBytes/sec             
ubuntu2004:  [  6]   7.00-8.00   sec   808 MBytes   808 MBytes/sec             
ubuntu2004:  [  6]   8.00-9.00   sec   882 MBytes   882 MBytes/sec             
ubuntu2004:  [  6]   9.00-10.00  sec   861 MBytes   861 MBytes/sec             
ubuntu2004:  - - - - - - - - - - - - - - - - - - - - - - - - -
ubuntu2004:  Test Complete. Summary Results:
ubuntu2004:  [ ID] Interval           Transfer     Bitrate         Retr
ubuntu2004:  [  6]   0.00-10.00  sec  8.00 GBytes   819 MBytes/sec  9635             sender
ubuntu2004:  [  6]   0.00-10.00  sec  7.99 GBytes   818 MBytes/sec                  receiver
ubuntu2004:  snd_tcp_congestion cubic
ubuntu2004:  rcv_tcp_congestion cubic
ubuntu2004:
ubuntu2004:  iperf Done.
Post Reply