Skip to content

Commit

Permalink
add initial RTT configurability
Browse files Browse the repository at this point in the history
  • Loading branch information
robamu committed Aug 29, 2024
1 parent 7e8d22d commit 5445216
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
5 changes: 5 additions & 0 deletions neqo-bin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ pub struct QuicParameters {
/// The idle timeout for connections, in seconds.
pub idle_timeout: u64,

#[arg(long = "init_rtt", default_value = "100")]
/// The initial round-trip time.
pub initial_rtt_ms: u64,

#[arg(long = "cc", default_value = "newreno")]
/// The congestion controller to use.
pub congestion_control: CongestionControlAlgorithm,
Expand Down Expand Up @@ -213,6 +217,7 @@ impl QuicParameters {
.max_streams(StreamType::BiDi, self.max_streams_bidi)
.max_streams(StreamType::UniDi, self.max_streams_uni)
.idle_timeout(Duration::from_secs(self.idle_timeout))
.initial_rtt(Duration::from_millis(self.initial_rtt_ms))
.cc_algorithm(self.congestion_control)
.pacing(!self.no_pacing)
.pmtud(!self.no_pmtud);
Expand Down
15 changes: 14 additions & 1 deletion neqo-transport/src/connection/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub use crate::recovery::FAST_PTO_SCALE;
use crate::{
connection::{ConnectionIdManager, Role, LOCAL_ACTIVE_CID_LIMIT},
recv_stream::RECV_BUFFER_SIZE,
rtt::GRANULARITY,
rtt::{DEFAULT_INITIAL_RTT, GRANULARITY},
stream_id::StreamType,
tparams::{self, PreferredAddress, TransportParameter, TransportParametersHandler},
tracking::DEFAULT_ACK_DELAY,
Expand Down Expand Up @@ -70,6 +70,7 @@ pub struct ConnectionParameters {
/// acknowledgments every round trip, set the value to `5 * ACK_RATIO_SCALE`.
/// Values less than `ACK_RATIO_SCALE` are clamped to `ACK_RATIO_SCALE`.
ack_ratio: u8,
initial_rtt: Duration,
/// The duration of the idle timeout for the connection.
idle_timeout: Duration,
preferred_address: PreferredAddressConfig,
Expand All @@ -96,6 +97,7 @@ impl Default for ConnectionParameters {
max_streams_uni: LOCAL_STREAM_LIMIT_UNI,
ack_ratio: DEFAULT_ACK_RATIO,
idle_timeout: DEFAULT_IDLE_TIMEOUT,
initial_rtt: DEFAULT_INITIAL_RTT,
preferred_address: PreferredAddressConfig::Default,
datagram_size: 0,
outgoing_datagram_queue: MAX_QUEUED_DATAGRAMS_DEFAULT,
Expand Down Expand Up @@ -268,6 +270,17 @@ impl ConnectionParameters {
self.datagram_size
}

#[must_use]
pub const fn get_initial_rtt(&self) -> Duration {
self.initial_rtt
}

#[must_use]
pub const fn initial_rtt(mut self, init_rtt: Duration) -> Self {
self.initial_rtt = init_rtt;
self
}

#[must_use]
pub const fn datagram_size(mut self, v: u64) -> Self {
self.datagram_size = v;
Expand Down
4 changes: 2 additions & 2 deletions neqo-transport/src/connection/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,8 +664,8 @@ fn create_client() {
assert!(matches!(client.state(), State::Init));
let stats = client.stats();
assert_default_stats(&stats);
assert_eq!(stats.rtt, crate::rtt::INITIAL_RTT);
assert_eq!(stats.rttvar, crate::rtt::INITIAL_RTT / 2);
assert_eq!(stats.rtt, crate::rtt::DEFAULT_INITIAL_RTT);
assert_eq!(stats.rttvar, crate::rtt::DEFAULT_INITIAL_RTT / 2);
}

#[test]
Expand Down
10 changes: 5 additions & 5 deletions neqo-transport/src/rtt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use crate::{
/// `select()`, or similar) can reliably deliver; see `neqo_common::hrtime`.
pub const GRANULARITY: Duration = Duration::from_millis(1);
// Defined in -recovery 6.2 as 333ms but using lower value.
pub const INITIAL_RTT: Duration = Duration::from_millis(100);
pub const DEFAULT_INITIAL_RTT: Duration = Duration::from_millis(100);

#[derive(Debug)]
#[allow(clippy::module_name_repetitions)]
Expand Down Expand Up @@ -200,10 +200,10 @@ impl Default for RttEstimate {
fn default() -> Self {
Self {
first_sample_time: None,
latest_rtt: INITIAL_RTT,
smoothed_rtt: INITIAL_RTT,
rttvar: INITIAL_RTT / 2,
min_rtt: INITIAL_RTT,
latest_rtt: DEFAULT_INITIAL_RTT,
smoothed_rtt: DEFAULT_INITIAL_RTT,
rttvar: DEFAULT_INITIAL_RTT / 2,
min_rtt: DEFAULT_INITIAL_RTT,
ack_delay: PeerAckDelay::default(),
}
}
Expand Down

0 comments on commit 5445216

Please sign in to comment.