What is iPerf?

Matt Lim
2 min readMar 11, 2021

Or, how fast is localhost?

iPerf is a command line tool that can be used to measure network throughput.

For example, if endpoint A is sending data to endpoint B, you can use iPerf to determine how many bytes/second endpoint A can send, and how many bytes/second endpoint B can receive.

The rates should be similar due to TCP congestion control, which limits the number of un-acked segments that can be sent. From what I’ve observed, if the rates are unequal, the sender rate will be higher than the receiver rate, which makes sense since the sender can send some number of un-acked segments.

Example

Run this on the same computer in two separate terminal tabs/windows.

Server side

$ iperf3 -s -p 3000
  • -s means “run in server mode”
  • -p dictates the port to listen on

Client Side

$ iperf3 -c localhost -p 3000 -f M
Connecting to host localhost, port 3000
[ 6] local ::1 port 57546 connected to ::1 port 3000
[ ID] Interval Transfer Bandwidth
[ 6] 0.00-1.00 sec 4.66 GBytes 4769 MBytes/sec
...
[ 6] 9.00-10.00 sec 4.69 GBytes 4807 MBytes/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth
[ 6] 0.00-10.00 sec 45.9 GBytes 4699 MBytes/sec sender
[ 6] 0.00-10.00 sec 45.9 GBytes 4699 MBytes/sec receiver
  • -c means “run in client mode”
  • -p dictates the port to connect to
  • -f M formats the output in MBytes (megabytes)

Interpreting the Results

What do these numbers actually mean?

The main rows of importance are the ones at the bottom:

[ ID] Interval           Transfer     Bandwidth
[ 6] 0.00-10.00 sec 45.9 GBytes 4699 MBytes/sec sender
[ 6] 0.00-10.00 sec 45.9 GBytes 4699 MBytes/sec receiver

This tells us that the sender, which is the “client” side, is able to send data at a rate of 4699 MBytes/sec. You can think of this as the upload speed from client to server.

The receiver, which is the “server” side, is able to receive data at a rate of 4699 MBytes/sec. You can think of this as the server’s download speed.

So, how fast is localhost?

The answer is now right in front of us — using localhost, we can transfer data at a rate of ~5 gigabytes/second!

A nifty application of this tool is to pair it with port forwarding. For example, you can pair it with an SSH tunnel. First, create an SSH tunnel.

$ ssh -L 3000:localhost:3000 my.srver.com

Then, you can run iPerf on the remote server and on your local machine to measure the throughput on both sides.

Lastly, there are lots of useful options, which you can see by running:

$ iperf3 — help

Resources

  1. https://iperf.fr/iperf-download.php (download link)
  2. https://en.wikipedia.org/wiki/Iperf
  3. https://github.com/esnet/iperf/issues/480

--

--

Matt Lim
Matt Lim

Written by Matt Lim

Software Engineer. Tweeting @pencilflip. Mediocre boulderer, amateur tennis player, terrible at Avalon. https://www.mattlim.me/

No responses yet