Skip to content

Commit

Permalink
prague: initial potential complete implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
qdeconinck committed Jan 10, 2024
1 parent 533abc1 commit c24a9aa
Show file tree
Hide file tree
Showing 6 changed files with 686 additions and 16 deletions.
15 changes: 15 additions & 0 deletions quiche/src/recovery/bbr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub static BBR: CongestionControlOps = CongestionControlOps {
on_packet_sent,
on_packets_acked,
congestion_event,
process_ecn,
collapse_cwnd,
checkpoint,
rollback,
Expand Down Expand Up @@ -335,6 +336,20 @@ fn congestion_event(
}
}

fn process_ecn(
r: &mut Recovery, _newly_ecn_marked_acked: u64, new_ce_marks: u64,
_acked_bytes: usize, largest_sent: &Sent, epoch: packet::Epoch, now: Instant,
) {
if new_ce_marks > 0 {
r.congestion_event(
new_ce_marks as usize * r.max_datagram_size,
largest_sent,
epoch,
now,
);
}
}

fn collapse_cwnd(r: &mut Recovery) {
r.bbr_state.prior_cwnd = per_ack::bbr_save_cwnd(r);

Expand Down
15 changes: 15 additions & 0 deletions quiche/src/recovery/bbr2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub static BBR2: CongestionControlOps = CongestionControlOps {
on_packet_sent,
on_packets_acked,
congestion_event,
process_ecn,
collapse_cwnd,
checkpoint,
rollback,
Expand Down Expand Up @@ -610,6 +611,20 @@ fn congestion_event(
}
}

fn process_ecn(
r: &mut Recovery, _newly_ecn_marked_acked: u64, new_ce_marks: u64,
_acked_bytes: usize, largest_sent: &Sent, epoch: packet::Epoch, now: Instant,
) {
if new_ce_marks > 0 {
r.congestion_event(
new_ce_marks as usize * r.max_datagram_size,
largest_sent,
epoch,
now,
);
}
}

fn collapse_cwnd(r: &mut Recovery) {
// BBROnEnterRTO()
r.bbr2_state.prior_cwnd = per_ack::bbr2_save_cwnd(r);
Expand Down
15 changes: 15 additions & 0 deletions quiche/src/recovery/cubic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pub static CUBIC: CongestionControlOps = CongestionControlOps {
on_packet_sent,
on_packets_acked,
congestion_event,
process_ecn,
collapse_cwnd,
checkpoint,
rollback,
Expand Down Expand Up @@ -396,6 +397,20 @@ fn congestion_event(
}
}

fn process_ecn(
r: &mut Recovery, _newly_ecn_marked_acked: u64, new_ce_marks: u64,
_acked_bytes: usize, largest_sent: &Sent, epoch: packet::Epoch, now: Instant,
) {
if new_ce_marks > 0 {
r.congestion_event(
new_ce_marks as usize * r.max_datagram_size,
largest_sent,
epoch,
now,
);
}
}

fn checkpoint(r: &mut Recovery) {
r.cubic_state.prior.congestion_window = r.congestion_window;
r.cubic_state.prior.ssthresh = r.ssthresh;
Expand Down
52 changes: 37 additions & 15 deletions quiche/src/recovery/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ pub struct Recovery {

/// Initial congestion window size in terms of packet count.
initial_congestion_window_packets: usize,

/// Prague state.
prague_state: prague::State,
}

pub struct RecoveryConfig {
Expand Down Expand Up @@ -313,6 +316,8 @@ impl Recovery {

initial_congestion_window_packets: recovery_config
.initial_congestion_window_packets,

prague_state: prague::State::default(),
}
}

Expand Down Expand Up @@ -473,7 +478,7 @@ impl Recovery {
let mut has_ack_eliciting = false;

let mut largest_newly_acked_pkt_num = 0;
let mut largest_newly_acked_size = 0;
let mut newly_acked_size = 0;
let mut largest_newly_acked_sent_time = now;

let mut newly_ecn_marked_acked = 0;
Expand Down Expand Up @@ -548,7 +553,7 @@ impl Recovery {
}

largest_newly_acked_pkt_num = unacked.pkt_num;
largest_newly_acked_size = unacked.size;
newly_acked_size += unacked.size;
largest_newly_acked_sent_time = unacked.time_sent;

self.acked[epoch].extend(unacked.frames.drain(..));
Expand Down Expand Up @@ -638,7 +643,7 @@ impl Recovery {
self.process_ecn(
newly_ecn_marked_acked,
ecn_counts,
largest_newly_acked_size,
newly_acked_size,
&largest_sent,
epoch,
now,
Expand Down Expand Up @@ -1118,16 +1123,18 @@ impl Recovery {

fn process_ecn(
&mut self, newly_ecn_marked_acked: u64,
ecn_counts: Option<packet::EcnCounts>, largest_acked_size: usize,
ecn_counts: Option<packet::EcnCounts>, acked_size: usize,
largest_acked_sent: &Sent, epoch: packet::Epoch, now: Instant,
) {
if self
.ecn
.on_ack_received(epoch, newly_ecn_marked_acked, ecn_counts) >
0
{
self.congestion_event(
largest_acked_size,
let new_ce_marks =
self.ecn
.on_ack_received(epoch, newly_ecn_marked_acked, ecn_counts);
if newly_ecn_marked_acked > 0 {
(self.cc_ops.process_ecn)(
self,
newly_ecn_marked_acked,
new_ce_marks,
acked_size,
largest_acked_sent,
epoch,
now,
Expand Down Expand Up @@ -1199,13 +1206,15 @@ impl Recovery {
#[repr(C)]
pub enum CongestionControlAlgorithm {
/// Reno congestion control algorithm. `reno` in a string form.
Reno = 0,
Reno = 0,
/// CUBIC congestion control algorithm (default). `cubic` in a string form.
CUBIC = 1,
CUBIC = 1,
/// BBR congestion control algorithm. `bbr` in a string form.
BBR = 2,
BBR = 2,
/// BBRv2 congestion control algorithm. `bbr2` in a string form.
BBR2 = 3,
BBR2 = 3,
/// Prague congestion control algorithm. `prague` in a string form.
Prague = 4,
}

impl FromStr for CongestionControlAlgorithm {
Expand All @@ -1220,6 +1229,7 @@ impl FromStr for CongestionControlAlgorithm {
"cubic" => Ok(CongestionControlAlgorithm::CUBIC),
"bbr" => Ok(CongestionControlAlgorithm::BBR),
"bbr2" => Ok(CongestionControlAlgorithm::BBR2),
"prague" => Ok(CongestionControlAlgorithm::Prague),

_ => Err(crate::Error::CongestionControl),
}
Expand Down Expand Up @@ -1248,6 +1258,16 @@ pub struct CongestionControlOps {
now: Instant,
),

pub process_ecn: fn(
r: &mut Recovery,
newly_ecn_marked_acked: u64,
new_ce_marks: u64,
acked_bytes: usize,
sent: &Sent,
epoch: packet::Epoch,
now: Instant,
),

pub collapse_cwnd: fn(r: &mut Recovery),

pub checkpoint: fn(r: &mut Recovery),
Expand All @@ -1267,6 +1287,7 @@ impl From<CongestionControlAlgorithm> for &'static CongestionControlOps {
CongestionControlAlgorithm::CUBIC => &cubic::CUBIC,
CongestionControlAlgorithm::BBR => &bbr::BBR,
CongestionControlAlgorithm::BBR2 => &bbr2::BBR2,
CongestionControlAlgorithm::Prague => &prague::PRAGUE,
}
}
}
Expand Down Expand Up @@ -2374,5 +2395,6 @@ mod cubic;
mod delivery_rate;
mod hystart;
mod pacer;
mod prague;
mod prr;
mod reno;
Loading

0 comments on commit c24a9aa

Please sign in to comment.