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

feat(transport): Use a shorter ECN probe threshold initially #1964

Merged
merged 13 commits into from
Jul 31, 2024
28 changes: 26 additions & 2 deletions neqo-transport/src/connection/tests/ecn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ use test_fixture::{
fixture_init, now, DEFAULT_ADDR_V4,
};

use super::send_something_with_modifier;
use super::{send_something_with_modifier, DEFAULT_RTT};
use crate::{
connection::tests::{
connect_force_idle, connect_force_idle_with_modifier, default_client, default_server,
migration::get_cid, new_client, new_server, send_something,
handshake_with_modifier, migration::get_cid, new_client, new_server, send_something,
},
ecn::ECN_TEST_COUNT,
ConnectionId, ConnectionParameters, StreamType,
Expand Down Expand Up @@ -67,6 +67,30 @@ fn drop() -> fn(Datagram) -> Option<Datagram> {
|_| None
}

fn drop_ecn_marked_datagrams() -> fn(Datagram) -> Option<Datagram> {
|d| (!d.tos().is_ecn_marked()).then_some(d)
}

#[test]
fn handshake_delay_with_ecn_blackhole() {
let start = now();
let mut client = default_client();
let mut server = default_server();
let finish = handshake_with_modifier(
&mut client,
&mut server,
start,
DEFAULT_RTT,
drop_ecn_marked_datagrams(),
);

assert_eq!(
(finish - start).as_millis() / DEFAULT_RTT.as_millis(),
43,
"expected 20 RTT for client to detect blackhole, 20 RTT for server to detect blackhole and 3 RTT for handshake to be confirmed.",
);
}

#[test]
fn disables_on_loss() {
let now = now();
Expand Down
20 changes: 12 additions & 8 deletions neqo-transport/src/connection/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,22 +179,24 @@ fn handshake_with_modifier(
rtt: Duration,
modifier: fn(Datagram) -> Option<Datagram>,
) -> Instant {
let start = now;
let mut a = client;
let mut b = server;
let mut now = now;

let mut input = None;
let is_done = |c: &mut Connection| {
matches!(
c.state(),
dbg!(c.state()),
State::Confirmed | State::Closing { .. } | State::Closed(..)
)
};

let mut did_ping = enum_map! {_ => false};
while !is_done(a) {
_ = maybe_authenticate(a);
let had_input = input.is_some();
// TODO
// let had_input = input.is_some();
// Insert a PING frame into the first application data packet an endpoint sends,
// in order to force the peer to ACK it. For the server, this is depending on the
// client's connection state, which is accessible during the tests.
Expand All @@ -208,17 +210,19 @@ fn handshake_with_modifier(
if should_ping {
a.test_frame_writer = Some(Box::new(PingWriter {}));
}
println!(
"Processing {} at {:?}ms",
a.role(),
(now - start).as_millis()
);
let output = a.process(input.as_ref(), now).dgram();
if should_ping {
a.test_frame_writer = None;
did_ping[a.role()] = true;
}
assert!(had_input || output.is_some());
larseggert marked this conversation as resolved.
Show resolved Hide resolved
if let Some(d) = output {
input = modifier(d);
} else {
input = output;
}
// TODO
// assert!(dbg!(had_input) || dbg!(output.is_some()));
larseggert marked this conversation as resolved.
Show resolved Hide resolved
input = output.and_then(modifier);
qtrace!("handshake: t += {:?}", rtt / 2);
now += rtt / 2;
mem::swap(&mut a, &mut b);
Expand Down
Loading