/// Called when packets are lost. Returns true if the congestion window was reduced. pubfn on_packets_lost(
&mutself,
first_rtt_sample_time: Option<Instant>,
prev_largest_acked_sent: Option<Instant>,
pto: Duration,
lost_packets: &[sent::Packet],
stats: &mut Stats,
now: Instant,
) -> bool { let ret = self.cc.on_packets_lost(
first_rtt_sample_time,
prev_largest_acked_sent,
pto,
lost_packets,
now,
&mut stats.cc,
); // Call below may change the size of MTU probes, so it needs to happen after the CC // reaction above, which needs to ignore probes based on their size. self.pmtud_mut().on_packets_lost(lost_packets, stats, now); self.maybe_update_pacer_mtu();
ret
}
/// Called when ECN CE mark received. Returns true if the congestion window was reduced. pubfn on_ecn_ce_received(
&mutself,
largest_acked_pkt: &sent::Packet,
now: Instant,
cc_stats: &mut CongestionControlStats,
) -> bool { self.cc.on_ecn_ce_received(largest_acked_pkt, now, cc_stats)
}
/// When we migrate, the congestion controller for the previously active path drops /// all bytes in flight. pubfn discard_in_flight(&mutself, now: Instant) { self.cc.discard_in_flight(now);
}
#[must_use] pubfn next_paced(&self, rtt: Duration) -> Option<Instant> { // Only pace if there are bytes in flight.
(self.cc.bytes_in_flight() > 0).then(|| self.pacer.next(rtt, self.cc.cwnd()))
}
/// Send `n` packets at once, ACK them one RTT later, return (`cwnd_before`, `cwnd_after`). fn send_and_ack(pacing: bool, n: usize) -> (usize, usize) { letmut sender = make_sender(pacing); let now = now(); let mtu = sender.pmtud().plpmtu(); let cwnd_before = sender.cwnd();
let pkts: Vec<_> = (0..n)
.map(|pn| { let p = sent::make_packet(pn as u64, now, mtu);
sender.on_packet_sent(&p, RTT, now);
p
})
.collect();
sender.on_packets_acked(
&pkts,
&RttEstimate::new(RTT),
now + RTT,
&mut Stats::default(),
);
(cwnd_before, sender.cwnd())
}
#[test] fn pacing_limited_allows_cwnd_growth() { // Sending more than PACING_BURST_SIZE packets exhausts burst credit, // making subsequent sends pacing-limited rather than app-limited. let (before, after) = send_and_ack(true, super::PACING_BURST_SIZE + 1);
assert!(after > before, "cwnd should grow: {after} vs {before}");
}
#[test] fn app_limited_suppresses_cwnd_growth() { // A single packet is well below cwnd and within burst — genuinely app-limited. let (before, after) = send_and_ack(true, 1);
assert_eq!(after, before, "cwnd should not grow when app-limited");
}
#[test] fn pacing_disabled_never_pacing_limited() { // With pacing off, spend() always returns false, so single-packet // sends remain app-limited regardless of burst budget. let (before, after) = send_and_ack(false, 1);
assert_eq!(after, before, "cwnd should not grow with pacing disabled");
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.25 Sekunden
(vorverarbeitet am 2026-08-25)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.