From 2980d2cd2e7120a2163e4ade2c0e21a000628e9c Mon Sep 17 00:00:00 2001 From: Wesley Rosenblum Date: Mon, 1 Feb 2021 11:57:35 -0800 Subject: [PATCH] Record time the congestion window was last utilized and allow it to grow for 1 RTT past that time --- quic/s2n-quic-core/src/recovery/cubic.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/quic/s2n-quic-core/src/recovery/cubic.rs b/quic/s2n-quic-core/src/recovery/cubic.rs index ba66d60aac..13f254fcf7 100644 --- a/quic/s2n-quic-core/src/recovery/cubic.rs +++ b/quic/s2n-quic-core/src/recovery/cubic.rs @@ -82,6 +82,7 @@ pub struct CubicCongestionController { //# congestion feedback. bytes_in_flight: BytesInFlight, time_of_last_sent_packet: Option, + time_last_utilized: Option, } type BytesInFlight = Counter; @@ -162,13 +163,28 @@ impl CongestionController for CubicCongestionController { ack_receive_time: Timestamp, ) { // Check if the congestion window is under utilized before updating bytes in flight - let under_utilized = self.is_congestion_window_under_utilized(); + let utilized = !self.is_congestion_window_under_utilized(); self.bytes_in_flight .try_sub(sent_bytes) .expect("sent bytes should not exceed u32::MAX"); - if under_utilized { + if utilized { + // Update the time last utilized to this ack receive time since the window + // is currently utilized. + self.time_last_utilized = Some(ack_receive_time); + } else if self.time_last_utilized.map_or(true, |time_last_utilized| { + // Once the congestion window is utilized within an RTT round, we consider it utilized + // until the end of the round. Otherwise, subsequent acks received in the round prior to + // the application sending any more data would decrease bytes in flight to a degree that + // the congestion window may not be considered utilized. This would prevent the congestion + // window from growing even if the application has enough data to send to utilize the + // congestion window. See https://github.com/awslabs/s2n-quic/issues/458 + ack_receive_time - time_last_utilized > rtt_estimator.smoothed_rtt() + }) { + // It's been more than 1 rtt since the congestion window was utilized, so the + // congestion window should not be increased further. + //= https://tools.ietf.org/id/draft-ietf-quic-recovery-32.txt#7.8 //# When bytes in flight is smaller than the congestion window and //# sending is not pacing limited, the congestion window is under- @@ -336,6 +352,7 @@ impl CubicCongestionController { state: SlowStart, bytes_in_flight: Counter::new(0), time_of_last_sent_packet: None, + time_last_utilized: None, } }