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

BBR2 - Fixes and updates #1521

Closed
wants to merge 19 commits into from
Closed
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
1 change: 1 addition & 0 deletions quiche/include/quiche.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ enum quiche_cc_algorithm {
QUICHE_CC_RENO = 0,
QUICHE_CC_CUBIC = 1,
QUICHE_CC_BBR = 2,
QUICHE_CC_BBR2 = 3,
};

// Sets the congestion control algorithm used.
Expand Down
2 changes: 2 additions & 0 deletions quiche/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4256,6 +4256,8 @@ impl Connection {
delivered_time: now,
first_sent_time: now,
is_app_limited: false,
tx_in_flight: 0,
lost: 0,
has_data,
};

Expand Down
18 changes: 16 additions & 2 deletions quiche/src/recovery/bbr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,13 +323,13 @@ fn on_packets_acked(
}

fn congestion_event(
r: &mut Recovery, lost_bytes: usize, time_sent: Instant,
r: &mut Recovery, lost_bytes: usize, largest_lost_pkt: &Sent,
_epoch: packet::Epoch, now: Instant,
) {
r.bbr_state.newly_lost_bytes = lost_bytes;

// Upon entering Fast Recovery.
if !r.in_congestion_recovery(time_sent) {
if !r.in_congestion_recovery(largest_lost_pkt.time_sent) {
// Upon entering Fast Recovery.
bbr_enter_recovery(r, now);
}
Expand Down Expand Up @@ -426,6 +426,8 @@ mod tests {
delivered_time: now,
first_sent_time: now,
is_app_limited: false,
tx_in_flight: 0,
lost: 0,
has_data: false,
};

Expand Down Expand Up @@ -494,6 +496,8 @@ mod tests {
delivered_time: now,
first_sent_time: now,
is_app_limited: false,
tx_in_flight: 0,
lost: 0,
has_data: false,
};

Expand Down Expand Up @@ -561,6 +565,8 @@ mod tests {
delivered_time: now,
first_sent_time: now,
is_app_limited: false,
tx_in_flight: 0,
lost: 0,
has_data: false,
};

Expand Down Expand Up @@ -610,6 +616,8 @@ mod tests {
delivered_time: now,
first_sent_time: now,
is_app_limited: false,
tx_in_flight: 0,
lost: 0,
has_data: false,
};

Expand Down Expand Up @@ -680,6 +688,8 @@ mod tests {
delivered_time: now,
first_sent_time: now,
is_app_limited: false,
tx_in_flight: 0,
lost: 0,
has_data: false,
};

Expand Down Expand Up @@ -749,6 +759,8 @@ mod tests {
delivered_time: now,
first_sent_time: now,
is_app_limited: false,
tx_in_flight: 0,
lost: 0,
has_data: false,
};

Expand Down Expand Up @@ -801,6 +813,8 @@ mod tests {
delivered_time: now,
first_sent_time: now,
is_app_limited: false,
tx_in_flight: 0,
lost: 0,
has_data: false,
};

Expand Down
90 changes: 90 additions & 0 deletions quiche/src/recovery/bbr2/init.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// Copyright (C) 2022, Cloudflare, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

use super::*;
use crate::recovery::Recovery;

use std::time::Instant;

// BBR2 Functions at Initialization.
//

// 4.2.1. Initialization
pub fn bbr2_init(r: &mut Recovery) {
let rtt = r.rtt();
let now = Instant::now();

let bbr = &mut r.bbr2_state;
bbr.min_rtt = rtt;
bbr.min_rtt_stamp = now;
bbr.probe_rtt_done_stamp = None;
bbr.probe_rtt_round_done = false;
bbr.prior_cwnd = 0;
bbr.idle_restart = false;
bbr.extra_acked_interval_start = now;
bbr.extra_acked_delivered = 0;
bbr.bw_lo = u64::MAX;
bbr.bw_hi = u64::MAX;
bbr.inflight_lo = usize::MAX;
bbr.inflight_hi = usize::MAX;
bbr.probe_up_cnt = usize::MAX;

r.send_quantum = r.max_datagram_size;

per_loss::bbr2_reset_congestion_signals(r);
per_loss::bbr2_reset_lower_bounds(r);
bbr2_init_round_counting(r);
bbr2_init_full_pipe(r);
pacing::bbr2_init_pacing_rate(r);
bbr2_enter_startup(r);
}

// 4.5.1. BBR.round_count: Tracking Packet-Timed Round Trips
fn bbr2_init_round_counting(r: &mut Recovery) {
let bbr = &mut r.bbr2_state;

bbr.next_round_delivered = 0;
bbr.round_start = false;
bbr.round_count = 0;
}

// 4.3.1.1. Startup Dynamics
pub fn bbr2_enter_startup(r: &mut Recovery) {
let bbr = &mut r.bbr2_state;

bbr.state = BBR2StateMachine::Startup;
bbr.pacing_gain = STARTUP_PACING_GAIN;
bbr.cwnd_gain = STARTUP_CWND_GAIN;
}

// 4.3.1.2. Exiting Startup Based on Bandwidth Plateau
fn bbr2_init_full_pipe(r: &mut Recovery) {
let bbr = &mut r.bbr2_state;

bbr.filled_pipe = false;
bbr.full_bw = 0;
bbr.full_bw_count = 0;
}
Loading
Loading