Skip to content

Commit

Permalink
recovery: introduce pacing rate multiplier
Browse files Browse the repository at this point in the history
From RFC9002, section 7.7:

    Using a value for N that is small, but at least 1 (for example,
    1.25) ensures that variations in RTT do not result in
    underutilization of the congestion window.
  • Loading branch information
ghedo committed Sep 23, 2021
1 parent cc1f8a2 commit b63c3e5
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/recovery/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ const MINIMUM_WINDOW_PACKETS: usize = 2;

const LOSS_REDUCTION_FACTOR: f64 = 0.5;

const PACING_MULTIPLIER: f64 = 1.25;

const MICROS_PER_SEC: u64 = 1_000_000;

pub struct Recovery {
Expand Down Expand Up @@ -285,8 +287,10 @@ impl Recovery {
// Pacing: Set the pacing rate if CC doesn't do its own.
if !(self.cc_ops.has_custom_pacing)() {
if let Some(srtt) = self.smoothed_rtt {
let rate = (self.congestion_window as u64 * MICROS_PER_SEC) /
srtt.as_micros() as u64;
let cwnd = self.congestion_window as u64;
let rate =
(cwnd * MICROS_PER_SEC) as f64 / srtt.as_micros() as f64;
let rate = (rate * PACING_MULTIPLIER) as u64;
self.set_pacing_rate(rate);
}
}
Expand Down Expand Up @@ -1953,11 +1957,11 @@ mod tests {

// We pace this outgoing packet. as all conditions for pacing
// are passed.
assert_eq!(r.pacing_rate, (12000.0 / 0.05) as u64);
assert_eq!(r.pacing_rate, (12000.0 * PACING_MULTIPLIER / 0.05) as u64);
assert_eq!(
r.get_packet_send_time().unwrap(),
now + Duration::from_micros(
(6500 * 1000000) / (12000.0 / 0.05) as u64
(6500 * 1000000) / (12000.0 * PACING_MULTIPLIER / 0.05) as u64
)
);
}
Expand Down

0 comments on commit b63c3e5

Please sign in to comment.