Measuring Network Bandwidth using Iperf and Docker

Measuring Network Bandwidth using Iperf and Docker

Networking

Measuring Network Bandwidth using Iperf and Docker

At the heart of any network engineer’s toolkit, are applications that let you peer into the network for performance, congestion and capacity planning. One of the thoroughbreds in the open source network tools collection is iperf. Iperf has been around for a long time. The good folks at ESnet updated the original iperf with new features and what not and released it as iperf3.

This tutorial assumes no working knowledge of Docker or Iperf3. If you don’t have Docker installed you can get it from here. More on Docker commands can be found here.

Run the Iperf Server Side Docker Container

Start a listener service on port 5201 and name the container “iperf3-server” (if the image is not yet downloaded, the run command will pull it down for you). This is bound to the host machine/node IP address via NAT thanks to the -p 5201:5201 mapping. This means there is a container with a private IP address, along with the host machine’s IP listening on 5201.

That returns an iperf3 process bound to a socket waiting for new connections on port 5201.

From a new console, you can view the running container with the following Docker command.

You can view the image you downloaded with the following Docker command.

Run the Iperf Client Side Docker Container

Since we started the server, we now want to a client from another host/node at the server to measure the bandwidth between the two endpoints. This can be the same host you are on it you are First, get the IP address of the new Iperf3 server container you just started. If you are testing in the real world against two seperate machines, you would point at the host’s IP that is reachable between the two endpoints

The following will run the client side command from the same host, the server container is running on:

Next, initiate a client connection from another container, to measure the bandwidth between the two endpoints.

Do this by running a client container pointing at the server service IP address.

And the output is the following:

Note: if you are new to Docker, the –rm flag will destroy the container after the test runs. I also left out explicitly naming the container. It’s totally optional. I typically explicitly name containers for organization and to maintain a consistent pattern but since the client container is run once and then detroyed until I am ready to take the next measurement, it is treated as a disposable container (e.g. pets vs. cattle).

You can do something fancier in a one liner like so (docker ps -ql returns the CID e.g. container ID of the last container started which would be the server we want in this case)

You can do lots of cool things by regularly measuring bandwidth with Iperf3 and doing so in containers makes it easy to run on any platform, anywhere. You can take those measurements and pump them into TSDBs or any other applications designed to collect metrics for trending, capacity planning or simply proactively monitoring for potential bottlenecks in your network.

That’s it for now. Hope everyone had a happy new year. As a resolution I plan to pry myself away from other projects and start blogging again regularly (hopefully). Cheers!

About the Author

Brent SalisburyI have over 15 years of experience wearing various hats from, network engineer, architect, devops and software engineer. I currently have the pleasure of working at the company that develops my favorite software I have ever used, Docker. My comments here are my personal thoughts and opinions. More at Brent's BioView all posts by Brent Salisbury →

  1. Pavel SkovajsaPavel Skovajsa01-03-2018


    Great post, we just need this docker thing to run on any Cat3524 and we are all set!

    Btw i love the terminal coloring is that zsh?

Leave a Reply