Skip to content

Commit

Permalink
add CLI at quiche-client to retire DCIDs
Browse files Browse the repository at this point in the history
  • Loading branch information
qdeconinck committed Jul 22, 2024
1 parent 2aecdbb commit faae5ce
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 6 deletions.
44 changes: 38 additions & 6 deletions apps/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
use std::net::SocketAddr;
use std::str::FromStr;

use itertools::Itertools;
use quiche::CIDSeq;
use quiche::PathId;

use super::common::alpns;

pub trait Args {
Expand Down Expand Up @@ -300,8 +304,9 @@ Options:
--perform-migration Perform connection migration on another source port.
--initial-max-path-id NUM Enable multipath support up to the number of paths.
-A --address ADDR ... Specify addresses to be used instead of the unspecified address. Non-routable addresses will lead to connectivity issues.
-R --rm-addr TIMEADDR ... Specify addresses to stop using after the provided time (format time,addr).
-S --status TIMEADDRSTAT ... Specify availability status to advertise to the peer after the provided time (format time,addr,available).
-R --rm-addr TIMEADDR ... Specify addresses to stop using after the provided time (format ms time,addr).
-S --status TIMEADDRSTAT ... Specify availability status to advertise to the peer after the provided time (format ms time,addr,available).
-T --retire-dcid TIMEPIDCID ... Specify CIDs to be retired on a specific path ID (format ms time,path id,CID).
-H --header HEADER ... Add a request header.
-n --requests REQUESTS Send the given number of identical requests [default: 1].
--send-priority-update Send HTTP/3 priority updates if the query string params 'u' or 'i' are present in URLs
Expand Down Expand Up @@ -334,6 +339,7 @@ pub struct ClientArgs {
pub addrs: Vec<SocketAddr>,
pub rm_addrs: Vec<(std::time::Duration, SocketAddr)>,
pub status: Vec<(std::time::Duration, SocketAddr, bool)>,
pub retire_dcids: Vec<(std::time::Duration, PathId, CIDSeq)>,
}

impl Args for ClientArgs {
Expand Down Expand Up @@ -425,15 +431,15 @@ impl Args for ClientArgs {
if s.len() != 2 {
return None;
}
let secs = match s[0].parse::<u64>() {
let millis = match s[0].parse::<u64>() {
Ok(s) => s,
Err(_) => return None,
};
let addr = match SocketAddr::from_str(s[1]) {
Ok(a) => a,
Err(_) => return None,
};
Some((std::time::Duration::from_secs(secs), addr))
Some((std::time::Duration::from_millis(millis), addr))
})
.collect();

Expand All @@ -445,7 +451,7 @@ impl Args for ClientArgs {
if s.len() != 3 {
return None;
}
let secs = match s[0].parse::<u64>() {
let millis = match s[0].parse::<u64>() {
Ok(s) => s,
Err(_) => return None,
};
Expand All @@ -458,10 +464,34 @@ impl Args for ClientArgs {
Ok(_) => true,
Err(_) => return None,
};
Some((std::time::Duration::from_secs(secs), addr, status))
Some((std::time::Duration::from_millis(millis), addr, status))
})
.collect();

let retire_dcids = args
.get_vec("--retire-dcid")
.into_iter()
.filter_map(|ta| {
let s = ta.split(',').collect_vec();
if s.len() != 3 {
return None;
}
let millis = match s[0].parse::<u64>() {
Ok(s) => s,
Err(_) => return None,
};
let path_id = match s[1].parse::<PathId>() {
Ok(p) => p,
Err(_) => return None,
};
let cid_seq = match s[2].parse::<CIDSeq>() {
Ok(c) => c,
Err(_) => return None,
};
Some((std::time::Duration::from_millis(millis), path_id, cid_seq))
})
.collect_vec();

ClientArgs {
version,
dump_response_path,
Expand All @@ -481,6 +511,7 @@ impl Args for ClientArgs {
addrs,
rm_addrs,
status,
retire_dcids,
}
}
}
Expand All @@ -506,6 +537,7 @@ impl Default for ClientArgs {
addrs: vec![],
rm_addrs: vec![],
status: vec![],
retire_dcids: vec![],
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions apps/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ pub fn connect(

let mut rm_addrs = args.rm_addrs.clone();
let mut status = args.status.clone();
let mut retire_dcids = args.retire_dcids.clone();

// Create the configuration for the QUIC connection.
let mut config = quiche::Config::new(args.version).unwrap();
Expand Down Expand Up @@ -543,6 +544,20 @@ pub fn connect(
});
}

if conn.is_established() {
retire_dcids.retain(|(d, path_id, cid_seq)| {
if conn.available_dcids_on_path(*path_id) > 0 && app_data_start.elapsed() >= *d {
info!("retiring DCID sequence number {cid_seq} with path_id {path_id}");
if let Err(e) = conn.retire_dcid_on_path(*path_id, *cid_seq) {
error!("error when retiring DCID: {e:?}");
}
false
} else {
true
}
});
}

// Determine in which order we are going to iterate over paths.
let scheduled_tuples = lowest_latency_scheduler(&conn);

Expand Down

0 comments on commit faae5ce

Please sign in to comment.