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

test(transport): maximum throughput on unlimited bandwidth and 50ms #1857

Closed
wants to merge 1 commit into from
Closed
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
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();
}
}
Loading