From 5fe5a979b960606901de91c2f40eecf6ea91dacb Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 15 Nov 2026 06:39:07 -0800 Subject: [PATCH 1/5] chore(quest): claim quest/m2/congestion-candidates.md Quest-Claim: 8dc91da8afd60b0c From 67c6148851f89ff0266a21567f8c0b11679ac94e Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 15 Nov 2026 06:55:01 -0800 Subject: [PATCH 2/5] feat!(congestion): ship BBR through the selector, candidates move to moq-congestion-lab GCC and SCReAMv2 move to the workspace-only moq-congestion-lab crate, BBR3's delay bound gets a hidden setter, and moq-ffi's MoqCongestionControl becomes an object with constructors so a new algorithm is additive in every binding. Co-Authored-By: Claude Opus 5.5 --- Cargo.lock | 12 + Cargo.toml | 1 + dart/moq/lib/src/aliases.dart | 4 +- dart/moq/test/moq_test.dart | 2 +- dart/moq_ffi/lib/src/moq.dart | 268 +++++++++++++++--- doc/bin/relay/config.md | 2 +- go/wrapper/reconnect_test.go | 2 +- go/wrapper/types.go | 27 +- .../kotlin/dev/moq/Aliases.kt | 5 +- .../kotlin/dev/moq/SmokeTest.kt | 2 +- nix/Cargo.nix | 62 +++- py/moq-rs/README.md | 2 +- py/moq-rs/tests/test_server.py | 2 +- quest/m2/congestion-candidates.md | 65 ----- quest/m3/vendor-sync/scream.md | 6 +- quest/m3/vendor-sync/webrtc.md | 4 +- quest/m3/webrtc/README.md | 2 +- quest/m4/quic-realtime.md | 19 +- rs/moq-c/src/api.rs | 2 +- rs/moq-congestion-lab/Cargo.toml | 22 ++ rs/moq-congestion-lab/LICENSE-APACHE | 201 +++++++++++++ rs/moq-congestion-lab/LICENSE-MIT | 7 + rs/moq-congestion-lab/README.md | 9 + .../src/gcc/AUTHORS | 0 .../src/gcc/LICENSE | 0 .../src/gcc/PATENTS | 0 .../src/gcc/alr_detector.rs | 0 .../src/gcc/api/mod.rs | 0 .../src/gcc/api/transport/bandwidth_usage.rs | 0 .../src/gcc/api/transport/mod.rs | 0 .../src/gcc/api/transport/network_types.rs | 0 .../src/gcc/api/units/data_rate.rs | 0 .../src/gcc/api/units/data_size.rs | 0 .../src/gcc/api/units/frequency.rs | 0 .../src/gcc/api/units/mod.rs | 0 .../src/gcc/api/units/time_delta.rs | 0 .../src/gcc/api/units/timestamp.rs | 0 .../src/gcc/api/units/unit_base.rs | 0 .../src/gcc/bench.rs | 2 +- .../congestion_window_pushback_controller.rs | 0 .../src/gcc/delay_based_bwe.rs | 0 .../gcc/delay_increase_detector_interface.rs | 0 .../src/gcc/experiments/field_trials.rs | 0 .../src/gcc/experiments/mod.rs | 0 .../src/gcc/experiments/rate_control.rs | 0 .../src/gcc/goog_cc_network_control.rs | 0 .../src/gcc/inter_arrival_delta.rs | 0 .../src/gcc/link_capacity_estimator.rs | 0 .../src/gcc/loss_based_bwe_v2.rs | 0 .../src/gcc/mod.rs | 11 +- .../src/gcc/pacing/bitrate_prober.rs | 0 .../src/gcc/pacing/interval_budget.rs | 0 .../src/gcc/pacing/mod.rs | 0 .../src/gcc/probe_bitrate_estimator.rs | 0 .../src/gcc/probe_controller.rs | 0 .../aimd_rate_control.rs | 0 .../remote_bitrate_estimator/bwe_defines.rs | 0 .../src/gcc/remote_bitrate_estimator/mod.rs | 0 .../src/gcc/robust_throughput_estimator.rs | 0 .../src/gcc/send_side_bandwidth_estimation.rs | 0 .../src/gcc/tests.rs | 2 +- .../src/gcc/trendline_estimator.rs | 0 rs/moq-congestion-lab/src/lib.rs | 52 ++++ .../src/scream.rs | 9 +- rs/moq-congestion/Cargo.toml | 3 +- rs/moq-congestion/README.md | 10 +- rs/moq-congestion/src/bbr3/mod.rs | 3 + rs/moq-congestion/src/lib.rs | 11 +- rs/moq-congestion/src/pacer.rs | 12 +- rs/moq-congestion/src/rate.rs | 5 +- rs/moq-ffi/src/session.rs | 43 +-- rs/moq-ffi/src/test.rs | 2 +- rs/moq-ffi/src/test/rung.rs | 2 +- rs/moq-quic/Cargo.toml | 2 + rs/moq-quic/src/tests/probe.rs | 3 +- rs/moq-quic/src/tests/scream.rs | 5 +- rs/moq-tokio/Cargo.toml | 2 + rs/moq-tokio/src/quic.rs | 7 +- rs/moq-tokio/tests/integration/scream.rs | 4 +- swift/Sources/Moq/Aliases.swift | 3 +- 80 files changed, 720 insertions(+), 201 deletions(-) delete mode 100644 quest/m2/congestion-candidates.md create mode 100644 rs/moq-congestion-lab/Cargo.toml create mode 100644 rs/moq-congestion-lab/LICENSE-APACHE create mode 100644 rs/moq-congestion-lab/LICENSE-MIT create mode 100644 rs/moq-congestion-lab/README.md rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/AUTHORS (100%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/LICENSE (100%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/PATENTS (100%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/alr_detector.rs (100%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/api/mod.rs (100%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/api/transport/bandwidth_usage.rs (100%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/api/transport/mod.rs (100%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/api/transport/network_types.rs (100%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/api/units/data_rate.rs (100%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/api/units/data_size.rs (100%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/api/units/frequency.rs (100%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/api/units/mod.rs (100%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/api/units/time_delta.rs (100%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/api/units/timestamp.rs (100%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/api/units/unit_base.rs (100%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/bench.rs (99%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/congestion_window_pushback_controller.rs (100%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/delay_based_bwe.rs (100%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/delay_increase_detector_interface.rs (100%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/experiments/field_trials.rs (100%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/experiments/mod.rs (100%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/experiments/rate_control.rs (100%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/goog_cc_network_control.rs (100%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/inter_arrival_delta.rs (100%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/link_capacity_estimator.rs (100%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/loss_based_bwe_v2.rs (100%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/mod.rs (99%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/pacing/bitrate_prober.rs (100%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/pacing/interval_budget.rs (100%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/pacing/mod.rs (100%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/probe_bitrate_estimator.rs (100%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/probe_controller.rs (100%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/remote_bitrate_estimator/aimd_rate_control.rs (100%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/remote_bitrate_estimator/bwe_defines.rs (100%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/remote_bitrate_estimator/mod.rs (100%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/robust_throughput_estimator.rs (100%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/send_side_bandwidth_estimation.rs (100%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/tests.rs (99%) rename rs/{moq-congestion => moq-congestion-lab}/src/gcc/trendline_estimator.rs (100%) create mode 100644 rs/moq-congestion-lab/src/lib.rs rename rs/{moq-congestion => moq-congestion-lab}/src/scream.rs (99%) diff --git a/Cargo.lock b/Cargo.lock index 50ce3a86a4b..952b3ea5b7f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4313,6 +4313,16 @@ dependencies = [ "rand 0.10.3", "rand_pcg", "stats_alloc", + "workspace-hack", +] + +[[package]] +name = "moq-congestion-lab" +version = "0.0.0" +dependencies = [ + "cpu-time", + "kio", + "moq-congestion", "tracing", "workspace-hack", ] @@ -4612,6 +4622,7 @@ dependencies = [ "kio", "lru-slab", "moq-congestion", + "moq-congestion-lab", "moq-crypto", "moq-quic", "proptest", @@ -4864,6 +4875,7 @@ dependencies = [ "libc", "mdns-sd", "moq-congestion", + "moq-congestion-lab", "moq-crypto", "moq-net", "moq-quic", diff --git a/Cargo.toml b/Cargo.toml index a74ae70474f..1a13d1d527f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,7 @@ default-members = [ "rs/hang", # "rs/moq-c", # requires C toolchain "rs/moq-congestion", + "rs/moq-congestion-lab", "rs/moq-archive", "rs/moq-auth", "rs/moq-boy", diff --git a/dart/moq/lib/src/aliases.dart b/dart/moq/lib/src/aliases.dart index f012ffbb44b..f3a8b4deda7 100644 --- a/dart/moq/lib/src/aliases.dart +++ b/dart/moq/lib/src/aliases.dart @@ -38,7 +38,9 @@ typedef Request = MoqRequest; /// The network transport carrying an incoming session. typedef Transport = MoqTransport; -/// The congestion control family for a QUIC connection. +/// The congestion control family for a QUIC connection. Build one with +/// `CongestionControl.delay()`, `.loss()`, or `.none()`; a new algorithm joins as +/// a new constructor. typedef CongestionControl = MoqCongestionControl; /// Certificate trust and the mTLS identity for `ConnectOptions.tls`. diff --git a/dart/moq/test/moq_test.dart b/dart/moq/test/moq_test.dart index 904a0b3b159..ca38716c679 100644 --- a/dart/moq/test/moq_test.dart +++ b/dart/moq/test/moq_test.dart @@ -522,7 +522,7 @@ void main() { keepAlive: Duration.zero, gso: false, mtuDiscovery: true, - congestionControl: CongestionControl.loss, + congestionControl: CongestionControl.loss(), keylog: false, ), once: true, diff --git a/dart/moq_ffi/lib/src/moq.dart b/dart/moq_ffi/lib/src/moq.dart index 2c5c866cab9..aacfd133cc7 100644 --- a/dart/moq_ffi/lib/src/moq.dart +++ b/dart/moq_ffi/lib/src/moq.dart @@ -8751,44 +8751,6 @@ class FfiConverterMoqTransport { } } -enum MoqCongestionControl { loss, delay, none } - -class FfiConverterMoqCongestionControl { - static LiftRetVal read(Uint8List buf) { - final index = buf.buffer.asByteData(buf.offsetInBytes).getInt32(0); - switch (index) { - case 1: - return LiftRetVal(MoqCongestionControl.loss, 4); - case 2: - return LiftRetVal(MoqCongestionControl.delay, 4); - case 3: - return LiftRetVal(MoqCongestionControl.none, 4); - default: - throw UniffiInternalError( - UniffiInternalError.unexpectedEnumCase, - "Unable to determine enum variant", - ); - } - } - - static MoqCongestionControl lift(RustBuffer buffer) { - return FfiConverterMoqCongestionControl.read(buffer.asUint8List()).value; - } - - static RustBuffer lower(MoqCongestionControl input) { - return toRustBuffer(createUint8ListFromInt(input.index + 1)); - } - - static int allocationSize(MoqCongestionControl _value) { - return 4; - } - - static int write(MoqCongestionControl value, Uint8List buf) { - buf.buffer.asByteData(buf.offsetInBytes).setInt32(0, value.index + 1); - return 4; - } -} - abstract class MoqConnectionPhase { RustBuffer lower(); int allocationSize(); @@ -15950,6 +15912,143 @@ class FfiConverterMoqClient { } } +abstract class MoqCongestionControlInterface {} + +final _MoqCongestionControlFinalizer = Finalizer>((ptr) { + rustCall( + (status) => uniffi_moq_ffi_fn_free_moqcongestioncontrol(ptr, status), + ); +}); + +class MoqCongestionControl implements MoqCongestionControlInterface { + late final Pointer _ptr; + bool _isDisposed = false; + MoqCongestionControl._(this._ptr) { + _MoqCongestionControlFinalizer.attach(this, _ptr, detach: this); + } + MoqCongestionControl.delay() + : _ptr = rustCall( + (status) => + uniffi_moq_ffi_fn_constructor_moqcongestioncontrol_delay(status), + null, + ) { + _MoqCongestionControlFinalizer.attach(this, _ptr, detach: this); + } + MoqCongestionControl.loss() + : _ptr = rustCall( + (status) => + uniffi_moq_ffi_fn_constructor_moqcongestioncontrol_loss(status), + null, + ) { + _MoqCongestionControlFinalizer.attach(this, _ptr, detach: this); + } + MoqCongestionControl.none() + : _ptr = rustCall( + (status) => + uniffi_moq_ffi_fn_constructor_moqcongestioncontrol_none(status), + null, + ) { + _MoqCongestionControlFinalizer.attach(this, _ptr, detach: this); + } + factory MoqCongestionControl.lift(Pointer ptr) { + return MoqCongestionControl._(ptr); + } + Pointer uniffiClonePointer() { + if (_isDisposed) { + throw StateError("Object has already been disposed"); + } + return rustCall( + (status) => uniffi_moq_ffi_fn_clone_moqcongestioncontrol(_ptr, status), + ); + } + + void dispose() { + if (_isDisposed) { + return; + } + final status = calloc(); + _isDisposed = true; + _MoqCongestionControlFinalizer.detach(this); + try { + uniffi_moq_ffi_fn_free_moqcongestioncontrol(_ptr, status); + checkCallStatus(NullRustCallStatusErrorHandler(), status); + } finally { + calloc.free(status); + } + } + + String debugString() { + return rustCallWithLifter( + (status) => + uniffi_moq_ffi_fn_method_moqcongestioncontrol_uniffi_trait_debug( + uniffiClonePointer(), + status, + ), + FfiConverterString.lift, + null, + ); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (other is! MoqCongestionControl) { + return false; + } + return rustCallWithLifter( + (status) => + uniffi_moq_ffi_fn_method_moqcongestioncontrol_uniffi_trait_eq_eq( + uniffiClonePointer(), + FfiConverterMoqCongestionControl.lower(other), + status, + ), + FfiConverterBool.lift, + null, + ); + } + + @override + int get hashCode { + return rustCallWithLifter( + (status) => + uniffi_moq_ffi_fn_method_moqcongestioncontrol_uniffi_trait_hash( + uniffiClonePointer(), + status, + ), + FfiConverterUInt64.lift, + null, + ); + } +} + +class FfiConverterMoqCongestionControl { + static MoqCongestionControl lift(Pointer ptr) { + return MoqCongestionControl.lift(ptr); + } + + static Pointer lower(MoqCongestionControl value) { + return value.uniffiClonePointer(); + } + + static int allocationSize(MoqCongestionControl value) { + return 8; + } + + static LiftRetVal read(Uint8List buf) { + final handle = buf.buffer.asByteData(buf.offsetInBytes).getInt64(0); + final pointer = Pointer.fromAddress(handle); + return LiftRetVal(MoqCongestionControl.lift(pointer), 8); + } + + static int write(MoqCongestionControl value, Uint8List buf) { + final handle = lower(value); + buf.buffer.asByteData(buf.offsetInBytes).setInt64(0, handle.address); + return 8; + } +} + abstract class MoqSessionInterface { MoqAllocator allocator(); void cancel({required int code}); @@ -23034,6 +23133,78 @@ external Pointer uniffi_moq_ffi_fn_method_moqclient_connect( RustBuffer url, ); +@Native Function(Pointer, Pointer)>( + assetId: _uniffiAssetId, +) +external Pointer uniffi_moq_ffi_fn_clone_moqcongestioncontrol( + Pointer handle, + Pointer uniffiStatus, +); + +@Native, Pointer)>( + assetId: _uniffiAssetId, +) +external void uniffi_moq_ffi_fn_free_moqcongestioncontrol( + Pointer handle, + Pointer uniffiStatus, +); + +@Native Function(Pointer)>( + assetId: _uniffiAssetId, +) +external Pointer uniffi_moq_ffi_fn_constructor_moqcongestioncontrol_delay( + Pointer uniffiStatus, +); + +@Native Function(Pointer)>( + assetId: _uniffiAssetId, +) +external Pointer uniffi_moq_ffi_fn_constructor_moqcongestioncontrol_loss( + Pointer uniffiStatus, +); + +@Native Function(Pointer)>( + assetId: _uniffiAssetId, +) +external Pointer uniffi_moq_ffi_fn_constructor_moqcongestioncontrol_none( + Pointer uniffiStatus, +); + +@Native, Pointer)>( + assetId: _uniffiAssetId, +) +external RustBuffer +uniffi_moq_ffi_fn_method_moqcongestioncontrol_uniffi_trait_debug( + Pointer ptr, + Pointer uniffiStatus, +); + +@Native, Pointer, Pointer)>( + assetId: _uniffiAssetId, +) +external int uniffi_moq_ffi_fn_method_moqcongestioncontrol_uniffi_trait_eq_eq( + Pointer ptr, + Pointer other, + Pointer uniffiStatus, +); + +@Native, Pointer, Pointer)>( + assetId: _uniffiAssetId, +) +external int uniffi_moq_ffi_fn_method_moqcongestioncontrol_uniffi_trait_eq_ne( + Pointer ptr, + Pointer other, + Pointer uniffiStatus, +); + +@Native, Pointer)>( + assetId: _uniffiAssetId, +) +external int uniffi_moq_ffi_fn_method_moqcongestioncontrol_uniffi_trait_hash( + Pointer ptr, + Pointer uniffiStatus, +); + @Native Function(Pointer, Pointer)>( assetId: _uniffiAssetId, ) @@ -24811,6 +24982,15 @@ external int uniffi_moq_ffi_checksum_constructor_moqserver_new(); @Native(assetId: _uniffiAssetId) external int uniffi_moq_ffi_checksum_constructor_moqclient_new(); +@Native(assetId: _uniffiAssetId) +external int uniffi_moq_ffi_checksum_constructor_moqcongestioncontrol_delay(); + +@Native(assetId: _uniffiAssetId) +external int uniffi_moq_ffi_checksum_constructor_moqcongestioncontrol_loss(); + +@Native(assetId: _uniffiAssetId) +external int uniffi_moq_ffi_checksum_constructor_moqcongestioncontrol_none(); + @Native(assetId: _uniffiAssetId) external int uniffi_moq_ffi_checksum_constructor_moqsocketendpoint_new(); @@ -25728,6 +25908,18 @@ void _checkApiChecksums() { if (uniffi_moq_ffi_checksum_constructor_moqclient_new() != 48355) { throw UniffiInternalError.panicked("UniFFI API checksum mismatch"); } + if (uniffi_moq_ffi_checksum_constructor_moqcongestioncontrol_delay() != + 62385) { + throw UniffiInternalError.panicked("UniFFI API checksum mismatch"); + } + if (uniffi_moq_ffi_checksum_constructor_moqcongestioncontrol_loss() != + 53409) { + throw UniffiInternalError.panicked("UniFFI API checksum mismatch"); + } + if (uniffi_moq_ffi_checksum_constructor_moqcongestioncontrol_none() != + 50250) { + throw UniffiInternalError.panicked("UniFFI API checksum mismatch"); + } if (uniffi_moq_ffi_checksum_constructor_moqsocketendpoint_new() != 25288) { throw UniffiInternalError.panicked("UniFFI API checksum mismatch"); } diff --git a/doc/bin/relay/config.md b/doc/bin/relay/config.md index 8330db7a7c6..bd4d998deb6 100644 --- a/doc/bin/relay/config.md +++ b/doc/bin/relay/config.md @@ -116,7 +116,7 @@ Transport tuning, applied to accepted and dialed connections alike. ```toml [quic] -congestion_control = "delay" # "delay" (BBR, the default), "loss" (CUBIC), or "none". +congestion_control = "delay" # "delay" (BBR v3, the default), "loss" (CUBIC), or "none". max_streams = 10000 # Concurrent streams per connection, bidi and uni; 0 is refused. Default. idle_timeout = "10s" # Drop a connection after this long with nothing on it. Default. # keep_alive = "3s" # Ping interval; unset or "0s" derives it from the idle timeout. diff --git a/go/wrapper/reconnect_test.go b/go/wrapper/reconnect_test.go index 20e7cc7a18d..1324869bf0d 100644 --- a/go/wrapper/reconnect_test.go +++ b/go/wrapper/reconnect_test.go @@ -328,7 +328,7 @@ func TestDialConnectionOptions(t *testing.T) { KeepAlive: ptr(time.Duration(0)), GSO: ptr(false), MTUDiscovery: ptr(true), - CongestionControl: ptr(moq.CongestionControlLoss), + CongestionControl: moq.LossCongestionControl(), }, WebSocket: moq.WebSocketConfig{Enabled: ptr(false)}, }) diff --git a/go/wrapper/types.go b/go/wrapper/types.go index 4660e3fed5b..154baa0acaf 100644 --- a/go/wrapper/types.go +++ b/go/wrapper/types.go @@ -19,7 +19,9 @@ type ( AudioSampleFormat = ffi.MoqAudioSampleFormat // AudioFrame is one audio frame: PCM payload plus a presentation Timestamp. AudioFrame = ffi.MoqAudioFrame - // CongestionControl is the congestion control family for a QUIC connection. + // CongestionControl is the congestion control family for a QUIC connection. Build one with + // DelayCongestionControl, LossCongestionControl, or NoneCongestionControl; a new algorithm + // joins as a new builder. CongestionControl = ffi.MoqCongestionControl // ErrorScope is whether a protocol code is from the session or stream registry. ErrorScope = ffi.MoqErrorScope @@ -164,15 +166,20 @@ const ( CompressionDeflate = ffi.MoqCompressionDeflate ) -// CongestionControl values. -const ( - // CongestionControlLoss is loss-based (CUBIC): it chases throughput, so the send rate sawtooths. - CongestionControlLoss = ffi.MoqCongestionControlLoss - // CongestionControlDelay is delay-based (BBR): it keeps queues short and the send rate steady. - CongestionControlDelay = ffi.MoqCongestionControlDelay - // CongestionControlNone runs no congestion control and no pacing, for tests and controlled links. - CongestionControlNone = ffi.MoqCongestionControlNone -) +// LossCongestionControl is loss-based (CUBIC): it chases throughput, so the send rate sawtooths. +func LossCongestionControl() *CongestionControl { + return ffi.MoqCongestionControlLoss() +} + +// DelayCongestionControl is delay-based (BBR v3), the default: it keeps queues short and the send rate steady. +func DelayCongestionControl() *CongestionControl { + return ffi.MoqCongestionControlDelay() +} + +// NoneCongestionControl runs no congestion control and no pacing, for tests and controlled links. +func NoneCongestionControl() *CongestionControl { + return ffi.MoqCongestionControlNone() +} // ParseInstance names an instance with text, failing with ErrInvalidInstance when it is empty. func ParseInstance(text string) (*Instance, error) { diff --git a/kt/moq/src/jvmAndAndroidMain/kotlin/dev/moq/Aliases.kt b/kt/moq/src/jvmAndAndroidMain/kotlin/dev/moq/Aliases.kt index 740f510eb8d..d459f78f241 100644 --- a/kt/moq/src/jvmAndAndroidMain/kotlin/dev/moq/Aliases.kt +++ b/kt/moq/src/jvmAndAndroidMain/kotlin/dev/moq/Aliases.kt @@ -40,7 +40,10 @@ typealias ServerTls = uniffi.moq.MoqServerTls /** QUIC transport tuning, such as the peer's inbound stream cap. */ typealias QuicConfig = uniffi.moq.MoqQuicConfig -/** The congestion control family for a QUIC connection. */ +/** + * The congestion control family for a QUIC connection. Build one with `CongestionControl.delay()`, + * `loss()`, or `none()`; a new algorithm joins as a new constructor. + */ typealias CongestionControl = uniffi.moq.MoqCongestionControl /** The WebSocket fallback raced against QUIC: whether it runs and QUIC's head start. */ diff --git a/kt/moq/src/jvmAndAndroidTest/kotlin/dev/moq/SmokeTest.kt b/kt/moq/src/jvmAndAndroidTest/kotlin/dev/moq/SmokeTest.kt index eeddca403a5..f70e82f3888 100644 --- a/kt/moq/src/jvmAndAndroidTest/kotlin/dev/moq/SmokeTest.kt +++ b/kt/moq/src/jvmAndAndroidTest/kotlin/dev/moq/SmokeTest.kt @@ -201,7 +201,7 @@ class SmokeTest { assertNotNull(defaults.timeout) assertNull(defaults.quic.congestionControl) assertTrue(versions().isNotEmpty()) - val congestion: CongestionControl = CongestionControl.DELAY + val congestion: CongestionControl = CongestionControl.delay() assertEquals(congestion, QuicConfig(congestionControl = congestion).congestionControl) // Dialing with the reported defaults is the same as dialing with none. Client(defaults).close() diff --git a/nix/Cargo.nix b/nix/Cargo.nix index b6f54547036..906f8799104 100644 --- a/nix/Cargo.nix +++ b/nix/Cargo.nix @@ -180,6 +180,16 @@ rec { # File a bug if you depend on any for non-debug work! debug = internal.debugCrate { inherit packageId; }; }; + "moq-congestion-lab" = rec { + packageId = "moq-congestion-lab"; + build = internal.buildRustCrateWithFeatures { + packageId = "moq-congestion-lab"; + }; + + # Debug support which might change between releases. + # File a bug if you depend on any for non-debug work! + debug = internal.debugCrate { inherit packageId; }; + }; "moq-crypto" = rec { packageId = "moq-crypto"; build = internal.buildRustCrateWithFeatures { @@ -18581,10 +18591,6 @@ rec { name = "rand_pcg"; packageId = "rand_pcg"; } - { - name = "tracing"; - packageId = "tracing"; - } ]; devDependencies = [ { @@ -18606,6 +18612,46 @@ rec { } ]; + }; + "moq-congestion-lab" = rec { + crateName = "moq-congestion-lab"; + version = "0.0.0"; + edition = "2024"; + src = lib.cleanSourceWith { + filter = sourceFilter; + src = ../rs/moq-congestion-lab; + }; + libName = "moq_congestion_lab"; + dependencies = [ + { + name = "kio"; + packageId = "kio"; + } + { + name = "moq-congestion"; + packageId = "moq-congestion"; + } + { + name = "tracing"; + packageId = "tracing"; + } + ]; + devDependencies = [ + { + name = "cpu-time"; + packageId = "cpu-time"; + } + { + name = "kio"; + packageId = "kio"; + features = [ "runtime" ]; + } + { + name = "workspace-hack"; + packageId = "workspace-hack"; + } + ]; + }; "moq-crypto" = rec { crateName = "moq-crypto"; @@ -20184,6 +20230,10 @@ rec { "sim" ]; } + { + name = "moq-congestion-lab"; + packageId = "moq-congestion-lab"; + } { name = "moq-quic"; packageId = "moq-quic"; @@ -21700,6 +21750,10 @@ rec { name = "moq-congestion"; packageId = "moq-congestion"; } + { + name = "moq-congestion-lab"; + packageId = "moq-congestion-lab"; + } { name = "moq-shaper"; packageId = "moq-shaper"; diff --git a/py/moq-rs/README.md b/py/moq-rs/README.md index 5a577bbc148..30f8706466b 100644 --- a/py/moq-rs/README.md +++ b/py/moq-rs/README.md @@ -141,7 +141,7 @@ client = moq.Client( - `fingerprints`. Hex SHA-256 fingerprint(s) to pin the peer's certificate to, the native equivalent of `serverCertificateHashes`. Accepts the values a server reports via `cert_fingerprints()`, so you can trust a self-signed certificate without `insecure=True`. - `cert`, `key`. Paired PEM certificate chain and private key paths for mTLS. - `host_name`. Verify the certificate against this name (SNI) instead of the URL's host. - - `quic=QuicConfig(...)`. QUIC tuning: `max_streams` raises the peer's inbound stream cap; `idle_timeout`, `keep_alive` (`timedelta(0)` uses the default), `gso`, `mtu_discovery`, `congestion_control` (a `CongestionControl`), and `qlog` (a trace directory when `qlog_supported()`). `keylog=True` writes TLS session secrets to the file `SSLKEYLOGFILE` names, for decrypting a capture; without `SSLKEYLOGFILE` the client refuses to build. + - `quic=QuicConfig(...)`. QUIC tuning: `max_streams` raises the peer's inbound stream cap; `idle_timeout`, `keep_alive` (`timedelta(0)` uses the default), `gso`, `mtu_discovery`, `congestion_control` (a `CongestionControl`, such as `CongestionControl.delay()`), and `qlog` (a trace directory when `qlog_supported()`). `keylog=True` writes TLS session secrets to the file `SSLKEYLOGFILE` names, for decrypting a capture; without `SSLKEYLOGFILE` the client refuses to build. - `websocket=WebSocketConfig(...)`. The fallback raced against QUIC: `enabled=False` turns it off, and `delay` is QUIC's head start. - `once`, `backoff`. Redial with a `Backoff` when the transport drops; `once=True` dials once. - `.session`. The connecting or connected `Session` (or `None` before entering / after exit). diff --git a/py/moq-rs/tests/test_server.py b/py/moq-rs/tests/test_server.py index a347f3dd818..af75f795424 100644 --- a/py/moq-rs/tests/test_server.py +++ b/py/moq-rs/tests/test_server.py @@ -367,7 +367,7 @@ async def accept_loop() -> None: keep_alive=timedelta(0), gso=False, mtu_discovery=True, - congestion_control=moq.CongestionControl.LOSS, + congestion_control=moq.CongestionControl.loss(), keylog=False, ), websocket=moq.WebSocketConfig(enabled=False), diff --git a/quest/m2/congestion-candidates.md b/quest/m2/congestion-candidates.md deleted file mode 100644 index c1120fd933d..00000000000 --- a/quest/m2/congestion-candidates.md +++ /dev/null @@ -1,65 +0,0 @@ -# [S] The congestion selector ships BBR, and new algorithms join it additively - -## Goal - -The cut ships one public congestion-control selector that applications, the -relay's config, the CLI, and every binding use, with BBR (v3) selectable and -the default. Algorithms still under test (GCC, SCReAMv2, and BBR3's delay -bound) are not reachable from any published crate's public API, and each can -join the selector later without a breaking change. - -## Plan - -Found 2026-11-14 by the [feature review](/quest/m3/release/feature-review.md). -GCC (`rs/moq-congestion/src/gcc/`, about 16.3k vendored lines), SCReAMv2 -(`scream.rs`), and BBR3's delay bound (`bbr3::Config::delay_bound`) from -[moq-dev/moq#7546](https://github.com/moq-dev/moq/pull/7546), -[moq-dev/moq#7547](https://github.com/moq-dev/moq/pull/7547), and -[moq-dev/moq#7544](https://github.com/moq-dev/moq/pull/7544) are public in -moq-congestion 0.1.0, which has never been published, yet no session can -select them, and nothing outside tests turns on the receive timestamps GCC -needs. - -Decided 2026-11-14 (maintainer, pick on [moq-dev/moq#8764](https://github.com/moq-dev/moq/pull/8764)), -in the maintainer's words: "Add a way to select them? We need BBR for sure, -while GCC and Scream can wait for more testing I guess. So long as new -algorithms are additive." ✅ A public selector ships BBR; GCC and SCReAM are -not selectable in the cut and stay out of the published surface until tested -(rejected: delete them now and restore them for the bake-off; ship them -behind an unstable feature; publish them as they are). - -Choices made with that pick, for review: - -- The selector already exists, so extend it rather than add a second one: - `moq_tokio::quic::CongestionControl` (`#[non_exhaustive]`, with `Loss` - for CUBIC, `Delay` for BBR v3 and the default, and `None`), the relay and - CLI's `congestion_control` key, and moq-ffi's `MoqCongestionControl` in - every binding. `quic::Controller` stays the escape hatch for an - application's own controller. Its spellings ship on `release` (`delay` and - `loss` in relay configs), so keep them rather than break every deployed - config, and name each new variant after its algorithm (`gcc`, `scream`). - The docs say plainly that `delay` is BBR v3. A generated enum that a - language switches over exhaustively (Swift, Kotlin, Dart) makes a new - variant a break for its users, so give `MoqCongestionControl` a shape each - binding can grow without one before the cut. -- The delay bound is a BBR option, not a variant of its own: it bounds BBR3's - inflight from the forward-delay trend inside BBR's own state machine, so a - separate variant would duplicate BBR's settings under a second name, while a - field on a non-exhaustive `bbr3::Config` is additive. Until it is tested, - its setter is not public; it graduates as that option, or as BBR's default - if the bake-off shows it wins. -- Keep GCC and SCReAM in the tree but off the published API. Recommended: - move them into a workspace-only crate (`publish = false`) that the - bake-off's sim and integration tests use as a path dev-dependency, which - `cargo publish` drops; the vendor-sync quests follow the code. -- JS has nothing to select: browsers choose WebTransport's congestion - control, and `js/net` already asks for `low-latency`. - -[Realtime QUIC](/quest/m4/quic-realtime.md) is the bake-off that tests the -candidates and adds each winner to the selector as a variant (or the delay -bound as a BBR option). - -Public API: removes `moq_congestion::gcc`, `moq_congestion::scream`, and -`bbr3::Config::delay_bound` from the public API, none of them yet -published; `CongestionControl` and `MoqCongestionControl` are unchanged. -Wire: none. diff --git a/quest/m3/vendor-sync/scream.md b/quest/m3/vendor-sync/scream.md index 981796bcb39..5979c75afef 100644 --- a/quest/m3/vendor-sync/scream.md +++ b/quest/m3/vendor-sync/scream.md @@ -1,12 +1,12 @@ -# [XS] moq-congestion's SCReAMv2 follows its draft and reference +# [XS] moq-congestion-lab's SCReAMv2 follows its draft and reference ## Goal -moq-congestion's `scream` carries every fix to its queue-delay target path +moq-congestion-lab's `scream` carries every fix to its queue-delay target path from newer revisions of draft-ietf-ccwg-rfc8298bis-screamv2 and from [EricssonResearch/scream](https://github.com/EricssonResearch/scream)'s `ScreamV2Tx.cpp`, each ported with its test or recorded as not applying, and -`rs/moq-congestion/src/scream.rs`'s module doc names the draft revision and +`rs/moq-congestion-lab/src/scream.rs`'s module doc names the draft revision and reference commit checked. ## Plan diff --git a/quest/m3/vendor-sync/webrtc.md b/quest/m3/vendor-sync/webrtc.md index a758f11649e..18c541758ec 100644 --- a/quest/m3/vendor-sync/webrtc.md +++ b/quest/m3/vendor-sync/webrtc.md @@ -2,7 +2,7 @@ ## Goal -moq-congestion's `gcc` module (GoogCC) carries every fix WebRTC has landed in +moq-congestion-lab's `gcc` module (GoogCC) carries every fix WebRTC has landed in its source files since the last check, each ported with its test or recorded as not applying, and its module doc names the newest WebRTC revision checked. @@ -12,7 +12,7 @@ Recurring child of the [vendor sync](/quest/m3/vendor-sync/README.md), which says how each run works and recurs. New in the 2026-11-05 scan: the port landed after the first run started. -GoogCC: `rs/moq-congestion/src/gcc/mod.rs` records WebRTC +GoogCC: `rs/moq-congestion-lab/src/gcc/mod.rs` records WebRTC [`556f7eec27`](https://webrtc.googlesource.com/src/+/556f7eec27) (2026-11-01), refreshed in [moq-dev/moq#7546](https://github.com/moq-dev/moq/pull/7546) from [goog_cc](https://github.com/kixelated/goog_cc) 0.1.4. Each file follows its diff --git a/quest/m3/webrtc/README.md b/quest/m3/webrtc/README.md index e9d7228e0bb..a9a780e97d1 100644 --- a/quest/m3/webrtc/README.md +++ b/quest/m3/webrtc/README.md @@ -12,7 +12,7 @@ Decided 2026-10-30 with the maintainer (planning interview), after the str0m wor - **Vendor, then replace.** Copy the upstream crates in, trim them, and fix them in-tree. Replacing a layer with our own (SDP, RTP/RTCP, SRTP) is a later child once a concrete need appears; none is planned yet. - **One crate.** The ICE driver (once `moq-ice`) lives in `moq-webrtc`, which depends on moq-tokio rather than the reverse, so moq-tokio needs no ICE. The vendored crates become private modules, not separate published crates, keeping their MIT/Apache-2.0 notices (str0m's `packet/` carries webrtc-rs's Apache notice). -- **What goes** (from the 2026-10-30 inventory: we use frame mode, full ICE, and DTLS 1.2, and never enable str0m's BWE, pacer, or stats): GCC bandwidth estimation (8k lines; GCC is ported into `moq-congestion` as `moq_congestion::gcc`), the leaky pacer (replaced by moq-congestion's pacer, made public by [rtc-pacing](/quest/m3/rtc-pacing.md)), H.266, RED, DTMF, G.7xx and comfort noise, VLA and simulcast layers, RTCP app feedback, stats, internal test exports, and dimpl's DTLS 1.3 and version auto-selection. RTCP XR stays: its RRTR/DLRR blocks are the receive side's only RTT measurement, which sets NACK retries and the video recovery deadline. Roughly 17k of str0m's 72k lines and 11k of dimpl's 33k. +- **What goes** (from the 2026-10-30 inventory: we use frame mode, full ICE, and DTLS 1.2, and never enable str0m's BWE, pacer, or stats): GCC bandwidth estimation (8k lines; GCC is ported into the workspace-only `moq-congestion-lab` as `moq_congestion_lab::gcc`), the leaky pacer (replaced by moq-congestion's pacer, made public by [rtc-pacing](/quest/m3/rtc-pacing.md)), H.266, RED, DTMF, G.7xx and comfort noise, VLA and simulcast layers, RTCP app feedback, stats, internal test exports, and dimpl's DTLS 1.3 and version auto-selection. RTCP XR stays: its RRTR/DLRR blocks are the receive side's only RTT measurement, which sets NACK retries and the video recovery deadline. Roughly 17k of str0m's 72k lines and 11k of dimpl's 33k. - **DTLS 1.2 only.** Every browser negotiates 1.2 today, and the vendored rind crypto provider offers 1.2 only to match. - **No SCTP.** Decided 2026-11-14 (maintainer): peer-to-peer routing, the only data-channel consumer, left the repository, so sctp-proto and str0m's data channels are cut and an offered `m=application` line is answered rejected. - **Upstream fixes:** after vendoring, nobody merges upstream automatically. The vendored upstream commits are recorded in `rs/moq-webrtc/src/vendor/mod.rs`'s `Upstream` section; the [vendor sync](/quest/m3/vendor-sync/webrtc-stack.md) checks the upstream changes once per release cycle for security fixes (malformed SRTP/RTCP input, for example) and ports them. diff --git a/quest/m4/quic-realtime.md b/quest/m4/quic-realtime.md index f3e7b10f528..aa4e1c743cc 100644 --- a/quest/m4/quic-realtime.md +++ b/quest/m4/quic-realtime.md @@ -36,7 +36,9 @@ spike assumed no consumer; teleoperation uplinks are one): scheduler's grants. So the candidates group arrivals into bursts before fitting a trend, as GoogCC does. Reproduce it with `just rs quic-sim`. - Bake-off: all three candidates in parallel, each a controller - in `moq-congestion`. The moq-shaper presets `cellular-step`, + in the workspace-only `moq-congestion-lab` (the delay bound stays in + `moq-congestion`'s `bbr3/`, its setter hidden); a winner moves into + `moq-congestion`. The moq-shaper presets `cellular-step`, `cellular-bursty` and `cellular-deep` decide it. The report states the shaper's timing jitter, measured over `near-zero`, as the noise floor of the delay signal. The BBR3 delay bound (`bbr3::Config::delay_bound`) brought @@ -60,14 +62,15 @@ spike assumed no consumer; teleoperation uplinks are one): only stops a rung on a session with a sender, so a `Realtime` that cannot probe would silently leave moq-cli, OBS, and FFI simulcast publishers with no rung disable or recovery. A candidate that cannot probe does not ship. -- Naming: add `Realtime` to `moq_tokio::quic::CongestionControl` (`realtime` - on the CLI and in TOML), which is `non_exhaustive`, so it is additive. - `Delay` keeps meaning BBR3; reword its doc line to say model-based, since - BBR does not react to queuing delay directly. A new variant rather than - upgrading `Delay`, so current users see no behavior change. +- Naming (revised 2026-11-14, below): each winner joins + `moq_tokio::quic::CongestionControl` as a variant named after its algorithm + (`gcc`, `scream` on the CLI and in TOML), which is `non_exhaustive`, so it is + additive, as is a new moq-ffi `MoqCongestionControl` constructor. `Delay` + keeps meaning BBR3, documented as model-based BBR v3. A new variant rather + than upgrading `Delay`, so current users see no behavior change. - Docs: inline only. The congestion-control lines in `doc/bin/cli.md` and `doc/lib/*` gain the new variant; no new page. -- SCReAMv2 landed as `moq_congestion::Scream` +- SCReAMv2 landed as `moq_congestion_lab::scream::Scream` ([moq-dev/moq#7547](https://github.com/moq-dev/moq/pull/7547)). moq-quic's `tests::scream` measures it on the sim beside BBR3, and moq-tokio's `scream` integration tests over the real presets. Its estimate is a window @@ -178,7 +181,7 @@ the candidates would publish unselectable with moq-congestion's first release. Decided 2026-11-14 (maintainer, pick on [moq-dev/moq#8764](https://github.com/moq-dev/moq/pull/8764)): ✅ the cut ships BBR through the existing selector and keeps GCC, SCReAM, and the BBR3 delay -bound off the published API ([congestion selector](/quest/m2/congestion-candidates.md)). +bound off the published API. This bake-off tests them, and each winner joins `CongestionControl` as a variant named after its algorithm, or, for the delay bound, a `bbr3::Config` option; losers stay out of the published API. diff --git a/rs/moq-c/src/api.rs b/rs/moq-c/src/api.rs index 44fa8216b40..90ad5b0f964 100644 --- a/rs/moq-c/src/api.rs +++ b/rs/moq-c/src/api.rs @@ -1631,7 +1631,7 @@ pub struct moq_client_config { /// Whether `quic_mtu_discovery` is present. pub has_quic_mtu_discovery: bool, - /// Congestion control family name (`loss`, `delay`, or `none`), or NULL for the backend's choice. + /// Congestion control family name (`loss` for CUBIC, `delay` for BBR v3, or `none`), or NULL for the backend's choice. pub quic_congestion_control: *const c_char, /// The length in bytes of `quic_congestion_control`. pub quic_congestion_control_len: usize, diff --git a/rs/moq-congestion-lab/Cargo.toml b/rs/moq-congestion-lab/Cargo.toml new file mode 100644 index 00000000000..68c03346f98 --- /dev/null +++ b/rs/moq-congestion-lab/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "moq-congestion-lab" +description = "Congestion controller candidates under test, kept out of moq-congestion's published API" +version = "0.0.0" +edition = "2024" +rust-version.workspace = true +repository = "https://github.com/moq-dev/moq" +license = "(MIT OR Apache-2.0) AND BSD-3-Clause" +publish = false + +[dependencies] +kio = { workspace = true } +moq-congestion = { workspace = true } +tracing = { workspace = true } + +[dev-dependencies] +cpu-time = "1.0.0" +kio = { path = "../kio", features = ["runtime"] } +workspace-hack = { path = "../workspace-hack" } + +[lints] +workspace = true diff --git a/rs/moq-congestion-lab/LICENSE-APACHE b/rs/moq-congestion-lab/LICENSE-APACHE new file mode 100644 index 00000000000..261eeb9e9f8 --- /dev/null +++ b/rs/moq-congestion-lab/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/rs/moq-congestion-lab/LICENSE-MIT b/rs/moq-congestion-lab/LICENSE-MIT new file mode 100644 index 00000000000..f6561040563 --- /dev/null +++ b/rs/moq-congestion-lab/LICENSE-MIT @@ -0,0 +1,7 @@ +Copyright (c) 2018 The quinn Developers + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/rs/moq-congestion-lab/README.md b/rs/moq-congestion-lab/README.md new file mode 100644 index 00000000000..2351707e5df --- /dev/null +++ b/rs/moq-congestion-lab/README.md @@ -0,0 +1,9 @@ +# moq-congestion-lab + +Congestion controller candidates under test, kept out of [moq-congestion](../moq-congestion)'s published API. The crate is never published: moq-quic's simulated comparisons and moq-tokio's real-socket tests take it as a path dev-dependency, which `cargo publish` drops. A candidate that wins the realtime bake-off moves into moq-congestion and joins `moq_tokio::quic::CongestionControl` as a variant named after its algorithm. + +SCReAMv2's delay-based path was ported from draft-ietf-ccwg-rfc8298bis-screamv2 and checked against Ericsson's [reference implementation](https://github.com/EricssonResearch/scream). + +GCC is libwebrtc's Google Congestion Control, a delay-based controller that reads the peer's receive timestamps (draft-ietf-quic-receive-ts). `src/gcc` vendors a Rust port of WebRTC's `goog_cc` under WebRTC's BSD license, kept in [`src/gcc/LICENSE`](src/gcc/LICENSE) with its `PATENTS` grant; its module docs record the WebRTC revision it tracks and what it trims. + +Tests run with `just rs test -p moq-congestion-lab`. diff --git a/rs/moq-congestion/src/gcc/AUTHORS b/rs/moq-congestion-lab/src/gcc/AUTHORS similarity index 100% rename from rs/moq-congestion/src/gcc/AUTHORS rename to rs/moq-congestion-lab/src/gcc/AUTHORS diff --git a/rs/moq-congestion/src/gcc/LICENSE b/rs/moq-congestion-lab/src/gcc/LICENSE similarity index 100% rename from rs/moq-congestion/src/gcc/LICENSE rename to rs/moq-congestion-lab/src/gcc/LICENSE diff --git a/rs/moq-congestion/src/gcc/PATENTS b/rs/moq-congestion-lab/src/gcc/PATENTS similarity index 100% rename from rs/moq-congestion/src/gcc/PATENTS rename to rs/moq-congestion-lab/src/gcc/PATENTS diff --git a/rs/moq-congestion/src/gcc/alr_detector.rs b/rs/moq-congestion-lab/src/gcc/alr_detector.rs similarity index 100% rename from rs/moq-congestion/src/gcc/alr_detector.rs rename to rs/moq-congestion-lab/src/gcc/alr_detector.rs diff --git a/rs/moq-congestion/src/gcc/api/mod.rs b/rs/moq-congestion-lab/src/gcc/api/mod.rs similarity index 100% rename from rs/moq-congestion/src/gcc/api/mod.rs rename to rs/moq-congestion-lab/src/gcc/api/mod.rs diff --git a/rs/moq-congestion/src/gcc/api/transport/bandwidth_usage.rs b/rs/moq-congestion-lab/src/gcc/api/transport/bandwidth_usage.rs similarity index 100% rename from rs/moq-congestion/src/gcc/api/transport/bandwidth_usage.rs rename to rs/moq-congestion-lab/src/gcc/api/transport/bandwidth_usage.rs diff --git a/rs/moq-congestion/src/gcc/api/transport/mod.rs b/rs/moq-congestion-lab/src/gcc/api/transport/mod.rs similarity index 100% rename from rs/moq-congestion/src/gcc/api/transport/mod.rs rename to rs/moq-congestion-lab/src/gcc/api/transport/mod.rs diff --git a/rs/moq-congestion/src/gcc/api/transport/network_types.rs b/rs/moq-congestion-lab/src/gcc/api/transport/network_types.rs similarity index 100% rename from rs/moq-congestion/src/gcc/api/transport/network_types.rs rename to rs/moq-congestion-lab/src/gcc/api/transport/network_types.rs diff --git a/rs/moq-congestion/src/gcc/api/units/data_rate.rs b/rs/moq-congestion-lab/src/gcc/api/units/data_rate.rs similarity index 100% rename from rs/moq-congestion/src/gcc/api/units/data_rate.rs rename to rs/moq-congestion-lab/src/gcc/api/units/data_rate.rs diff --git a/rs/moq-congestion/src/gcc/api/units/data_size.rs b/rs/moq-congestion-lab/src/gcc/api/units/data_size.rs similarity index 100% rename from rs/moq-congestion/src/gcc/api/units/data_size.rs rename to rs/moq-congestion-lab/src/gcc/api/units/data_size.rs diff --git a/rs/moq-congestion/src/gcc/api/units/frequency.rs b/rs/moq-congestion-lab/src/gcc/api/units/frequency.rs similarity index 100% rename from rs/moq-congestion/src/gcc/api/units/frequency.rs rename to rs/moq-congestion-lab/src/gcc/api/units/frequency.rs diff --git a/rs/moq-congestion/src/gcc/api/units/mod.rs b/rs/moq-congestion-lab/src/gcc/api/units/mod.rs similarity index 100% rename from rs/moq-congestion/src/gcc/api/units/mod.rs rename to rs/moq-congestion-lab/src/gcc/api/units/mod.rs diff --git a/rs/moq-congestion/src/gcc/api/units/time_delta.rs b/rs/moq-congestion-lab/src/gcc/api/units/time_delta.rs similarity index 100% rename from rs/moq-congestion/src/gcc/api/units/time_delta.rs rename to rs/moq-congestion-lab/src/gcc/api/units/time_delta.rs diff --git a/rs/moq-congestion/src/gcc/api/units/timestamp.rs b/rs/moq-congestion-lab/src/gcc/api/units/timestamp.rs similarity index 100% rename from rs/moq-congestion/src/gcc/api/units/timestamp.rs rename to rs/moq-congestion-lab/src/gcc/api/units/timestamp.rs diff --git a/rs/moq-congestion/src/gcc/api/units/unit_base.rs b/rs/moq-congestion-lab/src/gcc/api/units/unit_base.rs similarity index 100% rename from rs/moq-congestion/src/gcc/api/units/unit_base.rs rename to rs/moq-congestion-lab/src/gcc/api/units/unit_base.rs diff --git a/rs/moq-congestion/src/gcc/bench.rs b/rs/moq-congestion-lab/src/gcc/bench.rs similarity index 99% rename from rs/moq-congestion/src/gcc/bench.rs rename to rs/moq-congestion-lab/src/gcc/bench.rs index 42b0585174a..f67ff1f0f6e 100644 --- a/rs/moq-congestion/src/gcc/bench.rs +++ b/rs/moq-congestion-lab/src/gcc/bench.rs @@ -2,7 +2,7 @@ //! so its cost grows with the packets each ACK carries. use super::*; -use crate::Acked; +use moq_congestion::Acked; use cpu_time::ThreadTime; const PACKET: u16 = 1200; diff --git a/rs/moq-congestion/src/gcc/congestion_window_pushback_controller.rs b/rs/moq-congestion-lab/src/gcc/congestion_window_pushback_controller.rs similarity index 100% rename from rs/moq-congestion/src/gcc/congestion_window_pushback_controller.rs rename to rs/moq-congestion-lab/src/gcc/congestion_window_pushback_controller.rs diff --git a/rs/moq-congestion/src/gcc/delay_based_bwe.rs b/rs/moq-congestion-lab/src/gcc/delay_based_bwe.rs similarity index 100% rename from rs/moq-congestion/src/gcc/delay_based_bwe.rs rename to rs/moq-congestion-lab/src/gcc/delay_based_bwe.rs diff --git a/rs/moq-congestion/src/gcc/delay_increase_detector_interface.rs b/rs/moq-congestion-lab/src/gcc/delay_increase_detector_interface.rs similarity index 100% rename from rs/moq-congestion/src/gcc/delay_increase_detector_interface.rs rename to rs/moq-congestion-lab/src/gcc/delay_increase_detector_interface.rs diff --git a/rs/moq-congestion/src/gcc/experiments/field_trials.rs b/rs/moq-congestion-lab/src/gcc/experiments/field_trials.rs similarity index 100% rename from rs/moq-congestion/src/gcc/experiments/field_trials.rs rename to rs/moq-congestion-lab/src/gcc/experiments/field_trials.rs diff --git a/rs/moq-congestion/src/gcc/experiments/mod.rs b/rs/moq-congestion-lab/src/gcc/experiments/mod.rs similarity index 100% rename from rs/moq-congestion/src/gcc/experiments/mod.rs rename to rs/moq-congestion-lab/src/gcc/experiments/mod.rs diff --git a/rs/moq-congestion/src/gcc/experiments/rate_control.rs b/rs/moq-congestion-lab/src/gcc/experiments/rate_control.rs similarity index 100% rename from rs/moq-congestion/src/gcc/experiments/rate_control.rs rename to rs/moq-congestion-lab/src/gcc/experiments/rate_control.rs diff --git a/rs/moq-congestion/src/gcc/goog_cc_network_control.rs b/rs/moq-congestion-lab/src/gcc/goog_cc_network_control.rs similarity index 100% rename from rs/moq-congestion/src/gcc/goog_cc_network_control.rs rename to rs/moq-congestion-lab/src/gcc/goog_cc_network_control.rs diff --git a/rs/moq-congestion/src/gcc/inter_arrival_delta.rs b/rs/moq-congestion-lab/src/gcc/inter_arrival_delta.rs similarity index 100% rename from rs/moq-congestion/src/gcc/inter_arrival_delta.rs rename to rs/moq-congestion-lab/src/gcc/inter_arrival_delta.rs diff --git a/rs/moq-congestion/src/gcc/link_capacity_estimator.rs b/rs/moq-congestion-lab/src/gcc/link_capacity_estimator.rs similarity index 100% rename from rs/moq-congestion/src/gcc/link_capacity_estimator.rs rename to rs/moq-congestion-lab/src/gcc/link_capacity_estimator.rs diff --git a/rs/moq-congestion/src/gcc/loss_based_bwe_v2.rs b/rs/moq-congestion-lab/src/gcc/loss_based_bwe_v2.rs similarity index 100% rename from rs/moq-congestion/src/gcc/loss_based_bwe_v2.rs rename to rs/moq-congestion-lab/src/gcc/loss_based_bwe_v2.rs diff --git a/rs/moq-congestion/src/gcc/mod.rs b/rs/moq-congestion-lab/src/gcc/mod.rs similarity index 99% rename from rs/moq-congestion/src/gcc/mod.rs rename to rs/moq-congestion-lab/src/gcc/mod.rs index 2614226e404..e4aba8578d8 100644 --- a/rs/moq-congestion/src/gcc/mod.rs +++ b/rs/moq-congestion-lab/src/gcc/mod.rs @@ -77,7 +77,7 @@ use std::{collections::VecDeque, num::NonZeroU16, sync::Arc, time::Duration}; use kio::clock::Instant; -use crate::{ +use moq_congestion::{ Ack, Ce, Controller, Factory, Init, Loss, Metrics, Packet, Sent, pacer::{self, Pacer, Rate}, }; @@ -279,7 +279,7 @@ impl Gcc { /// GoogCC runs on the round-trip delay. Once it reports one, a packet without one, as when /// the ACK carrying its time was lost, still counts as received for the loss-based estimate, /// but not toward delay, rather than mix the two clocks. - fn acked(&mut self, packet: &crate::Acked, now: Instant) -> PacketResult { + fn acked(&mut self, packet: &moq_congestion::Acked, now: Instant) -> PacketResult { let (receive_time, ambiguous_receive_time) = match packet.received { Some(received) => (self.receive_time(received, now), false), None => (timestamp(now), self.receive_basis.is_some()), @@ -383,10 +383,9 @@ impl Controller for Gcc { data_in_flight: size(sent.in_flight), }); self.apply(update); - Packet { - probe_cluster, - ..Default::default() - } + let mut packet = Packet::default(); + packet.probe_cluster = probe_cluster; + packet } fn on_ack(&mut self, ack: Ack<'_>) { diff --git a/rs/moq-congestion/src/gcc/pacing/bitrate_prober.rs b/rs/moq-congestion-lab/src/gcc/pacing/bitrate_prober.rs similarity index 100% rename from rs/moq-congestion/src/gcc/pacing/bitrate_prober.rs rename to rs/moq-congestion-lab/src/gcc/pacing/bitrate_prober.rs diff --git a/rs/moq-congestion/src/gcc/pacing/interval_budget.rs b/rs/moq-congestion-lab/src/gcc/pacing/interval_budget.rs similarity index 100% rename from rs/moq-congestion/src/gcc/pacing/interval_budget.rs rename to rs/moq-congestion-lab/src/gcc/pacing/interval_budget.rs diff --git a/rs/moq-congestion/src/gcc/pacing/mod.rs b/rs/moq-congestion-lab/src/gcc/pacing/mod.rs similarity index 100% rename from rs/moq-congestion/src/gcc/pacing/mod.rs rename to rs/moq-congestion-lab/src/gcc/pacing/mod.rs diff --git a/rs/moq-congestion/src/gcc/probe_bitrate_estimator.rs b/rs/moq-congestion-lab/src/gcc/probe_bitrate_estimator.rs similarity index 100% rename from rs/moq-congestion/src/gcc/probe_bitrate_estimator.rs rename to rs/moq-congestion-lab/src/gcc/probe_bitrate_estimator.rs diff --git a/rs/moq-congestion/src/gcc/probe_controller.rs b/rs/moq-congestion-lab/src/gcc/probe_controller.rs similarity index 100% rename from rs/moq-congestion/src/gcc/probe_controller.rs rename to rs/moq-congestion-lab/src/gcc/probe_controller.rs diff --git a/rs/moq-congestion/src/gcc/remote_bitrate_estimator/aimd_rate_control.rs b/rs/moq-congestion-lab/src/gcc/remote_bitrate_estimator/aimd_rate_control.rs similarity index 100% rename from rs/moq-congestion/src/gcc/remote_bitrate_estimator/aimd_rate_control.rs rename to rs/moq-congestion-lab/src/gcc/remote_bitrate_estimator/aimd_rate_control.rs diff --git a/rs/moq-congestion/src/gcc/remote_bitrate_estimator/bwe_defines.rs b/rs/moq-congestion-lab/src/gcc/remote_bitrate_estimator/bwe_defines.rs similarity index 100% rename from rs/moq-congestion/src/gcc/remote_bitrate_estimator/bwe_defines.rs rename to rs/moq-congestion-lab/src/gcc/remote_bitrate_estimator/bwe_defines.rs diff --git a/rs/moq-congestion/src/gcc/remote_bitrate_estimator/mod.rs b/rs/moq-congestion-lab/src/gcc/remote_bitrate_estimator/mod.rs similarity index 100% rename from rs/moq-congestion/src/gcc/remote_bitrate_estimator/mod.rs rename to rs/moq-congestion-lab/src/gcc/remote_bitrate_estimator/mod.rs diff --git a/rs/moq-congestion/src/gcc/robust_throughput_estimator.rs b/rs/moq-congestion-lab/src/gcc/robust_throughput_estimator.rs similarity index 100% rename from rs/moq-congestion/src/gcc/robust_throughput_estimator.rs rename to rs/moq-congestion-lab/src/gcc/robust_throughput_estimator.rs diff --git a/rs/moq-congestion/src/gcc/send_side_bandwidth_estimation.rs b/rs/moq-congestion-lab/src/gcc/send_side_bandwidth_estimation.rs similarity index 100% rename from rs/moq-congestion/src/gcc/send_side_bandwidth_estimation.rs rename to rs/moq-congestion-lab/src/gcc/send_side_bandwidth_estimation.rs diff --git a/rs/moq-congestion/src/gcc/tests.rs b/rs/moq-congestion-lab/src/gcc/tests.rs similarity index 99% rename from rs/moq-congestion/src/gcc/tests.rs rename to rs/moq-congestion-lab/src/gcc/tests.rs index a833a1cfa8c..e6582c72793 100644 --- a/rs/moq-congestion/src/gcc/tests.rs +++ b/rs/moq-congestion-lab/src/gcc/tests.rs @@ -5,7 +5,7 @@ use std::collections::VecDeque; use super::*; -use crate::{Acked, Lost}; +use moq_congestion::{Acked, Lost}; const MTU: u16 = 1200; /// One-way propagation delay, each way diff --git a/rs/moq-congestion/src/gcc/trendline_estimator.rs b/rs/moq-congestion-lab/src/gcc/trendline_estimator.rs similarity index 100% rename from rs/moq-congestion/src/gcc/trendline_estimator.rs rename to rs/moq-congestion-lab/src/gcc/trendline_estimator.rs diff --git a/rs/moq-congestion-lab/src/lib.rs b/rs/moq-congestion-lab/src/lib.rs new file mode 100644 index 00000000000..ab69a0e4d1a --- /dev/null +++ b/rs/moq-congestion-lab/src/lib.rs @@ -0,0 +1,52 @@ +//! Congestion controllers under test, outside moq-congestion's published API. +//! +//! Each candidate implements [`moq_congestion::Controller`], so the simulated and real-socket +//! comparisons in moq-quic and moq-tokio drive it like any other. A winner graduates into +//! moq-congestion and joins `moq_tokio::quic::CongestionControl` as a new variant. + +/// libwebrtc's Google Congestion Control (GoogCC). +pub mod gcc; +/// SCReAMv2's delay-based congestion control. +pub mod scream; + +#[cfg(test)] +mod tests { + use std::{sync::Arc, time::Duration}; + + use kio::clock::Instant; + use moq_congestion::{Factory, Init}; + + use super::*; + + /// The largest UDP payload (RFC 9000), whose two datagrams outgrow every 1200-based default + const MTU: u16 = 65527; + + fn init(mtu: u16) -> Init { + Init { + now: Instant::ZERO, + mtu, + rtt: Duration::from_millis(100), + seed: 0, + } + } + + /// The window holds two datagrams at the path MTU (RFC 9002 section 7.2's minimum), or the + /// transport could never send its first one. + #[test] + fn window_holds_two_datagrams_at_large_mtu() { + let factories: [(&str, Arc); 2] = [ + ("gcc", Arc::new(gcc::Config::default())), + ("scream", Arc::new(scream::Config::default())), + ]; + let floor = 2 * u64::from(MTU); + for (name, factory) in factories { + let window = factory.clone().build(init(MTU)).window(); + assert!(window >= floor, "{name} starts at {window}"); + + let mut controller = factory.build(init(1200)); + controller.on_mtu_update(MTU); + let window = controller.window(); + assert!(window >= floor, "{name} grows its MTU to {window}"); + } + } +} diff --git a/rs/moq-congestion/src/scream.rs b/rs/moq-congestion-lab/src/scream.rs similarity index 99% rename from rs/moq-congestion/src/scream.rs rename to rs/moq-congestion-lab/src/scream.rs index c34b10745b1..597091e0a39 100644 --- a/rs/moq-congestion/src/scream.rs +++ b/rs/moq-congestion-lab/src/scream.rs @@ -16,9 +16,10 @@ use std::sync::Arc; -use crate::pacer::{Pacer, Rate}; -use crate::{Ack, Ce, Controller, Factory, Init, Loss, Metrics, Packet, Sent}; -use crate::{Duration, Instant}; +use moq_congestion::pacer::{Pacer, Rate}; +use moq_congestion::{Ack, Ce, Controller, Factory, Init, Loss, Metrics, Packet, Sent}; +use kio::clock::Instant; +use std::time::Duration; /// equivalent to MIN_REF_WND: the smallest reference window, in bytes const MIN_REF_WND: f64 = 3000.0; @@ -578,7 +579,7 @@ mod tests { use std::collections::VecDeque; use super::*; - use crate::{Acked, Lost}; + use moq_congestion::{Acked, Lost}; const MTU: u16 = 1200; const PROPAGATION: Duration = Duration::from_millis(20); diff --git a/rs/moq-congestion/Cargo.toml b/rs/moq-congestion/Cargo.toml index 796c6f4f092..2c2027a10b7 100644 --- a/rs/moq-congestion/Cargo.toml +++ b/rs/moq-congestion/Cargo.toml @@ -5,13 +5,12 @@ version = "0.1.0" edition = "2024" rust-version.workspace = true repository = "https://github.com/moq-dev/moq" -license = "(MIT OR Apache-2.0) AND BSD-3-Clause" +license = "MIT OR Apache-2.0" [dependencies] kio = { workspace = true } rand = { workspace = true } rand_pcg = { workspace = true } -tracing = { workspace = true } [dev-dependencies] cpu-time = "1.0.0" diff --git a/rs/moq-congestion/README.md b/rs/moq-congestion/README.md index 554851e0397..9de1b9da965 100644 --- a/rs/moq-congestion/README.md +++ b/rs/moq-congestion/README.md @@ -1,16 +1,14 @@ # moq-congestion -BBR3, Cubic, GCC, SCReAMv2, and Unlimited congestion controllers, consumed by moq-quic and the native transport drivers. +BBR3, Cubic, and Unlimited congestion controllers, consumed by moq-quic and the native transport drivers. Applications pick one through `moq_tokio::quic::CongestionControl`, where `delay` is BBR3 and the default. -BBR3's optional delay bound (`bbr3::Config::delay_bound`) reads the peer's receive timestamps and brakes when the forward delay's trend shows the bottleneck queue growing. +Candidates still under test stay off the published API: GCC and SCReAMv2 live in the workspace-only [moq-congestion-lab](../moq-congestion-lab), and BBR3's delay bound, which brakes when the peer's receive timestamps show the bottleneck queue growing, has a hidden setter. A winner joins `CongestionControl` as a new variant, or BBR3 as an option. The controllers take explicit `kio::clock::Instant` values and never drive a runtime. The `Controller` trait names no transport types: `on_sent` returns an opaque per-packet state that the transport stores and hands back with each acknowledgement or loss, and the controller paces its own sends. -Construct controllers with `Factory::build` on an `Arc`, `Arc`, `Arc`, `Arc`, or `Arc`. `Unlimited` and `Metrics` live at the crate root, and `gcc::Gcc` and `scream::Scream` in their modules. +Construct controllers with `Factory::build` on an `Arc`, `Arc`, or `Arc`. `Unlimited` and `Metrics` live at the crate root. -The code was extracted from [moq-quic](../moq-quic), under the same MIT or Apache-2.0 license. Cubic originated in quinn; BBR3 was ported from moq-dev/noq and carries the fixes listed in [moq-quic's fork history](../moq-quic/README.md). SCReAMv2's delay-based path was ported from draft-ietf-ccwg-rfc8298bis-screamv2 and checked against Ericsson's [reference implementation](https://github.com/EricssonResearch/scream). - -GCC is libwebrtc's Google Congestion Control, a delay-based controller that reads the peer's receive timestamps (draft-ietf-quic-receive-ts). `src/gcc` vendors a Rust port of WebRTC's `goog_cc` under WebRTC's BSD license, kept in [`src/gcc/LICENSE`](src/gcc/LICENSE) with its `PATENTS` grant; its module docs record the WebRTC revision it tracks and what it trims. +The code was extracted from [moq-quic](../moq-quic), under the same MIT or Apache-2.0 license. Cubic originated in quinn; BBR3 was ported from moq-dev/noq and carries the fixes listed in [moq-quic's fork history](../moq-quic/README.md). Controller tests run with `just rs test -p moq-congestion`. The per-packet benchmark runs nightly, or locally with: diff --git a/rs/moq-congestion/src/bbr3/mod.rs b/rs/moq-congestion/src/bbr3/mod.rs index e6c965b22b5..6c61e4f8404 100644 --- a/rs/moq-congestion/src/bbr3/mod.rs +++ b/rs/moq-congestion/src/bbr3/mod.rs @@ -2145,6 +2145,9 @@ impl Config { /// /// Without receive timestamps, which the transport requests separately, it does nothing. /// Off by default. + /// + /// Not public API until the realtime bake-off tests it: hidden, and changed in any release. + #[doc(hidden)] pub fn delay_bound(&mut self, value: bool) -> &mut Self { self.delay_bound = value; self diff --git a/rs/moq-congestion/src/lib.rs b/rs/moq-congestion/src/lib.rs index 2eb84820a90..ed60d528767 100644 --- a/rs/moq-congestion/src/lib.rs +++ b/rs/moq-congestion/src/lib.rs @@ -14,10 +14,11 @@ use std::sync::Arc; pub mod bbr3; /// CUBIC congestion control. pub mod cubic; -pub mod gcc; -mod pacer; +/// Not public API: the token-bucket pacer, shared with the workspace's candidate controllers until +/// it is published, and changed in any release. +#[doc(hidden)] +pub mod pacer; mod rate; -pub mod scream; mod unlimited; pub use rate::Packet; @@ -282,12 +283,10 @@ mod tests { /// The largest UDP payload (RFC 9000), whose two datagrams outgrow every 1200-based default const MTU: u16 = 65527; - fn factories() -> [(&'static str, Arc); 5] { + fn factories() -> [(&'static str, Arc); 3] { [ ("bbr3", Arc::new(bbr3::Config::default())), ("cubic", Arc::new(cubic::Config::default())), - ("gcc", Arc::new(gcc::Config::default())), - ("scream", Arc::new(scream::Config::default())), ("unlimited", Arc::new(Unlimited)), ] } diff --git a/rs/moq-congestion/src/pacer.rs b/rs/moq-congestion/src/pacer.rs index 85b3ea21104..caa14c15817 100644 --- a/rs/moq-congestion/src/pacer.rs +++ b/rs/moq-congestion/src/pacer.rs @@ -12,7 +12,7 @@ use std::time::Duration; /// than one congestion window per RTT, as recommended in /// #[derive(Debug, Clone)] -pub(crate) struct Pacer { +pub struct Pacer { capacity: u64, /// Inputs [`Self::capacity`] was derived from, or `None` if it was derived from a pacing rate last_window_inputs: Option, @@ -35,7 +35,7 @@ struct WindowInputs { impl Pacer { /// Obtains a new [`Pacer`]. - pub(crate) fn new(smoothed_rtt: Duration, window: u64, mtu: u16, now: Instant) -> Self { + pub fn new(smoothed_rtt: Duration, window: u64, mtu: u16, now: Instant) -> Self { let capacity = optimal_capacity(smoothed_rtt, window, mtu); Self { capacity, @@ -47,7 +47,7 @@ impl Pacer { } /// Record that a packet has been transmitted. - pub(crate) fn on_transmit(&mut self, packet_length: u16) { + pub fn on_transmit(&mut self, packet_length: u16) { let bytes = u64::from(packet_length); let spent = bytes.min(self.tokens); self.tokens -= spent; @@ -74,7 +74,7 @@ impl Pacer { /// The 5/4 ratio used here comes from the suggestion that N = 1.25 in the draft IETF RFC for /// QUIC. /// `rate` is the controller output the bucket refills at; see [`Rate`]. - pub(crate) fn delay( + pub fn delay( &mut self, smoothed_rtt: Duration, bytes_to_send: u64, @@ -206,7 +206,7 @@ impl Pacer { /// The controller output a [`Pacer`] refills at. #[derive(Debug, Clone, Copy)] -pub(crate) struct Rate { +pub struct Rate { /// Congestion window in bytes. Without a `pacing_rate`, the bucket refills at one window per /// smoothed RTT, sped up by 5/4. pub window: u64, @@ -220,7 +220,7 @@ pub(crate) struct Rate { /// Burst intervals trade distributing datagrams over time against waking the connection up more /// often than user-space timer accuracy can service; overshooting one by more than 25% loses the /// tokens for the extra elapsed time. -pub(crate) fn rate_capacity(pacing_rate: u64, mtu: u16) -> u64 { +pub fn rate_capacity(pacing_rate: u64, mtu: u16) -> u64 { let mtu = u64::from(mtu); let bytes_in = |interval: Duration| ((pacing_rate as u128 * interval.as_nanos()) / 1_000_000_000) as u64; diff --git a/rs/moq-congestion/src/rate.rs b/rs/moq-congestion/src/rate.rs index 34dd7a47461..a3d4e5ddc1f 100644 --- a/rs/moq-congestion/src/rate.rs +++ b/rs/moq-congestion/src/rate.rs @@ -34,7 +34,10 @@ pub struct Packet { /// The GCC probe cluster it was sent in, if any. Sixteen bits fit the padding after the /// fields above. GoogCC's clusters and the prober's restarts each wrap within half of them, /// far more than either starts in the two seconds a cluster is kept. - pub(crate) probe_cluster: Option, + /// + /// Not public API: GCC is a candidate outside this crate, and the field may go in any release. + #[doc(hidden)] + pub probe_cluster: Option, } /// An empty state, for a controller that keeps none. diff --git a/rs/moq-ffi/src/session.rs b/rs/moq-ffi/src/session.rs index 74ff7cf0ee2..65aa3c4c3ae 100644 --- a/rs/moq-ffi/src/session.rs +++ b/rs/moq-ffi/src/session.rs @@ -129,7 +129,7 @@ pub struct MoqQuicConfig { pub mtu_discovery: Option, /// The congestion control family. #[uniffi(default = None)] - pub congestion_control: Option, + pub congestion_control: Option>, /// Directory, which must exist, to write qlog traces into. Fails `new` unless /// [`moq_qlog_supported`]. #[uniffi(default = None)] @@ -141,23 +141,32 @@ pub struct MoqQuicConfig { } /// The congestion control family for a QUIC connection. -#[derive(Clone, Copy, Debug, PartialEq, Eq, uniffi::Enum)] -pub enum MoqCongestionControl { +/// +/// An immutable object rather than an enum, so a new algorithm joins as a constructor without +/// breaking callers that switch over a closed enum. +#[derive(Debug, PartialEq, Eq, Hash, uniffi::Object)] +#[uniffi::export(Debug, Eq, Hash)] +pub struct MoqCongestionControl(moq_tokio::quic::CongestionControl); + +#[uniffi::export] +impl MoqCongestionControl { /// Loss-based (CUBIC): chases throughput, so the send rate sawtooths. - Loss, - /// Delay-based (BBR): keeps queues short and the send rate steady enough for an encoder to track. - Delay, - /// No congestion control and no pacing, for tests and controlled links. - None, -} + #[uniffi::constructor] + pub fn loss() -> Arc { + Arc::new(Self(moq_tokio::quic::CongestionControl::Loss)) + } -impl From for moq_tokio::quic::CongestionControl { - fn from(family: MoqCongestionControl) -> Self { - match family { - MoqCongestionControl::Loss => Self::Loss, - MoqCongestionControl::Delay => Self::Delay, - MoqCongestionControl::None => Self::None, - } + /// Delay-based (BBR v3), the default: keeps queues short and the send rate steady enough for + /// an encoder to track. + #[uniffi::constructor] + pub fn delay() -> Arc { + Arc::new(Self(moq_tokio::quic::CongestionControl::Delay)) + } + + /// No congestion control and no pacing, for tests and controlled links. + #[uniffi::constructor] + pub fn none() -> Arc { + Arc::new(Self(moq_tokio::quic::CongestionControl::None)) } } @@ -169,7 +178,7 @@ impl From for moq_tokio::quic::Config { quic.keep_alive = config.keep_alive.map(Into::into); quic.gso = config.gso; quic.mtu_discovery = config.mtu_discovery; - quic.congestion_control = config.congestion_control.map(Into::into); + quic.congestion_control = config.congestion_control.map(|family| family.0); quic.qlog = config.qlog.map(Into::into); quic.keylog = config .keylog diff --git a/rs/moq-ffi/src/test.rs b/rs/moq-ffi/src/test.rs index 3bb602ae61a..f3d7841d42b 100644 --- a/rs/moq-ffi/src/test.rs +++ b/rs/moq-ffi/src/test.rs @@ -6849,7 +6849,7 @@ async fn client_connects_with_every_knob_set() { keep_alive: Some(Duration::ZERO), gso: Some(false), mtu_discovery: Some(true), - congestion_control: Some(MoqCongestionControl::Loss), + congestion_control: Some(MoqCongestionControl::loss()), qlog: None, keylog: Some(false), }, diff --git a/rs/moq-ffi/src/test/rung.rs b/rs/moq-ffi/src/test/rung.rs index 7b7168ecad7..d2add590e7e 100644 --- a/rs/moq-ffi/src/test/rung.rs +++ b/rs/moq-ffi/src/test/rung.rs @@ -46,7 +46,7 @@ async fn shaped_uplink_disables_and_resumes() { tls: insecure_tls(), once: true, quic: MoqQuicConfig { - congestion_control: Some(MoqCongestionControl::Delay), + congestion_control: Some(MoqCongestionControl::delay()), ..Default::default() }, websocket: MoqWebSocketConfig { diff --git a/rs/moq-quic/Cargo.toml b/rs/moq-quic/Cargo.toml index 02b815f3dae..d65492f8093 100644 --- a/rs/moq-quic/Cargo.toml +++ b/rs/moq-quic/Cargo.toml @@ -57,6 +57,8 @@ criterion = { package = "bench-harness", path = "../bench-harness" } hex-literal = "1" # The tests and benches read time through the runtime, as the drivers do. kio = { path = "../kio", features = ["runtime", "sim"] } +# The candidate controllers the simulated comparisons run. +moq-congestion-lab = { path = "../moq-congestion-lab" } # The mux module's tests run in the default merge gate. moq-quic = { path = ".", features = ["mux"] } proptest = { workspace = true } diff --git a/rs/moq-quic/src/tests/probe.rs b/rs/moq-quic/src/tests/probe.rs index 388d48dc76f..9640eb49440 100644 --- a/rs/moq-quic/src/tests/probe.rs +++ b/rs/moq-quic/src/tests/probe.rs @@ -18,7 +18,8 @@ use rand::{RngExt, SeedableRng}; use rand_pcg::Pcg32; use super::*; -use crate::congestion::{bbr3, cubic, gcc}; +use crate::congestion::{bbr3, cubic}; +use moq_congestion_lab::gcc; /// The media's usual bitrate, 2 Mbit/s, which the probe has to see past const MEDIA: u64 = 250_000; diff --git a/rs/moq-quic/src/tests/scream.rs b/rs/moq-quic/src/tests/scream.rs index 8c7ec9d444d..fe8d74865f1 100644 --- a/rs/moq-quic/src/tests/scream.rs +++ b/rs/moq-quic/src/tests/scream.rs @@ -1,4 +1,4 @@ -//! SCReAMv2 ([`congestion::scream::Scream`]) on the seeded sim: an encoder that follows the controller's +//! SCReAMv2 ([`scream::Scream`]) on the seeded sim: an encoder that follows the controller's //! estimate sends up through a bottleneck shaped like each cellular moq-shaper preset, and the run //! reports the queue it built, what it carried, and how fast it answered each step. //! @@ -11,7 +11,8 @@ use std::collections::HashMap; use super::*; -use crate::congestion::{bbr3, scream}; +use crate::congestion::bbr3; +use moq_congestion_lab::scream; const FPS: u64 = 30; /// Frames per group, each group on its own stream: a keyframe every two seconds diff --git a/rs/moq-tokio/Cargo.toml b/rs/moq-tokio/Cargo.toml index 0bec7dc2878..2f1fed0ddfb 100644 --- a/rs/moq-tokio/Cargo.toml +++ b/rs/moq-tokio/Cargo.toml @@ -132,6 +132,8 @@ flume = "0.12" kio = { path = "../kio", features = ["sim"] } # The integration tests build congestion controllers directly. moq-congestion = { path = "../moq-congestion" } +# The candidate controllers the real-socket comparisons run. +moq-congestion-lab = { path = "../moq-congestion-lab" } # A bufferbloated path for the receive-credit tests and benchmark. moq-shaper = { path = "../moq-shaper" } # The tests run QUIC sessions on the simulator. Only `sim`, so a test build keeps the diff --git a/rs/moq-tokio/src/quic.rs b/rs/moq-tokio/src/quic.rs index 9ca9eefd766..1187f45c2b5 100644 --- a/rs/moq-tokio/src/quic.rs +++ b/rs/moq-tokio/src/quic.rs @@ -99,8 +99,9 @@ impl std::fmt::Debug for Controller { /// The congestion control family for a QUIC connection. /// -/// CUBIC is used for loss-based control and BBRv3 for delay-based control. -#[derive(Clone, Copy, Debug, PartialEq, Eq, usage_rs::ValueEnum, serde::Serialize, serde::Deserialize)] +/// CUBIC is used for loss-based control and BBR v3 for delay-based control, the default. A new +/// algorithm joins as a variant named after it. +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, usage_rs::ValueEnum, serde::Serialize, serde::Deserialize)] #[usage(ignore_case)] #[serde(rename_all = "kebab-case")] #[non_exhaustive] @@ -108,7 +109,7 @@ pub enum CongestionControl { /// Loss-based (CUBIC): grows until it drops packets, so the send rate sawtooths. /// Throughput-oriented, and the default on most stacks. Loss, - /// Delay-based (BBR): tracks the measured delivery rate and RTT instead of waiting + /// Delay-based (BBR v3): tracks the measured delivery rate and RTT instead of waiting /// for loss, which keeps queues short and the send rate steady enough for an encoder /// to track. Delay, diff --git a/rs/moq-tokio/tests/integration/scream.rs b/rs/moq-tokio/tests/integration/scream.rs index 5878bfecead..29af29e98c7 100644 --- a/rs/moq-tokio/tests/integration/scream.rs +++ b/rs/moq-tokio/tests/integration/scream.rs @@ -1,4 +1,4 @@ -//! SCReAMv2 ([`congestion::scream::Scream`]) over real sockets through the cellular moq-shaper presets. +//! SCReAMv2 ([`moq_congestion_lab::scream::Scream`]) over real sockets through the cellular moq-shaper presets. //! //! A media sender encodes 30 frames a second at the controller's estimate, a keyframe every two //! seconds, each group on its own stream, up through the shaper's uplink. Each frame carries when @@ -221,7 +221,7 @@ async fn run(preset: &moq_shaper::Preset) -> Run { .with_no_client_auth(); let mut client = driver::client::Config::new(Arc::new(tls)); client.transport.congestion = Arc::new(Recorder { - inner: Arc::new(congestion::scream::Config::default()), + inner: Arc::new(moq_congestion_lab::scream::Config::default()), log: log.clone(), }); client.transport.receive_timestamps = std::num::NonZeroU32::new(32); diff --git a/swift/Sources/Moq/Aliases.swift b/swift/Sources/Moq/Aliases.swift index 9bc378d9fa1..abb5bf3154c 100644 --- a/swift/Sources/Moq/Aliases.swift +++ b/swift/Sources/Moq/Aliases.swift @@ -104,7 +104,8 @@ public typealias ServerTls = MoqFFI.MoqServerTls /// QUIC transport tuning, such as the peer's inbound stream cap. public typealias QuicConfig = MoqFFI.MoqQuicConfig -/// The congestion control family for a QUIC connection. +/// The congestion control family for a QUIC connection. Build one with `CongestionControl.delay()`, +/// `.loss()`, or `.none()`; a new algorithm joins as a new constructor. public typealias CongestionControl = MoqFFI.MoqCongestionControl /// The WebSocket fallback raced against QUIC: whether it runs and QUIC's head start. From 4a11ed3059270981cb1e3eb8c9a473db7cddae79 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 15 Nov 2026 07:05:50 -0800 Subject: [PATCH 3/5] fix(congestion): expose the candidates' needs through a lab test-support feature doc(hidden) is banned, so the pacer, a packet's GCC probe cluster, and BBR3's delay bound sit behind moq-congestion's documented lab feature, as test support does elsewhere. Co-Authored-By: Claude Opus 5.5 --- go/wrapper/client.go | 4 ++-- go/wrapper/origin.go | 8 ++++---- quest/m4/quic-realtime.md | 4 ++-- rs/moq-congestion-lab/.rustfmt.toml | 2 ++ rs/moq-congestion-lab/Cargo.toml | 2 +- rs/moq-congestion-lab/src/gcc/bench.rs | 2 +- rs/moq-congestion-lab/src/gcc/mod.rs | 14 +++++++------- rs/moq-congestion-lab/src/lib.rs | 2 -- rs/moq-congestion-lab/src/scream.rs | 2 +- rs/moq-congestion/Cargo.toml | 6 ++++++ rs/moq-congestion/README.md | 2 +- rs/moq-congestion/src/bbr3/mod.rs | 5 +++-- rs/moq-congestion/src/lib.rs | 8 +++++--- rs/moq-congestion/src/rate.rs | 23 +++++++++++++++++++---- rs/moq-quic/Cargo.toml | 3 ++- 15 files changed, 56 insertions(+), 31 deletions(-) create mode 100644 rs/moq-congestion-lab/.rustfmt.toml diff --git a/go/wrapper/client.go b/go/wrapper/client.go index 9b76bbb1c68..1bb3b43fca5 100644 --- a/go/wrapper/client.go +++ b/go/wrapper/client.go @@ -105,7 +105,7 @@ type QUICConfig struct { GSO *bool // MTUDiscovery toggles path MTU discovery. MTUDiscovery *bool - // CongestionControl picks the congestion control family. + // CongestionControl picks the congestion control family; nil leaves the choice to the backend. CongestionControl *CongestionControl // Qlog is a directory, which must exist, to write qlog traces into. Dial // fails unless QlogSupported. @@ -185,7 +185,7 @@ func (c ClientConfig) ffi() (ffi.MoqClientConfig, error) { KeepAlive: c.QUIC.KeepAlive, Gso: c.QUIC.GSO, MtuDiscovery: c.QUIC.MTUDiscovery, - CongestionControl: c.QUIC.CongestionControl, + CongestionControl: optional(c.QUIC.CongestionControl), Qlog: str(c.QUIC.Qlog), Keylog: keylog, }, diff --git a/go/wrapper/origin.go b/go/wrapper/origin.go index a70b7c559a4..6fdb7d8f3e8 100644 --- a/go/wrapper/origin.go +++ b/go/wrapper/origin.go @@ -57,12 +57,12 @@ func (o RouteOptions) ffi() ffi.MoqRouteOptions { return ffi.MoqRouteOptions{Hidden: o.Hidden, Cost: o.Cost, Instance: optional(o.Instance), Epoch: o.Epoch} } -// optional lowers a nil instance to the ffi's None. -func optional(instance *Instance) **ffi.MoqInstance { - if instance == nil { +// optional lowers a nil ffi object to the ffi's None. +func optional[T any](object *T) **T { + if object == nil { return nil } - return &instance + return &object } // Route creates a route at exactly path, owning a new broadcast to fill. diff --git a/quest/m4/quic-realtime.md b/quest/m4/quic-realtime.md index aa4e1c743cc..82b704a709f 100644 --- a/quest/m4/quic-realtime.md +++ b/quest/m4/quic-realtime.md @@ -37,8 +37,8 @@ spike assumed no consumer; teleoperation uplinks are one): fitting a trend, as GoogCC does. Reproduce it with `just rs quic-sim`. - Bake-off: all three candidates in parallel, each a controller in the workspace-only `moq-congestion-lab` (the delay bound stays in - `moq-congestion`'s `bbr3/`, its setter hidden); a winner moves into - `moq-congestion`. The moq-shaper presets `cellular-step`, + `moq-congestion`'s `bbr3/`, its setter behind the `lab` test-support + feature); a winner moves into `moq-congestion`. The moq-shaper presets `cellular-step`, `cellular-bursty` and `cellular-deep` decide it. The report states the shaper's timing jitter, measured over `near-zero`, as the noise floor of the delay signal. The BBR3 delay bound (`bbr3::Config::delay_bound`) brought diff --git a/rs/moq-congestion-lab/.rustfmt.toml b/rs/moq-congestion-lab/.rustfmt.toml new file mode 100644 index 00000000000..253a4108eb9 --- /dev/null +++ b/rs/moq-congestion-lab/.rustfmt.toml @@ -0,0 +1,2 @@ +# rustfmt defaults rather than the root .rustfmt.toml, as in moq-congestion, so a candidate +# moves between the two crates without whitespace churn. diff --git a/rs/moq-congestion-lab/Cargo.toml b/rs/moq-congestion-lab/Cargo.toml index 68c03346f98..edb95fb5474 100644 --- a/rs/moq-congestion-lab/Cargo.toml +++ b/rs/moq-congestion-lab/Cargo.toml @@ -10,7 +10,7 @@ publish = false [dependencies] kio = { workspace = true } -moq-congestion = { workspace = true } +moq-congestion = { workspace = true, features = ["lab"] } tracing = { workspace = true } [dev-dependencies] diff --git a/rs/moq-congestion-lab/src/gcc/bench.rs b/rs/moq-congestion-lab/src/gcc/bench.rs index f67ff1f0f6e..670cc136d4f 100644 --- a/rs/moq-congestion-lab/src/gcc/bench.rs +++ b/rs/moq-congestion-lab/src/gcc/bench.rs @@ -2,8 +2,8 @@ //! so its cost grows with the packets each ACK carries. use super::*; -use moq_congestion::Acked; use cpu_time::ThreadTime; +use moq_congestion::Acked; const PACKET: u16 = 1200; diff --git a/rs/moq-congestion-lab/src/gcc/mod.rs b/rs/moq-congestion-lab/src/gcc/mod.rs index e4aba8578d8..6aab6ce0be2 100644 --- a/rs/moq-congestion-lab/src/gcc/mod.rs +++ b/rs/moq-congestion-lab/src/gcc/mod.rs @@ -77,10 +77,6 @@ use std::{collections::VecDeque, num::NonZeroU16, sync::Arc, time::Duration}; use kio::clock::Instant; -use moq_congestion::{ - Ack, Ce, Controller, Factory, Init, Loss, Metrics, Packet, Sent, - pacer::{self, Pacer, Rate}, -}; use api::{ transport::{ NetworkAvailability, NetworkControlUpdate, PacedPacketInfo, PacerConfig, PacketResult, @@ -89,6 +85,10 @@ use api::{ }, units::{DataRate, DataSize, TimeDelta, Timestamp}, }; +use moq_congestion::{ + Ack, Ce, Controller, Factory, Init, Loss, Metrics, Packet, Sent, + pacer::{self, Pacer, Rate}, +}; use pacing::BitrateProber; /// How often GoogCC expects its process timer, as `GetProcessInterval` @@ -288,7 +288,7 @@ impl Gcc { sent_packet: SentPacket { send_time: timestamp(packet.sent), size: DataSize::from_bytes(packet.bytes.into()), - pacing_info: self.cluster(packet.packet.probe_cluster), + pacing_info: self.cluster(packet.packet.probe_cluster()), data_in_flight: DataSize::zero(), }, receive_time, @@ -384,7 +384,7 @@ impl Controller for Gcc { }); self.apply(update); let mut packet = Packet::default(); - packet.probe_cluster = probe_cluster; + packet.set_probe_cluster(probe_cluster); packet } @@ -421,7 +421,7 @@ impl Controller for Gcc { sent_packet: SentPacket { send_time: timestamp(packet.sent), size: DataSize::from_bytes(packet.bytes.into()), - pacing_info: self.cluster(packet.packet.probe_cluster), + pacing_info: self.cluster(packet.packet.probe_cluster()), data_in_flight: DataSize::zero(), }, receive_time: Timestamp::plus_infinity(), diff --git a/rs/moq-congestion-lab/src/lib.rs b/rs/moq-congestion-lab/src/lib.rs index ab69a0e4d1a..3023109f226 100644 --- a/rs/moq-congestion-lab/src/lib.rs +++ b/rs/moq-congestion-lab/src/lib.rs @@ -4,9 +4,7 @@ //! comparisons in moq-quic and moq-tokio drive it like any other. A winner graduates into //! moq-congestion and joins `moq_tokio::quic::CongestionControl` as a new variant. -/// libwebrtc's Google Congestion Control (GoogCC). pub mod gcc; -/// SCReAMv2's delay-based congestion control. pub mod scream; #[cfg(test)] diff --git a/rs/moq-congestion-lab/src/scream.rs b/rs/moq-congestion-lab/src/scream.rs index 597091e0a39..d47bdfe963e 100644 --- a/rs/moq-congestion-lab/src/scream.rs +++ b/rs/moq-congestion-lab/src/scream.rs @@ -16,9 +16,9 @@ use std::sync::Arc; +use kio::clock::Instant; use moq_congestion::pacer::{Pacer, Rate}; use moq_congestion::{Ack, Ce, Controller, Factory, Init, Loss, Metrics, Packet, Sent}; -use kio::clock::Instant; use std::time::Duration; /// equivalent to MIN_REF_WND: the smallest reference window, in bytes diff --git a/rs/moq-congestion/Cargo.toml b/rs/moq-congestion/Cargo.toml index 2c2027a10b7..6b3318b7808 100644 --- a/rs/moq-congestion/Cargo.toml +++ b/rs/moq-congestion/Cargo.toml @@ -7,6 +7,12 @@ rust-version.workspace = true repository = "https://github.com/moq-dev/moq" license = "MIT OR Apache-2.0" +[features] +# Test support for the workspace-only moq-congestion-lab and the comparisons that run its +# candidates: the pacer, a packet's GCC probe cluster, and BBR3's delay bound. Meant for +# dev-dependencies; not for applications. +lab = [] + [dependencies] kio = { workspace = true } rand = { workspace = true } diff --git a/rs/moq-congestion/README.md b/rs/moq-congestion/README.md index 9de1b9da965..b4109ca0249 100644 --- a/rs/moq-congestion/README.md +++ b/rs/moq-congestion/README.md @@ -2,7 +2,7 @@ BBR3, Cubic, and Unlimited congestion controllers, consumed by moq-quic and the native transport drivers. Applications pick one through `moq_tokio::quic::CongestionControl`, where `delay` is BBR3 and the default. -Candidates still under test stay off the published API: GCC and SCReAMv2 live in the workspace-only [moq-congestion-lab](../moq-congestion-lab), and BBR3's delay bound, which brakes when the peer's receive timestamps show the bottleneck queue growing, has a hidden setter. A winner joins `CongestionControl` as a new variant, or BBR3 as an option. +Candidates still under test stay off the published API: GCC and SCReAMv2 live in the workspace-only [moq-congestion-lab](../moq-congestion-lab), and BBR3's delay bound, which brakes when the peer's receive timestamps show the bottleneck queue growing, is settable only with the `lab` test-support feature those comparisons enable. A winner joins `CongestionControl` as a new variant, or BBR3 as an option. The controllers take explicit `kio::clock::Instant` values and never drive a runtime. The `Controller` trait names no transport types: `on_sent` returns an opaque per-packet state that the transport stores and hands back with each acknowledgement or loss, and the controller paces its own sends. diff --git a/rs/moq-congestion/src/bbr3/mod.rs b/rs/moq-congestion/src/bbr3/mod.rs index 6c61e4f8404..534b6dc4738 100644 --- a/rs/moq-congestion/src/bbr3/mod.rs +++ b/rs/moq-congestion/src/bbr3/mod.rs @@ -2146,8 +2146,9 @@ impl Config { /// Without receive timestamps, which the transport requests separately, it does nothing. /// Off by default. /// - /// Not public API until the realtime bake-off tests it: hidden, and changed in any release. - #[doc(hidden)] + /// Test support, enabled by the `lab` feature, until the realtime bake-off decides whether it + /// ships. + #[cfg(any(test, feature = "lab"))] pub fn delay_bound(&mut self, value: bool) -> &mut Self { self.delay_bound = value; self diff --git a/rs/moq-congestion/src/lib.rs b/rs/moq-congestion/src/lib.rs index ed60d528767..5222bdd1a69 100644 --- a/rs/moq-congestion/src/lib.rs +++ b/rs/moq-congestion/src/lib.rs @@ -14,10 +14,12 @@ use std::sync::Arc; pub mod bbr3; /// CUBIC congestion control. pub mod cubic; -/// Not public API: the token-bucket pacer, shared with the workspace's candidate controllers until -/// it is published, and changed in any release. -#[doc(hidden)] +/// Test support, enabled by the `lab` feature: the token-bucket pacer the candidate controllers +/// share. +#[cfg(feature = "lab")] pub mod pacer; +#[cfg(not(feature = "lab"))] +mod pacer; mod rate; mod unlimited; diff --git a/rs/moq-congestion/src/rate.rs b/rs/moq-congestion/src/rate.rs index a3d4e5ddc1f..43fd732cd82 100644 --- a/rs/moq-congestion/src/rate.rs +++ b/rs/moq-congestion/src/rate.rs @@ -6,6 +6,7 @@ //! use kio::clock::Instant; +#[cfg(feature = "lab")] use std::num::NonZeroU16; use std::time::Duration; @@ -34,10 +35,22 @@ pub struct Packet { /// The GCC probe cluster it was sent in, if any. Sixteen bits fit the padding after the /// fields above. GoogCC's clusters and the prober's restarts each wrap within half of them, /// far more than either starts in the two seconds a cluster is kept. - /// - /// Not public API: GCC is a candidate outside this crate, and the field may go in any release. - #[doc(hidden)] - pub probe_cluster: Option, + #[cfg(feature = "lab")] + probe_cluster: Option, +} + +/// Test support, enabled by the `lab` feature, for the GCC candidate in moq-congestion-lab. +#[cfg(feature = "lab")] +impl Packet { + /// The GCC probe cluster the packet was sent in, if any. + pub fn probe_cluster(&self) -> Option { + self.probe_cluster + } + + /// Records the GCC probe cluster the packet was sent in. + pub fn set_probe_cluster(&mut self, cluster: Option) { + self.probe_cluster = cluster; + } } /// An empty state, for a controller that keeps none. @@ -50,6 +63,7 @@ impl Default for Packet { lost: 0, tx_in_flight: 0, is_app_limited: false, + #[cfg(feature = "lab")] probe_cluster: None, } } @@ -124,6 +138,7 @@ impl Sampler { lost: self.lost, tx_in_flight: sent.in_flight.try_into().unwrap_or(u32::MAX), is_app_limited: self.app_limited != 0, + #[cfg(feature = "lab")] probe_cluster: None, } } diff --git a/rs/moq-quic/Cargo.toml b/rs/moq-quic/Cargo.toml index d65492f8093..277d7e915ad 100644 --- a/rs/moq-quic/Cargo.toml +++ b/rs/moq-quic/Cargo.toml @@ -57,7 +57,8 @@ criterion = { package = "bench-harness", path = "../bench-harness" } hex-literal = "1" # The tests and benches read time through the runtime, as the drivers do. kio = { path = "../kio", features = ["runtime", "sim"] } -# The candidate controllers the simulated comparisons run. +# The candidate controllers the simulated comparisons run, and through moq-congestion's +# `lab` feature, BBR3's delay bound. moq-congestion-lab = { path = "../moq-congestion-lab" } # The mux module's tests run in the default merge gate. moq-quic = { path = ".", features = ["mux"] } From 7678090ec44e470fe0cd423a2a9544946855c673 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 15 Nov 2026 07:09:16 -0800 Subject: [PATCH 4/5] fix(congestion): OBS, nightly benchmarks, hakari, and Cargo.nix follow the move Co-Authored-By: Claude Opus 5.5 --- Cargo.lock | 1 + cpp/obs/src/moq-settings.cpp | 4 ++-- cpp/obs/test/moq-settings-test.cpp | 3 ++- nix/Cargo.nix | 13 ++++++++++++- rs/workspace-hack/Cargo.toml | 2 ++ sh/gh/nightly.sh | 2 +- 6 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 952b3ea5b7f..f3b51f4c01f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10469,6 +10469,7 @@ dependencies = [ "toml_parser", "tower", "tower-http 0.6.11", + "tracing", "tracing-core", "tracing-subscriber", "tungstenite", diff --git a/cpp/obs/src/moq-settings.cpp b/cpp/obs/src/moq-settings.cpp index 3528bfebc81..1d49245e934 100644 --- a/cpp/obs/src/moq-settings.cpp +++ b/cpp/obs/src/moq-settings.cpp @@ -350,9 +350,9 @@ std::string Configure(obs_data_t *settings, moq::ClientConfig &config) // transport free to pick. if (const char *family = OptionalString(settings, QUIC_CONGESTION_CONTROL)) { if (strcmp(family, "delay") == 0) - config.quic.congestion_control = moq::CongestionControl::kDelay; + config.quic.congestion_control = moq::CongestionControl::delay(); else if (strcmp(family, "loss") == 0) - config.quic.congestion_control = moq::CongestionControl::kLoss; + config.quic.congestion_control = moq::CongestionControl::loss(); else Refuse(error, std::string("unknown congestion control: ") + family); } diff --git a/cpp/obs/test/moq-settings-test.cpp b/cpp/obs/test/moq-settings-test.cpp index 759160b8aca..47e564c71ed 100644 --- a/cpp/obs/test/moq-settings-test.cpp +++ b/cpp/obs/test/moq-settings-test.cpp @@ -191,7 +191,8 @@ int main() CHECK(config.timeout == std::chrono::milliseconds(7000)); CHECK(config.race == std::chrono::milliseconds(80)); CHECK(config.tls.host_name == std::string("relay.example")); - CHECK(config.quic.congestion_control == moq::CongestionControl::kLoss); + CHECK(config.quic.congestion_control); + CHECK(config.quic.congestion_control->eq(moq::CongestionControl::loss())); CHECK(config.quic.idle_timeout == std::chrono::milliseconds(9000)); CHECK(config.quic.keep_alive == std::chrono::nanoseconds::zero()); CHECK(config.quic.gso == false); diff --git a/nix/Cargo.nix b/nix/Cargo.nix index 906f8799104..f15cc4b7457 100644 --- a/nix/Cargo.nix +++ b/nix/Cargo.nix @@ -18611,7 +18611,9 @@ rec { packageId = "workspace-hack"; } ]; - + features = { + }; + resolvedDefaultFeatures = [ "lab" ]; }; "moq-congestion-lab" = rec { crateName = "moq-congestion-lab"; @@ -18630,6 +18632,7 @@ rec { { name = "moq-congestion"; packageId = "moq-congestion"; + features = [ "lab" ]; } { name = "tracing"; @@ -59721,6 +59724,10 @@ rec { "follow-redirect" ]; } + { + name = "tracing"; + packageId = "tracing"; + } { name = "tracing-core"; packageId = "tracing-core"; @@ -61163,6 +61170,10 @@ rec { "follow-redirect" ]; } + { + name = "tracing"; + packageId = "tracing"; + } { name = "tracing-core"; packageId = "tracing-core"; diff --git a/rs/workspace-hack/Cargo.toml b/rs/workspace-hack/Cargo.toml index 478af714887..694aabaa8b8 100644 --- a/rs/workspace-hack/Cargo.toml +++ b/rs/workspace-hack/Cargo.toml @@ -94,6 +94,7 @@ toml = { version = "1" } toml_datetime = { version = "1", features = ["serde"] } toml_parser = { version = "1" } tower = { version = "0.5", default-features = false, features = ["make", "util"] } +tracing = { version = "0.1" } tracing-core = { version = "0.1" } tracing-subscriber = { version = "0.3", features = ["env-filter", "local-time"] } tungstenite = { version = "0.30", default-features = false, features = ["__rustls-tls", "handshake"] } @@ -183,6 +184,7 @@ toml = { version = "1" } toml_datetime = { version = "1", features = ["serde"] } toml_parser = { version = "1" } tower = { version = "0.5", default-features = false, features = ["make", "util"] } +tracing = { version = "0.1" } tracing-core = { version = "0.1" } tracing-subscriber = { version = "0.3", features = ["env-filter", "local-time"] } tungstenite = { version = "0.30", default-features = false, features = ["__rustls-tls", "handshake"] } diff --git a/sh/gh/nightly.sh b/sh/gh/nightly.sh index 9dc255c6d43..e78a7759773 100755 --- a/sh/gh/nightly.sh +++ b/sh/gh/nightly.sh @@ -95,7 +95,7 @@ case "$1" in rust-test) export NEXTEST_PROFILE=bench NEXTEST_TEST_THREADS=1 nextest just rs bench-tests --no-fail-fast --run-ignored only \ - -p moq-bench -p moq-congestion -p moq-quic -p moq-net -p moq-tokio -p moq-uring \ + -p moq-bench -p moq-congestion -p moq-congestion-lab -p moq-quic -p moq-net -p moq-tokio -p moq-uring \ --features moq-net/async --lib --bin moq-bench --test integration \ -E 'test(benchmark_observation_contention) | test(benchmark_readiness_establishment) | test(benchmark_per_packet) | test(benchmark_feed_fetch_wakes) | test(=mesh_sweep::benchmark_route_mesh) | test(benchmark_route_rules) | test(benchmark_route_churn) | test(benchmark_receive_credit) | test(benchmark_receive_windows) | test(benchmark_datagram_delivery) | test(benchmark_socket_queues)' ;; From 2f2095af793f95e95293665508772917fcc81487 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 15 Nov 2026 12:08:28 -0800 Subject: [PATCH 5/5] refactor(congestion): GCC and SCReAMv2 stay in moq-congestion behind the lab feature The maintainer rejected a separate crate: the candidates are modules of moq-congestion again, compiled only with its `lab` test-support feature, which also gates BBR3's delay-bound setter. The pacer and a packet's probe cluster return to crate-private, the vendored WebRTC files keep their LICENSE and PATENTS beside them, and the license expression covers BSD-3-Clause again. moq-quic's and moq-tokio's comparisons enable `lab` as a dev-dependency, and the nightly GCC benchmark keeps its original series. Co-Authored-By: Claude Opus 5.5 --- Cargo.lock | 12 -- Cargo.toml | 1 - nix/Cargo.nix | 67 +----- quest/m3/vendor-sync/scream.md | 6 +- quest/m3/vendor-sync/webrtc.md | 4 +- quest/m3/webrtc/README.md | 2 +- quest/m4/quic-realtime.md | 17 +- rs/moq-congestion-lab/.rustfmt.toml | 2 - rs/moq-congestion-lab/Cargo.toml | 22 -- rs/moq-congestion-lab/LICENSE-APACHE | 201 ------------------ rs/moq-congestion-lab/LICENSE-MIT | 7 - rs/moq-congestion-lab/README.md | 9 - rs/moq-congestion-lab/src/lib.rs | 50 ----- rs/moq-congestion/Cargo.toml | 10 +- rs/moq-congestion/README.md | 12 +- .../src/gcc/AUTHORS | 0 .../src/gcc/LICENSE | 0 .../src/gcc/PATENTS | 0 .../src/gcc/alr_detector.rs | 0 .../src/gcc/api/mod.rs | 0 .../src/gcc/api/transport/bandwidth_usage.rs | 0 .../src/gcc/api/transport/mod.rs | 0 .../src/gcc/api/transport/network_types.rs | 0 .../src/gcc/api/units/data_rate.rs | 0 .../src/gcc/api/units/data_size.rs | 0 .../src/gcc/api/units/frequency.rs | 0 .../src/gcc/api/units/mod.rs | 0 .../src/gcc/api/units/time_delta.rs | 0 .../src/gcc/api/units/timestamp.rs | 0 .../src/gcc/api/units/unit_base.rs | 0 .../src/gcc/bench.rs | 2 +- .../congestion_window_pushback_controller.rs | 0 .../src/gcc/delay_based_bwe.rs | 0 .../gcc/delay_increase_detector_interface.rs | 0 .../src/gcc/experiments/field_trials.rs | 0 .../src/gcc/experiments/mod.rs | 0 .../src/gcc/experiments/rate_control.rs | 0 .../src/gcc/goog_cc_network_control.rs | 0 .../src/gcc/inter_arrival_delta.rs | 0 .../src/gcc/link_capacity_estimator.rs | 0 .../src/gcc/loss_based_bwe_v2.rs | 0 .../src/gcc/mod.rs | 24 ++- .../src/gcc/pacing/bitrate_prober.rs | 0 .../src/gcc/pacing/interval_budget.rs | 0 .../src/gcc/pacing/mod.rs | 0 .../src/gcc/probe_bitrate_estimator.rs | 0 .../src/gcc/probe_controller.rs | 0 .../aimd_rate_control.rs | 0 .../remote_bitrate_estimator/bwe_defines.rs | 0 .../src/gcc/remote_bitrate_estimator/mod.rs | 0 .../src/gcc/robust_throughput_estimator.rs | 0 .../src/gcc/send_side_bandwidth_estimation.rs | 0 .../src/gcc/tests.rs | 2 +- .../src/gcc/trendline_estimator.rs | 0 rs/moq-congestion/src/lib.rs | 15 +- rs/moq-congestion/src/pacer.rs | 12 +- rs/moq-congestion/src/rate.rs | 16 +- .../src/scream.rs | 12 +- rs/moq-quic/Cargo.toml | 5 +- rs/moq-quic/src/tests/probe.rs | 3 +- rs/moq-quic/src/tests/scream.rs | 5 +- rs/moq-tokio/Cargo.toml | 7 +- rs/moq-tokio/tests/integration/scream.rs | 4 +- sh/gh/nightly.sh | 4 +- 64 files changed, 91 insertions(+), 442 deletions(-) delete mode 100644 rs/moq-congestion-lab/.rustfmt.toml delete mode 100644 rs/moq-congestion-lab/Cargo.toml delete mode 100644 rs/moq-congestion-lab/LICENSE-APACHE delete mode 100644 rs/moq-congestion-lab/LICENSE-MIT delete mode 100644 rs/moq-congestion-lab/README.md delete mode 100644 rs/moq-congestion-lab/src/lib.rs rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/AUTHORS (100%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/LICENSE (100%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/PATENTS (100%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/alr_detector.rs (100%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/api/mod.rs (100%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/api/transport/bandwidth_usage.rs (100%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/api/transport/mod.rs (100%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/api/transport/network_types.rs (100%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/api/units/data_rate.rs (100%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/api/units/data_size.rs (100%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/api/units/frequency.rs (100%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/api/units/mod.rs (100%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/api/units/time_delta.rs (100%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/api/units/timestamp.rs (100%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/api/units/unit_base.rs (100%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/bench.rs (99%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/congestion_window_pushback_controller.rs (100%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/delay_based_bwe.rs (100%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/delay_increase_detector_interface.rs (100%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/experiments/field_trials.rs (100%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/experiments/mod.rs (100%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/experiments/rate_control.rs (100%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/goog_cc_network_control.rs (100%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/inter_arrival_delta.rs (100%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/link_capacity_estimator.rs (100%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/loss_based_bwe_v2.rs (100%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/mod.rs (98%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/pacing/bitrate_prober.rs (100%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/pacing/interval_budget.rs (100%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/pacing/mod.rs (100%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/probe_bitrate_estimator.rs (100%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/probe_controller.rs (100%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/remote_bitrate_estimator/aimd_rate_control.rs (100%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/remote_bitrate_estimator/bwe_defines.rs (100%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/remote_bitrate_estimator/mod.rs (100%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/robust_throughput_estimator.rs (100%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/send_side_bandwidth_estimation.rs (100%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/tests.rs (99%) rename rs/{moq-congestion-lab => moq-congestion}/src/gcc/trendline_estimator.rs (100%) rename rs/{moq-congestion-lab => moq-congestion}/src/scream.rs (99%) diff --git a/Cargo.lock b/Cargo.lock index f3b51f4c01f..3dff76a7c90 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4313,16 +4313,6 @@ dependencies = [ "rand 0.10.3", "rand_pcg", "stats_alloc", - "workspace-hack", -] - -[[package]] -name = "moq-congestion-lab" -version = "0.0.0" -dependencies = [ - "cpu-time", - "kio", - "moq-congestion", "tracing", "workspace-hack", ] @@ -4622,7 +4612,6 @@ dependencies = [ "kio", "lru-slab", "moq-congestion", - "moq-congestion-lab", "moq-crypto", "moq-quic", "proptest", @@ -4875,7 +4864,6 @@ dependencies = [ "libc", "mdns-sd", "moq-congestion", - "moq-congestion-lab", "moq-crypto", "moq-net", "moq-quic", diff --git a/Cargo.toml b/Cargo.toml index 1a13d1d527f..a74ae70474f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,6 @@ default-members = [ "rs/hang", # "rs/moq-c", # requires C toolchain "rs/moq-congestion", - "rs/moq-congestion-lab", "rs/moq-archive", "rs/moq-auth", "rs/moq-boy", diff --git a/nix/Cargo.nix b/nix/Cargo.nix index f15cc4b7457..b4015397a1a 100644 --- a/nix/Cargo.nix +++ b/nix/Cargo.nix @@ -180,16 +180,6 @@ rec { # File a bug if you depend on any for non-debug work! debug = internal.debugCrate { inherit packageId; }; }; - "moq-congestion-lab" = rec { - packageId = "moq-congestion-lab"; - build = internal.buildRustCrateWithFeatures { - packageId = "moq-congestion-lab"; - }; - - # Debug support which might change between releases. - # File a bug if you depend on any for non-debug work! - debug = internal.debugCrate { inherit packageId; }; - }; "moq-crypto" = rec { packageId = "moq-crypto"; build = internal.buildRustCrateWithFeatures { @@ -18591,6 +18581,11 @@ rec { name = "rand_pcg"; packageId = "rand_pcg"; } + { + name = "tracing"; + packageId = "tracing"; + optional = true; + } ]; devDependencies = [ { @@ -18612,50 +18607,10 @@ rec { } ]; features = { + "lab" = [ "dep:tracing" ]; }; resolvedDefaultFeatures = [ "lab" ]; }; - "moq-congestion-lab" = rec { - crateName = "moq-congestion-lab"; - version = "0.0.0"; - edition = "2024"; - src = lib.cleanSourceWith { - filter = sourceFilter; - src = ../rs/moq-congestion-lab; - }; - libName = "moq_congestion_lab"; - dependencies = [ - { - name = "kio"; - packageId = "kio"; - } - { - name = "moq-congestion"; - packageId = "moq-congestion"; - features = [ "lab" ]; - } - { - name = "tracing"; - packageId = "tracing"; - } - ]; - devDependencies = [ - { - name = "cpu-time"; - packageId = "cpu-time"; - } - { - name = "kio"; - packageId = "kio"; - features = [ "runtime" ]; - } - { - name = "workspace-hack"; - packageId = "workspace-hack"; - } - ]; - - }; "moq-crypto" = rec { crateName = "moq-crypto"; version = "0.0.11"; @@ -20234,8 +20189,9 @@ rec { ]; } { - name = "moq-congestion-lab"; - packageId = "moq-congestion-lab"; + name = "moq-congestion"; + packageId = "moq-congestion"; + features = [ "lab" ]; } { name = "moq-quic"; @@ -21752,10 +21708,7 @@ rec { { name = "moq-congestion"; packageId = "moq-congestion"; - } - { - name = "moq-congestion-lab"; - packageId = "moq-congestion-lab"; + features = [ "lab" ]; } { name = "moq-shaper"; diff --git a/quest/m3/vendor-sync/scream.md b/quest/m3/vendor-sync/scream.md index 5979c75afef..981796bcb39 100644 --- a/quest/m3/vendor-sync/scream.md +++ b/quest/m3/vendor-sync/scream.md @@ -1,12 +1,12 @@ -# [XS] moq-congestion-lab's SCReAMv2 follows its draft and reference +# [XS] moq-congestion's SCReAMv2 follows its draft and reference ## Goal -moq-congestion-lab's `scream` carries every fix to its queue-delay target path +moq-congestion's `scream` carries every fix to its queue-delay target path from newer revisions of draft-ietf-ccwg-rfc8298bis-screamv2 and from [EricssonResearch/scream](https://github.com/EricssonResearch/scream)'s `ScreamV2Tx.cpp`, each ported with its test or recorded as not applying, and -`rs/moq-congestion-lab/src/scream.rs`'s module doc names the draft revision and +`rs/moq-congestion/src/scream.rs`'s module doc names the draft revision and reference commit checked. ## Plan diff --git a/quest/m3/vendor-sync/webrtc.md b/quest/m3/vendor-sync/webrtc.md index 18c541758ec..a758f11649e 100644 --- a/quest/m3/vendor-sync/webrtc.md +++ b/quest/m3/vendor-sync/webrtc.md @@ -2,7 +2,7 @@ ## Goal -moq-congestion-lab's `gcc` module (GoogCC) carries every fix WebRTC has landed in +moq-congestion's `gcc` module (GoogCC) carries every fix WebRTC has landed in its source files since the last check, each ported with its test or recorded as not applying, and its module doc names the newest WebRTC revision checked. @@ -12,7 +12,7 @@ Recurring child of the [vendor sync](/quest/m3/vendor-sync/README.md), which says how each run works and recurs. New in the 2026-11-05 scan: the port landed after the first run started. -GoogCC: `rs/moq-congestion-lab/src/gcc/mod.rs` records WebRTC +GoogCC: `rs/moq-congestion/src/gcc/mod.rs` records WebRTC [`556f7eec27`](https://webrtc.googlesource.com/src/+/556f7eec27) (2026-11-01), refreshed in [moq-dev/moq#7546](https://github.com/moq-dev/moq/pull/7546) from [goog_cc](https://github.com/kixelated/goog_cc) 0.1.4. Each file follows its diff --git a/quest/m3/webrtc/README.md b/quest/m3/webrtc/README.md index a9a780e97d1..e9d7228e0bb 100644 --- a/quest/m3/webrtc/README.md +++ b/quest/m3/webrtc/README.md @@ -12,7 +12,7 @@ Decided 2026-10-30 with the maintainer (planning interview), after the str0m wor - **Vendor, then replace.** Copy the upstream crates in, trim them, and fix them in-tree. Replacing a layer with our own (SDP, RTP/RTCP, SRTP) is a later child once a concrete need appears; none is planned yet. - **One crate.** The ICE driver (once `moq-ice`) lives in `moq-webrtc`, which depends on moq-tokio rather than the reverse, so moq-tokio needs no ICE. The vendored crates become private modules, not separate published crates, keeping their MIT/Apache-2.0 notices (str0m's `packet/` carries webrtc-rs's Apache notice). -- **What goes** (from the 2026-10-30 inventory: we use frame mode, full ICE, and DTLS 1.2, and never enable str0m's BWE, pacer, or stats): GCC bandwidth estimation (8k lines; GCC is ported into the workspace-only `moq-congestion-lab` as `moq_congestion_lab::gcc`), the leaky pacer (replaced by moq-congestion's pacer, made public by [rtc-pacing](/quest/m3/rtc-pacing.md)), H.266, RED, DTMF, G.7xx and comfort noise, VLA and simulcast layers, RTCP app feedback, stats, internal test exports, and dimpl's DTLS 1.3 and version auto-selection. RTCP XR stays: its RRTR/DLRR blocks are the receive side's only RTT measurement, which sets NACK retries and the video recovery deadline. Roughly 17k of str0m's 72k lines and 11k of dimpl's 33k. +- **What goes** (from the 2026-10-30 inventory: we use frame mode, full ICE, and DTLS 1.2, and never enable str0m's BWE, pacer, or stats): GCC bandwidth estimation (8k lines; GCC is ported into `moq-congestion` as `moq_congestion::gcc`), the leaky pacer (replaced by moq-congestion's pacer, made public by [rtc-pacing](/quest/m3/rtc-pacing.md)), H.266, RED, DTMF, G.7xx and comfort noise, VLA and simulcast layers, RTCP app feedback, stats, internal test exports, and dimpl's DTLS 1.3 and version auto-selection. RTCP XR stays: its RRTR/DLRR blocks are the receive side's only RTT measurement, which sets NACK retries and the video recovery deadline. Roughly 17k of str0m's 72k lines and 11k of dimpl's 33k. - **DTLS 1.2 only.** Every browser negotiates 1.2 today, and the vendored rind crypto provider offers 1.2 only to match. - **No SCTP.** Decided 2026-11-14 (maintainer): peer-to-peer routing, the only data-channel consumer, left the repository, so sctp-proto and str0m's data channels are cut and an offered `m=application` line is answered rejected. - **Upstream fixes:** after vendoring, nobody merges upstream automatically. The vendored upstream commits are recorded in `rs/moq-webrtc/src/vendor/mod.rs`'s `Upstream` section; the [vendor sync](/quest/m3/vendor-sync/webrtc-stack.md) checks the upstream changes once per release cycle for security fixes (malformed SRTP/RTCP input, for example) and ports them. diff --git a/quest/m4/quic-realtime.md b/quest/m4/quic-realtime.md index 82b704a709f..454bbb8eb5d 100644 --- a/quest/m4/quic-realtime.md +++ b/quest/m4/quic-realtime.md @@ -36,9 +36,9 @@ spike assumed no consumer; teleoperation uplinks are one): scheduler's grants. So the candidates group arrivals into bursts before fitting a trend, as GoogCC does. Reproduce it with `just rs quic-sim`. - Bake-off: all three candidates in parallel, each a controller - in the workspace-only `moq-congestion-lab` (the delay bound stays in - `moq-congestion`'s `bbr3/`, its setter behind the `lab` test-support - feature); a winner moves into `moq-congestion`. The moq-shaper presets `cellular-step`, + in `moq-congestion` compiled only behind its `lab` test-support feature + (for the delay bound, only its setter); a winner leaves the feature. The + moq-shaper presets `cellular-step`, `cellular-bursty` and `cellular-deep` decide it. The report states the shaper's timing jitter, measured over `near-zero`, as the noise floor of the delay signal. The BBR3 delay bound (`bbr3::Config::delay_bound`) brought @@ -70,7 +70,7 @@ spike assumed no consumer; teleoperation uplinks are one): than upgrading `Delay`, so current users see no behavior change. - Docs: inline only. The congestion-control lines in `doc/bin/cli.md` and `doc/lib/*` gain the new variant; no new page. -- SCReAMv2 landed as `moq_congestion_lab::scream::Scream` +- SCReAMv2 landed as `moq_congestion::scream::Scream` ([moq-dev/moq#7547](https://github.com/moq-dev/moq/pull/7547)). moq-quic's `tests::scream` measures it on the sim beside BBR3, and moq-tokio's `scream` integration tests over the real presets. Its estimate is a window @@ -181,7 +181,14 @@ the candidates would publish unselectable with moq-congestion's first release. Decided 2026-11-14 (maintainer, pick on [moq-dev/moq#8764](https://github.com/moq-dev/moq/pull/8764)): ✅ the cut ships BBR through the existing selector and keeps GCC, SCReAM, and the BBR3 delay -bound off the published API. +bound off the published API. Decided 2026-11-15 (maintainer, /quest-complete, +on [moq-dev/moq#8850](https://github.com/moq-dev/moq/pull/8850)), in the +maintainer's words: "wait why a new crate? put them behind a feature then +definitely not a new crate". ✅ GCC and SCReAMv2 stay modules of +moq-congestion, compiled only behind its `lab` test-support feature, which +also gates the delay bound's setter (rejected: a separate workspace-only +crate). This supersedes the earlier record of the #8764 pick as rejecting "an +unstable feature", which paraphrased the pick rather than quoting it. This bake-off tests them, and each winner joins `CongestionControl` as a variant named after its algorithm, or, for the delay bound, a `bbr3::Config` option; losers stay out of the published API. diff --git a/rs/moq-congestion-lab/.rustfmt.toml b/rs/moq-congestion-lab/.rustfmt.toml deleted file mode 100644 index 253a4108eb9..00000000000 --- a/rs/moq-congestion-lab/.rustfmt.toml +++ /dev/null @@ -1,2 +0,0 @@ -# rustfmt defaults rather than the root .rustfmt.toml, as in moq-congestion, so a candidate -# moves between the two crates without whitespace churn. diff --git a/rs/moq-congestion-lab/Cargo.toml b/rs/moq-congestion-lab/Cargo.toml deleted file mode 100644 index edb95fb5474..00000000000 --- a/rs/moq-congestion-lab/Cargo.toml +++ /dev/null @@ -1,22 +0,0 @@ -[package] -name = "moq-congestion-lab" -description = "Congestion controller candidates under test, kept out of moq-congestion's published API" -version = "0.0.0" -edition = "2024" -rust-version.workspace = true -repository = "https://github.com/moq-dev/moq" -license = "(MIT OR Apache-2.0) AND BSD-3-Clause" -publish = false - -[dependencies] -kio = { workspace = true } -moq-congestion = { workspace = true, features = ["lab"] } -tracing = { workspace = true } - -[dev-dependencies] -cpu-time = "1.0.0" -kio = { path = "../kio", features = ["runtime"] } -workspace-hack = { path = "../workspace-hack" } - -[lints] -workspace = true diff --git a/rs/moq-congestion-lab/LICENSE-APACHE b/rs/moq-congestion-lab/LICENSE-APACHE deleted file mode 100644 index 261eeb9e9f8..00000000000 --- a/rs/moq-congestion-lab/LICENSE-APACHE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/rs/moq-congestion-lab/LICENSE-MIT b/rs/moq-congestion-lab/LICENSE-MIT deleted file mode 100644 index f6561040563..00000000000 --- a/rs/moq-congestion-lab/LICENSE-MIT +++ /dev/null @@ -1,7 +0,0 @@ -Copyright (c) 2018 The quinn Developers - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/rs/moq-congestion-lab/README.md b/rs/moq-congestion-lab/README.md deleted file mode 100644 index 2351707e5df..00000000000 --- a/rs/moq-congestion-lab/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# moq-congestion-lab - -Congestion controller candidates under test, kept out of [moq-congestion](../moq-congestion)'s published API. The crate is never published: moq-quic's simulated comparisons and moq-tokio's real-socket tests take it as a path dev-dependency, which `cargo publish` drops. A candidate that wins the realtime bake-off moves into moq-congestion and joins `moq_tokio::quic::CongestionControl` as a variant named after its algorithm. - -SCReAMv2's delay-based path was ported from draft-ietf-ccwg-rfc8298bis-screamv2 and checked against Ericsson's [reference implementation](https://github.com/EricssonResearch/scream). - -GCC is libwebrtc's Google Congestion Control, a delay-based controller that reads the peer's receive timestamps (draft-ietf-quic-receive-ts). `src/gcc` vendors a Rust port of WebRTC's `goog_cc` under WebRTC's BSD license, kept in [`src/gcc/LICENSE`](src/gcc/LICENSE) with its `PATENTS` grant; its module docs record the WebRTC revision it tracks and what it trims. - -Tests run with `just rs test -p moq-congestion-lab`. diff --git a/rs/moq-congestion-lab/src/lib.rs b/rs/moq-congestion-lab/src/lib.rs deleted file mode 100644 index 3023109f226..00000000000 --- a/rs/moq-congestion-lab/src/lib.rs +++ /dev/null @@ -1,50 +0,0 @@ -//! Congestion controllers under test, outside moq-congestion's published API. -//! -//! Each candidate implements [`moq_congestion::Controller`], so the simulated and real-socket -//! comparisons in moq-quic and moq-tokio drive it like any other. A winner graduates into -//! moq-congestion and joins `moq_tokio::quic::CongestionControl` as a new variant. - -pub mod gcc; -pub mod scream; - -#[cfg(test)] -mod tests { - use std::{sync::Arc, time::Duration}; - - use kio::clock::Instant; - use moq_congestion::{Factory, Init}; - - use super::*; - - /// The largest UDP payload (RFC 9000), whose two datagrams outgrow every 1200-based default - const MTU: u16 = 65527; - - fn init(mtu: u16) -> Init { - Init { - now: Instant::ZERO, - mtu, - rtt: Duration::from_millis(100), - seed: 0, - } - } - - /// The window holds two datagrams at the path MTU (RFC 9002 section 7.2's minimum), or the - /// transport could never send its first one. - #[test] - fn window_holds_two_datagrams_at_large_mtu() { - let factories: [(&str, Arc); 2] = [ - ("gcc", Arc::new(gcc::Config::default())), - ("scream", Arc::new(scream::Config::default())), - ]; - let floor = 2 * u64::from(MTU); - for (name, factory) in factories { - let window = factory.clone().build(init(MTU)).window(); - assert!(window >= floor, "{name} starts at {window}"); - - let mut controller = factory.build(init(1200)); - controller.on_mtu_update(MTU); - let window = controller.window(); - assert!(window >= floor, "{name} grows its MTU to {window}"); - } - } -} diff --git a/rs/moq-congestion/Cargo.toml b/rs/moq-congestion/Cargo.toml index 6b3318b7808..1bada257a09 100644 --- a/rs/moq-congestion/Cargo.toml +++ b/rs/moq-congestion/Cargo.toml @@ -5,18 +5,18 @@ version = "0.1.0" edition = "2024" rust-version.workspace = true repository = "https://github.com/moq-dev/moq" -license = "MIT OR Apache-2.0" +license = "(MIT OR Apache-2.0) AND BSD-3-Clause" [features] -# Test support for the workspace-only moq-congestion-lab and the comparisons that run its -# candidates: the pacer, a packet's GCC probe cluster, and BBR3's delay bound. Meant for -# dev-dependencies; not for applications. -lab = [] +# Test support for the candidates under test and the comparisons that run them: the `gcc` and +# `scream` controllers and BBR3's delay bound. Meant for dev-dependencies; not for applications. +lab = ["dep:tracing"] [dependencies] kio = { workspace = true } rand = { workspace = true } rand_pcg = { workspace = true } +tracing = { workspace = true, optional = true } [dev-dependencies] cpu-time = "1.0.0" diff --git a/rs/moq-congestion/README.md b/rs/moq-congestion/README.md index b4109ca0249..93dbe2be474 100644 --- a/rs/moq-congestion/README.md +++ b/rs/moq-congestion/README.md @@ -2,18 +2,20 @@ BBR3, Cubic, and Unlimited congestion controllers, consumed by moq-quic and the native transport drivers. Applications pick one through `moq_tokio::quic::CongestionControl`, where `delay` is BBR3 and the default. -Candidates still under test stay off the published API: GCC and SCReAMv2 live in the workspace-only [moq-congestion-lab](../moq-congestion-lab), and BBR3's delay bound, which brakes when the peer's receive timestamps show the bottleneck queue growing, is settable only with the `lab` test-support feature those comparisons enable. A winner joins `CongestionControl` as a new variant, or BBR3 as an option. +Candidates still under test compile only with the `lab` test-support feature, which the comparisons in moq-quic and moq-tokio enable as a dev-dependency: the `gcc` and `scream` modules, and BBR3's delay bound (`bbr3::Config::delay_bound`), which brakes when the peer's receive timestamps show the bottleneck queue growing. A winner joins `CongestionControl` as a new variant, or BBR3 as an option, and leaves the feature. The controllers take explicit `kio::clock::Instant` values and never drive a runtime. The `Controller` trait names no transport types: `on_sent` returns an opaque per-packet state that the transport stores and hands back with each acknowledgement or loss, and the controller paces its own sends. -Construct controllers with `Factory::build` on an `Arc`, `Arc`, or `Arc`. `Unlimited` and `Metrics` live at the crate root. +Construct controllers with `Factory::build` on an `Arc`, `Arc`, or `Arc`, and with `lab`, `Arc` or `Arc`. `Unlimited` and `Metrics` live at the crate root, and `gcc::Gcc` and `scream::Scream` in their modules. -The code was extracted from [moq-quic](../moq-quic), under the same MIT or Apache-2.0 license. Cubic originated in quinn; BBR3 was ported from moq-dev/noq and carries the fixes listed in [moq-quic's fork history](../moq-quic/README.md). +The code was extracted from [moq-quic](../moq-quic), under the same MIT or Apache-2.0 license. Cubic originated in quinn; BBR3 was ported from moq-dev/noq and carries the fixes listed in [moq-quic's fork history](../moq-quic/README.md). SCReAMv2's delay-based path was ported from draft-ietf-ccwg-rfc8298bis-screamv2 and checked against Ericsson's [reference implementation](https://github.com/EricssonResearch/scream). -Controller tests run with `just rs test -p moq-congestion`. The per-packet benchmark runs nightly, or locally with: +GCC is libwebrtc's Google Congestion Control, a delay-based controller that reads the peer's receive timestamps (draft-ietf-quic-receive-ts). `src/gcc` vendors a Rust port of WebRTC's `goog_cc` under WebRTC's BSD license, kept in [`src/gcc/LICENSE`](src/gcc/LICENSE) with its `PATENTS` grant; its module docs record the WebRTC revision it tracks and what it trims. + +Controller tests run with `just rs test -p moq-congestion`, and the candidates' with `--features lab`. The per-packet benchmark runs nightly, or locally with: ```sh -just rs test --release -p moq-congestion -E 'test(benchmark_per_packet)' --run-ignored only --success-output immediate +just rs test --release -p moq-congestion --features lab -E 'test(benchmark_per_packet)' --run-ignored only --success-output immediate ``` Connection characterization and simulated transport tests remain in moq-quic. diff --git a/rs/moq-congestion-lab/src/gcc/AUTHORS b/rs/moq-congestion/src/gcc/AUTHORS similarity index 100% rename from rs/moq-congestion-lab/src/gcc/AUTHORS rename to rs/moq-congestion/src/gcc/AUTHORS diff --git a/rs/moq-congestion-lab/src/gcc/LICENSE b/rs/moq-congestion/src/gcc/LICENSE similarity index 100% rename from rs/moq-congestion-lab/src/gcc/LICENSE rename to rs/moq-congestion/src/gcc/LICENSE diff --git a/rs/moq-congestion-lab/src/gcc/PATENTS b/rs/moq-congestion/src/gcc/PATENTS similarity index 100% rename from rs/moq-congestion-lab/src/gcc/PATENTS rename to rs/moq-congestion/src/gcc/PATENTS diff --git a/rs/moq-congestion-lab/src/gcc/alr_detector.rs b/rs/moq-congestion/src/gcc/alr_detector.rs similarity index 100% rename from rs/moq-congestion-lab/src/gcc/alr_detector.rs rename to rs/moq-congestion/src/gcc/alr_detector.rs diff --git a/rs/moq-congestion-lab/src/gcc/api/mod.rs b/rs/moq-congestion/src/gcc/api/mod.rs similarity index 100% rename from rs/moq-congestion-lab/src/gcc/api/mod.rs rename to rs/moq-congestion/src/gcc/api/mod.rs diff --git a/rs/moq-congestion-lab/src/gcc/api/transport/bandwidth_usage.rs b/rs/moq-congestion/src/gcc/api/transport/bandwidth_usage.rs similarity index 100% rename from rs/moq-congestion-lab/src/gcc/api/transport/bandwidth_usage.rs rename to rs/moq-congestion/src/gcc/api/transport/bandwidth_usage.rs diff --git a/rs/moq-congestion-lab/src/gcc/api/transport/mod.rs b/rs/moq-congestion/src/gcc/api/transport/mod.rs similarity index 100% rename from rs/moq-congestion-lab/src/gcc/api/transport/mod.rs rename to rs/moq-congestion/src/gcc/api/transport/mod.rs diff --git a/rs/moq-congestion-lab/src/gcc/api/transport/network_types.rs b/rs/moq-congestion/src/gcc/api/transport/network_types.rs similarity index 100% rename from rs/moq-congestion-lab/src/gcc/api/transport/network_types.rs rename to rs/moq-congestion/src/gcc/api/transport/network_types.rs diff --git a/rs/moq-congestion-lab/src/gcc/api/units/data_rate.rs b/rs/moq-congestion/src/gcc/api/units/data_rate.rs similarity index 100% rename from rs/moq-congestion-lab/src/gcc/api/units/data_rate.rs rename to rs/moq-congestion/src/gcc/api/units/data_rate.rs diff --git a/rs/moq-congestion-lab/src/gcc/api/units/data_size.rs b/rs/moq-congestion/src/gcc/api/units/data_size.rs similarity index 100% rename from rs/moq-congestion-lab/src/gcc/api/units/data_size.rs rename to rs/moq-congestion/src/gcc/api/units/data_size.rs diff --git a/rs/moq-congestion-lab/src/gcc/api/units/frequency.rs b/rs/moq-congestion/src/gcc/api/units/frequency.rs similarity index 100% rename from rs/moq-congestion-lab/src/gcc/api/units/frequency.rs rename to rs/moq-congestion/src/gcc/api/units/frequency.rs diff --git a/rs/moq-congestion-lab/src/gcc/api/units/mod.rs b/rs/moq-congestion/src/gcc/api/units/mod.rs similarity index 100% rename from rs/moq-congestion-lab/src/gcc/api/units/mod.rs rename to rs/moq-congestion/src/gcc/api/units/mod.rs diff --git a/rs/moq-congestion-lab/src/gcc/api/units/time_delta.rs b/rs/moq-congestion/src/gcc/api/units/time_delta.rs similarity index 100% rename from rs/moq-congestion-lab/src/gcc/api/units/time_delta.rs rename to rs/moq-congestion/src/gcc/api/units/time_delta.rs diff --git a/rs/moq-congestion-lab/src/gcc/api/units/timestamp.rs b/rs/moq-congestion/src/gcc/api/units/timestamp.rs similarity index 100% rename from rs/moq-congestion-lab/src/gcc/api/units/timestamp.rs rename to rs/moq-congestion/src/gcc/api/units/timestamp.rs diff --git a/rs/moq-congestion-lab/src/gcc/api/units/unit_base.rs b/rs/moq-congestion/src/gcc/api/units/unit_base.rs similarity index 100% rename from rs/moq-congestion-lab/src/gcc/api/units/unit_base.rs rename to rs/moq-congestion/src/gcc/api/units/unit_base.rs diff --git a/rs/moq-congestion-lab/src/gcc/bench.rs b/rs/moq-congestion/src/gcc/bench.rs similarity index 99% rename from rs/moq-congestion-lab/src/gcc/bench.rs rename to rs/moq-congestion/src/gcc/bench.rs index 670cc136d4f..42b0585174a 100644 --- a/rs/moq-congestion-lab/src/gcc/bench.rs +++ b/rs/moq-congestion/src/gcc/bench.rs @@ -2,8 +2,8 @@ //! so its cost grows with the packets each ACK carries. use super::*; +use crate::Acked; use cpu_time::ThreadTime; -use moq_congestion::Acked; const PACKET: u16 = 1200; diff --git a/rs/moq-congestion-lab/src/gcc/congestion_window_pushback_controller.rs b/rs/moq-congestion/src/gcc/congestion_window_pushback_controller.rs similarity index 100% rename from rs/moq-congestion-lab/src/gcc/congestion_window_pushback_controller.rs rename to rs/moq-congestion/src/gcc/congestion_window_pushback_controller.rs diff --git a/rs/moq-congestion-lab/src/gcc/delay_based_bwe.rs b/rs/moq-congestion/src/gcc/delay_based_bwe.rs similarity index 100% rename from rs/moq-congestion-lab/src/gcc/delay_based_bwe.rs rename to rs/moq-congestion/src/gcc/delay_based_bwe.rs diff --git a/rs/moq-congestion-lab/src/gcc/delay_increase_detector_interface.rs b/rs/moq-congestion/src/gcc/delay_increase_detector_interface.rs similarity index 100% rename from rs/moq-congestion-lab/src/gcc/delay_increase_detector_interface.rs rename to rs/moq-congestion/src/gcc/delay_increase_detector_interface.rs diff --git a/rs/moq-congestion-lab/src/gcc/experiments/field_trials.rs b/rs/moq-congestion/src/gcc/experiments/field_trials.rs similarity index 100% rename from rs/moq-congestion-lab/src/gcc/experiments/field_trials.rs rename to rs/moq-congestion/src/gcc/experiments/field_trials.rs diff --git a/rs/moq-congestion-lab/src/gcc/experiments/mod.rs b/rs/moq-congestion/src/gcc/experiments/mod.rs similarity index 100% rename from rs/moq-congestion-lab/src/gcc/experiments/mod.rs rename to rs/moq-congestion/src/gcc/experiments/mod.rs diff --git a/rs/moq-congestion-lab/src/gcc/experiments/rate_control.rs b/rs/moq-congestion/src/gcc/experiments/rate_control.rs similarity index 100% rename from rs/moq-congestion-lab/src/gcc/experiments/rate_control.rs rename to rs/moq-congestion/src/gcc/experiments/rate_control.rs diff --git a/rs/moq-congestion-lab/src/gcc/goog_cc_network_control.rs b/rs/moq-congestion/src/gcc/goog_cc_network_control.rs similarity index 100% rename from rs/moq-congestion-lab/src/gcc/goog_cc_network_control.rs rename to rs/moq-congestion/src/gcc/goog_cc_network_control.rs diff --git a/rs/moq-congestion-lab/src/gcc/inter_arrival_delta.rs b/rs/moq-congestion/src/gcc/inter_arrival_delta.rs similarity index 100% rename from rs/moq-congestion-lab/src/gcc/inter_arrival_delta.rs rename to rs/moq-congestion/src/gcc/inter_arrival_delta.rs diff --git a/rs/moq-congestion-lab/src/gcc/link_capacity_estimator.rs b/rs/moq-congestion/src/gcc/link_capacity_estimator.rs similarity index 100% rename from rs/moq-congestion-lab/src/gcc/link_capacity_estimator.rs rename to rs/moq-congestion/src/gcc/link_capacity_estimator.rs diff --git a/rs/moq-congestion-lab/src/gcc/loss_based_bwe_v2.rs b/rs/moq-congestion/src/gcc/loss_based_bwe_v2.rs similarity index 100% rename from rs/moq-congestion-lab/src/gcc/loss_based_bwe_v2.rs rename to rs/moq-congestion/src/gcc/loss_based_bwe_v2.rs diff --git a/rs/moq-congestion-lab/src/gcc/mod.rs b/rs/moq-congestion/src/gcc/mod.rs similarity index 98% rename from rs/moq-congestion-lab/src/gcc/mod.rs rename to rs/moq-congestion/src/gcc/mod.rs index 6aab6ce0be2..34f6507f8f6 100644 --- a/rs/moq-congestion-lab/src/gcc/mod.rs +++ b/rs/moq-congestion/src/gcc/mod.rs @@ -1,5 +1,8 @@ //! libwebrtc's Google Congestion Control (GoogCC), driven by QUIC receive timestamps. //! +//! A candidate under test, compiled only with the `lab` test-support feature: no session can +//! select it until the realtime bake-off picks it. +//! //! The submodules are a Rust port of WebRTC's `modules/congestion_controller/goog_cc`, with the //! parts of `api/transport`, `api/units`, `modules/pacing` and `modules/remote_bitrate_estimator` //! it uses. They began as [goog_cc](https://github.com/kixelated/goog_cc) 0.1.4, a port of WebRTC @@ -77,6 +80,10 @@ use std::{collections::VecDeque, num::NonZeroU16, sync::Arc, time::Duration}; use kio::clock::Instant; +use crate::{ + Ack, Ce, Controller, Factory, Init, Loss, Metrics, Packet, Sent, + pacer::{self, Pacer, Rate}, +}; use api::{ transport::{ NetworkAvailability, NetworkControlUpdate, PacedPacketInfo, PacerConfig, PacketResult, @@ -85,10 +92,6 @@ use api::{ }, units::{DataRate, DataSize, TimeDelta, Timestamp}, }; -use moq_congestion::{ - Ack, Ce, Controller, Factory, Init, Loss, Metrics, Packet, Sent, - pacer::{self, Pacer, Rate}, -}; use pacing::BitrateProber; /// How often GoogCC expects its process timer, as `GetProcessInterval` @@ -279,7 +282,7 @@ impl Gcc { /// GoogCC runs on the round-trip delay. Once it reports one, a packet without one, as when /// the ACK carrying its time was lost, still counts as received for the loss-based estimate, /// but not toward delay, rather than mix the two clocks. - fn acked(&mut self, packet: &moq_congestion::Acked, now: Instant) -> PacketResult { + fn acked(&mut self, packet: &crate::Acked, now: Instant) -> PacketResult { let (receive_time, ambiguous_receive_time) = match packet.received { Some(received) => (self.receive_time(received, now), false), None => (timestamp(now), self.receive_basis.is_some()), @@ -288,7 +291,7 @@ impl Gcc { sent_packet: SentPacket { send_time: timestamp(packet.sent), size: DataSize::from_bytes(packet.bytes.into()), - pacing_info: self.cluster(packet.packet.probe_cluster()), + pacing_info: self.cluster(packet.packet.probe_cluster), data_in_flight: DataSize::zero(), }, receive_time, @@ -383,9 +386,10 @@ impl Controller for Gcc { data_in_flight: size(sent.in_flight), }); self.apply(update); - let mut packet = Packet::default(); - packet.set_probe_cluster(probe_cluster); - packet + Packet { + probe_cluster, + ..Default::default() + } } fn on_ack(&mut self, ack: Ack<'_>) { @@ -421,7 +425,7 @@ impl Controller for Gcc { sent_packet: SentPacket { send_time: timestamp(packet.sent), size: DataSize::from_bytes(packet.bytes.into()), - pacing_info: self.cluster(packet.packet.probe_cluster()), + pacing_info: self.cluster(packet.packet.probe_cluster), data_in_flight: DataSize::zero(), }, receive_time: Timestamp::plus_infinity(), diff --git a/rs/moq-congestion-lab/src/gcc/pacing/bitrate_prober.rs b/rs/moq-congestion/src/gcc/pacing/bitrate_prober.rs similarity index 100% rename from rs/moq-congestion-lab/src/gcc/pacing/bitrate_prober.rs rename to rs/moq-congestion/src/gcc/pacing/bitrate_prober.rs diff --git a/rs/moq-congestion-lab/src/gcc/pacing/interval_budget.rs b/rs/moq-congestion/src/gcc/pacing/interval_budget.rs similarity index 100% rename from rs/moq-congestion-lab/src/gcc/pacing/interval_budget.rs rename to rs/moq-congestion/src/gcc/pacing/interval_budget.rs diff --git a/rs/moq-congestion-lab/src/gcc/pacing/mod.rs b/rs/moq-congestion/src/gcc/pacing/mod.rs similarity index 100% rename from rs/moq-congestion-lab/src/gcc/pacing/mod.rs rename to rs/moq-congestion/src/gcc/pacing/mod.rs diff --git a/rs/moq-congestion-lab/src/gcc/probe_bitrate_estimator.rs b/rs/moq-congestion/src/gcc/probe_bitrate_estimator.rs similarity index 100% rename from rs/moq-congestion-lab/src/gcc/probe_bitrate_estimator.rs rename to rs/moq-congestion/src/gcc/probe_bitrate_estimator.rs diff --git a/rs/moq-congestion-lab/src/gcc/probe_controller.rs b/rs/moq-congestion/src/gcc/probe_controller.rs similarity index 100% rename from rs/moq-congestion-lab/src/gcc/probe_controller.rs rename to rs/moq-congestion/src/gcc/probe_controller.rs diff --git a/rs/moq-congestion-lab/src/gcc/remote_bitrate_estimator/aimd_rate_control.rs b/rs/moq-congestion/src/gcc/remote_bitrate_estimator/aimd_rate_control.rs similarity index 100% rename from rs/moq-congestion-lab/src/gcc/remote_bitrate_estimator/aimd_rate_control.rs rename to rs/moq-congestion/src/gcc/remote_bitrate_estimator/aimd_rate_control.rs diff --git a/rs/moq-congestion-lab/src/gcc/remote_bitrate_estimator/bwe_defines.rs b/rs/moq-congestion/src/gcc/remote_bitrate_estimator/bwe_defines.rs similarity index 100% rename from rs/moq-congestion-lab/src/gcc/remote_bitrate_estimator/bwe_defines.rs rename to rs/moq-congestion/src/gcc/remote_bitrate_estimator/bwe_defines.rs diff --git a/rs/moq-congestion-lab/src/gcc/remote_bitrate_estimator/mod.rs b/rs/moq-congestion/src/gcc/remote_bitrate_estimator/mod.rs similarity index 100% rename from rs/moq-congestion-lab/src/gcc/remote_bitrate_estimator/mod.rs rename to rs/moq-congestion/src/gcc/remote_bitrate_estimator/mod.rs diff --git a/rs/moq-congestion-lab/src/gcc/robust_throughput_estimator.rs b/rs/moq-congestion/src/gcc/robust_throughput_estimator.rs similarity index 100% rename from rs/moq-congestion-lab/src/gcc/robust_throughput_estimator.rs rename to rs/moq-congestion/src/gcc/robust_throughput_estimator.rs diff --git a/rs/moq-congestion-lab/src/gcc/send_side_bandwidth_estimation.rs b/rs/moq-congestion/src/gcc/send_side_bandwidth_estimation.rs similarity index 100% rename from rs/moq-congestion-lab/src/gcc/send_side_bandwidth_estimation.rs rename to rs/moq-congestion/src/gcc/send_side_bandwidth_estimation.rs diff --git a/rs/moq-congestion-lab/src/gcc/tests.rs b/rs/moq-congestion/src/gcc/tests.rs similarity index 99% rename from rs/moq-congestion-lab/src/gcc/tests.rs rename to rs/moq-congestion/src/gcc/tests.rs index 9662a30b651..87a5350418e 100644 --- a/rs/moq-congestion-lab/src/gcc/tests.rs +++ b/rs/moq-congestion/src/gcc/tests.rs @@ -5,7 +5,7 @@ use std::collections::VecDeque; use super::*; -use moq_congestion::{Acked, Lost}; +use crate::{Acked, Lost}; const MTU: u16 = 1200; /// One-way propagation delay, each way diff --git a/rs/moq-congestion-lab/src/gcc/trendline_estimator.rs b/rs/moq-congestion/src/gcc/trendline_estimator.rs similarity index 100% rename from rs/moq-congestion-lab/src/gcc/trendline_estimator.rs rename to rs/moq-congestion/src/gcc/trendline_estimator.rs diff --git a/rs/moq-congestion/src/lib.rs b/rs/moq-congestion/src/lib.rs index 144fd7c82d1..fc4c25c5ea7 100644 --- a/rs/moq-congestion/src/lib.rs +++ b/rs/moq-congestion/src/lib.rs @@ -14,13 +14,12 @@ use std::sync::Arc; pub mod bbr3; /// CUBIC congestion control. pub mod cubic; -/// Test support, enabled by the `lab` feature: the token-bucket pacer the candidate controllers -/// share. #[cfg(feature = "lab")] -pub mod pacer; -#[cfg(not(feature = "lab"))] +pub mod gcc; mod pacer; mod rate; +#[cfg(feature = "lab")] +pub mod scream; mod unlimited; pub use rate::Packet; @@ -283,10 +282,14 @@ mod tests { /// The largest UDP payload (RFC 9000), whose two datagrams outgrow every 1200-based default const MTU: u16 = 65527; - fn factories() -> [(&'static str, Arc); 3] { - [ + fn factories() -> Vec<(&'static str, Arc)> { + vec![ ("bbr3", Arc::new(bbr3::Config::default())), ("cubic", Arc::new(cubic::Config::default())), + #[cfg(feature = "lab")] + ("gcc", Arc::new(gcc::Config::default())), + #[cfg(feature = "lab")] + ("scream", Arc::new(scream::Config::default())), ("unlimited", Arc::new(Unlimited)), ] } diff --git a/rs/moq-congestion/src/pacer.rs b/rs/moq-congestion/src/pacer.rs index 2fd0f418477..a2ca0051a9e 100644 --- a/rs/moq-congestion/src/pacer.rs +++ b/rs/moq-congestion/src/pacer.rs @@ -12,7 +12,7 @@ use std::time::Duration; /// than one congestion window per RTT, as recommended in /// #[derive(Debug, Clone)] -pub struct Pacer { +pub(crate) struct Pacer { capacity: u64, /// Inputs [`Self::capacity`] was derived from, or `None` if it was derived from a pacing rate last_window_inputs: Option, @@ -35,7 +35,7 @@ struct WindowInputs { impl Pacer { /// Obtains a new [`Pacer`]. - pub fn new(smoothed_rtt: Duration, window: u64, mtu: u16, now: Instant) -> Self { + pub(crate) fn new(smoothed_rtt: Duration, window: u64, mtu: u16, now: Instant) -> Self { let capacity = optimal_capacity(smoothed_rtt, window, mtu); Self { capacity, @@ -47,7 +47,7 @@ impl Pacer { } /// Record that a packet has been transmitted. - pub fn on_transmit(&mut self, packet_length: u16) { + pub(crate) fn on_transmit(&mut self, packet_length: u16) { let bytes = u64::from(packet_length); let spent = bytes.min(self.tokens); self.tokens -= spent; @@ -74,7 +74,7 @@ impl Pacer { /// The 5/4 ratio used here comes from the suggestion that N = 1.25 in the draft IETF RFC for /// QUIC. /// `rate` is the controller output the bucket refills at; see [`Rate`]. - pub fn delay( + pub(crate) fn delay( &mut self, smoothed_rtt: Duration, bytes_to_send: u64, @@ -206,7 +206,7 @@ impl Pacer { /// The controller output a [`Pacer`] refills at. #[derive(Debug, Clone, Copy)] -pub struct Rate { +pub(crate) struct Rate { /// Congestion window in bytes. Without a `pacing_rate`, the bucket refills at one window per /// smoothed RTT, sped up by 5/4. pub window: u64, @@ -220,7 +220,7 @@ pub struct Rate { /// Burst intervals trade distributing datagrams over time against waking the connection up more /// often than user-space timer accuracy can service; overshooting one by more than 25% loses the /// tokens for the extra elapsed time. -pub fn rate_capacity(pacing_rate: u64, mtu: u16) -> u64 { +pub(crate) fn rate_capacity(pacing_rate: u64, mtu: u16) -> u64 { let mtu = u64::from(mtu); let bytes_in = |interval: Duration| ((pacing_rate as u128 * interval.as_nanos()) / 1_000_000_000) as u64; diff --git a/rs/moq-congestion/src/rate.rs b/rs/moq-congestion/src/rate.rs index 70d27d86bd3..4fb5d525c67 100644 --- a/rs/moq-congestion/src/rate.rs +++ b/rs/moq-congestion/src/rate.rs @@ -36,21 +36,7 @@ pub struct Packet { /// fields above. GoogCC's clusters and the prober's restarts each wrap within half of them, /// far more than either starts in the two seconds a cluster is kept. #[cfg(feature = "lab")] - probe_cluster: Option, -} - -/// Test support, enabled by the `lab` feature, for the GCC candidate in moq-congestion-lab. -#[cfg(feature = "lab")] -impl Packet { - /// The GCC probe cluster the packet was sent in, if any. - pub fn probe_cluster(&self) -> Option { - self.probe_cluster - } - - /// Records the GCC probe cluster the packet was sent in. - pub fn set_probe_cluster(&mut self, cluster: Option) { - self.probe_cluster = cluster; - } + pub(crate) probe_cluster: Option, } /// An empty state, for a controller that keeps none. diff --git a/rs/moq-congestion-lab/src/scream.rs b/rs/moq-congestion/src/scream.rs similarity index 99% rename from rs/moq-congestion-lab/src/scream.rs rename to rs/moq-congestion/src/scream.rs index 7bc2c64d006..efea165bca0 100644 --- a/rs/moq-congestion-lab/src/scream.rs +++ b/rs/moq-congestion/src/scream.rs @@ -1,6 +1,9 @@ //! SCReAMv2's delay-based congestion control, ported from draft-ietf-ccwg-rfc8298bis-screamv2-01. //! //! +//! A candidate under test, compiled only with the `lab` test-support feature: no session can +//! select it until the realtime bake-off picks it. +//! //! A reference window caps the bytes in flight. It grows with every byte acknowledged, and shrinks //! on loss, on classic ECN-CE, and as the averaged queue delay passes half the target, in //! proportion to how far past it is ("virtual L4S" marking). The queue delay is each packet's @@ -16,10 +19,9 @@ use std::sync::Arc; -use kio::clock::Instant; -use moq_congestion::pacer::{Pacer, Rate}; -use moq_congestion::{Ack, Ce, Controller, Factory, Init, Loss, Metrics, Packet, Sent}; -use std::time::Duration; +use crate::pacer::{Pacer, Rate}; +use crate::{Ack, Ce, Controller, Factory, Init, Loss, Metrics, Packet, Sent}; +use crate::{Duration, Instant}; /// equivalent to MIN_REF_WND: the smallest reference window, in bytes const MIN_REF_WND: f64 = 3000.0; @@ -579,7 +581,7 @@ mod tests { use std::collections::VecDeque; use super::*; - use moq_congestion::{Acked, Lost}; + use crate::{Acked, Lost}; const MTU: u16 = 1200; const PROPAGATION: Duration = Duration::from_millis(20); diff --git a/rs/moq-quic/Cargo.toml b/rs/moq-quic/Cargo.toml index 277d7e915ad..c723522fb01 100644 --- a/rs/moq-quic/Cargo.toml +++ b/rs/moq-quic/Cargo.toml @@ -57,9 +57,8 @@ criterion = { package = "bench-harness", path = "../bench-harness" } hex-literal = "1" # The tests and benches read time through the runtime, as the drivers do. kio = { path = "../kio", features = ["runtime", "sim"] } -# The candidate controllers the simulated comparisons run, and through moq-congestion's -# `lab` feature, BBR3's delay bound. -moq-congestion-lab = { path = "../moq-congestion-lab" } +# The candidate controllers and BBR3's delay bound the simulated comparisons run. +moq-congestion = { path = "../moq-congestion", features = ["lab"] } # The mux module's tests run in the default merge gate. moq-quic = { path = ".", features = ["mux"] } proptest = { workspace = true } diff --git a/rs/moq-quic/src/tests/probe.rs b/rs/moq-quic/src/tests/probe.rs index 9640eb49440..388d48dc76f 100644 --- a/rs/moq-quic/src/tests/probe.rs +++ b/rs/moq-quic/src/tests/probe.rs @@ -18,8 +18,7 @@ use rand::{RngExt, SeedableRng}; use rand_pcg::Pcg32; use super::*; -use crate::congestion::{bbr3, cubic}; -use moq_congestion_lab::gcc; +use crate::congestion::{bbr3, cubic, gcc}; /// The media's usual bitrate, 2 Mbit/s, which the probe has to see past const MEDIA: u64 = 250_000; diff --git a/rs/moq-quic/src/tests/scream.rs b/rs/moq-quic/src/tests/scream.rs index fe8d74865f1..8c7ec9d444d 100644 --- a/rs/moq-quic/src/tests/scream.rs +++ b/rs/moq-quic/src/tests/scream.rs @@ -1,4 +1,4 @@ -//! SCReAMv2 ([`scream::Scream`]) on the seeded sim: an encoder that follows the controller's +//! SCReAMv2 ([`congestion::scream::Scream`]) on the seeded sim: an encoder that follows the controller's //! estimate sends up through a bottleneck shaped like each cellular moq-shaper preset, and the run //! reports the queue it built, what it carried, and how fast it answered each step. //! @@ -11,8 +11,7 @@ use std::collections::HashMap; use super::*; -use crate::congestion::bbr3; -use moq_congestion_lab::scream; +use crate::congestion::{bbr3, scream}; const FPS: u64 = 30; /// Frames per group, each group on its own stream: a keyframe every two seconds diff --git a/rs/moq-tokio/Cargo.toml b/rs/moq-tokio/Cargo.toml index 2f1fed0ddfb..deac204ddf1 100644 --- a/rs/moq-tokio/Cargo.toml +++ b/rs/moq-tokio/Cargo.toml @@ -130,10 +130,9 @@ criterion = { package = "bench-harness", path = "../bench-harness" } # be driven with synthetic daemon events. flume = "0.12" kio = { path = "../kio", features = ["sim"] } -# The integration tests build congestion controllers directly. -moq-congestion = { path = "../moq-congestion" } -# The candidate controllers the real-socket comparisons run. -moq-congestion-lab = { path = "../moq-congestion-lab" } +# The integration tests build congestion controllers directly, including the candidates the +# real-socket comparisons run. +moq-congestion = { path = "../moq-congestion", features = ["lab"] } # A bufferbloated path for the receive-credit tests and benchmark. moq-shaper = { path = "../moq-shaper" } # The tests run QUIC sessions on the simulator. Only `sim`, so a test build keeps the diff --git a/rs/moq-tokio/tests/integration/scream.rs b/rs/moq-tokio/tests/integration/scream.rs index 29af29e98c7..5878bfecead 100644 --- a/rs/moq-tokio/tests/integration/scream.rs +++ b/rs/moq-tokio/tests/integration/scream.rs @@ -1,4 +1,4 @@ -//! SCReAMv2 ([`moq_congestion_lab::scream::Scream`]) over real sockets through the cellular moq-shaper presets. +//! SCReAMv2 ([`congestion::scream::Scream`]) over real sockets through the cellular moq-shaper presets. //! //! A media sender encodes 30 frames a second at the controller's estimate, a keyframe every two //! seconds, each group on its own stream, up through the shaper's uplink. Each frame carries when @@ -221,7 +221,7 @@ async fn run(preset: &moq_shaper::Preset) -> Run { .with_no_client_auth(); let mut client = driver::client::Config::new(Arc::new(tls)); client.transport.congestion = Arc::new(Recorder { - inner: Arc::new(moq_congestion_lab::scream::Config::default()), + inner: Arc::new(congestion::scream::Config::default()), log: log.clone(), }); client.transport.receive_timestamps = std::num::NonZeroU32::new(32); diff --git a/sh/gh/nightly.sh b/sh/gh/nightly.sh index 362aab0b176..e5cb56cb9f9 100755 --- a/sh/gh/nightly.sh +++ b/sh/gh/nightly.sh @@ -115,8 +115,8 @@ case "$1" in rust-test) export NEXTEST_PROFILE=bench NEXTEST_TEST_THREADS=1 nextest just rs bench-tests --no-fail-fast --run-ignored only \ - -p moq-bench -p moq-congestion -p moq-congestion-lab -p moq-quic -p moq-net -p moq-tokio -p moq-uring \ - --features moq-net/async --lib --bin moq-bench --test integration \ + -p moq-bench -p moq-congestion -p moq-quic -p moq-net -p moq-tokio -p moq-uring \ + --features moq-net/async,moq-congestion/lab --lib --bin moq-bench --test integration \ -E 'test(benchmark_observation_contention) | test(benchmark_readiness_establishment) | test(benchmark_per_packet) | test(benchmark_feed_fetch_wakes) | test(=mesh_sweep::benchmark_route_mesh) | test(benchmark_route_rules) | test(benchmark_route_churn) | test(benchmark_receive_credit) | test(benchmark_receive_windows) | test(benchmark_datagram_delivery) | test(benchmark_socket_queues)' ;; rust-test-apps)