rwebtransport 0.2.2 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.lock +523 -140
- package/Cargo.toml +5 -5
- package/README.md +8 -4
- package/crates/echo-server/src/bin/gen-test-cert.rs +1 -1
- package/crates/native/Cargo.toml +2 -0
- package/crates/native/src/config.rs +69 -8
- package/crates/native/src/driver.rs +253 -90
- package/crates/native/src/lib.rs +80 -57
- package/crates/native/src/parser_memory.rs +203 -0
- package/crates/native/src/server.rs +215 -183
- package/crates/native/src/session.rs +1341 -243
- package/crates/native/src/test_support.rs +119 -0
- package/crates/wtcore/Cargo.toml +1 -0
- package/crates/wtcore/src/h3.rs +250 -46
- package/dist/index.js +218 -75
- package/dist/index.js.map +7 -1
- package/dist/index.mjs +214 -69
- package/dist/index.mjs.map +7 -1
- package/dist/native.d.ts +10 -4
- package/dist/server.d.ts +1 -0
- package/package.json +84 -78
- package/prebuilds/darwin-arm64/rwebtransport.node +0 -0
- package/prebuilds/linux-arm64/rwebtransport.node +0 -0
- package/prebuilds/linux-x64/rwebtransport.node +0 -0
- package/prebuilds/win32-x64/rwebtransport.node +0 -0
- package/scripts/build-linux-prebuilt.sh +46 -0
- package/scripts/build-ts.js +41 -0
- package/scripts/build.js +10 -3
- package/vendor/quiche/AGENTS.md +10 -0
- package/vendor/quiche/Cargo.lock +239 -248
- package/vendor/quiche/Cargo.toml +23 -10
- package/vendor/quiche/examples/Makefile +4 -4
- package/vendor/quiche/examples/client.rs +10 -28
- package/vendor/quiche/examples/http3-client.rs +20 -34
- package/vendor/quiche/examples/http3-server.rs +47 -78
- package/vendor/quiche/examples/server.rs +19 -49
- package/vendor/quiche/include/quiche.h +35 -4
- package/vendor/quiche/src/build.rs +17 -0
- package/vendor/quiche/src/cid.rs +129 -61
- package/vendor/quiche/src/crypto/boringssl.rs +98 -86
- package/vendor/quiche/src/crypto/mod.rs +64 -77
- package/vendor/quiche/src/dgram.rs +2 -3
- package/vendor/quiche/src/error.rs +22 -20
- package/vendor/quiche/src/ffi.rs +558 -280
- package/vendor/quiche/src/flowcontrol.rs +0 -7
- package/vendor/quiche/src/frame.rs +134 -135
- package/vendor/quiche/src/h3/ffi.rs +73 -60
- package/vendor/quiche/src/h3/frame.rs +70 -90
- package/vendor/quiche/src/h3/mod.rs +1024 -593
- package/vendor/quiche/src/h3/qpack/decoder.rs +248 -34
- package/vendor/quiche/src/h3/qpack/dynamic_table.rs +859 -0
- package/vendor/quiche/src/h3/qpack/encoder.rs +14 -17
- package/vendor/quiche/src/h3/qpack/mod.rs +48 -0
- package/vendor/quiche/src/h3/qpack/static_table.rs +86 -73
- package/vendor/quiche/src/h3/stream.rs +1009 -194
- package/vendor/quiche/src/lib.rs +1361 -1195
- package/vendor/quiche/src/minmax.rs +2 -6
- package/vendor/quiche/src/packet.rs +420 -552
- package/vendor/quiche/src/path.rs +202 -72
- package/vendor/quiche/src/pmtud.rs +18 -16
- package/vendor/quiche/src/ranges.rs +184 -82
- package/vendor/quiche/src/recovery/AGENTS.md +5 -2
- package/vendor/quiche/src/recovery/bandwidth.rs +59 -40
- package/vendor/quiche/src/recovery/bytes_in_flight.rs +2 -2
- package/vendor/quiche/src/recovery/congestion/cubic.rs +38 -47
- package/vendor/quiche/src/recovery/congestion/delivery_rate.rs +54 -60
- package/vendor/quiche/src/recovery/congestion/hystart.rs +6 -10
- package/vendor/quiche/src/recovery/congestion/mod.rs +110 -42
- package/vendor/quiche/src/recovery/congestion/prr.rs +4 -1
- package/vendor/quiche/src/recovery/congestion/recovery.rs +91 -95
- package/vendor/quiche/src/recovery/congestion/reno.rs +17 -12
- package/vendor/quiche/src/recovery/congestion/test_sender.rs +8 -27
- package/vendor/quiche/src/recovery/gcongestion/bbr/bandwidth_sampler.rs +159 -247
- package/vendor/quiche/src/recovery/gcongestion/bbr/windowed_filter.rs +9 -14
- package/vendor/quiche/src/recovery/gcongestion/bbr2/drain.rs +18 -15
- package/vendor/quiche/src/recovery/gcongestion/bbr2/mode.rs +43 -28
- package/vendor/quiche/src/recovery/gcongestion/bbr2/network_model.rs +349 -76
- package/vendor/quiche/src/recovery/gcongestion/bbr2/probe_bw.rs +147 -195
- package/vendor/quiche/src/recovery/gcongestion/bbr2/probe_rtt.rs +29 -27
- package/vendor/quiche/src/recovery/gcongestion/bbr2/rtt_jump_detector/global_min.rs +180 -0
- package/vendor/quiche/src/recovery/gcongestion/bbr2/rtt_jump_detector/global_min_tests.rs +221 -0
- package/vendor/quiche/src/recovery/gcongestion/bbr2/rtt_jump_detector/hmm.rs +395 -0
- package/vendor/quiche/src/recovery/gcongestion/bbr2/rtt_jump_detector/hmm_tests.rs +473 -0
- package/vendor/quiche/src/recovery/gcongestion/bbr2/rtt_jump_detector/mod.rs +175 -0
- package/vendor/quiche/src/recovery/gcongestion/bbr2/startup.rs +33 -26
- package/vendor/quiche/src/recovery/gcongestion/bbr2.rs +107 -60
- package/vendor/quiche/src/recovery/gcongestion/mod.rs +64 -11
- package/vendor/quiche/src/recovery/gcongestion/pacer.rs +34 -25
- package/vendor/quiche/src/recovery/gcongestion/recovery.rs +81 -86
- package/vendor/quiche/src/recovery/mod.rs +414 -173
- package/vendor/quiche/src/recovery/rtt.rs +8 -5
- package/vendor/quiche/src/stream/mod.rs +864 -133
- package/vendor/quiche/src/stream/recv_buf.rs +476 -172
- package/vendor/quiche/src/stream/send_buf.rs +343 -81
- package/vendor/quiche/src/test_utils.rs +78 -64
- package/vendor/quiche/src/tests.rs +2559 -1335
- package/vendor/quiche/src/tls/boringssl.rs +60 -63
- package/vendor/quiche/src/tls/mod.rs +146 -193
- package/vendor/quiche/src/transport_params.rs +87 -103
|
@@ -74,8 +74,10 @@ impl ModeImpl for ProbeBW {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
fn enter(
|
|
77
|
-
&mut self,
|
|
78
|
-
|
|
77
|
+
&mut self,
|
|
78
|
+
now: Instant,
|
|
79
|
+
_congestion_event: Option<&BBRv2CongestionEvent>,
|
|
80
|
+
params: &Params,
|
|
79
81
|
) {
|
|
80
82
|
self.cycle.start_time = now;
|
|
81
83
|
|
|
@@ -83,19 +85,24 @@ impl ModeImpl for ProbeBW {
|
|
|
83
85
|
CyclePhase::NotStarted => {
|
|
84
86
|
// First time entering PROBE_BW. Start a new probing cycle.
|
|
85
87
|
self.enter_probe_down(false, false, now, params)
|
|
86
|
-
}
|
|
88
|
+
}
|
|
87
89
|
CyclePhase::Cruise => self.enter_probe_cruise(now),
|
|
88
|
-
CyclePhase::Refill =>
|
|
89
|
-
|
|
90
|
-
CyclePhase::Up | CyclePhase::Down => {},
|
|
90
|
+
CyclePhase::Refill => self.enter_probe_refill(self.cycle.probe_up_rounds, now),
|
|
91
|
+
CyclePhase::Up | CyclePhase::Down => {}
|
|
91
92
|
}
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
fn on_congestion_event(
|
|
95
|
-
mut self,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
mut self,
|
|
97
|
+
prior_in_flight: usize,
|
|
98
|
+
event_time: Instant,
|
|
99
|
+
_: &[Acked],
|
|
100
|
+
_: &[Lost],
|
|
101
|
+
congestion_event: &mut BBRv2CongestionEvent,
|
|
102
|
+
target_bytes_inflight: usize,
|
|
103
|
+
params: &Params,
|
|
104
|
+
_recovery_stats: &mut RecoveryStats,
|
|
105
|
+
_cwnd: usize,
|
|
99
106
|
) -> Mode {
|
|
100
107
|
if congestion_event.end_of_round_trip {
|
|
101
108
|
if self.cycle.start_time != event_time {
|
|
@@ -118,27 +125,19 @@ impl ModeImpl for ProbeBW {
|
|
|
118
125
|
params,
|
|
119
126
|
),
|
|
120
127
|
CyclePhase::Down => {
|
|
121
|
-
self.update_probe_down(
|
|
122
|
-
|
|
123
|
-
congestion_event,
|
|
124
|
-
params,
|
|
125
|
-
);
|
|
126
|
-
if self.cycle.phase != CyclePhase::Down &&
|
|
127
|
-
self.model.maybe_expire_min_rtt(congestion_event, params)
|
|
128
|
+
self.update_probe_down(target_bytes_inflight, congestion_event, params);
|
|
129
|
+
if self.cycle.phase != CyclePhase::Down
|
|
130
|
+
&& self.model.maybe_expire_min_rtt(congestion_event, params)
|
|
128
131
|
{
|
|
129
132
|
switch_to_probe_rtt = true;
|
|
130
133
|
}
|
|
131
|
-
}
|
|
132
|
-
CyclePhase::Cruise =>
|
|
133
|
-
target_bytes_inflight,
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
target_bytes_inflight,
|
|
139
|
-
congestion_event,
|
|
140
|
-
params,
|
|
141
|
-
),
|
|
134
|
+
}
|
|
135
|
+
CyclePhase::Cruise => {
|
|
136
|
+
self.update_probe_cruise(target_bytes_inflight, congestion_event, params)
|
|
137
|
+
}
|
|
138
|
+
CyclePhase::Refill => {
|
|
139
|
+
self.update_probe_refill(target_bytes_inflight, congestion_event, params)
|
|
140
|
+
}
|
|
142
141
|
}
|
|
143
142
|
|
|
144
143
|
// Do not need to set the gains if switching to PROBE_RTT, they will be
|
|
@@ -165,42 +164,39 @@ impl ModeImpl for ProbeBW {
|
|
|
165
164
|
return Limits::no_greater_than(limit);
|
|
166
165
|
}
|
|
167
166
|
|
|
168
|
-
if self.cycle.phase == CyclePhase::Up &&
|
|
169
|
-
params.probe_up_ignore_inflight_hi
|
|
170
|
-
{
|
|
167
|
+
if self.cycle.phase == CyclePhase::Up && params.probe_up_ignore_inflight_hi {
|
|
171
168
|
// Similar to STARTUP.
|
|
172
169
|
return Limits::no_greater_than(self.model.inflight_lo());
|
|
173
170
|
}
|
|
174
171
|
|
|
175
|
-
Limits::no_greater_than(
|
|
176
|
-
self.model.inflight_lo().min(self.model.inflight_hi()),
|
|
177
|
-
)
|
|
172
|
+
Limits::no_greater_than(self.model.inflight_lo().min(self.model.inflight_hi()))
|
|
178
173
|
}
|
|
179
174
|
|
|
180
175
|
fn is_probing_for_bandwidth(&self) -> bool {
|
|
181
|
-
self.cycle.phase == CyclePhase::Refill ||
|
|
182
|
-
self.cycle.phase == CyclePhase::Up
|
|
176
|
+
self.cycle.phase == CyclePhase::Refill || self.cycle.phase == CyclePhase::Up
|
|
183
177
|
}
|
|
184
178
|
|
|
185
179
|
fn on_exit_quiescence(
|
|
186
|
-
mut self,
|
|
180
|
+
mut self,
|
|
181
|
+
now: Instant,
|
|
182
|
+
quiescence_start_time: Instant,
|
|
183
|
+
_params: &Params,
|
|
187
184
|
) -> Mode {
|
|
188
185
|
self.model
|
|
189
186
|
.postpone_min_rtt_timestamp(now - quiescence_start_time);
|
|
190
187
|
Mode::ProbeBW(self)
|
|
191
188
|
}
|
|
192
189
|
|
|
193
|
-
fn leave(
|
|
194
|
-
&mut self, _now: Instant,
|
|
195
|
-
_congestion_event: Option<&BBRv2CongestionEvent>,
|
|
196
|
-
) {
|
|
197
|
-
}
|
|
190
|
+
fn leave(&mut self, _now: Instant, _congestion_event: Option<&BBRv2CongestionEvent>) {}
|
|
198
191
|
}
|
|
199
192
|
|
|
200
193
|
impl ProbeBW {
|
|
201
194
|
fn enter_probe_down(
|
|
202
|
-
&mut self,
|
|
203
|
-
|
|
195
|
+
&mut self,
|
|
196
|
+
probed_too_high: bool,
|
|
197
|
+
stopped_risky_probe: bool,
|
|
198
|
+
now: Instant,
|
|
199
|
+
params: &Params,
|
|
204
200
|
) {
|
|
205
201
|
let cycle = &mut self.cycle;
|
|
206
202
|
cycle.last_cycle_probed_too_high = probed_too_high;
|
|
@@ -212,19 +208,16 @@ impl ProbeBW {
|
|
|
212
208
|
cycle.rounds_in_phase = 0;
|
|
213
209
|
|
|
214
210
|
if params.bw_lo_mode != BwLoMode::Default {
|
|
215
|
-
// Clear
|
|
216
|
-
//
|
|
217
|
-
//
|
|
218
|
-
// was a valid value, it'll quickly be rediscovered.
|
|
211
|
+
// Clear `bandwidth_lo` if it was set in PROBE_UP because losses in
|
|
212
|
+
// that phase should not change it permanently.
|
|
213
|
+
// A valid REFILL value for `bandwidth_lo` is quickly rediscovered.
|
|
219
214
|
self.model.clear_bandwidth_lo();
|
|
220
215
|
}
|
|
221
216
|
|
|
222
|
-
//
|
|
223
|
-
// TODO(vlad): actually pick time
|
|
217
|
+
// TODO(vlad): Choose a probe wait time.
|
|
224
218
|
cycle.rounds_since_probe = 0;
|
|
225
|
-
cycle.probe_wait_time =
|
|
226
|
-
params.probe_bw_probe_base_duration + Duration::from_micros(500)
|
|
227
|
-
);
|
|
219
|
+
cycle.probe_wait_time =
|
|
220
|
+
Some(params.probe_bw_probe_base_duration + Duration::from_micros(500));
|
|
228
221
|
|
|
229
222
|
cycle.probe_up_bytes = None;
|
|
230
223
|
cycle.probe_up_app_limited_since_inflight_hi_limited = false;
|
|
@@ -286,8 +279,10 @@ impl ProbeBW {
|
|
|
286
279
|
}
|
|
287
280
|
|
|
288
281
|
fn update_probe_down(
|
|
289
|
-
&mut self,
|
|
290
|
-
|
|
282
|
+
&mut self,
|
|
283
|
+
target_bytes_inflight: usize,
|
|
284
|
+
congestion_event: &BBRv2CongestionEvent,
|
|
285
|
+
params: &Params,
|
|
291
286
|
) {
|
|
292
287
|
if self.cycle.rounds_in_phase == 1 && congestion_event.end_of_round_trip {
|
|
293
288
|
self.cycle.is_sample_from_probing = false;
|
|
@@ -297,32 +292,22 @@ impl ProbeBW {
|
|
|
297
292
|
self.cycle.has_advanced_max_bw = true;
|
|
298
293
|
}
|
|
299
294
|
|
|
300
|
-
if self.cycle.last_cycle_stopped_risky_probe &&
|
|
301
|
-
!self.cycle.last_cycle_probed_too_high
|
|
302
|
-
{
|
|
295
|
+
if self.cycle.last_cycle_stopped_risky_probe && !self.cycle.last_cycle_probed_too_high {
|
|
303
296
|
self.enter_probe_refill(0, congestion_event.event_time);
|
|
304
297
|
return;
|
|
305
298
|
}
|
|
306
299
|
}
|
|
307
300
|
|
|
308
|
-
self.maybe_adapt_upper_bounds(
|
|
309
|
-
target_bytes_inflight,
|
|
310
|
-
congestion_event,
|
|
311
|
-
params,
|
|
312
|
-
);
|
|
301
|
+
self.maybe_adapt_upper_bounds(target_bytes_inflight, congestion_event, params);
|
|
313
302
|
|
|
314
|
-
if self.is_time_to_probe_bandwidth(
|
|
315
|
-
target_bytes_inflight,
|
|
316
|
-
congestion_event,
|
|
317
|
-
params,
|
|
318
|
-
) {
|
|
303
|
+
if self.is_time_to_probe_bandwidth(target_bytes_inflight, congestion_event, params) {
|
|
319
304
|
self.enter_probe_refill(0, congestion_event.event_time);
|
|
320
305
|
return;
|
|
321
306
|
}
|
|
322
307
|
|
|
323
308
|
// This exit condition is experimental code from Google quiche which
|
|
324
|
-
// diverges from the RFC. Use `disable_probe_down_early_exit` to
|
|
325
|
-
// the behavior.
|
|
309
|
+
// diverges from the RFC. Use `disable_probe_down_early_exit` to
|
|
310
|
+
// override the behavior.
|
|
326
311
|
if self.has_stayed_long_enough_in_probe_down(congestion_event, params) {
|
|
327
312
|
self.enter_probe_cruise(congestion_event.event_time);
|
|
328
313
|
return;
|
|
@@ -345,58 +330,42 @@ impl ProbeBW {
|
|
|
345
330
|
}
|
|
346
331
|
|
|
347
332
|
fn update_probe_cruise(
|
|
348
|
-
&mut self,
|
|
349
|
-
|
|
333
|
+
&mut self,
|
|
334
|
+
target_bytes_inflight: usize,
|
|
335
|
+
congestion_event: &BBRv2CongestionEvent,
|
|
336
|
+
params: &Params,
|
|
350
337
|
) {
|
|
351
|
-
self.maybe_adapt_upper_bounds(
|
|
352
|
-
target_bytes_inflight,
|
|
353
|
-
congestion_event,
|
|
354
|
-
params,
|
|
355
|
-
);
|
|
338
|
+
self.maybe_adapt_upper_bounds(target_bytes_inflight, congestion_event, params);
|
|
356
339
|
|
|
357
|
-
if self.is_time_to_probe_bandwidth(
|
|
358
|
-
target_bytes_inflight,
|
|
359
|
-
congestion_event,
|
|
360
|
-
params,
|
|
361
|
-
) {
|
|
340
|
+
if self.is_time_to_probe_bandwidth(target_bytes_inflight, congestion_event, params) {
|
|
362
341
|
self.enter_probe_refill(0, congestion_event.event_time);
|
|
363
342
|
}
|
|
364
343
|
}
|
|
365
344
|
|
|
366
345
|
fn update_probe_refill(
|
|
367
|
-
&mut self,
|
|
368
|
-
|
|
346
|
+
&mut self,
|
|
347
|
+
target_bytes_inflight: usize,
|
|
348
|
+
congestion_event: &BBRv2CongestionEvent,
|
|
349
|
+
params: &Params,
|
|
369
350
|
) {
|
|
370
|
-
self.maybe_adapt_upper_bounds(
|
|
371
|
-
target_bytes_inflight,
|
|
372
|
-
congestion_event,
|
|
373
|
-
params,
|
|
374
|
-
);
|
|
351
|
+
self.maybe_adapt_upper_bounds(target_bytes_inflight, congestion_event, params);
|
|
375
352
|
|
|
376
353
|
if self.cycle.rounds_in_phase > 0 && congestion_event.end_of_round_trip {
|
|
377
|
-
self.enter_probe_up(
|
|
378
|
-
congestion_event.event_time,
|
|
379
|
-
congestion_event.prior_cwnd,
|
|
380
|
-
);
|
|
354
|
+
self.enter_probe_up(congestion_event.event_time, congestion_event.prior_cwnd);
|
|
381
355
|
}
|
|
382
356
|
}
|
|
383
357
|
|
|
384
358
|
fn update_probe_up(
|
|
385
|
-
&mut self,
|
|
386
|
-
|
|
359
|
+
&mut self,
|
|
360
|
+
prior_in_flight: usize,
|
|
361
|
+
target_bytes_inflight: usize,
|
|
362
|
+
congestion_event: &BBRv2CongestionEvent,
|
|
363
|
+
params: &Params,
|
|
387
364
|
) {
|
|
388
|
-
if self.maybe_adapt_upper_bounds(
|
|
389
|
-
|
|
390
|
-
congestion_event,
|
|
391
|
-
params,
|
|
392
|
-
) == AdaptUpperBoundsResult::AdaptedProbedTooHigh
|
|
365
|
+
if self.maybe_adapt_upper_bounds(target_bytes_inflight, congestion_event, params)
|
|
366
|
+
== AdaptUpperBoundsResult::AdaptedProbedTooHigh
|
|
393
367
|
{
|
|
394
|
-
self.enter_probe_down(
|
|
395
|
-
true,
|
|
396
|
-
false,
|
|
397
|
-
congestion_event.event_time,
|
|
398
|
-
params,
|
|
399
|
-
);
|
|
368
|
+
self.enter_probe_down(true, false, congestion_event.event_time, params);
|
|
400
369
|
return;
|
|
401
370
|
}
|
|
402
371
|
|
|
@@ -404,55 +373,42 @@ impl ProbeBW {
|
|
|
404
373
|
|
|
405
374
|
let mut is_risky = false;
|
|
406
375
|
let mut is_queuing = false;
|
|
407
|
-
if self.cycle.last_cycle_probed_too_high &&
|
|
408
|
-
prior_in_flight >= self.model.inflight_hi()
|
|
409
|
-
{
|
|
376
|
+
if self.cycle.last_cycle_probed_too_high && prior_in_flight >= self.model.inflight_hi() {
|
|
410
377
|
is_risky = true;
|
|
411
378
|
} else if self.cycle.rounds_in_phase > 0 {
|
|
412
379
|
if params.max_probe_up_queue_rounds > 0 {
|
|
413
380
|
if congestion_event.end_of_round_trip {
|
|
414
381
|
self.model
|
|
415
382
|
.check_persistent_queue(params.full_bw_threshold, params);
|
|
416
|
-
if self.model.rounds_with_queueing() >=
|
|
417
|
-
params.max_probe_up_queue_rounds
|
|
418
|
-
{
|
|
383
|
+
if self.model.rounds_with_queueing() >= params.max_probe_up_queue_rounds {
|
|
419
384
|
is_queuing = true;
|
|
420
385
|
}
|
|
421
386
|
}
|
|
422
387
|
} else {
|
|
423
|
-
let mut queuing_threshold_extra_bytes =
|
|
424
|
-
self.model.queueing_threshold_extra_bytes();
|
|
388
|
+
let mut queuing_threshold_extra_bytes = self.model.queueing_threshold_extra_bytes();
|
|
425
389
|
if params.add_ack_height_to_queueing_threshold {
|
|
426
390
|
queuing_threshold_extra_bytes += self.model.max_ack_height();
|
|
427
391
|
}
|
|
428
|
-
let queuing_threshold = (params.full_bw_threshold *
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
queuing_threshold_extra_bytes;
|
|
392
|
+
let queuing_threshold = (params.full_bw_threshold * self.model.bdp0() as f32)
|
|
393
|
+
as usize
|
|
394
|
+
+ queuing_threshold_extra_bytes;
|
|
432
395
|
|
|
433
|
-
is_queuing =
|
|
434
|
-
congestion_event.bytes_in_flight >= queuing_threshold;
|
|
396
|
+
is_queuing = congestion_event.bytes_in_flight >= queuing_threshold;
|
|
435
397
|
}
|
|
436
398
|
}
|
|
437
399
|
|
|
438
400
|
if is_risky || is_queuing {
|
|
439
|
-
self.enter_probe_down(
|
|
440
|
-
false,
|
|
441
|
-
is_risky,
|
|
442
|
-
congestion_event.event_time,
|
|
443
|
-
params,
|
|
444
|
-
);
|
|
401
|
+
self.enter_probe_down(false, is_risky, congestion_event.event_time, params);
|
|
445
402
|
}
|
|
446
403
|
}
|
|
447
404
|
|
|
448
405
|
fn is_time_to_probe_bandwidth(
|
|
449
|
-
&self,
|
|
450
|
-
|
|
406
|
+
&self,
|
|
407
|
+
target_bytes_inflight: usize,
|
|
408
|
+
congestion_event: &BBRv2CongestionEvent,
|
|
409
|
+
params: &Params,
|
|
451
410
|
) -> bool {
|
|
452
|
-
if self.has_cycle_lasted(
|
|
453
|
-
self.cycle.probe_wait_time.unwrap(),
|
|
454
|
-
congestion_event,
|
|
455
|
-
) {
|
|
411
|
+
if self.has_cycle_lasted(self.cycle.probe_wait_time.unwrap(), congestion_event) {
|
|
456
412
|
return true;
|
|
457
413
|
}
|
|
458
414
|
|
|
@@ -469,8 +425,10 @@ impl ProbeBW {
|
|
|
469
425
|
}
|
|
470
426
|
|
|
471
427
|
fn maybe_adapt_upper_bounds(
|
|
472
|
-
&mut self,
|
|
473
|
-
|
|
428
|
+
&mut self,
|
|
429
|
+
target_bytes_inflight: usize,
|
|
430
|
+
congestion_event: &BBRv2CongestionEvent,
|
|
431
|
+
params: &Params,
|
|
474
432
|
) -> AdaptUpperBoundsResult {
|
|
475
433
|
let send_state = congestion_event.last_packet_send_state;
|
|
476
434
|
|
|
@@ -481,8 +439,8 @@ impl ProbeBW {
|
|
|
481
439
|
// TODO(vlad): use BytesInFlight?
|
|
482
440
|
let mut inflight_at_send = send_state.bytes_in_flight;
|
|
483
441
|
if params.use_bytes_delivered_for_inflight_hi {
|
|
484
|
-
inflight_at_send = self.model.total_bytes_acked()
|
|
485
|
-
congestion_event.last_packet_send_state.total_bytes_acked;
|
|
442
|
+
inflight_at_send = self.model.total_bytes_acked()
|
|
443
|
+
- congestion_event.last_packet_send_state.total_bytes_acked;
|
|
486
444
|
}
|
|
487
445
|
|
|
488
446
|
if self.cycle.is_sample_from_probing {
|
|
@@ -492,15 +450,11 @@ impl ProbeBW {
|
|
|
492
450
|
params,
|
|
493
451
|
) {
|
|
494
452
|
self.cycle.is_sample_from_probing = false;
|
|
495
|
-
if !send_state.is_app_limited ||
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
let inflight_target = (target_bytes_inflight as f32 *
|
|
499
|
-
(1.0 - params.beta))
|
|
500
|
-
as usize;
|
|
453
|
+
if !send_state.is_app_limited || params.max_probe_up_queue_rounds > 0 {
|
|
454
|
+
let inflight_target =
|
|
455
|
+
(target_bytes_inflight as f32 * (1.0 - params.beta)) as usize;
|
|
501
456
|
|
|
502
|
-
let mut new_inflight_hi =
|
|
503
|
-
inflight_at_send.max(inflight_target);
|
|
457
|
+
let mut new_inflight_hi = inflight_at_send.max(inflight_target);
|
|
504
458
|
|
|
505
459
|
if params.limit_inflight_hi_by_max_delivered {
|
|
506
460
|
new_inflight_hi = self
|
|
@@ -529,20 +483,27 @@ impl ProbeBW {
|
|
|
529
483
|
}
|
|
530
484
|
|
|
531
485
|
fn has_cycle_lasted(
|
|
532
|
-
&self,
|
|
486
|
+
&self,
|
|
487
|
+
duration: Duration,
|
|
488
|
+
congestion_event: &BBRv2CongestionEvent,
|
|
533
489
|
) -> bool {
|
|
534
490
|
(congestion_event.event_time - self.cycle.start_time) > duration
|
|
535
491
|
}
|
|
536
492
|
|
|
537
493
|
fn has_phase_lasted(
|
|
538
|
-
&self,
|
|
494
|
+
&self,
|
|
495
|
+
duration: Duration,
|
|
496
|
+
congestion_event: &BBRv2CongestionEvent,
|
|
539
497
|
) -> bool {
|
|
540
498
|
(congestion_event.event_time - self.cycle.phase_start_time) > duration
|
|
541
499
|
}
|
|
542
500
|
|
|
543
501
|
fn is_time_to_probe_for_reno_coexistence(
|
|
544
|
-
&self,
|
|
545
|
-
|
|
502
|
+
&self,
|
|
503
|
+
target_bytes_inflight: usize,
|
|
504
|
+
probe_wait_fraction: f64,
|
|
505
|
+
_congestion_event: &BBRv2CongestionEvent,
|
|
506
|
+
params: &Params,
|
|
546
507
|
) -> bool {
|
|
547
508
|
if !params.enable_reno_coexistence {
|
|
548
509
|
return false;
|
|
@@ -550,25 +511,25 @@ impl ProbeBW {
|
|
|
550
511
|
|
|
551
512
|
let mut rounds = params.probe_bw_probe_max_rounds;
|
|
552
513
|
if params.probe_bw_probe_reno_gain > 0.0 {
|
|
553
|
-
let reno_rounds = (params.probe_bw_probe_reno_gain *
|
|
554
|
-
|
|
555
|
-
DEFAULT_MSS as f32) as usize;
|
|
514
|
+
let reno_rounds = (params.probe_bw_probe_reno_gain * target_bytes_inflight as f32
|
|
515
|
+
/ DEFAULT_MSS as f32) as usize;
|
|
556
516
|
rounds = reno_rounds.min(rounds);
|
|
557
517
|
}
|
|
558
518
|
|
|
559
|
-
self.cycle.rounds_since_probe >=
|
|
560
|
-
(rounds as f64 * probe_wait_fraction) as usize
|
|
519
|
+
self.cycle.rounds_since_probe >= (rounds as f64 * probe_wait_fraction) as usize
|
|
561
520
|
}
|
|
562
521
|
|
|
563
522
|
// Used to prevent a BBR2 flow from staying in PROBE_DOWN for too
|
|
564
523
|
// long, as seen in some multi-sender simulator tests.
|
|
565
524
|
//
|
|
566
|
-
// This is experimental code from Google quiche and diverges from the RFC.
|
|
567
|
-
// `disable_probe_down_early_exit` to override the behavior.
|
|
525
|
+
// This is experimental code from Google quiche and diverges from the RFC.
|
|
526
|
+
// Use `disable_probe_down_early_exit` to override the behavior.
|
|
568
527
|
// - RFC: https://www.ietf.org/archive/id/draft-ietf-ccwg-bbr-02.html#name-probebw_down
|
|
569
528
|
// - Google quiche: https://github.com/google/quiche/blob/b370e7a/quiche/quic/core/congestion_control/bbr2_probe_bw.cc#L142
|
|
570
529
|
fn has_stayed_long_enough_in_probe_down(
|
|
571
|
-
&self,
|
|
530
|
+
&self,
|
|
531
|
+
congestion_event: &BBRv2CongestionEvent,
|
|
532
|
+
params: &Params,
|
|
572
533
|
) -> bool {
|
|
573
534
|
if params.disable_probe_down_early_exit {
|
|
574
535
|
return false;
|
|
@@ -581,16 +542,18 @@ impl ProbeBW {
|
|
|
581
542
|
|
|
582
543
|
fn raise_inflight_high_slope(&mut self, cwnd: usize) {
|
|
583
544
|
let growth_this_round = 1usize << self.cycle.probe_up_rounds;
|
|
584
|
-
//
|
|
585
|
-
//
|
|
586
|
-
//
|
|
545
|
+
// Capping rounds at 30 limits `growth_this_round` to 1G and keeps
|
|
546
|
+
// `probe_up_bytes` near one MSS. This grows `inflight_hi` by about one
|
|
547
|
+
// packet per ACK.
|
|
587
548
|
self.cycle.probe_up_rounds = self.cycle.probe_up_rounds.add(1).min(30);
|
|
588
549
|
let probe_up_bytes = cwnd / growth_this_round;
|
|
589
550
|
self.cycle.probe_up_bytes = Some(probe_up_bytes.max(DEFAULT_MSS));
|
|
590
551
|
}
|
|
591
552
|
|
|
592
553
|
fn probe_inflight_high_upward(
|
|
593
|
-
&mut self,
|
|
554
|
+
&mut self,
|
|
555
|
+
congestion_event: &BBRv2CongestionEvent,
|
|
556
|
+
params: &Params,
|
|
594
557
|
) {
|
|
595
558
|
if params.probe_up_ignore_inflight_hi {
|
|
596
559
|
// When inflight_hi is disabled in PROBE_UP, it increases when
|
|
@@ -598,9 +561,7 @@ impl ProbeBW {
|
|
|
598
561
|
return;
|
|
599
562
|
} else {
|
|
600
563
|
// TODO(vlad): probe_up_simplify_inflight_hi?
|
|
601
|
-
if congestion_event.prior_bytes_in_flight <
|
|
602
|
-
congestion_event.prior_cwnd
|
|
603
|
-
{
|
|
564
|
+
if congestion_event.prior_bytes_in_flight < congestion_event.prior_cwnd {
|
|
604
565
|
// Not fully utilizing cwnd, so can't safely grow.
|
|
605
566
|
return;
|
|
606
567
|
}
|
|
@@ -620,8 +581,7 @@ impl ProbeBW {
|
|
|
620
581
|
// probe_up_acked >= delta * probe_up_bytes so this
|
|
621
582
|
// can't underflow.
|
|
622
583
|
self.cycle.probe_up_acked -= delta * probe_up_bytes;
|
|
623
|
-
let new_inflight_hi =
|
|
624
|
-
self.model.inflight_hi() + delta * DEFAULT_MSS;
|
|
584
|
+
let new_inflight_hi = self.model.inflight_hi() + delta * DEFAULT_MSS;
|
|
625
585
|
if new_inflight_hi > self.model.inflight_hi() {
|
|
626
586
|
self.model.set_inflight_hi(new_inflight_hi);
|
|
627
587
|
}
|
|
@@ -634,7 +594,9 @@ impl ProbeBW {
|
|
|
634
594
|
}
|
|
635
595
|
|
|
636
596
|
fn into_probe_rtt(
|
|
637
|
-
mut self,
|
|
597
|
+
mut self,
|
|
598
|
+
now: Instant,
|
|
599
|
+
congestion_event: Option<&BBRv2CongestionEvent>,
|
|
638
600
|
params: &Params,
|
|
639
601
|
) -> Mode {
|
|
640
602
|
self.leave(now, congestion_event);
|
|
@@ -654,30 +616,26 @@ mod tests {
|
|
|
654
616
|
|
|
655
617
|
#[rstest]
|
|
656
618
|
fn probe_upward(#[values(100, 10_000, 65_536, 300_000)] step: usize) {
|
|
657
|
-
let test_event =
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
};
|
|
619
|
+
let test_event = |probe_bw: &ProbeBW, bytes_acked: usize, end_of_round_trip: bool| {
|
|
620
|
+
BBRv2CongestionEvent {
|
|
621
|
+
event_time: probe_bw.cycle.start_time,
|
|
622
|
+
prior_cwnd: probe_bw.model.inflight_hi(),
|
|
623
|
+
prior_bytes_in_flight: probe_bw.model.inflight_hi(),
|
|
624
|
+
bytes_in_flight: 0,
|
|
625
|
+
bytes_acked,
|
|
626
|
+
bytes_lost: 0,
|
|
627
|
+
end_of_round_trip,
|
|
628
|
+
is_probing_for_bandwidth: true,
|
|
629
|
+
sample_max_bandwidth: None,
|
|
630
|
+
sample_min_rtt: None,
|
|
631
|
+
last_packet_send_state: SendTimeState::default(),
|
|
632
|
+
}
|
|
633
|
+
};
|
|
673
634
|
|
|
674
|
-
let do_probe_up = |probe_bw: &mut ProbeBW,
|
|
675
|
-
params: &Params,
|
|
676
|
-
total_bytes: usize| {
|
|
635
|
+
let do_probe_up = |probe_bw: &mut ProbeBW, params: &Params, total_bytes: usize| {
|
|
677
636
|
let mut remaining = total_bytes;
|
|
678
637
|
loop {
|
|
679
|
-
let congestion_event =
|
|
680
|
-
test_event(probe_bw, step.min(remaining), false);
|
|
638
|
+
let congestion_event = test_event(probe_bw, step.min(remaining), false);
|
|
681
639
|
|
|
682
640
|
probe_bw.probe_inflight_high_upward(&congestion_event, params);
|
|
683
641
|
|
|
@@ -704,10 +662,7 @@ mod tests {
|
|
|
704
662
|
assert_eq!(probe_bw.model.inflight_hi(), 113_000);
|
|
705
663
|
|
|
706
664
|
// Slope is increased at the end of round by decreasing probe_up_bytes.
|
|
707
|
-
probe_bw.probe_inflight_high_upward(
|
|
708
|
-
&test_event(&probe_bw, 10_000, true),
|
|
709
|
-
params,
|
|
710
|
-
);
|
|
665
|
+
probe_bw.probe_inflight_high_upward(&test_event(&probe_bw, 10_000, true), params);
|
|
711
666
|
assert_eq!(probe_bw.cycle.probe_up_rounds, 2);
|
|
712
667
|
assert_eq!(probe_bw.cycle.probe_up_bytes, Some(56500));
|
|
713
668
|
|
|
@@ -715,10 +670,7 @@ mod tests {
|
|
|
715
670
|
// End inflight_hi should be independent of step size.
|
|
716
671
|
assert_eq!(probe_bw.model.inflight_hi(), 135_100);
|
|
717
672
|
|
|
718
|
-
probe_bw.probe_inflight_high_upward(
|
|
719
|
-
&test_event(&probe_bw, 10_000, true),
|
|
720
|
-
params,
|
|
721
|
-
);
|
|
673
|
+
probe_bw.probe_inflight_high_upward(&test_event(&probe_bw, 10_000, true), params);
|
|
722
674
|
assert_eq!(probe_bw.cycle.probe_up_rounds, 3);
|
|
723
675
|
assert_eq!(probe_bw.cycle.probe_up_bytes, Some(33775));
|
|
724
676
|
|