Skip to content

Commit 5445216

Browse files
committed
add initial RTT configurability
1 parent 7e8d22d commit 5445216

File tree

4 files changed

+26
-8
lines changed

4 files changed

+26
-8
lines changed

neqo-bin/src/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ pub struct QuicParameters {
116116
/// The idle timeout for connections, in seconds.
117117
pub idle_timeout: u64,
118118

119+
#[arg(long = "init_rtt", default_value = "100")]
120+
/// The initial round-trip time.
121+
pub initial_rtt_ms: u64,
122+
119123
#[arg(long = "cc", default_value = "newreno")]
120124
/// The congestion controller to use.
121125
pub congestion_control: CongestionControlAlgorithm,
@@ -213,6 +217,7 @@ impl QuicParameters {
213217
.max_streams(StreamType::BiDi, self.max_streams_bidi)
214218
.max_streams(StreamType::UniDi, self.max_streams_uni)
215219
.idle_timeout(Duration::from_secs(self.idle_timeout))
220+
.initial_rtt(Duration::from_millis(self.initial_rtt_ms))
216221
.cc_algorithm(self.congestion_control)
217222
.pacing(!self.no_pacing)
218223
.pmtud(!self.no_pmtud);

neqo-transport/src/connection/params.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub use crate::recovery::FAST_PTO_SCALE;
1010
use crate::{
1111
connection::{ConnectionIdManager, Role, LOCAL_ACTIVE_CID_LIMIT},
1212
recv_stream::RECV_BUFFER_SIZE,
13-
rtt::GRANULARITY,
13+
rtt::{DEFAULT_INITIAL_RTT, GRANULARITY},
1414
stream_id::StreamType,
1515
tparams::{self, PreferredAddress, TransportParameter, TransportParametersHandler},
1616
tracking::DEFAULT_ACK_DELAY,
@@ -70,6 +70,7 @@ pub struct ConnectionParameters {
7070
/// acknowledgments every round trip, set the value to `5 * ACK_RATIO_SCALE`.
7171
/// Values less than `ACK_RATIO_SCALE` are clamped to `ACK_RATIO_SCALE`.
7272
ack_ratio: u8,
73+
initial_rtt: Duration,
7374
/// The duration of the idle timeout for the connection.
7475
idle_timeout: Duration,
7576
preferred_address: PreferredAddressConfig,
@@ -96,6 +97,7 @@ impl Default for ConnectionParameters {
9697
max_streams_uni: LOCAL_STREAM_LIMIT_UNI,
9798
ack_ratio: DEFAULT_ACK_RATIO,
9899
idle_timeout: DEFAULT_IDLE_TIMEOUT,
100+
initial_rtt: DEFAULT_INITIAL_RTT,
99101
preferred_address: PreferredAddressConfig::Default,
100102
datagram_size: 0,
101103
outgoing_datagram_queue: MAX_QUEUED_DATAGRAMS_DEFAULT,
@@ -268,6 +270,17 @@ impl ConnectionParameters {
268270
self.datagram_size
269271
}
270272

273+
#[must_use]
274+
pub const fn get_initial_rtt(&self) -> Duration {
275+
self.initial_rtt
276+
}
277+
278+
#[must_use]
279+
pub const fn initial_rtt(mut self, init_rtt: Duration) -> Self {
280+
self.initial_rtt = init_rtt;
281+
self
282+
}
283+
271284
#[must_use]
272285
pub const fn datagram_size(mut self, v: u64) -> Self {
273286
self.datagram_size = v;

neqo-transport/src/connection/tests/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -664,8 +664,8 @@ fn create_client() {
664664
assert!(matches!(client.state(), State::Init));
665665
let stats = client.stats();
666666
assert_default_stats(&stats);
667-
assert_eq!(stats.rtt, crate::rtt::INITIAL_RTT);
668-
assert_eq!(stats.rttvar, crate::rtt::INITIAL_RTT / 2);
667+
assert_eq!(stats.rtt, crate::rtt::DEFAULT_INITIAL_RTT);
668+
assert_eq!(stats.rttvar, crate::rtt::DEFAULT_INITIAL_RTT / 2);
669669
}
670670

671671
#[test]

neqo-transport/src/rtt.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use crate::{
2626
/// `select()`, or similar) can reliably deliver; see `neqo_common::hrtime`.
2727
pub const GRANULARITY: Duration = Duration::from_millis(1);
2828
// Defined in -recovery 6.2 as 333ms but using lower value.
29-
pub const INITIAL_RTT: Duration = Duration::from_millis(100);
29+
pub const DEFAULT_INITIAL_RTT: Duration = Duration::from_millis(100);
3030

3131
#[derive(Debug)]
3232
#[allow(clippy::module_name_repetitions)]
@@ -200,10 +200,10 @@ impl Default for RttEstimate {
200200
fn default() -> Self {
201201
Self {
202202
first_sample_time: None,
203-
latest_rtt: INITIAL_RTT,
204-
smoothed_rtt: INITIAL_RTT,
205-
rttvar: INITIAL_RTT / 2,
206-
min_rtt: INITIAL_RTT,
203+
latest_rtt: DEFAULT_INITIAL_RTT,
204+
smoothed_rtt: DEFAULT_INITIAL_RTT,
205+
rttvar: DEFAULT_INITIAL_RTT / 2,
206+
min_rtt: DEFAULT_INITIAL_RTT,
207207
ack_delay: PeerAckDelay::default(),
208208
}
209209
}

0 commit comments

Comments
 (0)