Benchmark network throughput between Linux hosts

This article will cover various methods for testing network throughput between two Linux hosts.

dd and netcat

Two basic utilities commonly found on Linux systems are dd and netcat. You can use these tools together to benchmark a network by reading and redirecting /dev/zero on one system to a raw TCP listener (netcat) on another.

Create a TCP listener on "node-a" using netcat:

# netcat -l 9919 > /dev/null

NOTE: netcat might also be named nc or ncat depending on your distribution and how netcat was installed.

Redirect dd read blocks from /dev/zero to a TCP connection on "node-b" (substitute "node-a" IP address in the following command):

# dd if=/dev/zero bs=1M count=1024 > /dev/tcp/<ip-of-node-a>/9919

Adjust the count= option to control the amount of data you're sending across slower networks. The speed of the dd will be equal to the maximum network throughput between node-a and node-b.

iperf

iperf is a utility specifically for testing/benchmarking network throughput between hosts. It's not as likely to already be present, but can often be installed using the package manager on most modern Linux distributions.

On one node, create an iperf server (by default iperf listens on all interfaces):

# iperf -s

On the peer node, connect to the server as a client, specifying the server's IP address:

# iperf -c <ip-of-server-iperf>

You should see the bandwidth of the network between nodes output in both the client and server outputs.

CTRL+C will terminate the iperf server.

 

Reviewed 2020/12/01 - DGT