Skip to content

Commit

Permalink
cc: initial implementation of BBRv2 congestion control algorithm
Browse files Browse the repository at this point in the history
Based on draft-cardwell-iccrg-bbr-congestion-control-02.

Largely based on bbr module but most of functions are
renamed/changed a bit. per_loss.rs contains loss-related
functions.
  • Loading branch information
junhochoi authored and ghedo committed Aug 29, 2023
1 parent 9f25785 commit 39ce9ca
Show file tree
Hide file tree
Showing 10 changed files with 1,842 additions and 9 deletions.
1 change: 1 addition & 0 deletions quiche/include/quiche.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,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
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

0 comments on commit 39ce9ca

Please sign in to comment.