This article describes how to test network latency between Azure virtual machines (VMs) by using the publicly available tools Latte for Windows or SockPerf for Linux.
For the most accurate results, you should measure VM network latency with a tool that's designed for the task and excludes other types of latency, such as application latency. Latte and SockPerf provide the most relevant network latency results by focusing on Transmission Control Protocol (TCP) and User Datagram Protocol (UDP) traffic. Most applications use these protocols, and this traffic has the largest effect on application performance.
Many other common network latency test tools, such as Ping, don't measure TCP or UDP traffic. Tools like Ping use Internet Control Message Protocol (ICMP), which applications don't use. ICMP traffic can be treated differently from application traffic and doesn't directly affect application performance. ICMP test results don't directly apply to workloads that use TCP and UDP.
Latte and SockPerf measure only TCP or UDP payload delivery times. These tools use the following approach to measure network latency between two physical or virtual computers:
Create a two-way communication channel between the computers by designating one as sender and one as receiver.
Send and receive packets in both directions and measure the round-trip time (RTT).
Tips and best practices to optimize network latency
To optimize VMs for network latency, observe the following recommendations when you create the VMs:
Use the following best practices to test and analyze network latency:
As soon as you finish deploying, configuring, and optimizing network VMs, take baseline network latency measurements between deployed VMs to establish benchmarks.
Test the effects on network latency of changing any of the following components:
Operating system (OS) or network stack software, including configuration changes.
VM deployment methods, such as deploying to an availability zone or proximity placement group (PPG).
VM properties, such as Accelerated Networking or size changes.
Virtual network configuration, such as routing or filtering changes.
Always compare new test results to the baseline or to the latest test results before controlled changes.
Repeat tests whenever you observe or deploy changes.
Test VMs with Latte or SockPerf
Use the following procedures to install and test network latency with Latte for Windows or SockPerf for Linux.
On the receiver VM, create a Windows Defender Firewall allow rule to allow the Latte traffic to arrive. It's easier to allow the latte.exe program by name than to allow specific inbound TCP ports. In the command, replace the <path> placeholder with the path you downloaded latte.exe to, such as c:\tools\.
Run latte.exe from the Windows command line, not from PowerShell.
On the receiver VM, run the following command, replacing the <receiver IP address>, <port>, and <iterations> placeholders with your own values.
พร้อมท์คําสั่งของ Windows
latte -a <receiver IP address>:<port> -i <iterations>
Around 65,000 iterations are enough to return representative results.
Any available port number is fine.
The following example shows the command for a VM with an IP address of 10.0.0.4:
latte -a 10.0.0.4:5005 -i 65100
On the sender VM, run the same command as on the receiver, except with -c added to indicate the client or sender VM. Again, replace the <receiver IP address>, <port>, and <iterations> placeholders with your own values.
พร้อมท์คําสั่งของ Windows
latte -c -a <receiver IP address>:<port> -i <iterations>
For example:
latte -c -a 10.0.0.4:5005 -i 65100
Wait for the results. Depending on how far apart the VMs are, the test could take a few minutes to finish. Consider starting with fewer iterations to test for success before running longer tests.
Prepare VMs
On both the sender and receiver Linux VMs, run the following commands to prepare for SockPerf, depending on your Linux distro.
Copy, compile, and install SockPerf by running the following commands:
Bash
#Bash - all distros#From bash command line (assumes Git is installed)
git clone https://github.com/mellanox/sockperf
cd sockperf/
./autogen.sh
./configure --prefix=
#make is slow, may take several minutes
make
#make install is fast
sudo make install
Run SockPerf on the VMs
After the SockPerf installation is complete, start SockPerf on the receiver VM. Any available port number is fine. The following example uses port 12345. Replace the example IP address of 10.0.0.4 with the IP address of your receiver VM.
Bash
#Server/Receiver for IP 10.0.0.4:
sudo sockperf sr --tcp -i 10.0.0.4 -p 12345
Now that the receiver is listening, run the following command on the sender or client computer to send packets to the receiver on the listening port, in this case 12345.
Bash
#Client/Sender for IP 10.0.0.4:
sockperf ping-pong -i 10.0.0.4 --tcp -m 350 -t 101 -p 12345 --full-rtt
The -t option sets testing time in seconds. About 100 seconds is long enough to return representative results.
The -m denotes message size in bytes. A 350-byte message size is typical for an average packet. You can adjust the size to more accurately represent your VM's workloads.
Wait for the results. Depending on how far apart the VMs are, the number of iterations varies. To test for success before you run longer tests, consider starting with shorter tests of about five seconds.