Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial rtt config. #77

Merged
merged 2 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions apps/src/bin/tquic_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,17 @@ pub struct ClientOpt {
pub send_udp_payload_size: usize,

/// Handshake timeout in microseconds.
#[clap(long, default_value = "5000", value_name = "TIME")]
#[clap(long, default_value = "10000", value_name = "TIME")]
pub handshake_timeout: u64,

/// Connection idle timeout in microseconds.
#[clap(long, default_value = "5000", value_name = "TIME")]
#[clap(long, default_value = "30000", value_name = "TIME")]
pub idle_timeout: u64,

/// Initial RTT in milliseconds.
#[clap(long, default_value = "333", value_name = "TIME")]
pub initial_rtt: u64,

/// Save TLS key log into the given file.
#[clap(short, long, value_name = "FILE")]
pub keylog_file: Option<String>,
Expand Down Expand Up @@ -375,6 +379,7 @@ impl Worker {
config.enable_stateless_reset(!option.disable_stateless_reset);
config.set_max_handshake_timeout(option.handshake_timeout);
config.set_max_idle_timeout(option.idle_timeout);
config.set_initial_rtt(option.initial_rtt);
config.set_max_concurrent_conns(option.max_concurrent_conns);
config.set_initial_max_streams_bidi(option.max_concurrent_requests);
config.set_send_batch_size(option.send_batch_size);
Expand Down
9 changes: 7 additions & 2 deletions apps/src/bin/tquic_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,17 @@ pub struct ServerOpt {
pub send_udp_payload_size: usize,

/// Handshake timeout in microseconds.
#[clap(long, default_value = "5000", value_name = "TIME")]
#[clap(long, default_value = "10000", value_name = "TIME")]
pub handshake_timeout: u64,

/// Connection idle timeout in microseconds.
#[clap(long, default_value = "5000", value_name = "TIME")]
#[clap(long, default_value = "30000", value_name = "TIME")]
pub idle_timeout: u64,

/// Initial RTT in milliseconds.
#[clap(long, default_value = "333", value_name = "TIME")]
pub initial_rtt: u64,

/// Save TLS key log into the given file.
#[clap(long, value_name = "FILE")]
pub keylog_file: Option<String>,
Expand Down Expand Up @@ -158,6 +162,7 @@ impl Server {
config.enable_stateless_reset(!option.disable_stateless_reset);
config.set_max_handshake_timeout(option.handshake_timeout);
config.set_max_idle_timeout(option.idle_timeout);
config.set_initial_rtt(option.initial_rtt);
config.set_send_batch_size(option.send_batch_size);
config.set_multipath(option.enable_multipath);
config.set_multipath_algor(option.multipath_algor);
Expand Down
7 changes: 7 additions & 0 deletions include/tquic.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,13 @@ void quic_config_set_max_ack_delay(struct quic_config_t *config, uint64_t v);
void quic_config_set_congestion_control_algorithm(struct quic_config_t *config,
enum quic_congestion_control_algorithm v);

/**
* Set the initial RTT in milliseconds. The default value is 333ms.
* The configuration should be changed with caution. Setting a value less than the default
* will cause retransmission of handshake packets to be more aggressive.
*/
void quic_config_set_initial_rtt(struct quic_config_t *config, uint64_t v);

/**
* Set the `active_connection_id_limit` transport parameter.
*/
Expand Down
8 changes: 6 additions & 2 deletions interop/run_endpoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ if [ "$ROLE" == "client" ]; then

REQS=($REQUESTS)

CLIENT_ARGS="--dump-path ${DOWNLOAD_DIR} --keylog-file $SSLKEYLOGFILE --log-level TRACE --max-concurrent-requests ${#REQS[@]}"
CLIENT_ARGS="--dump-path ${DOWNLOAD_DIR} --keylog-file $SSLKEYLOGFILE --log-level TRACE --idle-timeout 30000 --handshake-timeout 30000 --max-concurrent-requests ${#REQS[@]}"
CLIENT_ALPN="--alpn hq-interop"
case $TESTCASE in
resumption)
Expand All @@ -67,6 +67,7 @@ if [ "$ROLE" == "client" ]; then

case $TESTCASE in
multiconnect|resumption)
CLIENT_ARGS="$CLIENT_ARGS --initial-rtt 100"
for REQ in $REQUESTS
do
$TQUIC_DIR/$TQUIC_CLIENT $CLIENT_ARGS $REQ >> $LOG_DIR/$ROLE.log 2>&1
Expand All @@ -81,11 +82,14 @@ if [ "$ROLE" == "client" ]; then
;;
esac
elif [ "$ROLE" == "server" ]; then
SERVER_ARGS="-c /certs/cert.pem -k /certs/priv.key --listen [::]:443 --root $ROOT_DIR --log-level TRACE --keylog-file $SSLKEYLOGFILE"
SERVER_ARGS="-c /certs/cert.pem -k /certs/priv.key --listen [::]:443 --root $ROOT_DIR --keylog-file $SSLKEYLOGFILE --log-level TRACE --idle-timeout 30000 --handshake-timeout 30000"
case $TESTCASE in
retry)
SERVER_ARGS="$SERVER_ARGS --enable-retry"
;;
multiconnect)
SERVER_ARGS="$SERVER_ARGS --initial-rtt 100"
;;
*)
;;
esac
Expand Down
8 changes: 8 additions & 0 deletions src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,14 @@ pub extern "C" fn quic_config_set_congestion_control_algorithm(
config.set_congestion_control_algorithm(v);
}

/// Set the initial RTT in milliseconds. The default value is 333ms.
/// The configuration should be changed with caution. Setting a value less than the default
/// will cause retransmission of handshake packets to be more aggressive.
#[no_mangle]
pub extern "C" fn quic_config_set_initial_rtt(config: &mut Config, v: u64) {
config.set_initial_rtt(v);
}

/// Set the `active_connection_id_limit` transport parameter.
#[no_mangle]
pub extern "C" fn quic_config_set_active_connection_id_limit(config: &mut Config, v: u64) {
Expand Down
22 changes: 18 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,11 +486,12 @@ impl Config {
self.recovery.congestion_control_algorithm = cca;
}

/// Set the initial RTT. The default value is 333ms.
/// The function is for unit testing only.
#[cfg(test)]
/// Set the initial RTT in milliseconds. The default value is 333ms.
///
/// The configuration should be changed with caution. Setting a value less than the default
/// will cause retransmission of handshake packets to be more aggressive.
pub fn set_initial_rtt(&mut self, millisecs: u64) {
self.recovery.initial_rtt = Duration::from_millis(millisecs);
self.recovery.initial_rtt = cmp::max(Duration::from_millis(millisecs), TIMER_GRANULARITY);
}

/// Set the `active_connection_id_limit` transport parameter.
Expand Down Expand Up @@ -825,6 +826,19 @@ mod tests {
};
assert_eq!(format!("{}", cid), "a8a8a8a8");
}

#[test]
fn initial_rtt() -> Result<()> {
let mut config = Config::new()?;

config.set_initial_rtt(0);
assert_eq!(config.recovery.initial_rtt, TIMER_GRANULARITY);

config.set_initial_rtt(100);
assert_eq!(config.recovery.initial_rtt, Duration::from_millis(100));

Ok(())
}
}

pub use crate::congestion_control::CongestionControlAlgorithm;
Expand Down