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: DPLPMTUD #1903

Merged
merged 105 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
de41d72
WIP
larseggert May 13, 2024
a3b0f0c
Merge remote-tracking branch 'origin/main' into feat-dplpmtud
larseggert May 14, 2024
80fd884
Fixes
larseggert May 14, 2024
76f3fd4
Minimize diff
larseggert May 14, 2024
3cc307b
Progress
larseggert May 14, 2024
9f51395
Fix clippy
larseggert May 14, 2024
9ecfda2
Reduce diff to main
larseggert May 14, 2024
213ad01
Merge branch 'main' into feat-dplpmtud
larseggert May 15, 2024
19c2f44
Use RefCell
larseggert May 15, 2024
103ac4e
Make Pacer use PmtudState
larseggert May 15, 2024
cc03dc2
Merge branch 'main' into feat-dplpmtud
larseggert May 16, 2024
3a7a923
Renamings
larseggert May 17, 2024
b42b525
Fix tests broken by changing PATH_MTU_V6
larseggert May 17, 2024
e02ddf7
WIP
larseggert May 20, 2024
b3e4fd0
Finalize
larseggert May 21, 2024
da3cbb9
Merge branch 'main' into feat-dplpmtud
larseggert May 21, 2024
608e1c6
Update neqo-transport/src/path.rs
larseggert May 22, 2024
f4ee0f5
Address comments
larseggert May 22, 2024
819d08c
Update neqo-transport/src/pmtud.rs
larseggert May 22, 2024
848260c
Remove PmtudRef from ClassicCongestionControl
larseggert May 22, 2024
3c120c6
Disable PMTUD by default, except for demo client and server, and simu…
larseggert May 22, 2024
55cd448
Fix clippy
larseggert May 22, 2024
a8d49a3
Make Pmtud part of Pacer only
larseggert May 22, 2024
62a06aa
These are now `const_assert`s
larseggert May 22, 2024
5ae0466
Cleanups
larseggert May 22, 2024
4195f6c
Address more comments
larseggert May 22, 2024
4f6a3c4
Cleanups
larseggert May 22, 2024
84154c5
Add some initial tests
larseggert May 22, 2024
ee91c3c
Fix clippy
larseggert May 23, 2024
90f5761
Minimize diff
larseggert May 23, 2024
a450767
Probe with non-padding data
larseggert May 23, 2024
c9081f9
Search table based on TMA paper
larseggert May 23, 2024
1736a43
Deal with PMTU reductions
larseggert May 23, 2024
acbc0c6
Fix crypto invocation limits
larseggert May 23, 2024
e76be7c
Fix comment
larseggert May 23, 2024
68cca5b
More comments
larseggert May 23, 2024
a114469
Add PMTU_RAISE_TIMER
larseggert May 23, 2024
b8219c6
Lost PMTUD probes do not elicit a congestion control reaction
larseggert May 24, 2024
7de5e4e
Update pacer when MTU changes
larseggert May 24, 2024
810864a
Better way to update pacer
larseggert May 27, 2024
46f4ed0
Merge branch 'main' into feat-dplpmtud
larseggert May 27, 2024
31bb86f
Fix last commit
larseggert May 27, 2024
3536ad4
Merge branch 'main' into feat-dplpmtud
larseggert May 28, 2024
439a55a
Merge branch 'feat-dplpmtud' of github.com:larseggert/neqo into feat-…
larseggert May 28, 2024
501b150
Potential fix for bench
larseggert May 28, 2024
bf4f1e4
Update neqo-transport/src/pmtud.rs
larseggert May 28, 2024
08f2404
Update neqo-transport/src/pmtud.rs
larseggert May 28, 2024
6b9cb1c
Update neqo-transport/src/pmtud.rs
larseggert May 28, 2024
c1b85b9
Merge branch 'main' into feat-dplpmtud
larseggert May 29, 2024
eca5ee9
Update neqo-transport/src/cc/classic_cc.rs
larseggert May 29, 2024
a7636c4
Undo
larseggert May 29, 2024
1dc9d2c
Simplifications
larseggert May 29, 2024
9f88d7f
rustfmt
larseggert May 29, 2024
4cea3c8
Disarm raise timer when it fired
larseggert May 30, 2024
a538a58
Merge branch 'main' into feat-dplpmtud
larseggert May 30, 2024
cbcd621
Merge branch 'feat-dplpmtud' of github.com:larseggert/neqo into feat-…
larseggert May 30, 2024
f296efe
test script that triggers the bug
larseggert May 31, 2024
d5705b5
Merge branch 'main' into feat-dplpmtud
larseggert Jun 18, 2024
622e754
Merge branch 'main' into feat-dplpmtud
larseggert Jul 2, 2024
26f54d9
Merge branch 'main' into feat-dplpmtud
larseggert Jul 2, 2024
5c0322c
Revert test.sh (modulo bug fix)
larseggert Jul 2, 2024
9230cbd
Increase coverage
larseggert Jul 2, 2024
5f4563d
Better test
larseggert Jul 2, 2024
5a5750b
Another test
larseggert Jul 2, 2024
3cfe47d
Merge branch 'main' into feat-dplpmtud
larseggert Jul 2, 2024
7265c5d
let Some(...) instead of testing
martinthomson Jul 3, 2024
0b3583b
Fix
larseggert Jul 3, 2024
8f4caee
Merge branch 'main' into feat-dplpmtud
larseggert Jul 3, 2024
b5b39ca
Merge branch 'main' into feat-dplpmtud
larseggert Jul 3, 2024
c05a50e
Merge branch 'main' into feat-dplpmtud
larseggert Jul 3, 2024
35b94c4
static_assertions to dev-dependencies
larseggert Jul 4, 2024
ba10440
Panic on failure
larseggert Jul 4, 2024
4393d95
Merge branch 'feat-dplpmtud' of github.com:larseggert/neqo into feat-…
larseggert Jul 4, 2024
4fade01
Merge branch 'main' into feat-dplpmtud
larseggert Jul 4, 2024
de4a269
Fixes after merge
larseggert Jul 4, 2024
35b1512
Make test-only plpmtu() panic on error
larseggert Jul 4, 2024
07bae07
set_confirmed
larseggert Jul 4, 2024
8e13974
invocations_base -> largest_packet_len
larseggert Jul 4, 2024
7376ccb
Simplify
larseggert Jul 4, 2024
065e9fd
Set builder limit in output_path()
larseggert Jul 4, 2024
fcd02bb
fmt
larseggert Jul 4, 2024
714c547
A bunch of changes based on Martin's review
larseggert Jul 8, 2024
54dd5ab
Avoid spurious PMTUD restarts better. Possible perf. optimizations.
larseggert Jul 9, 2024
bcf0024
Merge branch 'main' into feat-dplpmtud
larseggert Jul 9, 2024
9582235
Improve coverage
larseggert Jul 9, 2024
c942fd9
Enable PMTUD for simulator
larseggert Jul 9, 2024
d0c078d
Update neqo-transport/src/connection/mod.rs
larseggert Jul 10, 2024
95e1717
Update neqo-transport/src/connection/mod.rs
larseggert Jul 10, 2024
e1a0ee6
Update neqo-transport/src/connection/mod.rs
larseggert Jul 10, 2024
61e9fbe
Update neqo-transport/src/packet/mod.rs
larseggert Jul 10, 2024
be7dcdb
Update neqo-transport/src/stats.rs
larseggert Jul 10, 2024
3a8f2c4
Suggestions from Max
larseggert Jul 10, 2024
fd2af00
Update neqo-transport/src/pmtud.rs
larseggert Jul 10, 2024
3d8ba19
Suggestions from Martin
larseggert Jul 10, 2024
1f7e277
More suggestions
larseggert Jul 10, 2024
5c06141
Add TODO
larseggert Jul 10, 2024
6f03b99
Use filter fn
mxinden Jul 10, 2024
bd58c96
clippy
mxinden Jul 10, 2024
3a3d554
Merge pull request #25 from mxinden/feat-dplpmtud
larseggert Jul 10, 2024
8d1d1cd
Fixes
larseggert Jul 10, 2024
673216a
doc fix
larseggert Jul 10, 2024
c4f03ce
refactor(pmtud): implement Copy for Probe
mxinden Jul 10, 2024
2ce8db1
Merge pull request #26 from mxinden/feat-dplpmtud
larseggert Jul 10, 2024
151e802
Make search_tables identical length, and deal with the fallout
larseggert Jul 10, 2024
5a1f659
More
larseggert Jul 10, 2024
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
215 changes: 130 additions & 85 deletions neqo-transport/src/cc/classic_cc.rs

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions neqo-transport/src/cc/cubic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::{

use neqo_common::qtrace;

use crate::cc::{classic_cc::WindowAdjustment, MAX_DATAGRAM_SIZE_F64};
use crate::cc::classic_cc::WindowAdjustment;

// CUBIC congestion control

Expand All @@ -38,7 +38,7 @@ const EXPONENTIAL_GROWTH_REDUCTION: f64 = 2.0;
/// Convert an integer congestion window value into a floating point value.
/// This has the effect of reducing larger values to `1<<53`.
/// If you have a congestion window that large, something is probably wrong.
fn convert_to_f64(v: usize) -> f64 {
pub fn convert_to_f64(v: usize) -> f64 {
let mut f_64 = f64::from(u32::try_from(v >> 21).unwrap_or(u32::MAX));
f_64 *= 2_097_152.0; // f_64 <<= 21
f_64 += f64::from(u32::try_from(v & 0x1f_ffff).unwrap());
Expand Down Expand Up @@ -91,17 +91,17 @@ impl Cubic {
///
/// From that equation we can calculate K as:
/// K = cubic_root((W_max - W_cubic) / C / MSS);
fn calc_k(&self, curr_cwnd: f64) -> f64 {
((self.w_max - curr_cwnd) / CUBIC_C / MAX_DATAGRAM_SIZE_F64).cbrt()
fn calc_k(&self, curr_cwnd: f64, mtu: usize) -> f64 {
((self.w_max - curr_cwnd) / CUBIC_C / convert_to_f64(mtu)).cbrt()
}

/// W_cubic(t) = C*(t-K)^3 + W_max (Eq. 1)
/// t is relative to the start of the congestion avoidance phase and it is in seconds.
fn w_cubic(&self, t: f64) -> f64 {
CUBIC_C * (t - self.k).powi(3) * MAX_DATAGRAM_SIZE_F64 + self.w_max
fn w_cubic(&self, t: f64, mtu: usize) -> f64 {
CUBIC_C * (t - self.k).powi(3) * convert_to_f64(mtu) + self.w_max
}

fn start_epoch(&mut self, curr_cwnd_f64: f64, new_acked_f64: f64, now: Instant) {
fn start_epoch(&mut self, curr_cwnd_f64: f64, new_acked_f64: f64, mtu: usize, now: Instant) {
self.ca_epoch_start = Some(now);
// reset tcp_acked_bytes and estimated_tcp_cwnd;
self.tcp_acked_bytes = new_acked_f64;
Expand All @@ -111,7 +111,7 @@ impl Cubic {
self.k = 0.0;
} else {
self.w_max = self.last_max_cwnd;
self.k = self.calc_k(curr_cwnd_f64);
self.k = self.calc_k(curr_cwnd_f64, mtu);
}
qtrace!([self], "New epoch");
}
Expand All @@ -126,13 +126,14 @@ impl WindowAdjustment for Cubic {
curr_cwnd: usize,
new_acked_bytes: usize,
min_rtt: Duration,
mtu: usize,
now: Instant,
) -> usize {
let curr_cwnd_f64 = convert_to_f64(curr_cwnd);
let new_acked_f64 = convert_to_f64(new_acked_bytes);
if self.ca_epoch_start.is_none() {
// This is a start of a new congestion avoidance phase.
self.start_epoch(curr_cwnd_f64, new_acked_f64, now);
self.start_epoch(curr_cwnd_f64, new_acked_f64, mtu, now);
} else {
self.tcp_acked_bytes += new_acked_f64;
}
Expand All @@ -149,12 +150,13 @@ impl WindowAdjustment for Cubic {
}
})
.as_secs_f64();
let target_cubic = self.w_cubic(time_ca);
let target_cubic = self.w_cubic(time_ca, mtu);

let mtu = convert_to_f64(mtu);
let tcp_cnt = self.estimated_tcp_cwnd / CUBIC_ALPHA;
while self.tcp_acked_bytes > tcp_cnt {
self.tcp_acked_bytes -= tcp_cnt;
self.estimated_tcp_cwnd += MAX_DATAGRAM_SIZE_F64;
self.estimated_tcp_cwnd += mtu;
}

let target_cwnd = target_cubic.max(self.estimated_tcp_cwnd);
Expand All @@ -165,24 +167,22 @@ impl WindowAdjustment for Cubic {
// The amount of data required therefore reduces asymptotically as the target increases.
// If the target is not significantly higher than the congestion window, require a very
// large amount of acknowledged data (effectively block increases).
let mut acked_to_increase =
MAX_DATAGRAM_SIZE_F64 * curr_cwnd_f64 / (target_cwnd - curr_cwnd_f64).max(1.0);
let mut acked_to_increase = mtu * curr_cwnd_f64 / (target_cwnd - curr_cwnd_f64).max(1.0);

// Limit increase to max 1 MSS per EXPONENTIAL_GROWTH_REDUCTION ack packets.
// This effectively limits target_cwnd to (1 + 1 / EXPONENTIAL_GROWTH_REDUCTION) cwnd.
acked_to_increase =
acked_to_increase.max(EXPONENTIAL_GROWTH_REDUCTION * MAX_DATAGRAM_SIZE_F64);
acked_to_increase = acked_to_increase.max(EXPONENTIAL_GROWTH_REDUCTION * mtu);
acked_to_increase as usize
}

fn reduce_cwnd(&mut self, curr_cwnd: usize, acked_bytes: usize) -> (usize, usize) {
fn reduce_cwnd(&mut self, curr_cwnd: usize, acked_bytes: usize, mtu: usize) -> (usize, usize) {
let curr_cwnd_f64 = convert_to_f64(curr_cwnd);
// Fast Convergence
// If congestion event occurs before the maximum congestion window before the last
// congestion event, we reduce the the maximum congestion window and thereby W_max.
// check cwnd + MAX_DATAGRAM_SIZE instead of cwnd because with cwnd in bytes, cwnd may be
// slightly off.
self.last_max_cwnd = if curr_cwnd_f64 + MAX_DATAGRAM_SIZE_F64 < self.last_max_cwnd {
self.last_max_cwnd = if curr_cwnd_f64 + convert_to_f64(mtu) < self.last_max_cwnd {
curr_cwnd_f64 * CUBIC_FAST_CONVERGENCE
} else {
curr_cwnd_f64
Expand Down
14 changes: 8 additions & 6 deletions neqo-transport/src/cc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,18 @@ use std::{

use neqo_common::qlog::NeqoQlog;

use crate::{path::PATH_MTU_V6, recovery::SentPacket, rtt::RttEstimate, Error};
use crate::{recovery::SentPacket, rtt::RttEstimate, Error};

mod classic_cc;
mod cubic;
mod new_reno;

pub use classic_cc::ClassicCongestionControl;
#[cfg(test)]
pub use classic_cc::{CWND_INITIAL, CWND_INITIAL_PKTS, CWND_MIN};
pub use classic_cc::CWND_INITIAL_PKTS;
pub use cubic::Cubic;
pub use new_reno::NewReno;

pub const MAX_DATAGRAM_SIZE: usize = PATH_MTU_V6;
#[allow(clippy::cast_precision_loss)]
pub const MAX_DATAGRAM_SIZE_F64: f64 = MAX_DATAGRAM_SIZE as f64;

pub trait CongestionControl: Display + Debug {
fn set_qlog(&mut self, qlog: NeqoQlog);

Expand All @@ -42,6 +38,12 @@ pub trait CongestionControl: Display + Debug {
#[must_use]
fn cwnd_avail(&self) -> usize;

#[must_use]
fn cwnd_min(&self) -> usize;

#[must_use]
fn cwnd_initial(&self) -> usize;

fn on_packets_acked(&mut self, acked_pkts: &[SentPacket], rtt_est: &RttEstimate, now: Instant);

/// Returns true if the congestion window was reduced.
Expand Down
3 changes: 2 additions & 1 deletion neqo-transport/src/cc/new_reno.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ impl WindowAdjustment for NewReno {
curr_cwnd: usize,
_new_acked_bytes: usize,
_min_rtt: Duration,
_mtu: usize,
_now: Instant,
) -> usize {
curr_cwnd
}

fn reduce_cwnd(&mut self, curr_cwnd: usize, acked_bytes: usize) -> (usize, usize) {
fn reduce_cwnd(&mut self, curr_cwnd: usize, acked_bytes: usize, _mtu: usize) -> (usize, usize) {
(curr_cwnd / 2, acked_bytes / 2)
}

Expand Down
Loading
Loading