Skip to content

Commit 17518c6

Browse files
Have 3MB test use slow start
1 parent e3cfb69 commit 17518c6

File tree

2 files changed

+194
-31
lines changed

2 files changed

+194
-31
lines changed

quic/s2n-quic-core/tests/recovery/simulation.rs

Lines changed: 49 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use s2n_quic_core::{
55
packet::number::PacketNumberSpace,
66
path::MINIMUM_MTU,
77
recovery::{CongestionController, CubicCongestionController, RTTEstimator},
8-
time::{Clock, NoopClock},
8+
time::{Clock, NoopClock, Timestamp},
99
};
1010
use std::{
1111
env,
@@ -22,10 +22,10 @@ fn slow_start_unlimited_test() {
2222
}
2323

2424
#[test]
25-
fn five_mb_loss_test() {
25+
fn loss_at_3mb_test() {
2626
let cc = CubicCongestionController::new(MINIMUM_MTU);
2727

28-
five_mb_loss(cc, 150).finish();
28+
loss_at_3mb(cc, 135).finish();
2929
}
3030

3131
#[derive(Debug)]
@@ -170,29 +170,20 @@ fn slow_start_unlimited<CC: CongestionController>(
170170
}
171171
}
172172

173-
/// Simulates a network that experienced loss at a 5MB congestion window
174-
fn five_mb_loss<CC: CongestionController>(
173+
/// Simulates a network that experienced loss at a 3MB congestion window
174+
fn loss_at_3mb<CC: CongestionController>(
175175
mut congestion_controller: CC,
176176
num_rounds: usize,
177177
) -> Simulation {
178178
let time_zero = NoopClock.get_time();
179179
let mut rtt_estimator = RTTEstimator::new(Duration::from_millis(0));
180180
let mut rounds = Vec::with_capacity(num_rounds);
181181

182-
// Ensure the congestion window is always fully utilized
182+
// Ensure the congestion window is fully utilized
183183
congestion_controller.on_packet_sent(time_zero, u32::MAX as usize);
184184

185-
// Start the window at 5MB
186-
congestion_controller.on_packet_ack(time_zero, 5_000_000, &rtt_estimator, time_zero);
187-
188-
// Exit slow start
189-
congestion_controller.on_congestion_event(time_zero);
190-
191185
let mut ack_receive_time = time_zero + Duration::from_millis(1);
192186

193-
// Exit recovery
194-
congestion_controller.on_packet_ack(ack_receive_time, 1, &rtt_estimator, ack_receive_time);
195-
196187
// Update the rtt with 200 ms
197188
rtt_estimator.update_rtt(
198189
Duration::from_millis(0),
@@ -202,34 +193,61 @@ fn five_mb_loss<CC: CongestionController>(
202193
PacketNumberSpace::ApplicationData,
203194
);
204195

205-
for round in 0..num_rounds {
196+
let mut slow_start_round = 0;
197+
198+
while congestion_controller.congestion_window() < 3_000_000 && slow_start_round < num_rounds {
199+
ack_receive_time += Duration::from_millis(200);
200+
201+
// Ack the full congestion window
202+
ack_cwnd(&mut congestion_controller, &rtt_estimator, ack_receive_time);
203+
204+
rounds.push(Round {
205+
number: slow_start_round,
206+
cwnd: congestion_controller.congestion_window(),
207+
});
208+
209+
slow_start_round += 1;
210+
}
211+
212+
// Lose a packet to exit slow start
213+
congestion_controller.on_packets_lost(MINIMUM_MTU as u32, false, ack_receive_time);
214+
215+
for round in slow_start_round..num_rounds {
206216
rounds.push(Round {
207217
number: round,
208218
cwnd: congestion_controller.congestion_window(),
209219
});
210220

211221
ack_receive_time += Duration::from_millis(200);
212222

213-
let mut cwnd = congestion_controller.congestion_window();
214-
215223
// Ack the full congestion window
216-
while cwnd > MINIMUM_MTU as u32 {
217-
congestion_controller.on_packet_ack(
218-
ack_receive_time,
219-
MINIMUM_MTU as usize,
220-
&rtt_estimator,
221-
ack_receive_time,
222-
);
223-
cwnd -= MINIMUM_MTU as u32;
224-
// Ensure the congestion window is always fully utilized by sending a packet the
225-
// same size as the one that we just acked.
226-
congestion_controller.on_packet_sent(ack_receive_time, MINIMUM_MTU as usize);
227-
}
224+
ack_cwnd(&mut congestion_controller, &rtt_estimator, ack_receive_time);
228225
}
229226

230227
Simulation {
231-
name: "5MB Loss",
228+
name: "Loss at 3MB",
232229
cc: core::any::type_name::<CC>(),
233230
rounds,
234231
}
235232
}
233+
234+
/// Acknowledge a full congestion window of packets
235+
fn ack_cwnd<CC: CongestionController>(
236+
congestion_controller: &mut CC,
237+
rtt_estimator: &RTTEstimator,
238+
timestamp: Timestamp,
239+
) {
240+
let mut cwnd = congestion_controller.congestion_window();
241+
while cwnd >= MINIMUM_MTU as u32 {
242+
congestion_controller.on_packet_ack(
243+
timestamp,
244+
MINIMUM_MTU as usize,
245+
rtt_estimator,
246+
timestamp,
247+
);
248+
cwnd -= MINIMUM_MTU as u32;
249+
// Ensure the congestion window is always fully utilized by sending a packet the
250+
// same size as the one that we just acked.
251+
congestion_controller.on_packet_sent(timestamp, MINIMUM_MTU as usize);
252+
}
253+
}
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
---
2+
source: quic/s2n-quic-core/tests/recovery/simulation.rs
3+
expression: self
4+
---
5+
Simulation {
6+
name: "Loss at 3MB",
7+
cc: "s2n_quic_core::recovery::cubic::CubicCongestionController",
8+
rounds: [
9+
0: cwnd: 24000,
10+
1: cwnd: 48000,
11+
2: cwnd: 96000,
12+
3: cwnd: 192000,
13+
4: cwnd: 384000,
14+
5: cwnd: 768000,
15+
6: cwnd: 1536000,
16+
7: cwnd: 3072000,
17+
8: cwnd: 2150400,
18+
9: cwnd: 2177382,
19+
10: cwnd: 2213988,
20+
11: cwnd: 2253323,
21+
12: cwnd: 2292821,
22+
13: cwnd: 2331555,
23+
14: cwnd: 2369174,
24+
15: cwnd: 2405575,
25+
16: cwnd: 2440711,
26+
17: cwnd: 2474599,
27+
18: cwnd: 2507254,
28+
19: cwnd: 2538697,
29+
20: cwnd: 2568945,
30+
21: cwnd: 2598009,
31+
22: cwnd: 2625973,
32+
23: cwnd: 2652756,
33+
24: cwnd: 2678458,
34+
25: cwnd: 2703107,
35+
26: cwnd: 2726659,
36+
27: cwnd: 2749208,
37+
28: cwnd: 2770781,
38+
29: cwnd: 2791302,
39+
30: cwnd: 2810877,
40+
31: cwnd: 2829553,
41+
32: cwnd: 2847298,
42+
33: cwnd: 2864109,
43+
34: cwnd: 2880066,
44+
35: cwnd: 2895228,
45+
36: cwnd: 2909562,
46+
37: cwnd: 2923030,
47+
38: cwnd: 2935720,
48+
39: cwnd: 2947691,
49+
40: cwnd: 2958972,
50+
41: cwnd: 2969568,
51+
42: cwnd: 2979367,
52+
43: cwnd: 2988501,
53+
44: cwnd: 2997001,
54+
45: cwnd: 3004947,
55+
46: cwnd: 3012326,
56+
47: cwnd: 3019191,
57+
48: cwnd: 3025418,
58+
49: cwnd: 3031022,
59+
50: cwnd: 3036145,
60+
51: cwnd: 3040817,
61+
52: cwnd: 3045043,
62+
53: cwnd: 3048843,
63+
54: cwnd: 3052340,
64+
55: cwnd: 3055499,
65+
56: cwnd: 3058316,
66+
57: cwnd: 3060728,
67+
58: cwnd: 3062569,
68+
59: cwnd: 3064131,
69+
60: cwnd: 3065437,
70+
61: cwnd: 3066508,
71+
62: cwnd: 3067369,
72+
63: cwnd: 3068043,
73+
64: cwnd: 3068552,
74+
65: cwnd: 3068920,
75+
66: cwnd: 3069169,
76+
67: cwnd: 3069323,
77+
68: cwnd: 3069405,
78+
69: cwnd: 3069437,
79+
70: cwnd: 3069443,
80+
71: cwnd: 3069445,
81+
72: cwnd: 3069467,
82+
73: cwnd: 3069532,
83+
74: cwnd: 3069662,
84+
75: cwnd: 3069881,
85+
76: cwnd: 3070212,
86+
77: cwnd: 3070679,
87+
78: cwnd: 3071302,
88+
79: cwnd: 3072106,
89+
80: cwnd: 3073116,
90+
81: cwnd: 3074351,
91+
82: cwnd: 3075835,
92+
83: cwnd: 3077594,
93+
84: cwnd: 3079647,
94+
85: cwnd: 3082020,
95+
86: cwnd: 3084663,
96+
87: cwnd: 3087525,
97+
88: cwnd: 3090691,
98+
89: cwnd: 3094214,
99+
90: cwnd: 3098152,
100+
91: cwnd: 3102644,
101+
92: cwnd: 3107642,
102+
93: cwnd: 3113144,
103+
94: cwnd: 3119216,
104+
95: cwnd: 3125854,
105+
96: cwnd: 3132975,
106+
97: cwnd: 3140572,
107+
98: cwnd: 3148783,
108+
99: cwnd: 3157621,
109+
100: cwnd: 3167163,
110+
101: cwnd: 3177414,
111+
102: cwnd: 3188382,
112+
103: cwnd: 3200084,
113+
104: cwnd: 3212423,
114+
105: cwnd: 3225524,
115+
106: cwnd: 3239428,
116+
107: cwnd: 3254175,
117+
108: cwnd: 3269795,
118+
109: cwnd: 3286292,
119+
110: cwnd: 3303594,
120+
111: cwnd: 3321766,
121+
112: cwnd: 3340905,
122+
113: cwnd: 3361007,
123+
114: cwnd: 3382120,
124+
115: cwnd: 3404220,
125+
116: cwnd: 3427287,
126+
117: cwnd: 3451389,
127+
118: cwnd: 3476581,
128+
119: cwnd: 3502879,
129+
120: cwnd: 3530322,
130+
121: cwnd: 3558842,
131+
122: cwnd: 3588507,
132+
123: cwnd: 3619355,
133+
124: cwnd: 3651435,
134+
125: cwnd: 3684752,
135+
126: cwnd: 3719332,
136+
127: cwnd: 3755134,
137+
128: cwnd: 3792231,
138+
129: cwnd: 3830657,
139+
130: cwnd: 3870442,
140+
131: cwnd: 3911611,
141+
132: cwnd: 3954148,
142+
133: cwnd: 3998073,
143+
134: cwnd: 4043424,
144+
],
145+
}

0 commit comments

Comments
 (0)