A Network Time Protocol (NTP) tracing tool written in Go. Similar to traceroute but specifically designed for NTP servers, it traces the path to NTP stratum servers and displays detailed timing information.
- NTP Tracing: Trace the path to NTP stratum servers
- Detailed Timing: Display clock offset, root distance, and RTT information
- Configurable: Customizable timeout, port, and count parameters
- Stratum Detection: Automatically stops when reaching stratum 1 servers
- Template Output: Customizable output format using Go templates
- Go 1.23 or later
git clone https://github.com/mengzhuo/tracentp.git
cd tracentp
go build -o tracentp main.gogo install github.com/mengzhuo/tracentp@latest# Trace to a specific NTP server
./tracentp pool.ntp.org
# Trace with custom port
./tracentp -p 123 time.google.com
# Trace with custom timeout
./tracentp -t 5s time.nist.gov
# Limit the number of hops
./tracentp -c 5 time.windows.com| Option | Description | Default |
|---|---|---|
-t, --timeout |
Timeout duration for each query | 3s |
-p, --port |
NTP server port | 123 |
-c, --count |
Stop after COUNT replies | 16 |
--version |
Show version information | - |
The tool outputs detailed information for each hop in the NTP trace:
OK from pool.ntp.org:seq=1 stratum=2 offset=0.000123 distance=0.001234 RTT=0.005678 ref=time.google.com
OK from time.google.com:seq=2 stratum=1 offset=0.000456 distance=0.000789 RTT=0.003456 ref=GPS
- Validate: Status of the NTP response
- Address: NTP server address
- Seq: Sequence number of the hop
- Stratum: NTP stratum level (1 = primary reference)
- ClockOffset: Clock offset in seconds
- RootDistance: Root distance in seconds
- RTT: Round-trip time in seconds
- ReferenceString: Reference identifier
./tracentp pool.ntp.org./tracentp -t 10s -p 123 -c 10 time.google.com./tracentp -c 1 time.nist.gov- Initial Query: Sends an NTP query to the specified server
- Response Analysis: Extracts timing information and reference server
- Recursive Tracing: Uses the reference server as the next target
- Stratum Detection: Stops when reaching a stratum 1 server
- Output Formatting: Displays results using a customizable template
- github.com/alexflint/go-arg - Command line argument parsing
- github.com/beevik/ntp - NTP client implementation
- Go 1.23 or later
- Make (optional, for using Makefile targets)
# Run all tests
go test ./...
# Run tests with coverage
make test-coverage
# Run benchmarks
make bench# Build for current platform
make build
# Build for multiple platforms
make build-all
# Install globally
make install# Format code
make format
# Lint code
make lint
# Clean build artifacts
make clean# For Linux
GOOS=linux GOARCH=amd64 go build -o tracentp-linux-amd64 main.go
# For Windows
GOOS=windows GOARCH=amd64 go build -o tracentp-windows-amd64.exe main.go
# For macOS
GOOS=darwin GOARCH=amd64 go build -o tracentp-darwin-amd64 main.goThe project uses GoReleaser for automated releases. To create a release:
-
Create a new tag:
git tag v1.0.0 git push origin v1.0.0
-
Test release locally:
make release-dry-run
-
GitHub Actions will automatically:
- Build binaries for multiple platforms
- Create a GitHub release
- Upload artifacts
- Generate checksums
This project is licensed under the MIT License - see the LICENSE file for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request