ant-quic
A QUIC transport protocol implementation with advanced NAT traversal capabilities, optimized for P2P networks and the Autonomi ecosystem.
Features
- Advanced NAT Traversal: ICE-like candidate discovery and coordinated hole punching
- P2P Optimized: Designed for peer-to-peer networks with minimal infrastructure
- High Connectivity: Near 100% connection success rate through sophisticated NAT handling
- Autonomi Ready: Integrated with Autonomi's decentralized networking requirements
- Built on Quinn: Leverages the proven Quinn QUIC implementation as foundation
Key Capabilities
- Symmetric NAT Penetration: Breakthrough restrictive NATs through coordinated hole punching
- Server Reflexive Discovery: Automatic detection of external addresses and port mappings
- Multi-path Connectivity: Test multiple connection paths simultaneously for reliability
- Automatic Role Detection: Nodes dynamically become coordinators when publicly reachable
- Bootstrap Node Coordination: Decentralized discovery and coordination services
- Connection Migration: Seamless adaptation to changing network conditions
- Path Validation: Robust verification of connection paths before use
- Peer Authentication: Ed25519-based cryptographic authentication with challenge-response protocol
- Secure Chat Messaging: Encrypted peer-to-peer messaging with protocol versioning
- Real-time Monitoring: Built-in statistics dashboard for connection and performance metrics
Quick Start
Installation
# Install the binary
# Or build from source
Basic Usage
# Run as P2P node with QUIC protocol
# Connect to bootstrap nodes for peer discovery
# Run as coordinator with NAT traversal event monitoring
# Run with dashboard for real-time statistics
# Check NAT traversal status while running
# Type /status to see discovered addresses and coordination sessions
# Type /help for available commands
How It Works
ant-quic automatically detects its network reachability and adapts its role:
- Public IP + Reachable: Becomes full coordinator providing bootstrap services to other nodes
- Limited Reachability: Provides limited coordinator services while also acting as client
- Behind NAT: Client-only mode, connects to others through NAT traversal
This creates a decentralized bootstrap network where any publicly reachable node automatically helps coordinate connections for nodes behind NATs.
Library Usage
use ;
// Create NAT traversal endpoint
let config = NatTraversalConfig ;
let endpoint = new.await?;
// Connect to peer through NAT traversal
let peer_id = PeerId;
let connection = endpoint.connect_to_peer.await?;
Examples
The repository includes several example applications demonstrating various features:
- simple_chat: Basic P2P chat with authentication
- chat_demo: Advanced chat with peer discovery and messaging
- dashboard_demo: Real-time connection statistics monitoring
Run examples with:
Architecture
ant-quic extends the proven Quinn QUIC implementation with sophisticated NAT traversal capabilities:
Core Components
- Transport Parameter Extensions: RFC-style negotiation of NAT traversal capabilities
- Extension Frames: Custom QUIC frames for address advertisement and coordination
ADD_ADDRESS(0xBAAD): Advertise candidate addressesPUNCH_ME_NOW(0xBEEF): Coordinate simultaneous hole punchingREMOVE_ADDRESS(0xDEAD): Remove invalid candidates
- ICE-like Candidate Pairing: Priority-based connection establishment
- Round-based Coordination: Synchronized hole punching protocol
NAT Traversal Process
- Candidate Discovery: Enumerate local and server-reflexive addresses
- Bootstrap Coordination: Connect to bootstrap nodes for peer discovery
- Address Advertisement: Exchange candidate addresses with peers
- Priority Calculation: Rank candidate pairs using ICE-like algorithms
- Coordinated Hole Punching: Synchronized transmission to establish connectivity
- Path Validation: Verify connection paths before promoting to active
- Connection Migration: Adapt to network changes and path failures
Network Topology Support
- Full Cone NAT: Direct connection establishment
- Restricted Cone NAT: Coordinated hole punching with address filtering
- Port Restricted NAT: Port-specific coordination protocols
- Symmetric NAT: Advanced prediction and multi-path establishment
- Carrier Grade NAT (CGNAT): Relay-assisted connection fallback
Specifications
ant-quic implements and extends the following IETF specifications and drafts:
1. QUIC Core Specification
- RFC 9000 – "QUIC: A UDP-Based Multiplexed and Secure Transport"
https://datatracker.ietf.org/doc/rfc9000/
(Companion RFCs: RFC 9001 for TLS integration and RFC 9002 for loss detection)
2. Raw Key Encoding / Key Schedule Used by QUIC
- RFC 9001 – "Using TLS to Secure QUIC" (see §5 Key Derivation)
https://datatracker.ietf.org/doc/rfc9001/ - RFC 7250 – "Using Raw Public Keys in TLS/DTLS"
https://www.rfc-editor.org/rfc/rfc7250
Used for raw public key support instead of X.509 certificates
3. QUIC Address Discovery Extension
- draft-ietf-quic-address-discovery-00 – "QUIC Address Discovery"
https://datatracker.ietf.org/doc/draft-ietf-quic-address-discovery-00/
Enables endpoints to learn the public IP:port a peer sees for any QUIC path
4. Native NAT Traversal for QUIC
- draft-seemann-quic-nat-traversal-02 – "Using QUIC to traverse NATs"
https://datatracker.ietf.org/doc/draft-seemann-quic-nat-traversal/
Describes hole-punching and ICE-style techniques directly over QUIC, including new frames such as ADD_ADDRESS and PUNCH_ME_NOW
Future Work & Roadmap
Current Implementation Status
✅ Completed:
- Core QUIC protocol with NAT traversal extensions
- Transport parameter negotiation (ID 0x58)
- Extension frames (ADD_ADDRESS, PUNCH_ME_NOW, REMOVE_ADDRESS)
- ICE-like candidate pairing with priority calculation
- Multi-path packet transmission
- Round-based coordination protocol
- High-level NAT traversal API with Quinn integration
- Candidate discovery framework
- Connection establishment with fallback
- Comprehensive test suite (580+ tests including auth, chat, and security tests)
- Test binaries: coordinator, P2P node, network simulation
🚧 In Progress/TODO:
- Platform-specific network interface discovery:
- Windows: IP Helper API integration
- Linux: Netlink interface enumeration
- macOS: System Configuration framework
- Session state machine polling implementation
- Relay connection logic for fallback scenarios
Roadmap
v0.1.0 - Foundation Release
- ✅ Core NAT traversal functionality
- ✅ Basic binary tools
- ✅ Full Quinn endpoint integration
- 🚧 Complete platform-specific interface discovery
- 📋 Performance benchmarking and optimization
v0.2.0 - Reliability & Platform Support
- 📋 Enhanced error handling and recovery
- 📋 Improved symmetric NAT prediction algorithms
- 📋 Comprehensive metrics and monitoring
- 📋 Cross-platform testing and validation
- 📋 Connection quality assessment
v0.3.0 - Advanced Features
- 📋 Adaptive retry strategies based on network conditions
- 📋 Advanced relay selection algorithms
- 📋 Protocol optimizations from real-world usage data
- 📋 Enhanced debugging and diagnostic tools
- 📋 Performance profiling and bottleneck analysis
v0.4.0 - Autonomi Integration
- 📋 Native Autonomi network protocol integration
- 📋 Decentralized bootstrap node discovery
- 📋 Enhanced security features for P2P networks
- 📋 Integration with additional discovery mechanisms
- 📋 Production-ready defaults and configurations
Technical Debt & Improvements
High Priority (Blocking v0.1.0):
- Replace placeholder implementations with real peer ID management
- Implement comprehensive session lifecycle management
- Add adaptive timeout mechanisms based on network conditions
- Complete path validation with sophisticated algorithms
Medium Priority (v0.2.0):
- Enhance connection migration optimization strategies
- Add support for IPv6 dual-stack configurations
- Implement connection quality-based path selection
- Add comprehensive error recovery mechanisms
Low Priority (v0.3.0+):
- Optimize memory usage in high-throughput scenarios
- Add advanced congestion control for P2P networks
- Implement sophisticated relay overlay networks
- Add machine learning-based NAT prediction
Known Limitations
- Platform-specific interface discovery requires completion for full functionality
- Relay selection algorithms need real-world testing and optimization
- IPv6 support needs enhancement for production deployment
- Performance optimization required for high-scale deployments
Performance
ant-quic is designed for high-performance P2P networking:
- Low Latency: Minimized connection establishment time through parallel candidate testing
- High Throughput: Leverages Quinn's optimized QUIC implementation
- Scalability: Efficient resource usage for large-scale P2P networks
- Reliability: Multiple connection paths and automatic failover
Performance benchmarks will be added in future releases after comprehensive testing across different network scenarios.
Contributing
Contributions are welcome! Please see our contributing guidelines for details.
Development Setup
# Run the QUIC binary
Testing
# Run all tests
# Run with verbose output
# Run specific test categories
# Run benchmarks
License
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Acknowledgments
- Built on the excellent Quinn QUIC implementation
- Implements NAT traversal based on draft-seemann-quic-nat-traversal-01
- Inspired by WebRTC ICE protocols and P2P networking research
- Developed for the Autonomi decentralized network ecosystem
Contributors
We are deeply grateful to all our contributors who have helped make this project possible. These true heroes dedicate their time and expertise to help others at their own cost. Thank you for your contributions to open source!
See our CONTRIBUTORS.md file for a full list of amazing people who have contributed to this project.
Security
For security vulnerabilities, please email security@autonomi.com rather than filing a public issue.