Skip to content

Commit 032ebef

Browse files
feat(proto): replace BBR with BBRv3 + breaking Controller API changes
Pulls in upstream quinn PR quinn-rs/quinn#2481 Squashes the four upstream commits and adapts them to noq's multipath divergence Closes 603 Upstream commits - f8b25b24b - granular packet events for congestion controllers - 52f04ed9b - Pacer queries Controller for pacing rate / send quantum - c022e308a - BBRv3 implementation + MaxFilter - ce60e5b5c - remove old BBR implementation Breaking changes to `Controller` trait: - `on_ack` gains `pn: u64` - `on_congestion_event` gains `largest_lost: u64` - New optional `on_packet_sent`, `on_packet_lost`, `on_ack_frequency_update` - New `metrics()` -> `ControllerMetrics { congestion_window, ssthresh, pacing_rate, send_quantum }`, used by the pacer Pacer changes: - `Pacer::delay()` now also takes `capacity: Option<u64>` and `pacing_rate: Option<u64>` from the controller; CC-supplied values take precedence over the window-derived defaults but are still capped by noq's `max_bytes_per_second`. Co-authored-by: Tipuch <fiorini751@proton.me>
1 parent 4a310f7 commit 032ebef

13 files changed

Lines changed: 2054 additions & 938 deletions

File tree

noq-proto/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ identity-hash = { workspace = true }
6464
lru-slab = { workspace = true }
6565
qlog = { workspace = true, optional = true }
6666
rand = { workspace = true }
67+
rand_pcg = "0.10"
6768
ring = { workspace = true, optional = true }
6869
rustc-hash = { workspace = true }
6970
rustls = { workspace = true, optional = true }
@@ -86,7 +87,6 @@ web-time = { workspace = true }
8687
assert_matches = { workspace = true }
8788
hex-literal = { workspace = true }
8889
proptest = { workspace = true }
89-
rand_pcg = "0.10"
9090
rcgen = { workspace = true }
9191
test-strategy = { workspace = true }
9292
testresult = "0.4.1"

noq-proto/src/congestion.rs

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
//! Logic for controlling the rate at which data is sent
22
3-
use crate::Instant;
43
use crate::connection::RttEstimator;
4+
use crate::{Duration, Instant};
55
use std::any::Any;
66
use std::sync::Arc;
77

8-
mod bbr;
8+
mod bbr3;
99
mod cubic;
1010
mod new_reno;
1111

12-
pub use bbr::{Bbr, BbrConfig};
12+
pub use bbr3::{Bbr3, Bbr3Config};
1313
pub use cubic::{Cubic, CubicConfig};
1414
pub use new_reno::{NewReno, NewRenoConfig};
1515

@@ -19,6 +19,10 @@ pub trait Controller: Send + Sync + std::fmt::Debug {
1919
#[allow(unused_variables)]
2020
fn on_sent(&mut self, now: Instant, bytes: u64, last_packet_number: u64) {}
2121

22+
/// One packet was just sent
23+
#[allow(unused_variables)]
24+
fn on_packet_sent(&mut self, now: Instant, bytes: u16, packet_number: u64) {}
25+
2226
/// Packet deliveries were confirmed
2327
///
2428
/// `app_limited` indicates whether the connection was blocked on outgoing
@@ -29,6 +33,7 @@ pub trait Controller: Send + Sync + std::fmt::Debug {
2933
now: Instant,
3034
sent: Instant,
3135
bytes: u64,
36+
pn: u64,
3237
app_limited: bool,
3338
rtt: &RttEstimator,
3439
) {
@@ -51,15 +56,22 @@ pub trait Controller: Send + Sync + std::fmt::Debug {
5156
/// congestion threshold period ending when the most recent packet in this batch was sent were
5257
/// lost.
5358
/// `lost_bytes` indicates how many bytes were lost. This value will be 0 for ECN triggers.
59+
/// `largest_lost` indicates the packet number of the packet with the highest packet number
60+
/// in the congestion event.
5461
fn on_congestion_event(
5562
&mut self,
5663
now: Instant,
5764
sent: Instant,
5865
is_persistent_congestion: bool,
5966
is_ecn: bool,
6067
lost_bytes: u64,
68+
largest_lost: u64,
6169
);
6270

71+
/// One packet was just lost
72+
#[allow(unused_variables)]
73+
fn on_packet_lost(&mut self, lost_bytes: u16, packet_number: u64, now: Instant) {}
74+
6375
/// Packets were incorrectly deemed lost
6476
///
6577
/// This function is called when all packets that were deemed lost (for instance because
@@ -69,15 +81,35 @@ pub trait Controller: Send + Sync + std::fmt::Debug {
6981
/// The known MTU for the current network path has been updated
7082
fn on_mtu_update(&mut self, new_mtu: u16);
7183

84+
/// The peer's ACK-frequency parameters have changed
85+
///
86+
/// `ack_eliciting_threshold` is the number of ack-eliciting packets the peer may receive
87+
/// before being required to send an immediate ACK (per the QUIC ACK frequency extension).
88+
/// `requested_max_ack_delay` is the maximum delay we asked the peer to wait before sending
89+
/// an ACK when the threshold hasn't been reached.
90+
///
91+
/// Controllers can use this to refine estimates that depend on peer ACK behavior (e.g.
92+
/// BBR's offload budget).
93+
#[allow(unused_variables)]
94+
fn on_ack_frequency_update(
95+
&mut self,
96+
ack_eliciting_threshold: u64,
97+
requested_max_ack_delay: Duration,
98+
) {
99+
}
100+
72101
/// Number of ack-eliciting bytes that may be in flight
73102
fn window(&self) -> u64;
74103

75104
/// Retrieve implementation-specific metrics used to populate `qlog` traces when they are enabled
105+
/// This is also used to alter the pacing of the connection with
106+
/// `pacing_rate` and `send_quantum`
76107
fn metrics(&self) -> ControllerMetrics {
77108
ControllerMetrics {
78109
congestion_window: self.window(),
79110
ssthresh: None,
80111
pacing_rate: None,
112+
send_quantum: None,
81113
}
82114
}
83115

@@ -91,16 +123,20 @@ pub trait Controller: Send + Sync + std::fmt::Debug {
91123
fn into_any(self: Box<Self>) -> Box<dyn Any>;
92124
}
93125

94-
/// Common congestion controller metrics
95-
#[derive(Default, Debug)]
126+
/// Common congestion controller metrics used both for logging purposes
127+
/// but also to alter the pacing of the connection with
128+
/// `pacing_rate` and `send_quantum`
129+
#[derive(Default)]
96130
#[non_exhaustive]
97131
pub struct ControllerMetrics {
98132
/// Congestion window (bytes)
99133
pub congestion_window: u64,
100134
/// Slow start threshold (bytes)
101135
pub ssthresh: Option<u64>,
102-
/// Pacing rate (bits/s)
136+
/// Pacing rate (bytes/s)
103137
pub pacing_rate: Option<u64>,
138+
/// Send Quantum (bytes) used to control the size of packet bursts
139+
pub send_quantum: Option<u64>,
104140
}
105141

106142
/// Constructs controllers on demand

noq-proto/src/congestion/bbr/bw_estimation.rs

Lines changed: 0 additions & 100 deletions
This file was deleted.

noq-proto/src/congestion/bbr/min_max.rs

Lines changed: 0 additions & 152 deletions
This file was deleted.

0 commit comments

Comments
 (0)