diff --git a/docs/PRD-mtu-discovery.md b/docs/PRD-mtu-discovery.md new file mode 100644 index 0000000..1808544 --- /dev/null +++ b/docs/PRD-mtu-discovery.md @@ -0,0 +1,59 @@ +# PRD: QUIC Path MTU Discovery + +## Problem + +WarzonePhone uses conservative 1200-byte QUIC datagrams. Some network paths support larger MTUs (1400+), wasting bandwidth. Some broken paths (VPNs, tunnels, double-NAT, cellular) have MTU < 1200, causing silent packet drops — this may explain why Opus 64k fails on some paths while 24k works (larger encoded frames + FEC repair packets). + +## Solution + +Enable Quinn's built-in Path MTU Discovery (PMTUD) and handle edge cases: +1. PMTUD probes larger packet sizes and discovers the actual path MTU +2. Graceful fallback when datagrams exceed discovered MTU +3. Expose MTU in metrics for debugging + +## Implementation + +### Phase 1: Enable PMTUD in Quinn + +`crates/wzp-transport/src/config.rs` — update `transport_config()`: + +```rust +// Enable PMTUD (Quinn default is enabled, but we should ensure it) +config.mtu_discovery_config(Some(quinn::MtuDiscoveryConfig::default())); + +// Set minimum MTU for safety (some paths can't handle 1200) +// Quinn default min is 1200, which is the QUIC spec minimum +``` + +Quinn's `MtuDiscoveryConfig` has: +- `interval`: how often to probe (default: 600s) +- `upper_bound`: max MTU to probe (default: 1452 for IPv4) +- `minimum_change`: min MTU increase to be worth probing (default: 20) + +### Phase 2: Handle MTU-related Failures + +In federation forwarding (`send_raw_datagram`), if the datagram exceeds the connection's current MTU, Quinn returns an error. Handle gracefully: +- Log warning with packet size vs MTU +- Drop the packet (don't crash) +- Track in metrics: `wzp_relay_mtu_exceeded_total` + +### Phase 3: Codec-Aware MTU + +When the path MTU is small, the relay or client should: +- Prefer lower-bitrate codecs (smaller packets) +- Reduce FEC ratio (fewer repair packets) +- This feeds into the adaptive quality system + +### Phase 4: Expose MTU in Stats + +- Add `path_mtu` to relay metrics (per peer) +- Add `path_mtu` to client stats (visible in UI) +- Log MTU on connection establishment + +## Non-Goals (v1) + +- Datagram fragmentation (QUIC datagrams are atomic — either fit or don't) +- Manual MTU override per relay config +- MTU-based codec selection (future, needs adaptive quality) + +## Effort: 1 day diff --git a/scripts/build-and-notify.sh b/scripts/build-and-notify.sh index 2d501d5..699b1a7 100755 --- a/scripts/build-and-notify.sh +++ b/scripts/build-and-notify.sh @@ -68,7 +68,8 @@ find "$BASE_DIR/data/source" "$BASE_DIR/data/cache" \ # Clean jniLibs rm -rf "$BASE_DIR/data/source/android/app/src/main/jniLibs/arm64-v8a" -notify "WZP build started..." +GIT_HASH=$(cd $BASE_DIR/data/source && git rev-parse --short HEAD 2>/dev/null || echo unknown) +notify "WZP Android build started [$GIT_HASH]..." echo ">>> Building in Docker..." docker run --rm --user 1000:1000 \ @@ -112,7 +113,7 @@ APK=$(find "$BASE_DIR/data/source/android" -name "app-debug*.apk" -path "*/outpu if [ -n "$APK" ]; then URL=$(curl -s -F "file=@$APK" -H "Authorization: $rusty_auth_token" "$rusty_address") echo "UPLOAD_URL=$URL" - notify "WZP build done! APK: $URL" + notify "WZP Android [$GIT_HASH] done! APK: $URL" echo ">>> Done! APK at: $URL" else notify "WZP build FAILED - no APK" diff --git a/scripts/build-linux-docker.sh b/scripts/build-linux-docker.sh index a04239a..07d73ad 100755 --- a/scripts/build-linux-docker.sh +++ b/scripts/build-linux-docker.sh @@ -114,7 +114,8 @@ docker run --rm \ URL=$(curl -s -F "file=@/tmp/wzp-linux-x86_64.tar.gz" -H "Authorization: $rusty_auth_token" "$rusty_address") if [ -n "$URL" ]; then echo "UPLOAD_URL=$URL" - notify "WZP Linux x86_64 binaries ready! $URL" + GIT_HASH=$(cd /build/source && git rev-parse --short HEAD 2>/dev/null || echo unknown) +notify "WZP Linux x86_64 [$GIT_HASH] ready! $URL" echo ">>> Done! Binaries at: $URL" else notify "WZP Linux build FAILED - upload error"