Repository navigation
Upgrade pion and make its ICE, DTLS and SCTP defaults tunable - #478
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Tuning contract and platform behavior clientcore/tuning.go, clientcore/tuning_native.go, clientcore/tuning_wasm.go, clientcore/tuning_test.go, go.mod |
Adds tuning fields and ICE timer defaults. Native builds apply positive tuning values; WebAssembly leaves the setting engine unchanged. Tests cover zero values and individual tuning fields. Pion dependencies are upgraded. |
Tuning in consumer and producer setup clientcore/settings.go, clientcore/consumer.go, clientcore/producer.go, clientcore/webrtc_api.go, clientcore/webrtc_api_js.go, clientcore/tuning_test.go |
Adds tuning to WebRTCOptions and passes it into consumer API and producer peer-connection setup. The integration test checks that tuned peers open a data channel. |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Feature
Possibly related PRs
- getlantern/unbounded#477: Adds DTLS retransmission tuning to Pion
SettingEngineinstances inrtcprobe; this pull request adds the corresponding setting to consumer and producer WebRTC setup.
Suggested reviewers: noahlevenson
Merge Risk: 
Minimal · up to eebf9
-
No merge-blocking issue was established for this change; it is ready for normal checks.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passedFull details: Docstring Coverage
-
Explanation
Docstring coverage is 18.18% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 9 files. (1 skipped: 1 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches: 💡 1
-
📝 Generate docstrings: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
There was a problem hiding this comment.
🔵 Needs a closer look
The multi-layer protocol upgrade and coordinated breaking transport/v5 migration require final human validation of downstream compatibility and network behavior.
No open issues 🎉
What changed in this PR
Upgrades the Pion WebRTC stack to improve connections on lossy networks and adds configurable transport tuning for native consumers and producers, following the rtcprobe work in #477.
Changes:
- Updates Pion dependencies and migrates the public network interface to
transport/v5. - Adds ICE, DTLS, and SCTP tuning options; zero values preserve defaults, and browser builds ignore tuning.
- Adds tests for tuning activation and a tuned peer-to-peer data-channel handshake.
| File | Description |
|---|---|
| go.sum | Updates dependency checksums for the upgraded stack. |
| go.mod | Upgrades Pion modules and related dependencies. |
| clientcore/webrtc_api.go | Applies native tuning and adopts transport v5. |
| clientcore/webrtc_api_js.go | Aligns the browser helper signature and transport import. |
| clientcore/tuning.go | Defines tuning options and ICE fallback defaults. |
| clientcore/tuning_wasm.go | Makes tuning a no-op in browser builds. |
| clientcore/tuning_test.go | Tests tuning activation and data-channel connectivity. |
| clientcore/tuning_native.go | Maps tuning options to Pion settings. |
| clientcore/settings.go | Exposes tuning through WebRTCOptions. |
| clientcore/producer.go | Applies tuning when creating producer connections. |
| clientcore/consumer.go | Passes consumer tuning into API creation. |
Review effort: Balanced
webrtc v4.2.11 -> v4.2.25, ice v4.2.2 -> v4.4.8, sctp v1.9.4 -> v1.12.0, dtls v3.1.2 -> v3.1.15. pion moved to transport/v5, so clientcore's Net option is now a transport/v5.Net. The DTLS fixes matter for our consumers, which are the DTLS server: dtls v3.1.12 retransmits the server flight when the client repeats its ClientHello, and v3.1.9 reassembles re-fragmented handshake retransmits. In rtcprobe runs at 20% UDP loss with only the consumer upgraded, connections went from 16/26 to 27/30 and DTLS stalls from 6 to 1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019DnqgLJf7p4sK87dDvktjx
WebRTCOptions.Tuning overrides, on native consumers and producers: ICE's binding-request cap, STUN gather timeout, liveness timers and srflx nomination wait; DTLS's initial handshake retransmission interval; and SCTP's maximum retransmission timeout and receive buffer. A zero field keeps pion's default, so the zero value changes nothing, and browsers, whose stack can't be tuned, ignore it. These are the knobs our failure buckets point at, and having them in options lets the server tune them per track instead of per release. In rtcprobe runs at 20% UDP loss, a 200ms DTLS retransmit cut the median DTLS time after ICE from about 1.2s to 0.4s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019DnqgLJf7p4sK87dDvktjx
7cc9e9d to
eebf937
Compare
Upgrades pion to the latest releases, and adds
WebRTCOptions.Tuningso the server can tune pion's ICE, DTLS and SCTP defaults per track instead of per release.pion/webrtc/v4pion/ice/v4pion/sctppion/dtls/v3pion/transportBuilds on #477 (
-dtls-retransmitfor rtcprobe, now merged). Rebased onto main: the two commits are unchanged apart from the base, which now includes #477's review fix.Why
About 27% of volunteer attempts reach "ICE connected" and then stall before the data channel opens. Our consumer makes the offer, so it's the DTLS server. Several pion fixes since v3.1.2 target exactly that side on lossy paths:
On the ICE side:
Evidence
These are
rtcproberuns from Frankfurt to Newark, with UDP loss on both hosts and a 15 s window.Same pion on both ends, at 20% loss: v3.1.2 connected 10/20 with 5 DTLS stalls; the latest connected 17/20 with 1. Across every lossy run, DTLS stalls fell from 21 to 7, and connections rose from 82 to 97, out of 120.
Mixed versions, 20% loss, with the probe as consumer and DTLS server:
So the gain comes from upgrading the consumer; browser volunteers run Chrome's DTLS and don't need to change. Separately, a 200 ms DTLS retransmit at 20% loss cut the median DTLS time after ICE from about 1.2 s to about 0.4 s. That's the first knob worth tuning live.
Changes
Commit 1: the pion upgrade.
go.mod/go.sum: the bumps above, withgo mod tidy.clientcore/settings.go,webrtc_api.go,webrtc_api_js.go: pion moved totransport/v5, soWebRTCOptions.Netis now atransport/v5.Net. This breaks the build of anything that implementsNet. lantern-box does, and its companion migration builds and passes its tests against this branch.Commit 2:
WebRTCOptions.Tuning(clientcore/tuning*.go, applied inconsumer.goandproducer.go). It overrides pion's defaults on native consumers and producers. A zero field keeps the default, so the zero value changes nothing; browsers ignore it, since their stack can't be tuned.ICEMaxBindingRequestsSTUNGatherTimeoutICEDisconnectedTimeout/ICEFailedTimeout/ICEKeepaliveIntervalSrflxAcceptanceMinWaitDTLSRetransmitIntervalSCTPRTOMaxSCTPMaxReceiveBufferlantern-box will carry these as an open-ended
tuningmap that ignores unknown keys. Once a client supports it, the server can add knobs without further client changes, and lantern-cloud can send it to the clients that advertise support.Testing
go test -race ./clientcore/... ./common/... ./freddie/... ./rtcprobe/... ./egress/...: ok. New clientcore tests:go build ./...andGOOS=js GOARCH=wasm go build ./cmd: ok. Each commit builds and tests on its own.Risk
Medium, because this is a dependency upgrade across ICE, DTLS and SCTP.
transport/v5move, a compile-time break for implementers ofNet. The lantern-box companion covers it.Tuningis a no-op unless set.How to revert
Revert the merge commit, and the lantern-box companion if it has merged, since it needs the
transport/v5NetandWebRTCTuning.Pre-PR review (local Codex gate)
CODEX GATE: verdict=approve critical=0 important=0 minor=0 preexisting=0 reviewed=537cc9e9d, which iseebf937before the rebase onto main (no conflicts, same diff). It checked each tuning knob against its pion setter and default, read lantern-box'snet.go,outbound.goandtuning.go, and compared both pion versions in the module cache.approveclientcore/settings.go:13—transport/v5breaks lantern-box's v4rtcNet. This is a coordinated migration: lantern-box'sfeat/unbounded-pion-latestmovesrtcNetto v5 and is tested against this branch. An adapter would only postpone the same change.AGENTS.mdadditions: none🤖 Generated with Claude Code
https://claude.ai/code/session_019DnqgLJf7p4sK87dDvktjx
Summary by CodeRabbit