A powerful cross-platform terminal-based application for monitoring and analyzing PTPv2 (Precision Time Protocol) networks in real-time with full keyboard and mouse support.
- ๐ Real-time dashboard with multiple panels
- ๐จ Multiple themes: Default, Monokai, Matrix
- โจ๏ธ Intuitive keyboard navigation
- ๐ฑ๏ธ Mouse support - Click to switch views, select rows, and navigate content
- ๐ฑ Responsive layout that adapts to terminal size
- ๐ Live updates without screen flicker
- โธ๏ธ Pause mode to temporarily stop network parsing for UI inspection
- ๐ Automatic PTP and gPTP host discovery (UDP ports 319/320 and Ethernet 0x88f7)
- ๐ก Cross-platform packet capture - Uses pnet for live capturing on Linux, macOS, and Windows
- ๐ Dual protocol support - Handles both PTP over UDP (Layer 3) and gPTP over Ethernet (Layer 2, IEEE 802.1AS)
- ๐ PCAP file support - Read and analyze PTP packets from captured pcap files (offline analysis mode)
- ๐ Multicast group membership - Ensures network interfaces receive multicast PTP traffic
- ๐ Full packet analysis - Records both raw packet data and parsed PTP content
- ๐ฏ Smart interface selection - Automatically filters virtual interfaces while supporting manual override
- ๐ท๏ธ Host classification by PTP state
- ๐ BMCA (Best Master Clock Algorithm) - Automatic primary time transmitter detection
- ๐ Primary Time Transmitter marked with "PTT" indicator
- ๐ Network statistics and quality metrics
- ๐ Timing relationship tracking
- โธ๏ธ Time reference modes - Live network uses current system time; pcap mode uses last packet timestamp as reference
- ๐ณ Tree view mode - Hierarchical display showing transmitter-receiver relationships with proper indentation and PTT (Primary Time Transmitter) indicators
- ๐ณ Visual hierarchy mapping of transmitter-receiver relationships
- ๐ท๏ธ VLAN support - Detects and displays VLAN tags in PTP packets
- ๐ Comprehensive host table with sortable columns
- ๐ข Multiple sort options (State, IP, Clock Identity, Domain, etc.)
- ๐ฏ Selection tracking across operations
- ๐ Quality indicators and confidence levels
- ๐ OUI database integration to show vendor information
- โญ Local machine identification: Your own machine is marked with asterisks (*) in the host list and details
- ๐ฑ๏ธ Mouse-enabled selection - Click on any host row to select it instantly
- ๐ Real-time packet history with version identification
- ๐จ Color-coded message types (ANNOUNCE, SYNC, DELAY_REQ, PDELAY_REQ, etc.)
- ๐ Interface-aware capture - Tracks which interface each packet was received on
- ๐ฑ๏ธ Interactive packet selection - Click to select packets, double-click for detailed view
- ๐ Scroll wheel support - Navigate through packet history with mouse wheel
PTP Trace supports offline analysis of PTP traffic from pcap files in offline mode.
# Capture PTP traffic with tcpdump (Linux/macOS)
sudo tcpdump -i eth0 -w ptp_capture.pcap 'udp port 319 or udp port 320 or ether proto 0x88f7'
# Capture with Wireshark (all platforms)
# Filter: udp.port == 319 or udp.port == 320 or eth.type == 0x88f7
# Save as: ptp_capture.pcap
# Analyze the captured file
./target/release/ptp-trace --pcap-file ptp_capture.pcap- ๐ฆ Rust 1.70.0 or later
- ๐ง Administrator privileges required - Needed for promiscuous mode packet capture (in live capture mode)
- ๐ Network interfaces with PTP traffic (ports 319/320)
- ๐ฆ Platform-specific requirements:
- macOS: Xcode command line tools (
xcode-select --install) - Windows: WinPcap or Npcap installed
- macOS: Xcode command line tools (
# Clone the repository
git clone https://github.com/holoplot/ptp-trace.git
cd ptp-trace
# Build from source
cargo build --release
# Run with default settings (requires root)
sudo ./target/release/ptp-trace# ๐ Analyze packets from pcap file (offline mode, no admin privileges needed)
./target/release/ptp-trace --pcap-file capture.pcap
# ๐ Monitor specific interface (requires root)
sudo ./target/release/ptp-trace --interface eth0
# ๐ Monitor multiple interfaces (requires admin privileges)
sudo ./target/release/ptp-trace --interface eth0 --interface eth1 # Linux/macOS
# ๐ Monitor all suitable interfaces (default behavior, requires admin privileges)
# Automatically excludes virtual interfaces (Docker, VPN, etc.)
sudo ./target/release/ptp-trace # Linux/macOS
./target/release/ptp-trace.exe # Windows (as Administrator)
# ๐ Force monitoring of virtual interfaces (requires explicit specification)
sudo ./target/release/ptp-trace --interface docker0 --interface br-123456
# โก Faster updates (500ms)
sudo ./target/release/ptp-trace --update-interval 500
# ๐จ Use Matrix theme
sudo ./target/release/ptp-trace --theme matrix
# ๐ฑ๏ธ Disable mouse support (enabled by default)
sudo ./target/release/ptp-trace --no-mouse
# ๐ Analyze pcap file with custom theme and faster updates
./target/release/ptp-trace --pcap-file capture.pcap --theme matrix --update-interval 250
# ๐ Enable debug mode
sudo ./target/release/ptp-trace --debug
# ๐ง Combine options for live monitoring
sudo ./target/release/ptp-trace --interface eth0 --interface eth1 --theme matrix --update-interval 500 --no-mouse
# Note: --interface and --pcap-file options are mutually exclusiveTab- ๐ Cycle between views: Host Table โ Host Details โ Packet Historyโ/k- ๐ Move selection up (host table) or scroll up (details/packets)โ/j- ๐ Move selection down (host table) or scroll down (details/packets)PgUp/PgDn- ๐ Page navigation (10 items) or scroll by pageHome/End- ๐ Jump to top/bottomEnter- ๐ Show packet details modal (when packet history is active)q- ๐ช Close packet details modal (when modal is open) or quit applicationEsc- ๐ช Close help screen
Click- ๐ฏ Switch to view and select row (host table/packet history)Double-click- ๐ Open packet details modal (packet history rows)Click outside modal- ๐ช Close packet details modal (or use 'q' key)Scroll wheel- ๐ Navigate selections/scroll content (3 lines per scroll)
s- ๐ Cycle sort columnsS-โ๏ธ Toggle sort directiona- โฌ ๏ธ Previous sort columnt- ๐ณ Toggle tree view mode- Green headers indicate active sort column
r- ๐ Refresh/rescan networkCtrl+L- ๐ Refresh/redraw screenc- ๐๏ธ Clear hosts and packet historyx- ๐๏ธ Clear packet history for selected hostp- โธ๏ธ Toggle pause mode (stops network parsing, shows "PAUSED" in header)w- ๐ Toggle packet auto-scrolle- ๐ Toggle expanded packet historyd- ๐ Toggle debug mode
h/F1- โ Show/hide helpEsc/q- ๐ช Close help screenq- ๐ซ Close modal/help or quit application
- Three-way navigation: Use
Tabto cycle between Host Table, Host Details, and Packet History - Scrollable views: Host Details and Packet History are fully scrollable with arrow keys, Page Up/Down, Home/End
- Preserved selections: Packet selection is maintained when switching views until you select a different host
- Auto-scroll control: Packet auto-scroll is disabled when manually navigating, re-enable with
w - Smart resets: Scroll positions reset to top when selecting a different host
- Mouse integration: Mouse and keyboard controls work seamlessly together
- Accessibility: Use
--no-mouseflag to disable mouse support if needed
In accordance with IEEE 1588g-2022, this project uses inclusive terminology to describe the roles of network components.
| Inclusive term | Industry Standard | Description |
|---|---|---|
| Time Transmitter | Master Clock | Device that provides timing reference |
| Time Receiver | Slave Clock | Device that synchronizes to timing reference |
| Primary Time Transmitter (PTT) | Grandmaster Clock | Best master clock selected by BMCA algorithm |
The underlying PTP protocol and packet structures remain unchanged - only the user-facing terminology has been modernized for clarity and inclusivity.
A blog post from Meinberg has more information about the topic.
Choose from multiple built-in themes. See the output of ptp-trace --help to get a list of available themes.
- ๐ผ๏ธ Complete terminal UI framework
- ๐ฎ Application structure and navigation
- ๐ Host table with sorting and scrolling
- ๐ฆ Packet history with detailed view
- ๐จ Multiple theme support
- โจ๏ธ Comprehensive keyboard controls
- ๐ Debug mode with scroll information
- ๐ค Data export - JSON, PCAP output formats for raw packet data
- ๐ Advanced filtering - Search and filter capabilities for both live and pcap modes
- ๐ Enhanced analytics - Statistical analysis of timing data
- ๐ง Configuration management - Save/load application settings
- โก Hardware-accelerated filtering - Use BPF filters for efficient packet capture
# Development build
cargo build
# Optimized release build
cargo build --release
# Run tests
cargo test
# Format code
cargo fmt
# Lint code
cargo clippyThis project features an integrated OUI database for MAC address lookup. The information is compiled into the binary at build time so that it can be used without an internet connection from a single binary. To update the database, follow these steps:
# Update OUI database
python3 -r oui/requirements.txt
python3 oui/gen_oui_rust_phf.py >src/oui_map.rs
# Make sure to lint the code after updating the database
cargo clippyFeel free to contribute to this project by submitting pull requests with the updated OUI database.
- ๐ฅ๏ธ ratatui - Terminal UI framework
- โก tokio - Async runtime
- โจ๏ธ crossterm - Cross-platform terminal handling
- ๐ clap - Command line argument parsing
- โ anyhow - Error handling
- ๐ pnet - Cross-platform packet capture
- ๐ง socket2 - Advanced socket operations and multicast group joining
- ๐งฎ libc - Low-level system calls
We welcome contributions! Please:
- ๐ด Fork the repository
- ๐ฟ Create a feature branch
- ๐ง Make your changes
- โ Add tests if applicable
- ๐ Update documentation
- ๐ Submit a pull request
- ๐ฆ Follow Rust best practices
- ๐ Document public APIs
- โ Include tests for new features
- ๐จ Use
cargo fmtfor formatting - ๐ Pass
cargo clippylints
This project is licensed under the GPLv2 License - see the LICENSE file for details.
- ๐ฐ๏ธ statime - Rust PTP implementation
- ๐ง ptp4l - Linux PTP daemon
- ๐ผ๏ธ ratatui - Terminal UI library
- โก tokio - Async runtime for Rust
- ๐ Use
horF1in the application for interactive help - ๐ Enable debug mode with
dfor troubleshooting - ๐ง Report issues on the project's issue tracker
- ๐ฌ Join discussions for feature requests and support
๐ฐ๏ธ Built for precision timing networks โข ๐ฆ Written in Rust โข ๐ฅ๏ธ Runs in your terminal