A beautiful, real-time CLI tool for monitoring network latency over configurable time windows. Track ping statistics with live updates, color-coded metrics, and sliding window analytics.
- π Sliding Window Statistics β Track metrics across multiple configurable time periods (10s, 1m, 5m, 1h, etc.)
- π¨ Live Color-Coded Display β Green for healthy, yellow for moderate, red for critical latency/loss
- β‘ Real-Time Updates β In-place refresh shows evolving stats as old pings age out of each window
- π No Root Required β Uses unprivileged ICMP sockets (works on most modern Linux systems)
- π Comprehensive Metrics β Min/Max/Avg RTT, packet loss percentage, and network jitter
- β¨οΈ Simple & Intuitive β Clean interface, sensible defaults, easy to customize
# Clone the repository
git clone https://github.com/yourusername/ltping.git
cd ltping
# Make it executable
chmod +x ltping.py
# Run with default settings (10s / 30s / 60s windows)
python3 ltping.py google.com- Python 3.10 or newer
- Linux with kernel support for unprivileged ICMP sockets
Most modern Linux distributions allow unprivileged ping sockets by default. If you see a "ping_group_range" error on first run, fix it with:
sudo sysctl -w net.ipv4.ping_group_range='0 2147483647'To make this permanent across reboots:
echo 'net.ipv4.ping_group_range = 0 2147483647' | sudo tee -a /etc/sysctl.conf
sudo sysctl -p# Default: monitor with 10s, 30s, and 60s windows
python3 ltping.py google.com
# Ping an IP address
python3 ltping.py 8.8.8.8
# Custom time windows
python3 ltping.py example.com -w 5s 15s 60s 5m
# Fast ping interval (500ms between pings)
python3 ltping.py 1.1.1.1 -i 0.5
# Long-term monitoring with multiple windows
python3 ltping.py example.com -w 10s 1m 5m 30m 1hltping [-h] [-w WINDOWS [WINDOWS ...]] [-i INTERVAL] [-t TIMEOUT] [--no-color] target
Positional arguments:
target Hostname or IP address to ping
Options:
-h, --help Show help message and exit
-w, --windows Time windows (e.g. 10s 30s 60s 5m 1h)
Default: 10s 30s 60s
-i, --interval Seconds between pings (default: 1.0)
-t, --timeout Seconds to wait for each reply (default: 2.0)
--no-color Disable colored output
Time windows can be specified in seconds (s), minutes (m), or hours (h):
10sβ 10 seconds5mβ 5 minutes (300 seconds)1hβ 1 hour (3600 seconds)30β Plain numbers are treated as seconds
ltping google.com (142.250.80.46) seq=42 last=15.3 ms lifetime 42/42 (100.0%)
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Window Sent Rcvd Loss Min Max Avg Jitter
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
10s 10 10 0.0% 12 ms 18 ms 15 ms 2.1 ms
30s 30 30 0.0% 12 ms 20 ms 15 ms 2.3 ms
60s 60 59 1.7% 12 ms 25 ms 16 ms 3.1 ms
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Press Ctrl+C to stop.
- Window β Time period for the rolling statistics
- Sent β Total pings sent in this window
- Rcvd β Pings that received a reply
- Loss β Packet loss percentage (color-coded: green = 0%, yellow < 10%, red β₯ 10%)
- Min/Max/Avg β Round-trip time statistics in milliseconds
- Jitter β Average variation between consecutive RTTs (lower is better)
Packet Loss:
- π’ Green: 0% loss
- π‘ Yellow: < 10% loss
- π Orange: < 50% loss
- π΄ Red: β₯ 50% loss
Latency (RTT):
- π’ Bright Green: < 20ms (excellent)
- π΅ Cyan: 20-100ms (good)
- π‘ Yellow: 100-300ms (moderate)
- π΄ Red: > 300ms (high)
Jitter:
- π’ Green: Low variance (< 20% of average RTT)
- π‘ Yellow: Moderate (20-50% of average)
- π΄ Red: High variance (> 50% of average)
Monitor intermittent connectivity issues over extended periods:
python3 ltping.py gateway.local -w 1m 5m 15m 1hTrack your internet connection quality throughout the day:
python3 ltping.py 8.8.8.8 -w 5m 30m 1h 6h -i 2Measure response time to a remote service with high-frequency pings:
python3 ltping.py api.example.com -i 0.2 -w 10s 30s 60sCompare latency before and after VPN connection:
python3 ltping.py cloudflare.com -w 30s 2m 5mSliding Windows: Each time window maintains a queue of recent ping results. As new pings arrive, old ones beyond the window duration are automatically dropped. This gives you real-time insight into recent network behavior.
Unprivileged ICMP: Uses SOCK_DGRAM with IPPROTO_ICMP β the Linux kernel's ping socket API. No raw sockets required, so no root privileges needed on most systems.
Jitter Calculation: Computed as the average of absolute differences between consecutive RTTs within each window. This helps identify network instability beyond simple packet loss.
Your kernel's ping_group_range is restricted. Fix with:
sudo sysctl -w net.ipv4.ping_group_range='0 2147483647'Or run with sudo as a one-time workaround:
sudo python3 ltping.py example.comIf you're piping output or using a non-TTY terminal, colors are automatically disabled. You can force disable with --no-color:
python3 ltping.py example.com --no-color > log.txtBy default, ltping pings once per second. If you've set a very short interval (e.g., -i 0.01), it may consume more CPU. For most monitoring scenarios, 0.2-1.0 second intervals are sufficient.
- Language: Python 3.10+
- Dependencies: Standard library only (no pip packages required)
- Protocol: ICMP Echo Request/Reply (RFC 792)
- Socket Type:
AF_INET,SOCK_DGRAM,IPPROTO_ICMP - Platform: Linux (kernel 2.6.39+)
- IPv4 only β IPv6 support is not currently implemented
- Linux only β Uses Linux-specific ping socket API (won't work on macOS/Windows without modification)
- Single target β Monitors one host at a time (run multiple instances for parallel monitoring)
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
MIT License β see LICENSE file for details.
- Inspired by traditional
pingand network monitoring tools - Built with a focus on real-time visualization and user experience
pingβ The original ICMP echo utilitymtrβ Network diagnostic tool combining ping and tracerouteiperfβ Network bandwidth measurement tool
Made with β€οΈ for network engineers, sysadmins, and anyone who needs to know if their internet is actually working.