Skip to content

Commit

Permalink
adaptions for CLI arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
robamu committed Aug 29, 2024
1 parent 5445216 commit 1b1ce85
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 14 deletions.
14 changes: 9 additions & 5 deletions neqo-bin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::{
use clap::Parser;
use neqo_transport::{
tparams::PreferredAddress, CongestionControlAlgorithm, ConnectionParameters, StreamType,
Version,
Version, INITIAL_RTT,
};

pub mod client;
Expand Down Expand Up @@ -116,9 +116,9 @@ 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 = "init_rtt")]
/// The initial round-trip time. Defaults to [``INITIAL_RTT``] if not specified.
pub initial_rtt_ms: Option<u64>,

#[arg(long = "cc", default_value = "newreno")]
/// The congestion controller to use.
Expand Down Expand Up @@ -149,6 +149,7 @@ impl Default for QuicParameters {
max_streams_bidi: 16,
max_streams_uni: 16,
idle_timeout: 30,
initial_rtt_ms: None,
congestion_control: CongestionControlAlgorithm::NewReno,
no_pacing: false,
no_pmtud: false,
Expand Down Expand Up @@ -217,7 +218,10 @@ 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))
.initial_rtt(
self.initial_rtt_ms
.map_or(INITIAL_RTT, Duration::from_millis),
)
.cc_algorithm(self.congestion_control)
.pacing(!self.no_pacing)
.pmtud(!self.no_pmtud);
Expand Down
4 changes: 2 additions & 2 deletions 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::{DEFAULT_INITIAL_RTT, GRANULARITY},
rtt::{GRANULARITY, INITIAL_RTT},
stream_id::StreamType,
tparams::{self, PreferredAddress, TransportParameter, TransportParametersHandler},
tracking::DEFAULT_ACK_DELAY,
Expand Down Expand Up @@ -97,7 +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,
initial_rtt: INITIAL_RTT,
preferred_address: PreferredAddressConfig::Default,
datagram_size: 0,
outgoing_datagram_queue: MAX_QUEUED_DATAGRAMS_DEFAULT,
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::DEFAULT_INITIAL_RTT);
assert_eq!(stats.rttvar, crate::rtt::DEFAULT_INITIAL_RTT / 2);
assert_eq!(stats.rtt, crate::rtt::INITIAL_RTT);
assert_eq!(stats.rttvar, crate::rtt::INITIAL_RTT / 2);
}

#[test]
Expand Down
2 changes: 2 additions & 0 deletions neqo-transport/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ pub mod tparams;
mod tracking;
pub mod version;

pub use rtt::INITIAL_RTT;

pub use self::{
cc::CongestionControlAlgorithm,
cid::{
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 DEFAULT_INITIAL_RTT: Duration = Duration::from_millis(100);
pub const 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: DEFAULT_INITIAL_RTT,
smoothed_rtt: DEFAULT_INITIAL_RTT,
rttvar: DEFAULT_INITIAL_RTT / 2,
min_rtt: DEFAULT_INITIAL_RTT,
latest_rtt: INITIAL_RTT,
smoothed_rtt: INITIAL_RTT,
rttvar: INITIAL_RTT / 2,
min_rtt: INITIAL_RTT,
ack_delay: PeerAckDelay::default(),
}
}
Expand Down

0 comments on commit 1b1ce85

Please sign in to comment.