Skip to content

Commit

Permalink
And more
Browse files Browse the repository at this point in the history
  • Loading branch information
larseggert committed Jul 3, 2024
1 parent 7bf9e34 commit a264142
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
12 changes: 4 additions & 8 deletions neqo-transport/src/cc/cubic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,12 @@ impl WindowAdjustment for Cubic {
}
})
.as_secs_f64();
let target_cubic = self.w_cubic(time_ca);

let target_cubic = self.w_cubic(time_ca);
let tcp_cnt = self.estimated_tcp_cwnd / CUBIC_ALPHA;
#[allow(unknown_lints)]
#[allow(clippy::while_float)]
while self.tcp_acked_bytes > tcp_cnt {
self.tcp_acked_bytes -= tcp_cnt;
self.estimated_tcp_cwnd += MAX_DATAGRAM_SIZE_F64;
}

let incr = self.tcp_acked_bytes / tcp_cnt;
self.tcp_acked_bytes -= incr * tcp_cnt;
self.estimated_tcp_cwnd += incr * MAX_DATAGRAM_SIZE_F64;
let target_cwnd = target_cubic.max(self.estimated_tcp_cwnd);

// Calculate the number of bytes that would need to be acknowledged for an increase
Expand Down
8 changes: 4 additions & 4 deletions neqo-transport/src/cc/tests/cubic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ fn tcp_phase() {
assert!(num_acks2 < expected_ack_tcp_increase2);

// The time needed to increase cwnd by MAX_DATAGRAM_SIZE using the cubic equation will be
// calculates from: W_cubic(elapsed_time + t_to_increase) - W_cubis(elapsed_time) =
// calculates from: W_cubic(elapsed_time + t_to_increase) - W_cubic(elapsed_time) =
// MAX_DATAGRAM_SIZE => CUBIC_C * (elapsed_time + t_to_increase)^3 * MAX_DATAGRAM_SIZE +
// CWND_INITIAL - CUBIC_C * elapsed_time^3 * MAX_DATAGRAM_SIZE + CWND_INITIAL =
// CWND_INITIAL - CUBIC_C * elapsed_time^3 * MAX_DATAGRAM_SIZE + CWND_INITIAL =
// MAX_DATAGRAM_SIZE => t_to_increase = cbrt((1 + CUBIC_C * elapsed_time^3) / CUBIC_C) -
// elapsed_time (t_to_increase is in seconds)
// number of ack needed is t_to_increase / time_increase.
Expand All @@ -186,9 +186,9 @@ fn tcp_phase() {
/ time_increase.as_secs_f64())
.ceil() as u64;
// num_acks is very close to the calculated value. The exact value is hard to calculate
// because the proportional increase(i.e. curr_cwnd_f64 / (target - curr_cwnd_f64) *
// because the proportional increase (i.e. curr_cwnd_f64 / (target - curr_cwnd_f64) *
// MAX_DATAGRAM_SIZE_F64) and the byte counting.
assert_eq!(num_acks2, expected_ack_cubic_increase + 2);
assert_eq!(num_acks2, expected_ack_cubic_increase + 3);
}

#[test]
Expand Down

0 comments on commit a264142

Please sign in to comment.