A high-performance CLI utility to test, benchmark, and rank public NTP (Network Time Protocol) servers to find the optimal time source for your network configuration.
C:\> python bestntpserver.py --test
=== Best Server ===
Server: 1.br.pool.ntp.org
NTP response time: 0.004 seconds
Ping time: 4.67 ms
Hops: 7
=== All Results ===
+---------------------+--------------+-----------+------+
| Server | NTP Time (s) | Ping (ms) | Hops |
+---------------------+--------------+-----------+------+
| 1.br.pool.ntp.org | 0.004 | 4.67 | 7 |
| 1.pool.ntp.org | 0.005 | 5.67 | 7 |
| 2.pool.ntp.org | 0.006 | 9.00 | inf |
| time.apple.com | 0.006 | 5.33 | inf |
| 0.br.pool.ntp.org | 0.006 | 5.67 | 9 |
| time.cloudflare.com | 0.007 | 5.00 | 7 |
...
- Concurrent Execution: Benchmarks servers in parallel using automated multi-threading optimization based on CPU core count.
- Smart Ranking: Evaluates via a tuple hierarchy (NTP sync delay > raw hops > raw ping).
- Cross-Platform: Automatically adapts OS-level networking checks (
tracertvstracerouteandping) for Windows, macOS, and Linux. - Robust Parsing: Built-in multi-language ping support (handles
time=,tempo=,Zeit=,temps=). - Curated Dataset: Includes 29 highly reliable global and regional (Brazil) public NTP IP addresses/URLs.
git clone https://github.com/reneoliveirajr/ntp-benchmark-tool.git
cd ntp-benchmark-tool
pip install -r requirements.txt
python bestntpserver.py --test| Argument | Description |
|---|---|
--test |
Benchmark all configured servers (runs parallel by default). |
--server <addr> |
Benchmark a single specific NTP server address. |
--show-servers |
Output a table of all hardcoded NTP servers. |
--sequential |
Run the benchmark synchronously (disables parallel execution). |
--timeout <sec> |
Customize the network timeout for requests (default: 10). |
--workers <num> |
Override the default thread pool worker limit (default: 5). |
--verbose |
Print trace diagnostic/debug-level logging. |
The tool orchestrates asynchronous execution on three fronts per target server and then scores them by a sorted tuple algorithm:
- Lowest NTP Response Time: Measures the actual NTP synchronization lag (
ntplib). This is the absolute priority determinant for benchmarking time servers. - Fewest Network Hops: Performs an OS-based
traceroute. A shorter network path denotes fewer routing points of failure. - Lowest ICMP Ping: Evaluates raw ICMP response time in milliseconds. Acts mainly as a final tiebreaker.
(Note: Failed routes or unreachable endpoints fallback to inf instead of throwing exceptions).
- ntplib: Core protocol query client.
- prettytable: Terminal ANSI ASCII formatting.
concurrent.futures.ThreadPoolExecutor: Standard library parallelization.subprocess: OS-level routing commands binding.
This project is licensed under the MIT License.