Skip to content

Commit 1b1ce85

Browse files
committed
adaptions for CLI arguments
1 parent 5445216 commit 1b1ce85

File tree

5 files changed

+20
-14
lines changed

5 files changed

+20
-14
lines changed

neqo-bin/src/lib.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use std::{
1717
use clap::Parser;
1818
use neqo_transport::{
1919
tparams::PreferredAddress, CongestionControlAlgorithm, ConnectionParameters, StreamType,
20-
Version,
20+
Version, INITIAL_RTT,
2121
};
2222

2323
pub mod client;
@@ -116,9 +116,9 @@ 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,
119+
#[arg(long = "init_rtt")]
120+
/// The initial round-trip time. Defaults to [``INITIAL_RTT``] if not specified.
121+
pub initial_rtt_ms: Option<u64>,
122122

123123
#[arg(long = "cc", default_value = "newreno")]
124124
/// The congestion controller to use.
@@ -149,6 +149,7 @@ impl Default for QuicParameters {
149149
max_streams_bidi: 16,
150150
max_streams_uni: 16,
151151
idle_timeout: 30,
152+
initial_rtt_ms: None,
152153
congestion_control: CongestionControlAlgorithm::NewReno,
153154
no_pacing: false,
154155
no_pmtud: false,
@@ -217,7 +218,10 @@ impl QuicParameters {
217218
.max_streams(StreamType::BiDi, self.max_streams_bidi)
218219
.max_streams(StreamType::UniDi, self.max_streams_uni)
219220
.idle_timeout(Duration::from_secs(self.idle_timeout))
220-
.initial_rtt(Duration::from_millis(self.initial_rtt_ms))
221+
.initial_rtt(
222+
self.initial_rtt_ms
223+
.map_or(INITIAL_RTT, Duration::from_millis),
224+
)
221225
.cc_algorithm(self.congestion_control)
222226
.pacing(!self.no_pacing)
223227
.pmtud(!self.no_pmtud);

neqo-transport/src/connection/params.rs

+2-2
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::{DEFAULT_INITIAL_RTT, GRANULARITY},
13+
rtt::{GRANULARITY, INITIAL_RTT},
1414
stream_id::StreamType,
1515
tparams::{self, PreferredAddress, TransportParameter, TransportParametersHandler},
1616
tracking::DEFAULT_ACK_DELAY,
@@ -97,7 +97,7 @@ impl Default for ConnectionParameters {
9797
max_streams_uni: LOCAL_STREAM_LIMIT_UNI,
9898
ack_ratio: DEFAULT_ACK_RATIO,
9999
idle_timeout: DEFAULT_IDLE_TIMEOUT,
100-
initial_rtt: DEFAULT_INITIAL_RTT,
100+
initial_rtt: INITIAL_RTT,
101101
preferred_address: PreferredAddressConfig::Default,
102102
datagram_size: 0,
103103
outgoing_datagram_queue: MAX_QUEUED_DATAGRAMS_DEFAULT,

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::DEFAULT_INITIAL_RTT);
668-
assert_eq!(stats.rttvar, crate::rtt::DEFAULT_INITIAL_RTT / 2);
667+
assert_eq!(stats.rtt, crate::rtt::INITIAL_RTT);
668+
assert_eq!(stats.rttvar, crate::rtt::INITIAL_RTT / 2);
669669
}
670670

671671
#[test]

neqo-transport/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ pub mod tparams;
5050
mod tracking;
5151
pub mod version;
5252

53+
pub use rtt::INITIAL_RTT;
54+
5355
pub use self::{
5456
cc::CongestionControlAlgorithm,
5557
cid::{

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 DEFAULT_INITIAL_RTT: Duration = Duration::from_millis(100);
29+
pub const 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: DEFAULT_INITIAL_RTT,
204-
smoothed_rtt: DEFAULT_INITIAL_RTT,
205-
rttvar: DEFAULT_INITIAL_RTT / 2,
206-
min_rtt: DEFAULT_INITIAL_RTT,
203+
latest_rtt: INITIAL_RTT,
204+
smoothed_rtt: INITIAL_RTT,
205+
rttvar: INITIAL_RTT / 2,
206+
min_rtt: INITIAL_RTT,
207207
ack_delay: PeerAckDelay::default(),
208208
}
209209
}

0 commit comments

Comments
 (0)