This script was born from a real scenario: a friend experienced connection issues while playing multiplayer games in GT7.
Even though his connection measured well (400 Mbps download, 160 Mbps upload) and NAT2, he still suffered disconnections.
The goal of this project is to collect detailed connection data and monitor network stability over time, to analyze latency spikes, high-latency events, and packet losses.
- Running
ping
from the OS requires special privileges (raw sockets), which can cause errors when using scripts or running as a compiled executable (.exe). - Some traditional methods also fail when executed from a PyInstaller-generated executable.
Therefore, this script uses TCP ping, creating brief connections to a target port (default: Google DNS 8.8.8.8, port 53).
This allows measuring connection latency without special privileges, and better reflects real-world performance in TCP/online applications.
- Real-time TCP ping and network stability monitoring:
- Live chart showing the last 100 ping samples.
- Background color bands according to latency:
- Green: good (< 60 ms)
- Yellow: moderate (60–100 ms)
- Red: high (> 100 ms)
- Packet losses marked with red 'X'.
- Current ping displayed in the top-left corner.
- Historical logging:
- Each ping saved to a CSV in a
runs/
folder. - Columns: timestamp, latency in ms (or DROP if packet lost).
- Automatic creation of the folder and unique CSV names by date/time.
- Each ping saved to a CSV in a
- Local and historical statistics:
- Maximum latency in the last 100 samples.
- Count of high-latency events (> threshold).
- Packet loss percentage.
The final product can be compiled into a standalone executable (.exe) using PyInstaller, so it can be run on any PC without installing Python or dependencies.
All CSV logs will be saved in the runs/
folder next to the executable.
HOST
→ target host to ping (default: 8.8.8.8)PORT
→ TCP port for ping (default: 53)max_points
→ number of recent points shown on the chart (default: 100)thresholds
→ tuple for latency bands in ms, e.g.,(60, 100)
for green/yellow/red