Don't enter persistent congestion without an RTT sample

RFC 9002 §7.6.2: [..] a prior RTT sample existed when these two
packets were sent.
This commit is contained in:
Benjamin Saunders
2021-11-02 19:11:34 -07:00
committed by Dirkjan Ochtman
parent f116fc1adf
commit c35e61a9e3
2 changed files with 17 additions and 2 deletions
+10 -1
View File
@@ -1159,6 +1159,10 @@ impl Connection {
};
let rtt = instant_saturating_sub(now, self.spaces[space].largest_acked_packet_sent);
self.path.rtt.update(ack_delay, rtt);
if self.path.first_packet_after_rtt_sample.is_none() {
self.path.first_packet_after_rtt_sample =
Some((space, self.spaces[space].next_packet_number));
}
}
// Must be called before crypto/pto_count are clobbered
@@ -1338,7 +1342,12 @@ impl Connection {
Some(start) if info.time_sent - start > congestion_period => {
in_persistent_congestion = true;
}
None => {
// Persistent congestion must start after the first RTT sample
None if self
.path
.first_packet_after_rtt_sample
.map_or(false, |x| x < (pn_space, packet)) =>
{
persistent_congestion_start = Some(info.time_sent);
}
_ => {}
+7 -1
View File
@@ -1,7 +1,7 @@
use std::{cmp, net::SocketAddr, time::Duration, time::Instant};
use super::pacing::Pacer;
use crate::{congestion, INITIAL_MAX_UDP_PAYLOAD_SIZE, TIMER_GRANULARITY};
use crate::{congestion, packet::SpaceId, INITIAL_MAX_UDP_PAYLOAD_SIZE, TIMER_GRANULARITY};
/// Description of a particular network path
pub struct PathData {
@@ -25,6 +25,10 @@ pub struct PathData {
/// Total size of all UDP datagrams received on this path
pub total_recvd: u64,
pub max_udp_payload_size: u16,
/// Packet number of the first packet sent after an RTT sample was collected on this path
///
/// Used in persistent congestion determination.
pub first_packet_after_rtt_sample: Option<(SpaceId, u64)>,
}
impl PathData {
@@ -52,6 +56,7 @@ impl PathData {
total_sent: 0,
total_recvd: 0,
max_udp_payload_size: INITIAL_MAX_UDP_PAYLOAD_SIZE,
first_packet_after_rtt_sample: None,
}
}
@@ -75,6 +80,7 @@ impl PathData {
total_sent: 0,
total_recvd: 0,
max_udp_payload_size: prev.max_udp_payload_size,
first_packet_after_rtt_sample: prev.first_packet_after_rtt_sample,
}
}