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

The data channel's SCTP association runs RFC 4960's AIMD: a fast retransmit
halves cwnd, a T3 drops it to one MTU, and on a path whose loss is random
rather than congestion that pins the rate to MSS/(RTT*sqrt(p)) - about
1.3 Mbps at 70ms RTT and 1% loss - however idle the link is. KCP has always
shipped its turbo profile (nc=1) with no congestion window, which is why the
same link streams over KCP and crawls over WebRTC.

The sctp fork now carries a process-wide switch that bypasses the two places
gating sends on cwnd. Turn it on unless `allow-webrtc-congestion-control` is
set: the same opt-in `allow-kcp-congestion-control` gives KCP, for the reason
at `get_kcp_cc_enabled`. It is re-read on every new peer connection, so a
changed option reaches the next session without a restart.

Sender-side only: nothing is negotiated, and a browser or an older build on
the other end interoperates.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019aokqJuhjvB3kijXtAg5Ns
This commit is contained in:
rustdeskandClaude Opus 5 committed 2026-09-04 23:34:08 +08:00
1 parent 31d3789079
commit 846daf86f0
2 files changed
+13

No files matched your search

+2
View File
@@ -3000,6 +3000,7 @@ pub mod keys {
pub const OPTION_ENABLE_PORT_FORWARD_MUX: &str = "enable-port-forward-mux";
pub const OPTION_ENABLE_WEBRTC: &str = "enable-webrtc";
pub const OPTION_ALLOW_KCP_CC: &str = "allow-kcp-congestion-control";
pub const OPTION_ALLOW_WEBRTC_CC: &str = "allow-webrtc-congestion-control";
pub const OPTION_HIDE_USERNAME_ON_CARD: &str = "hide-username-on-card";
pub const OPTION_HIDE_HELP_CARDS: &str = "hide-help-cards";
pub const OPTION_DEFAULT_CONNECT_PASSWORD: &str = "default-connect-password";
@@ -3208,6 +3209,7 @@ pub mod keys {
OPTION_KEEP_AWAKE_DURING_INCOMING_SESSIONS,
OPTION_ALLOW_AUTO_UPDATE,
OPTION_ALLOW_KCP_CC,
OPTION_ALLOW_WEBRTC_CC,
];
// BUILDIN_SETTINGS
+11
View File
@@ -473,6 +473,12 @@ impl WebRTCStream {
})
}
#[inline]
fn get_cc_enabled() -> bool {
let k = config::keys::OPTION_ALLOW_WEBRTC_CC;
config::option2bool(k, &config::Config::get_option(k))
}
#[inline]
fn get_ice_servers() -> Vec<RTCIceServer> {
Self::parse_ice_servers(&config::Config::get_option(
@@ -599,6 +605,11 @@ impl WebRTCStream {
IpAddr::V4(_) => true,
}));
// KCP's nc=1 profile by default, with the same opt-in to a congestion window as
// `allow-kcp-congestion-control`, for the reason given at `get_kcp_cc_enabled`. Set per
// connection so the option takes effect on the next session, not the next start.
webrtc::sctp::association::set_no_congestion_control(!Self::get_cc_enabled());
// Create the API object
let api = APIBuilder::new().with_setting_engine(s).build();