Network latency directly impacts application performance, user experience, and service reliability. Whether you are diagnosing slow database connections, optimizing CDN delivery, or troubleshooting VPN performance, accurate latency measurement is essential. This guide covers practical latency testing techniques from basic ping to advanced TCP connection timing.
ICMP Ping: The Foundation
# Basic ping (10 packets)
ping -c 10 8.8.8.8
# Fast ping with custom interval
ping -c 100 -i 0.2 host
# Large packet test (MTU issues)
ping -s 1472 -M do host
# Quiet mode (summary only)
ping -c 50 -q host
Pay attention to three metrics: average latency (avg), packet loss percentage, and mdev (mean deviation = jitter). High jitter causes inconsistent performance even when average latency is acceptable.
Understanding Jitter
Jitter is the variation in latency between packets. For real-time applications (VoIP, video), jitter matters more than absolute latency:
- <5ms jitter β Excellent (suitable for real-time)
- 5-20ms jitter β Good (acceptable for most applications)
- 20-50ms jitter β Fair (may affect real-time quality)
- >50ms jitter β Poor (problematic for interactive use)
Traceroute: Path Analysis
# Standard traceroute
traceroute -n 8.8.8.8
# TCP traceroute (bypasses ICMP blocks)
traceroute -T -p 443 host
# MTR: combined ping + traceroute
mtr -rw -c 100 host
TCP Connection Latency
Application-level latency matters more than ICMP ping for web services:
# HTTP response time
curl -o /dev/null -w "Connect: %{time_connect}s\nTotal: %{time_total}s" https://host
# TCP SYN latency
hping3 -S -p 443 -c 10 host
Automated Latency Testing
pip install dargslan-network-latency
dargslan-latency ping 8.8.8.8 # Detailed ping stats
dargslan-latency tcp example.com 443 # TCP connection latency
dargslan-latency compare 8.8.8.8 1.1.1.1 9.9.9.9 # Compare hosts
dargslan-latency trace 8.8.8.8 # Traceroute
Latency Optimization Tips
- Use CDNs to reduce geographic latency
- Enable TCP BBR congestion control for better throughput
- Optimize DNS resolution time (use fast resolvers)
- Enable HTTP/2 and connection keep-alive
- Monitor latency trends over time, not just point measurements
Download our free Network Latency Testing Cheat Sheet for essential diagnostic commands. For deeper networking knowledge, explore our Networking & DevOps eBooks.