When it comes to measuring network speed, you might think of testing the Internet connection speed with the famous speedtest. But in fact, just testing the Internet connection speed is not reliable. In some scenarios, the final Internet speed is also affected by the your infrastructure like the connection to your ISP's server. Therefore, it is very important to know where your network performance bottleneck is. And iPerf is a professional network speed test tool that can be used to test the network connection speed between two machines on the LAN or the Internet, so that you can better understand the network performance in your network infrastructure.

Testing process

Suppose you need to test the connection speed of host A to B. We need to install the iPerf software on both machine A and machine B (the latest version is called iPerf3). iPerf itself does not distinguish between client and server. It uses different parameters to act the role of client or server. We need to start the server on server B, start the client on server A, and initiate a connection from A to B to test the network speed.

Install iPerf3

iPerf3 can be installed on Windows and most mainstream Linux systems. Taking Ubuntu Server as an example, iPerf3 can be installed via apt:

sudo apt install iperf3

We need to install iPerf3 on both server A and server B.

Open test port

What we want to test is the connection speed from host A to host B. Data packets are sent from A to B. Therefore, we need to open the iPerf3 port on host B to allow the connection.

Open the management page of host B on Azure, enter "Networking" tab, and add TCP 5001 and 5201 ports. 5001 is for iperf and 5201 is for iperf3. If you only use iperf3, you can just open port 5201 only.

The port of iPerf 3 can also be specified by the -p parameter. Similarly, after specifying the port, you must remember to allow it in Azure NSG.

Prepare server B

Run command on server B

iperf3 -s

The -s parameter is the means "server". iperf3 now acts the role of the server and waits for connection on the default port 5201.

Test on server A

Run command on server A

iperf3 -c <IP address of server B> -p 5201 -t 10

-p indicates the designated port number, if not specified, the default port 5201 will be used. -t means the how long the test should run, I specified 10 seconds here.

The test starts after the command is executed, and we can see the data size and network speed of each request in the output of host A. And see the average connection speed after the test.

Here, my host A is a VM in Azure China (21Vianet), and my host B is another VM of Azure global east a sia region.

During the test, server B will also show the same data output:

We can see that the connection speed from Azure China to the Azure Global East Asia is about 13MB/s.

You can also use this method to test the network speed of two VMs in the same data center. For example, two VMs in the East Asia region of the Azure Global have a network speed of 1GB/s: