Skip to content

Commit

Permalink
Use packet number instead of time sent to identify packets sent after…
Browse files Browse the repository at this point in the history
… recovery event

This doesn't change behavior, simplifies after_recovery_start check by
removing the ambiguousness when the recovery packet was sent at the same
time as some other packet.
  • Loading branch information
mb committed Nov 2, 2023
1 parent 310a9d1 commit 887d256
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions neqo-transport/src/cc/classic_cc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use std::time::{Duration, Instant};
use super::CongestionControl;

use crate::cc::MAX_DATAGRAM_SIZE;
use crate::packet::PacketNumber;
use crate::qlog::{self, QlogMetric};
use crate::sender::PACING_BURST_SIZE;
use crate::tracking::SentPacket;
Expand Down Expand Up @@ -109,7 +110,7 @@ pub struct ClassicCongestionControl<T> {
bytes_in_flight: usize,
acked_bytes: usize,
ssthresh: usize,
recovery_start: Option<Instant>,
recovery_start: Option<PacketNumber>,

qlog: NeqoQlog,
}
Expand Down Expand Up @@ -315,7 +316,7 @@ impl<T: WindowAdjustment> CongestionControl for ClassicCongestionControl<T> {
fn on_packet_sent(&mut self, pkt: &SentPacket) {
// Record the recovery time and exit any transient state.
if self.state.transient() {
self.recovery_start = Some(pkt.time_sent);
self.recovery_start = Some(pkt.pn);
self.state.update();
}

Expand Down Expand Up @@ -464,7 +465,7 @@ impl<T: WindowAdjustment> ClassicCongestionControl<T> {
// state and update the variable `self.recovery_start`. Before the
// first recovery, all packets were sent after the recovery event,
// allowing to reduce the cwnd on congestion events.
!self.state.transient() && self.recovery_start.map_or(true, |t| packet.time_sent >= t)
!self.state.transient() && self.recovery_start.map_or(true, |pn| packet.pn >= pn)
}

/// Handle a congestion event.
Expand Down

0 comments on commit 887d256

Please sign in to comment.