QUIC-Based Peer-to-Peer Mesh Network Overlay Architecture
1. Overview
This architecture designs a decentralized P2P mesh network overlay using QUIC (RFC 9000) as the underlying transport. QUIC provides multiplexing, built-in TLS 1.3 encryption, migration, and low-latency handshakes, making it ideal for P2P over unreliable networks.
Key Goals :
Full-mesh connectivity where feasible (direct QUIC streams between peers).
Scalable to 10k+ nodes via hybrid mesh + DHT routing.
NAT traversal for 95%+ direct connectivity.
Tuned congestion control for low-latency, high-throughput mesh flooding/gossip.
Self-sovereign certificate trust without central CAs.
DDoS resilience via distributed defenses.
Stack :
code Copy code
Application (e.g., pub/sub, file sharing)
↓
Overlay Routing (Kademlia DHT)
↓
QUIC Transport (streams, CC, encryption)
↓
UDP/IP (with NAT traversal)
Assumptions :
Nodes run on standard hardware (e.g., via Go's quic-go or Rust's quinn).
Bootstrap via well-known seeds or DNS.
2. Peer Discovery and Bootstrap
Kademlia DHT (inspired by libp2p/Kademlia): Each node has a 256-bit NodeID (SHA-256 of pubkey). Store peer records (IP:port, NodeID, cert fingerprint) with TTL.
Bootstrap :
Query hardcoded seed nodes (hardened servers, 5-10 globally).
Perform STUN to get public UDP addr.
Announce self to DHT via STORE RPC.
Discovery RPCs : Over QUIC streams (e.g., FIND_NODE, FIND_PEERS).
Mesh Formation : Connect to k=20 closest DHT neighbors + random samples for redundancy.
3. NAT Traversal
Achieve >95% direct P2P connectivity using ICE-inspired hole punching (RFC 8445 principles adapted to QUIC).
Candidate Gathering (per peer):
Host Candidates : Local IPv4/IPv6:port.
Server-Reflexive (srflx) : Query public STUN servers (e.g., stun.l.google.com:19302) → get public UDP addr.
Relay (TURN) : Fallback to 5-10 distributed TURN relays (incentivized nodes earning tokens).
Connectivity Checks (Concurrent ICE-like):
Exchange candidate lists via DHT gossip or initial QUIC 0-RTT (if prior conn).
Hole Punching :
Peer A sends QUIC Initial packet to B's srflx candidate (with Connection ID predicting B's response).
B simultaneously sends to A's srflx.
QUIC's stateless handshake tolerates NAT bindings (keepalives via PING frames).
Prioritize: host → srflx → relay.
Success: Migrate to direct QUIC conn (QUIC's NEW_TOKEN + addr validation).
Fallbacks :
TURN relays for symmetric NATs (5% cases).
UPnP/Port Mapping if available.
Connection lifetime: 2min idle → probe → migrate.
Implementation : Use quic-go's UDP socket multiplexing; track NAT type (Full Cone, Restricted, Port-Restricted, Symmetric) via check responses.
4. Congestion Control Tuning
QUIC's pluggable CC (RFC 9002). Default NewReno is TCP-like; tune for P2P mesh (bursty, multi-path, lossy WiFi/mobile).
Primary Algorithm : BBR v2 (RFC 9002-compliant impl):
Bandwidth estimation + RTT minimization → excels in latency-sensitive P2P (e.g., video calls, live gossip).
Handles bufferbloat better than loss-based CC.
Params:
Param Value Rationale pacing_gain 1.25 Gentle burst control for mesh flooding. cwnd_gain 2.0 (inflight) Probe BW aggressively. max_datagram 1200B Avoid IP fragmentation.
Per-Stream/Path Tuning :
Control streams (RPY): Low CWND (4 packets), high priority.
Data streams (mesh gossip): BBR + ECN marking.
Multi-path QUIC (MP-QUIC draft): Aggregate paths (WiFi + Cellular) for mobile nodes.
Mesh-Specific :
Fanout Limiting : Max 100 concurrent streams/peer; gossip epidemic with TTL=5.
Loss Recovery : QUIC's ACK + PTO timers tuned for 50-200ms RTT (urban P2P).
Monitoring : Expose CC stats (BW, RTT, loss) via admin stream; auto-switch to Cubic on high loss (>5%).
5. Certificate Trust Model
TOFU + Distributed Certificate Transparency (DCT) for self-sovereign auth. No central CA; mutual TLS via QUIC's TLS 1.3.
6. DDoS Resilience
Distributed design inherently resilient; layer defenses.
7. Implementation Roadmap
Phase 1 : QUIC + NAT (use quic-go + pion/ice).
Phase 2 : DHT routing (go-libp2p-kadence).
Phase 3 : CC tuning + security (custom BBR, DCT).
Testing : Simulate 1k nodes (ns-3 + real STUN); measure conn success (98%), latency (<100ms p99).
This design draws from libp2p, WireGuard, and Tailscale, optimized for QUIC. Open-source prototype feasible in 3 months. Questions?