This project measures TCP round-trip latency from any Linux host to a specified endpoint using TCP ping.
- Measures TCP round-trip latency to a specified endpoint and port.
- Logs destination IP address for each request.
- Results saved in CSV format for analysis.
- Each run produces a uniquely named results file with the UNIX timestamp.
- The last row of the CSV contains the average response time and the start time UNIX timestamp.
- Python 3.8+
- traceroute
- Docker (optional)
- No external Python dependencies required for the TCP ping script.
apk add python3 traceroute
mkdir -p resultswget https://raw.githubusercontent.com/deajan/tcpping/master/tcpping
chmod +x tcpping
export TCP_ENDPOINT="your-endpoint"
export TCP_PORT=443
export NUM_REQUESTS=10
python3 script.pyResults will be saved in the results/ directory.
docker build -f Dockerfile -t latency-tcp .The container image is available at ghcr.io/peanutsguy/tcpping_latency.
docker run --rm \
-e TCP_ENDPOINT="your-endpoint" \
-e TCP_PORT=443 \
-e NUM_REQUESTS=10 \
-v $(pwd)/results:/app/results \
ghcr.io/peanutsguy/tcpping_latencyResults will be available in your local results/ directory.
CSV file columns:
- request
- latency_ms
- destination_ip
- tcp_port
- msg (error or status or hostname)
- start_time (only in the summary row)
The last row contains:
- request: "Average"
- latency_ms: average response time (ms)
- start_time: UNIX timestamp when the test started
- msg: hostname
- Do not commit sensitive credentials.
- Use environment variables for endpoint configuration.