Skip to content

Commit

Permalink
Do not encode long RTT guesses in resumption tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
larseggert committed Sep 9, 2024
1 parent c01c442 commit b736526
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions neqo-transport/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ use crate::{
quic_datagrams::{DatagramTracking, QuicDatagrams},
recovery::{LossRecovery, RecoveryToken, SendProfile, SentPacket},
recv_stream::RecvStreamStats,
rtt::{RttEstimate, GRANULARITY},
rtt::{RttEstimate, GRANULARITY, INITIAL_RTT},
send_stream::SendStream,
stats::{Stats, StatsCell},
stream_id::StreamType,
Expand Down Expand Up @@ -594,9 +594,25 @@ impl Connection {
fn make_resumption_token(&mut self) -> ResumptionToken {
debug_assert_eq!(self.role, Role::Client);
debug_assert!(self.crypto.has_resumption_token());
// Values less than GRANULARITY are ignored when using the token, so use 0 where needed.
let zero = Duration::from_millis(0);
let rtt = self.paths.primary().map_or_else(
|| RttEstimate::default().estimate(),
|p| p.borrow().rtt().estimate(),
|| zero,
|p| {
let rtt = p.borrow().rtt().estimate();
// Do not encode a guestimated RTT if we have no actual samples and the guess is
// larger than the default initial RTT. (The guess can be very large under lossy
// conditions.)
if p.borrow().rtt().first_sample_time().is_none() {
if rtt < INITIAL_RTT {
rtt
} else {
zero
}
} else {
rtt
}
},
);

self.crypto
Expand Down

0 comments on commit b736526

Please sign in to comment.