Skip to content

holoplot/ptp-trace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

29 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ•ฐ๏ธ PTP Trace

A powerful terminal-based application for monitoring and analyzing PTPv2 (Precision Time Protocol) networks in real-time.

License Rust

โœจ Features

๐Ÿ–ฅ๏ธ Interactive Terminal UI

  • ๐Ÿ“Š Real-time dashboard with multiple panels
  • ๐ŸŽจ Multiple themes: Default, Monokai, Matrix
  • โŒจ๏ธ Intuitive keyboard navigation
  • ๐Ÿ“ฑ Responsive layout that adapts to terminal size
  • ๐Ÿ”„ Live updates without screen flicker
  • โธ๏ธ Pause mode to temporarily stop network parsing for UI inspection

๐ŸŒ Network Monitoring

  • ๐Ÿ” Automatic PTP host discovery on port 319 and 320
  • ๐Ÿ“ก Real-time packet capture and analysis
  • ๐Ÿท๏ธ Host classification by PTP state
  • ๐Ÿ“ˆ Network statistics and quality metrics
  • ๐Ÿ• Timing relationship tracking
  • ๐ŸŒณ Visual hierarchy mapping of leader-follower relationships

๐Ÿ“‹ Host Management

  • ๐Ÿ“ Comprehensive host table with sortable columns
  • ๐ŸŒณ Hierarchical tree view showing leader-follower relationships
  • ๐Ÿ”ข 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

๐Ÿ“ฆ Packet Analysis

  • ๐Ÿ“‹ Real-time packet history
  • ๐ŸŽจ Color-coded message types (ANNOUNCE, SYNC, DELAY_REQ, etc.)

Demo

Demo

๐Ÿš€ Quick Start

๐Ÿ“‹ Prerequisites

  • ๐Ÿฆ€ Rust 1.70.0 or later
  • ๐Ÿ”ง Privilege to bind ports < 1024 (root)

๐Ÿ”จ Installation

# 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
./target/release/ptp-trace

โš™๏ธ Command Line Options

# ๐ŸŒ Monitor specific interface
./target/release/ptp-trace --interface eth0

# ๐ŸŒ Monitor multiple interfaces
./target/release/ptp-trace --interface eth0 --interface eth1

# ๐ŸŒ Monitor all interfaces (default behavior)
./target/release/ptp-trace

# โšก Faster updates (500ms)
./target/release/ptp-trace --update-interval 500

# ๐ŸŽจ Use Matrix theme
./target/release/ptp-trace --theme matrix

# ๐Ÿ› Enable debug mode
./target/release/ptp-trace --debug

# ๐Ÿ”ง Combine options
./target/release/ptp-trace --interface eth0 --interface eth1 --theme matrix --update-interval 500

๐ŸŽฎ Controls

๐ŸŽฎ Navigation

  • โ†‘ / k - ๐Ÿ“ˆ Move selection up
  • โ†“ / j - ๐Ÿ“‰ Move selection down
  • PgUp / PgDn - ๐Ÿ“„ Page navigation (10 items)
  • Home / End - ๐Ÿ  Jump to top/bottom

๐Ÿ“Š Table Operations

  • s - ๐Ÿ”„ Cycle sort columns
  • S - โ†•๏ธ Toggle sort direction
  • t - ๐ŸŒณ Toggle hierarchical tree view
  • Green headers indicate active sort column

๐ŸŽฌ Actions

  • r - ๐Ÿ”„ Refresh/rescan network
  • c - ๐Ÿ—‘๏ธ Clear hosts and packet history
  • p - โธ๏ธ Toggle pause mode (stops network parsing, shows "PAUSED" in header)
  • e - ๐Ÿ“Š Toggle expanded packet history
  • d - ๐Ÿ› Toggle debug mode

โ„น๏ธ Help & Exit

  • h / F1 - โ“ Show/hide help
  • Esc - ๐Ÿšช Close help or quit
  • q - ๐Ÿšซ Quit application

๐ŸŽจ Themes

Choose from multiple built-in themes. See the output of ptp-trace --help to get a list of available themes.

๐Ÿšง Current Status

โœ… Implemented Features

  • ๐Ÿ–ผ๏ธ Complete terminal UI framework
  • ๐ŸŽฎ Application structure and navigation
  • ๐Ÿ“Š Host table with sorting and scrolling
  • ๐ŸŒณ Hierarchical tree view for PTP topology visualization
  • ๐Ÿ“ฆ Packet history with detailed view
  • ๐ŸŽจ Multiple theme support
  • โŒจ๏ธ Comprehensive keyboard controls
  • ๐Ÿ” Debug mode with scroll information

๐Ÿ—บ๏ธ Future Roadmap

  • ๐Ÿ“ค Data export - JSON, PCAP output formats
  • ๐Ÿ” Advanced filtering - Search and filter capabilities
  • ๐Ÿ“Š Enhanced analytics - Statistical analysis of timing data
  • ๐Ÿ”ง Configuration management - Save/load application settings

๐Ÿ› ๏ธ Development

๐Ÿ”ง Building

# Development build
cargo build

# Optimized release build
cargo build --release

# Run tests
cargo test

# Format code
cargo fmt

# Lint code
cargo clippy

Update built-in OUI database

This 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 clippy

Feel free to contribute to this project by submitting pull requests with the updated OUI database.

๐Ÿ“š Dependencies

  • ๐Ÿ–ฅ๏ธ ratatui - Terminal UI framework
  • โšก tokio - Async runtime
  • โŒจ๏ธ crossterm - Cross-platform terminal handling
  • ๐Ÿ“ clap - Command line argument parsing
  • โ— anyhow - Error handling

๐Ÿค Contributing

We welcome contributions! Please:

  1. ๐Ÿด Fork the repository
  2. ๐ŸŒฟ Create a feature branch
  3. ๐Ÿ”ง Make your changes
  4. โœ… Add tests if applicable
  5. ๐Ÿ“ Update documentation
  6. ๐Ÿš€ Submit a pull request

๐Ÿ“ Code Standards

  • ๐Ÿฆ€ Follow Rust best practices
  • ๐Ÿ“ Document public APIs
  • โœ… Include tests for new features
  • ๐ŸŽจ Use cargo fmt for formatting
  • ๐Ÿ” Pass cargo clippy lints

๐Ÿ“œ License

This project is licensed under the GPLv2 License - see the LICENSE file for details.

๐Ÿ”— Related Projects

  • ๐Ÿ•ฐ๏ธ statime - Rust PTP implementation
  • ๐Ÿง ptp4l - Linux PTP daemon
  • ๐Ÿ–ผ๏ธ ratatui - Terminal UI library
  • โšก tokio - Async runtime for Rust

๐Ÿ†˜ Support

  • ๐Ÿ“– Use h or F1 in the application for interactive help
  • ๐Ÿ› Enable debug mode with d for 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

About

Terminal application to trace ๐Ÿ•ฐ๏ธ PTP traffic, written in Rust ๐Ÿฆ€

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •