Skip to content

Commit

Permalink
test(transport): maximum throughput on unlimited bandwidth and 50ms
Browse files Browse the repository at this point in the history
This commit adds a basic smoke test using the `test-ficture` simulator,
asserting that on a connection with unlimited bandwidth and 50ms round-trip-time
Neqo can eventually achieve > 1 Gbit/s throughput.

Showcases the potential a future stream flow-control auto-tuning algorithm can have.

See mozilla#733.
  • Loading branch information
mxinden committed Apr 25, 2024
1 parent 17c5895 commit c0a72ce
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
35 changes: 35 additions & 0 deletions neqo-transport/tests/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,38 @@ fn transfer_fixed_seed() {
sim.seed_str("117f65d90ee5c1a7fb685f3af502c7730ba5d31866b758d98f5e3c2117cf9b86");
sim.run();
}

#[test]
fn unlimited_bandwidth_50ms_delay_connection() {
// TODO: Not tenable as a unit test today, given that this will take roughly 300s
// of wallclock time to execute on the simulator. Large for now to make sure
// congestion control isn't the limiting factor.
const TRANSFER_AMOUNT: usize = 1024 * 1024 * 1024;
// One way delay of 25ms, thus RTT of 50ms.
const DELAY: Duration = Duration::from_millis(25);
// TODO: We actually always want 25ms here. Hack for a range including 25ms
// only. Better use RangeInclusive.
const DELAY_RANGE: Range<Duration> = DELAY..Duration::from_nanos(25_000_002);

let mut sim = Simulator::new(
"unlimited_bandwidth_50ms_delay_connection",
boxed![
ConnectionNode::default_client(boxed![SendData::new(TRANSFER_AMOUNT)]),
Delay::new(DELAY_RANGE.clone()),
ConnectionNode::default_server(boxed![ReceiveData::new(TRANSFER_AMOUNT)]),
Delay::new(DELAY_RANGE),
],
);
// TODO: Shouldn't matter. No packet loss. Ideally no randomness in delay.
sim.seed_str("117f65d90ee5c1a7fb685f3af502c7730ba5d31866b758d98f5e3c2117cf9b86");

let simulated_time = sim.setup().run_sim_time();
let bandwidth = TRANSFER_AMOUNT as f64 * 8.0 / simulated_time.as_secs_f64();

assert!(
1024.0 * 1024.0 * 1024.0 < bandwidth,
"expect transfer on 50ms connection with unlimited bandwidth to eventually surpass 1 Gbit/s but got {} Mbit/s.",
bandwidth / 1024.0 / 1024.0,

);
}
7 changes: 6 additions & 1 deletion test-fixture/src/sim/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ pub struct ReadySimulator {
}

impl ReadySimulator {
pub fn run(mut self) {
pub fn run_sim_time(mut self) -> Duration {
let real_start = Instant::now();
let end = self.sim.process_loop(self.start, self.now);
let sim_time = end - self.now;
Expand All @@ -289,5 +289,10 @@ impl ReadySimulator {
wall = real_start.elapsed(),
);
self.sim.print_summary();
sim_time
}

pub fn run(self) {
self.run_sim_time();
}
}

0 comments on commit c0a72ce

Please sign in to comment.