Linux - How to Measure Network Latency
Network latency is a nice thing to be able to measure. If you’ve found your way to this page you are probably wondering how to check this on your Linux system. It is relatively easy so keep reading.
You can measure network latency on Linux with these tools ( and many others too ):
You can use the ping command with the ‘-U’ option. This will give you the full user-to-user latency.
ping -U 192.168.1.155
Without the ‘-U’ option it would normally print the round trip time.
Using tcpdump and Wireshark
You can use wireshark or tcpdump to capture the network traffic and compare the difference between the request time and reply time.
You can run tcpdump like this:
sudo tcpdump -i eno2
You can also try these two options with tcpdump:
|-ttt||Print the difference between the current and previous line ( in micro-seconds )|
|-ttttt||Print the difference between the current and first line ( in micro-seconds )|
This command should be very helpful:
sudo tcpdump -i eno2 -ttt
The idea is that you will run the Qperf server on one host and the client on another host. The client initiates different tests that you can specify.
Install the qperf:
yum install qperf # on older RHEL/CentOS/Fedora sudo apt install qperf # on Ubuntu and probably Debian
Run a server on one host:
This will listen on port 19765. Make sure it isn’t blocked by the firewall. You will then use the client from the other host to measure latency. Launch the client like this to measure TCP latency in GiB per second ( or other unit ):
qperf -ip 19766 -t 60 192.168.3.22 tcp_lat
Measure TCP latency in bits per second like this:
qperf -ip 19766 -t 60 --use_bits_per_sec 192.168.3.22 tcp_lat
You can measure TCP one way latency with tcp_lat or TCP streaming one way bandwidth with tcp_bw. There are other tests in addition to these. See the man page for more info.