Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proto: add a way to configure the minimum MTU change needed to stop the binary search used during the MTU discovery phase. #1702

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions quinn-proto/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ impl Default for AckFrequencyConfig {
pub struct MtuDiscoveryConfig {
pub(crate) interval: Duration,
pub(crate) upper_bound: u16,
pub(crate) minimum_change: u16,
pub(crate) black_hole_cooldown: Duration,
}

Expand Down Expand Up @@ -587,6 +588,13 @@ impl MtuDiscoveryConfig {
self.black_hole_cooldown = value;
self
}

/// Specifies the minimum MTU change to stop the MTU discovery phase.
/// Defaults to 20.
pub fn minimum_change(&mut self, value: u16) -> &mut Self {
self.minimum_change = value;
self
}
}

impl Default for MtuDiscoveryConfig {
Expand All @@ -595,6 +603,7 @@ impl Default for MtuDiscoveryConfig {
interval: Duration::from_secs(600),
upper_bound: 1452,
black_hole_cooldown: Duration::from_secs(60),
minimum_change: 20,
}
}
}
Expand Down
11 changes: 5 additions & 6 deletions quinn-proto/src/connection/mtud.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@ struct SearchState {
lower_bound: u16,
/// The upper bound for the current binary search
upper_bound: u16,
/// The minimum change to stop the current binary search
minimum_change: u16,
/// The UDP payload size we last sent a probe for
last_probed_mtu: u16,
/// Packet number of an in-flight probe (if any)
Expand All @@ -314,6 +316,7 @@ impl SearchState {
lost_probe_count: 0,
lower_bound,
upper_bound,
minimum_change: config.minimum_change,
// During initialization, we consider the lower bound to have already been
// successfully probed
last_probed_mtu: lower_bound,
Expand All @@ -333,13 +336,10 @@ impl SearchState {
let next_mtu = (self.lower_bound as i32 + self.upper_bound as i32) / 2;

// Binary search stopping condition
if ((next_mtu - self.last_probed_mtu as i32).unsigned_abs() as u16)
< BINARY_SEARCH_MINIMUM_CHANGE
{
if ((next_mtu - self.last_probed_mtu as i32).unsigned_abs() as u16) < self.minimum_change {
// Special case: if the upper bound is far enough, we want to probe it as a last
// step (otherwise we will never achieve the upper bound)
if self.upper_bound.saturating_sub(self.last_probed_mtu) >= BINARY_SEARCH_MINIMUM_CHANGE
{
if self.upper_bound.saturating_sub(self.last_probed_mtu) >= self.minimum_change {
return Some(self.upper_bound);
}

Expand Down Expand Up @@ -478,7 +478,6 @@ impl BlackHoleDetector {
// https://www.rfc-editor.org/rfc/rfc8899#section-5.1.2)
const MAX_PROBE_RETRANSMITS: usize = 3;
const BLACK_HOLE_THRESHOLD: u8 = 3;
const BINARY_SEARCH_MINIMUM_CHANGE: u16 = 20;

#[cfg(test)]
mod tests {
Expand Down
Loading