webrtc: send over SCTP without a congestion window, as KCP does

The same link that streams over KCP crawls over WebRTC. webrtc-sctp runs
RFC 4960's AIMD: a fast retransmit halves cwnd, a T3 drops it to one MTU, and
slow start only rebuilds it while data is queued behind it. Where the loss is
random rather than congestion - a lossy long-haul link - the rate settles at
the Mathis ceiling MSS/(RTT*sqrt(p)) however idle the link is: about 1.3 Mbps
at 70ms RTT and 1% loss, 0.6 Mbps at 5%, while 1080p wants 2-5 Mbps. KCP's
turbo profile (nc=1) has no congestion window at all.

The fork now carries a switch that bypasses the two places gating sends on
cwnd, and hbb_common turns it on for every peer connection unless
`allow-webrtc-congestion-control` is set - the same opt-in KCP has in
`allow-kcp-congestion-control`, for the reason at `get_kcp_cc_enabled`.
Sender-side only; a browser or an older build on the other end interoperates.

Measured over a simulated link (35ms one-way, random loss both ways, 12 KB
frames at 30fps, 300 frames): at 1% loss the window stretches 9.9s of video to
20.7s with a mean latency of 5.5s; without it the stream stays realtime at a
mean of 113ms. At 3%: 47s and 15s against 10.2s and 290ms.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019aokqJuhjvB3kijXtAg5Ns
This commit is contained in:
rustdesk
2026-09-02 11:26:07 +08:00
parent 3432b8bc30
commit 98c0401134
3 changed files with 7 additions and 6 deletions

4
Cargo.lock generated
View File

@@ -9707,7 +9707,7 @@ dependencies = [
[[package]]
name = "webrtc-sctp"
version = "0.12.0"
source = "git+https://github.com/rustdesk-org/webrtc?rev=0a84ba37fbca940b82f230fb469d1b3a3172abf6#0a84ba37fbca940b82f230fb469d1b3a3172abf6"
source = "git+https://github.com/rustdesk-org/webrtc?rev=65fbe090326bf3abe8480d159b6bb07b5f509c22#65fbe090326bf3abe8480d159b6bb07b5f509c22"
dependencies = [
"arc-swap",
"async-trait",
@@ -9747,7 +9747,7 @@ dependencies = [
[[package]]
name = "webrtc-util"
version = "0.11.0"
source = "git+https://github.com/rustdesk-org/webrtc?rev=0a84ba37fbca940b82f230fb469d1b3a3172abf6#0a84ba37fbca940b82f230fb469d1b3a3172abf6"
source = "git+https://github.com/rustdesk-org/webrtc?rev=65fbe090326bf3abe8480d159b6bb07b5f509c22#65fbe090326bf3abe8480d159b6bb07b5f509c22"
dependencies = [
"async-trait",
"bitflags 1.3.2",

View File

@@ -220,10 +220,11 @@ libxdo-sys = { path = "libs/libxdo-sys-stub" }
# one comes out byte-swapped, fails to bind, and ICE gathers no IPv6 host candidate on Windows.
# webrtc-sctp: RFC 4960's 1s RTO floor makes a single loss cost 1-3s on a link whose RTT is 24-64ms,
# and fast retransmit cannot cover a request/response exchange; INITIAL_MTU 1228 also fragments on
# IPv6. The fork commit carries the arithmetic.
# IPv6; and its AIMD pins a lossy long-haul link to MSS/(RTT*sqrt(p)), so a switch sends without
# a congestion window, as KCP does - on by default, `allow-webrtc-congestion-control` opts back in.
# Pinned by rev, not branch: a fork branch can be rewritten out from under the lockfile.
webrtc-util = { git = "https://github.com/rustdesk-org/webrtc", rev = "0a84ba37fbca940b82f230fb469d1b3a3172abf6" }
webrtc-sctp = { git = "https://github.com/rustdesk-org/webrtc", rev = "0a84ba37fbca940b82f230fb469d1b3a3172abf6" }
webrtc-util = { git = "https://github.com/rustdesk-org/webrtc", rev = "65fbe090326bf3abe8480d159b6bb07b5f509c22" }
webrtc-sctp = { git = "https://github.com/rustdesk-org/webrtc", rev = "65fbe090326bf3abe8480d159b6bb07b5f509c22" }
[package.metadata.winres]
LegalCopyright = "Copyright © 2026 Purslane Tech Pte. Ltd. All rights reserved."