A simple and reliable tool for network performance testing using iperf3 and ping, designed for automated logging, debug mode, and optional cleanup β suitable for Linux & macOS clients.
iperf3 is a powerful network testing tool used to measure:
- Bandwidth (throughput)
- Jitter
- Packet loss
- Latency
It uses client-server architecture:
- The server runs
iperf3 -sand listens for incoming tests. - The client initiates the test using
iperf3 -c <server-ip>.
πΌ Learn more: https://iperf.fr
+-------------+ +---------------+
| Client | <=====> | Server |
| (runs this | test via | (runs iperf3 |
| script) | iperf3 | in server |
+-------------+ +---------------+
sudo apt install iperf3
iperf3 -sβ‘ The server will listen on TCP/UDP port 5201 by default.
sudo apt install iperf3
chmod +x performance_test.pypython3 performance_test.py --server <server_ipv4_address> --duration 60 --port 5201 --udp-bandwidth 1000M --direction upload --os-mode Linux --debug--server: IP address of iperf3 server (IPv4 only)--duration: Duration in seconds (60,300,600)--port: Optional, default5201--udp-bandwidth: Optional, default1000M(used only for UDP test)--direction:upload(default) ordownloadfor reverse test--debug: Show raw result output in terminal--clean-tmp: Remove all related/tmp/test files after execution--os-mode: Optional override for OS auto-detection (LinuxorMacOS, case-insensitive)
/tmp/
βββ ping_<timestamp>.log # Initial ping
βββ ping_live_<timestamp>.log # Ping during iperf
βββ ping_post_<timestamp>.log # Ping after iperf
βββ iperf3_udp_<timestamp>.log # Raw UDP test
βββ iperf3_tcp_<timestamp>.log # Raw TCP test
~/iperf_logs/ (or /var/log/iperf_tests if run as root)
βββ iperf_summary.log # Parsed single-line summary
2025-06-13_16-05-29 STATUS=OK SERVER=10.184.0.2:5201 DURATION=60s LATENCY=32.415ms PING_LOSS=0% LIVE_LAT=35.2ms LIVE_LOSS=1% POST_LAT=30.5ms POST_LOSS=0% UDP_BW=88.8 Mbits/sec UDP_JITTER=0.200ms UDP_LOSS=90% TCP_BW=39.8 Mbits/sec
python3 performance_test.py --server <server_ip>python3 performance_test.py --server <server_ip> --direction downloadpython3 performance_test.py --server <server_ip> --duration 300python3 performance_test.py --server <server_ip> --udp-bandwidth 500Mpython3 performance_test.py --server <server_ip> --debugpython3 performance_test.py --server <server_ip> --os-mode MacOSpython3 performance_test.py --server <server_ip>(Logs will be written to ~/iperf_logs/ automatically.)
python3 performance_test.py --server <server_ip> --duration 300 --udp-bandwidth 500M --direction upload --port 5201 --debugpython3 performance_test.py --server <server_ip> --duration 300 --udp-bandwidth 500M --direction download --port 5201 --debugpython3 performance_test.py --server <server_ip> --duration 60 --direction upload --clean-tmpExample:
MacBook β LAN β FortiGate β IPsec β GCP Instance
Useful for verifying advanced tunneling stability before deployment to clients.
- UDP Loss (%): Packet loss due to network congestion or MTU mismatch.
- UDP Jitter (ms): Variability in packet delay; important for VoIP/Video.
- UDP Bandwidth: Receiver-side bandwidth (may be limited by loss).
- TCP Bandwidth: Effective throughput measured via TCP acknowledgments.
Run 4 times a day:
crontab -eExample:
0 0,6,12,18 * * * /usr/bin/python3 /path/to/performance_test.py --server 192.168.1.100 --duration 60 >> ~/iperf_logs/cron.log 2>&1Optional daily cleanup:
0 4 * * * find /tmp -name "ping_*.log" -o -name "iperf3_*.log" -mtime +7 -delete- Export to CSV/JSON
- Slack/email alerts
- REST API or webhook
- Grafana integration via InfluxDB
MIT License β Free to use, modify, distribute.
*.log
*.pyc
__pycache__/
/tmp/ping_*.log
/tmp/ping_live_*.log
/tmp/ping_post_*.log
/tmp/iperf3_udp_*.log
/tmp/iperf3_tcp_*.log
/var/log/iperf_tests/*.log
~/iperf_logs/*.log