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
|
@@ -37,6 +37,7 @@ use crate::recovery::gcongestion::bbr2::Params;
|
|
|
37
37
|
use crate::recovery::gcongestion::Bandwidth;
|
|
38
38
|
use crate::recovery::gcongestion::Lost;
|
|
39
39
|
|
|
40
|
+
use super::rtt_jump_detector::RttJumpDetector;
|
|
40
41
|
use super::Acked;
|
|
41
42
|
use super::BBRv2CongestionEvent;
|
|
42
43
|
use super::BwLoMode;
|
|
@@ -65,7 +66,7 @@ impl RoundTripCounter {
|
|
|
65
66
|
self.round_trip_count += 1;
|
|
66
67
|
self.end_of_round_trip = Some(self.last_sent_packet);
|
|
67
68
|
true
|
|
68
|
-
}
|
|
69
|
+
}
|
|
69
70
|
}
|
|
70
71
|
}
|
|
71
72
|
|
|
@@ -191,6 +192,9 @@ pub(super) struct BBRv2NetworkModel {
|
|
|
191
192
|
latest_send_rate: Option<Bandwidth>,
|
|
192
193
|
/// The most recent ack rate from the BandwidthSampler.
|
|
193
194
|
latest_ack_rate: Option<Bandwidth>,
|
|
195
|
+
|
|
196
|
+
/// Detector for persistent RTT jump episodes.
|
|
197
|
+
rtt_jump_detector: RttJumpDetector,
|
|
194
198
|
}
|
|
195
199
|
|
|
196
200
|
impl BBRv2NetworkModel {
|
|
@@ -238,6 +242,8 @@ impl BBRv2NetworkModel {
|
|
|
238
242
|
|
|
239
243
|
latest_send_rate: None,
|
|
240
244
|
latest_ack_rate: None,
|
|
245
|
+
|
|
246
|
+
rtt_jump_detector: RttJumpDetector::new(params.rtt_jump_detector),
|
|
241
247
|
}
|
|
242
248
|
}
|
|
243
249
|
|
|
@@ -287,13 +293,16 @@ impl BBRv2NetworkModel {
|
|
|
287
293
|
}
|
|
288
294
|
|
|
289
295
|
pub(super) fn on_packet_sent(
|
|
290
|
-
&mut self,
|
|
291
|
-
|
|
296
|
+
&mut self,
|
|
297
|
+
sent_time: Instant,
|
|
298
|
+
bytes_in_flight: usize,
|
|
299
|
+
packet_number: u64,
|
|
300
|
+
bytes: usize,
|
|
301
|
+
is_retransmissible: bool,
|
|
292
302
|
) {
|
|
293
303
|
// Updating the min here ensures a more realistic (0) value when flows
|
|
294
304
|
// exit quiescence.
|
|
295
|
-
self.min_bytes_in_flight_in_round =
|
|
296
|
-
self.min_bytes_in_flight_in_round.min(bytes_in_flight);
|
|
305
|
+
self.min_bytes_in_flight_in_round = self.min_bytes_in_flight_in_round.min(bytes_in_flight);
|
|
297
306
|
|
|
298
307
|
if bytes_in_flight + bytes >= self.inflight_hi {
|
|
299
308
|
self.inflight_hi_limited_in_round = true;
|
|
@@ -310,21 +319,23 @@ impl BBRv2NetworkModel {
|
|
|
310
319
|
}
|
|
311
320
|
|
|
312
321
|
pub(super) fn on_congestion_event_start(
|
|
313
|
-
&mut self,
|
|
314
|
-
|
|
322
|
+
&mut self,
|
|
323
|
+
acked_packets: &[Acked],
|
|
324
|
+
lost_packets: &[Lost],
|
|
325
|
+
congestion_event: &mut BBRv2CongestionEvent,
|
|
326
|
+
params: &Params,
|
|
315
327
|
) {
|
|
316
328
|
let prior_bytes_acked = self.total_bytes_acked();
|
|
317
329
|
let prior_bytes_lost = self.total_bytes_lost();
|
|
318
330
|
|
|
319
331
|
let event_time = congestion_event.event_time;
|
|
320
332
|
|
|
321
|
-
congestion_event.end_of_round_trip =
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
};
|
|
333
|
+
congestion_event.end_of_round_trip = if let Some(largest_acked) = acked_packets.last() {
|
|
334
|
+
self.round_trip_counter
|
|
335
|
+
.on_packets_acked(largest_acked.pkt_num)
|
|
336
|
+
} else {
|
|
337
|
+
false
|
|
338
|
+
};
|
|
328
339
|
|
|
329
340
|
let sample = self.bandwidth_sampler.on_congestion_event(
|
|
330
341
|
event_time,
|
|
@@ -336,26 +347,21 @@ impl BBRv2NetworkModel {
|
|
|
336
347
|
);
|
|
337
348
|
|
|
338
349
|
if sample.extra_acked == 0 {
|
|
339
|
-
self.cwnd_limited_before_aggregation_epoch =
|
|
340
|
-
.prior_bytes_in_flight >=
|
|
341
|
-
congestion_event.prior_cwnd;
|
|
350
|
+
self.cwnd_limited_before_aggregation_epoch =
|
|
351
|
+
congestion_event.prior_bytes_in_flight >= congestion_event.prior_cwnd;
|
|
342
352
|
}
|
|
343
353
|
|
|
344
354
|
if sample.last_packet_send_state.is_valid {
|
|
345
|
-
congestion_event.last_packet_send_state =
|
|
346
|
-
sample.last_packet_send_state;
|
|
355
|
+
congestion_event.last_packet_send_state = sample.last_packet_send_state;
|
|
347
356
|
}
|
|
348
357
|
|
|
349
|
-
//
|
|
350
|
-
//
|
|
351
|
-
//
|
|
352
|
-
// total_bytes_acked() will not change.
|
|
358
|
+
// Do not update `max_bandwidth_filter` for a loss-only event or when no
|
|
359
|
+
// acknowledged packet produced a valid sample. In either case,
|
|
360
|
+
// `total_bytes_acked()` remains unchanged.
|
|
353
361
|
if let Some(sample_max) = sample.sample_max_bandwidth {
|
|
354
362
|
if prior_bytes_acked != self.total_bytes_acked() {
|
|
355
363
|
congestion_event.sample_max_bandwidth = Some(sample_max);
|
|
356
|
-
if !sample.sample_is_app_limited ||
|
|
357
|
-
sample_max > self.max_bandwidth()
|
|
358
|
-
{
|
|
364
|
+
if !sample.sample_is_app_limited || sample_max > self.max_bandwidth() {
|
|
359
365
|
self.max_bandwidth_filter.update(sample_max);
|
|
360
366
|
}
|
|
361
367
|
}
|
|
@@ -363,14 +369,20 @@ impl BBRv2NetworkModel {
|
|
|
363
369
|
|
|
364
370
|
if let Some(rtt_sample) = sample.sample_rtt {
|
|
365
371
|
congestion_event.sample_min_rtt = Some(rtt_sample);
|
|
372
|
+
|
|
373
|
+
self.rtt_jump_detector.on_rtt_sample(
|
|
374
|
+
rtt_sample,
|
|
375
|
+
event_time,
|
|
376
|
+
self.full_bandwidth_reached,
|
|
377
|
+
);
|
|
378
|
+
|
|
366
379
|
self.min_rtt_filter.update(rtt_sample, event_time);
|
|
367
380
|
}
|
|
368
381
|
|
|
369
382
|
self.latest_send_rate = sample.sample_max_send_rate;
|
|
370
383
|
self.latest_ack_rate = sample.sample_max_ack_rate;
|
|
371
384
|
|
|
372
|
-
congestion_event.bytes_acked =
|
|
373
|
-
self.total_bytes_acked() - prior_bytes_acked;
|
|
385
|
+
congestion_event.bytes_acked = self.total_bytes_acked() - prior_bytes_acked;
|
|
374
386
|
congestion_event.bytes_lost = self.total_bytes_lost() - prior_bytes_lost;
|
|
375
387
|
|
|
376
388
|
congestion_event.bytes_in_flight = congestion_event
|
|
@@ -383,13 +395,12 @@ impl BBRv2NetworkModel {
|
|
|
383
395
|
self.loss_events_in_round += 1;
|
|
384
396
|
}
|
|
385
397
|
|
|
386
|
-
if congestion_event.bytes_acked > 0
|
|
387
|
-
congestion_event.last_packet_send_state.is_valid
|
|
388
|
-
self.total_bytes_acked() >
|
|
389
|
-
congestion_event.last_packet_send_state.total_bytes_acked
|
|
398
|
+
if congestion_event.bytes_acked > 0
|
|
399
|
+
&& congestion_event.last_packet_send_state.is_valid
|
|
400
|
+
&& self.total_bytes_acked() > congestion_event.last_packet_send_state.total_bytes_acked
|
|
390
401
|
{
|
|
391
|
-
let bytes_delivered = self.total_bytes_acked()
|
|
392
|
-
congestion_event.last_packet_send_state.total_bytes_acked;
|
|
402
|
+
let bytes_delivered = self.total_bytes_acked()
|
|
403
|
+
- congestion_event.last_packet_send_state.total_bytes_acked;
|
|
393
404
|
self.max_bytes_delivered_in_round =
|
|
394
405
|
self.max_bytes_delivered_in_round.max(bytes_delivered);
|
|
395
406
|
}
|
|
@@ -428,13 +439,9 @@ impl BBRv2NetworkModel {
|
|
|
428
439
|
self.bandwidth_sampler.on_packet_neutered(packet_number)
|
|
429
440
|
}
|
|
430
441
|
|
|
431
|
-
fn adapt_lower_bounds(
|
|
432
|
-
&mut self, congestion_event: &BBRv2CongestionEvent, params: &Params,
|
|
433
|
-
) {
|
|
442
|
+
fn adapt_lower_bounds(&mut self, congestion_event: &BBRv2CongestionEvent, params: &Params) {
|
|
434
443
|
if params.bw_lo_mode == BwLoMode::Default {
|
|
435
|
-
if !congestion_event.end_of_round_trip ||
|
|
436
|
-
congestion_event.is_probing_for_bandwidth
|
|
437
|
-
{
|
|
444
|
+
if !congestion_event.end_of_round_trip || congestion_event.is_probing_for_bandwidth {
|
|
438
445
|
return;
|
|
439
446
|
}
|
|
440
447
|
|
|
@@ -452,8 +459,7 @@ impl BBRv2NetworkModel {
|
|
|
452
459
|
self.inflight_lo = congestion_event.prior_cwnd;
|
|
453
460
|
}
|
|
454
461
|
|
|
455
|
-
let inflight_lo_new =
|
|
456
|
-
(self.inflight_lo as f32 * (1.0 - params.beta)) as usize;
|
|
462
|
+
let inflight_lo_new = (self.inflight_lo as f32 * (1.0 - params.beta)) as usize;
|
|
457
463
|
self.inflight_lo = self.inflight_latest.max(inflight_lo_new);
|
|
458
464
|
}
|
|
459
465
|
return;
|
|
@@ -491,45 +497,40 @@ impl BBRv2NetworkModel {
|
|
|
491
497
|
self.bandwidth_lo = self
|
|
492
498
|
.bandwidth_lo
|
|
493
499
|
.map(|b| (b - reduction).unwrap_or(Bandwidth::zero()));
|
|
494
|
-
}
|
|
500
|
+
}
|
|
495
501
|
BwLoMode::InflightReduction => {
|
|
496
502
|
// Use a max of BDP and inflight to avoid starving app-limited
|
|
497
503
|
// flows.
|
|
498
|
-
let effective_inflight =
|
|
499
|
-
self.bdp0().max(congestion_event.prior_bytes_in_flight);
|
|
504
|
+
let effective_inflight = self.bdp0().max(congestion_event.prior_bytes_in_flight);
|
|
500
505
|
// This could use bytes_lost_in_round if the bandwidth_lo_ was
|
|
501
506
|
// saved when entering 'recovery', but this BBRv2
|
|
502
507
|
// implementation doesn't have recovery defined.
|
|
503
508
|
self.bandwidth_lo = self.bandwidth_lo.map(|b| {
|
|
504
|
-
b * ((effective_inflight as f64 -
|
|
505
|
-
|
|
506
|
-
effective_inflight as f64)
|
|
509
|
+
b * ((effective_inflight as f64 - congestion_event.bytes_lost as f64)
|
|
510
|
+
/ effective_inflight as f64)
|
|
507
511
|
});
|
|
508
|
-
}
|
|
512
|
+
}
|
|
509
513
|
BwLoMode::CwndReduction => {
|
|
510
514
|
self.bandwidth_lo = self.bandwidth_lo.map(|b| {
|
|
511
|
-
b * ((congestion_event.prior_cwnd as f64 -
|
|
512
|
-
congestion_event.
|
|
513
|
-
congestion_event.prior_cwnd as f64)
|
|
515
|
+
b * ((congestion_event.prior_cwnd as f64 - congestion_event.bytes_lost as f64)
|
|
516
|
+
/ congestion_event.prior_cwnd as f64)
|
|
514
517
|
});
|
|
515
|
-
}
|
|
518
|
+
}
|
|
516
519
|
}
|
|
517
520
|
|
|
518
521
|
let mut last_bandwidth = self.bandwidth_latest;
|
|
519
522
|
// sample_max_bandwidth will be None if the loss is triggered by a timer
|
|
520
523
|
// expiring. Ideally we'd use the most recent bandwidth sample,
|
|
521
524
|
// but bandwidth_latest is safer than None.
|
|
522
|
-
if let Some(sample_max_bandwidth) = congestion_event.sample_max_bandwidth
|
|
523
|
-
{
|
|
525
|
+
if let Some(sample_max_bandwidth) = congestion_event.sample_max_bandwidth {
|
|
524
526
|
// bandwidth_latest is the max bandwidth for the round, but to allow
|
|
525
527
|
// fast, conservation style response to loss, use the last sample.
|
|
526
528
|
last_bandwidth = sample_max_bandwidth;
|
|
527
529
|
}
|
|
528
530
|
if self.pacing_gain > params.full_bw_threshold {
|
|
529
|
-
//
|
|
530
|
-
//
|
|
531
|
-
// the
|
|
532
|
-
// last_bandwidth * full_bw_threshold.
|
|
531
|
+
// STARTUP applies `pacing_gain` to `bandwidth_lo`. Remove that
|
|
532
|
+
// factor so pacing can decrease without falling below
|
|
533
|
+
// the threshold.
|
|
533
534
|
self.bandwidth_lo = self.bandwidth_lo.max(Some(
|
|
534
535
|
last_bandwidth * (params.full_bw_threshold / self.pacing_gain),
|
|
535
536
|
));
|
|
@@ -537,8 +538,8 @@ impl BBRv2NetworkModel {
|
|
|
537
538
|
// Ensure bandwidth_lo isn't lower than last_bandwidth.
|
|
538
539
|
self.bandwidth_lo = self.bandwidth_lo.max(Some(last_bandwidth))
|
|
539
540
|
}
|
|
540
|
-
//
|
|
541
|
-
// than beta
|
|
541
|
+
// At the end of a round, ensure `bandwidth_lo` does not decrease by
|
|
542
|
+
// more than `beta`.
|
|
542
543
|
if congestion_event.end_of_round_trip {
|
|
543
544
|
self.bandwidth_lo = self.bandwidth_lo.max(
|
|
544
545
|
self.prior_bandwidth_lo
|
|
@@ -550,7 +551,8 @@ impl BBRv2NetworkModel {
|
|
|
550
551
|
}
|
|
551
552
|
|
|
552
553
|
pub(super) fn on_congestion_event_finish(
|
|
553
|
-
&mut self,
|
|
554
|
+
&mut self,
|
|
555
|
+
least_unacked_packet: u64,
|
|
554
556
|
congestion_event: &BBRv2CongestionEvent,
|
|
555
557
|
) {
|
|
556
558
|
if congestion_event.end_of_round_trip {
|
|
@@ -562,14 +564,16 @@ impl BBRv2NetworkModel {
|
|
|
562
564
|
}
|
|
563
565
|
|
|
564
566
|
pub(super) fn maybe_expire_min_rtt(
|
|
565
|
-
&mut self,
|
|
567
|
+
&mut self,
|
|
568
|
+
congestion_event: &BBRv2CongestionEvent,
|
|
569
|
+
params: &Params,
|
|
566
570
|
) -> bool {
|
|
567
571
|
if congestion_event.sample_min_rtt.is_none() {
|
|
568
572
|
return false;
|
|
569
573
|
}
|
|
570
574
|
|
|
571
|
-
if congestion_event.event_time
|
|
572
|
-
self.min_rtt_filter.min_rtt_timestamp + params.probe_rtt_period
|
|
575
|
+
if congestion_event.event_time
|
|
576
|
+
< self.min_rtt_filter.min_rtt_timestamp + params.probe_rtt_period
|
|
573
577
|
{
|
|
574
578
|
return false;
|
|
575
579
|
}
|
|
@@ -583,7 +587,9 @@ impl BBRv2NetworkModel {
|
|
|
583
587
|
}
|
|
584
588
|
|
|
585
589
|
pub(super) fn is_inflight_too_high(
|
|
586
|
-
&self,
|
|
590
|
+
&self,
|
|
591
|
+
congestion_event: &BBRv2CongestionEvent,
|
|
592
|
+
max_loss_events: usize,
|
|
587
593
|
params: &Params,
|
|
588
594
|
) -> bool {
|
|
589
595
|
let send_state = &congestion_event.last_packet_send_state;
|
|
@@ -628,7 +634,9 @@ impl BBRv2NetworkModel {
|
|
|
628
634
|
}
|
|
629
635
|
|
|
630
636
|
pub(super) fn has_bandwidth_growth(
|
|
631
|
-
&mut self,
|
|
637
|
+
&mut self,
|
|
638
|
+
congestion_event: &BBRv2CongestionEvent,
|
|
639
|
+
params: &Params,
|
|
632
640
|
) -> bool {
|
|
633
641
|
let threshold = self.full_bandwidth_baseline * params.full_bw_threshold;
|
|
634
642
|
|
|
@@ -644,16 +652,16 @@ impl BBRv2NetworkModel {
|
|
|
644
652
|
return false;
|
|
645
653
|
}
|
|
646
654
|
|
|
647
|
-
let ignore_round = self.ignore_app_limited_for_no_bandwidth_growth
|
|
648
|
-
congestion_event.last_packet_send_state.is_app_limited;
|
|
655
|
+
let ignore_round = self.ignore_app_limited_for_no_bandwidth_growth
|
|
656
|
+
&& congestion_event.last_packet_send_state.is_app_limited;
|
|
649
657
|
|
|
650
658
|
if !ignore_round {
|
|
651
659
|
self.rounds_without_bandwidth_growth += 1;
|
|
652
660
|
}
|
|
653
661
|
|
|
654
662
|
// full_bandwidth_reached is only set to true when not app-limited
|
|
655
|
-
if self.rounds_without_bandwidth_growth >= params.startup_full_bw_rounds
|
|
656
|
-
!congestion_event.last_packet_send_state.is_app_limited
|
|
663
|
+
if self.rounds_without_bandwidth_growth >= params.startup_full_bw_rounds
|
|
664
|
+
&& !congestion_event.last_packet_send_state.is_app_limited
|
|
657
665
|
{
|
|
658
666
|
self.full_bandwidth_reached = true;
|
|
659
667
|
}
|
|
@@ -666,9 +674,7 @@ impl BBRv2NetworkModel {
|
|
|
666
674
|
2 * DEFAULT_MSS
|
|
667
675
|
}
|
|
668
676
|
|
|
669
|
-
pub(super) fn check_persistent_queue(
|
|
670
|
-
&mut self, target_gain: f32, params: &Params,
|
|
671
|
-
) {
|
|
677
|
+
pub(super) fn check_persistent_queue(&mut self, target_gain: f32, params: &Params) {
|
|
672
678
|
let target = self
|
|
673
679
|
.bdp(self.max_bandwidth(), target_gain)
|
|
674
680
|
.max(self.bdp0() + self.queueing_threshold_extra_bytes());
|
|
@@ -697,6 +703,33 @@ impl BBRv2NetworkModel {
|
|
|
697
703
|
self.bandwidth_sampler.total_bytes_lost()
|
|
698
704
|
}
|
|
699
705
|
|
|
706
|
+
/// Total number of confirmed persistent RTT jump episodes over the
|
|
707
|
+
/// lifetime of the connection.
|
|
708
|
+
pub(super) fn rtt_persistent_jump_count(&self) -> u64 {
|
|
709
|
+
self.rtt_jump_detector.rtt_persistent_jump_count()
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
/// The start time of the most recently confirmed persistent RTT jump
|
|
713
|
+
/// episode, if any.
|
|
714
|
+
#[cfg(test)]
|
|
715
|
+
pub(super) fn last_persistent_jump_time(&self) -> Option<Instant> {
|
|
716
|
+
self.rtt_jump_detector.last_persistent_jump_time()
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
/// Whether an RTT jump episode is currently active (elevated but not yet
|
|
720
|
+
/// resolved), regardless of whether it has been confirmed persistent.
|
|
721
|
+
#[cfg(test)]
|
|
722
|
+
pub(super) fn is_rtt_jump_active(&self) -> bool {
|
|
723
|
+
self.rtt_jump_detector.is_rtt_jump_active()
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
/// Whether the current RTT jump episode has been confirmed as a persistent
|
|
727
|
+
/// network condition.
|
|
728
|
+
#[cfg(test)]
|
|
729
|
+
pub(super) fn is_rtt_jump_persistent(&self) -> bool {
|
|
730
|
+
self.rtt_jump_detector.is_rtt_jump_persistent()
|
|
731
|
+
}
|
|
732
|
+
|
|
700
733
|
fn round_trip_count(&self) -> usize {
|
|
701
734
|
self.round_trip_counter.round_trip_count
|
|
702
735
|
}
|
|
@@ -730,8 +763,7 @@ impl BBRv2NetworkModel {
|
|
|
730
763
|
}
|
|
731
764
|
|
|
732
765
|
pub(super) fn inflight_hi_with_headroom(&self, params: &Params) -> usize {
|
|
733
|
-
let headroom =
|
|
734
|
-
(self.inflight_hi as f32 * params.inflight_hi_headroom) as usize;
|
|
766
|
+
let headroom = (self.inflight_hi as f32 * params.inflight_hi_headroom) as usize;
|
|
735
767
|
self.inflight_hi.saturating_sub(headroom)
|
|
736
768
|
}
|
|
737
769
|
|
|
@@ -782,3 +814,244 @@ impl BBRv2NetworkModel {
|
|
|
782
814
|
self.rounds_with_queueing
|
|
783
815
|
}
|
|
784
816
|
}
|
|
817
|
+
|
|
818
|
+
#[cfg(test)]
|
|
819
|
+
mod tests {
|
|
820
|
+
use super::*;
|
|
821
|
+
use crate::recovery::gcongestion::bbr2::DEFAULT_PARAMS;
|
|
822
|
+
use crate::recovery::gcongestion::BbrRttJumpDetector;
|
|
823
|
+
|
|
824
|
+
fn ms(millis: u64) -> Duration {
|
|
825
|
+
Duration::from_millis(millis)
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
const RTT: Duration = Duration::from_millis(50);
|
|
829
|
+
const RTT_3X: Duration = Duration::from_millis(150);
|
|
830
|
+
const RTT_JUMP: Duration = Duration::from_millis(151);
|
|
831
|
+
|
|
832
|
+
/// Ack a packet with the given RTT through the real congestion-event path.
|
|
833
|
+
fn ack_with_rtt(
|
|
834
|
+
model: &mut BBRv2NetworkModel,
|
|
835
|
+
params: &Params,
|
|
836
|
+
pkt_num: u64,
|
|
837
|
+
base: Instant,
|
|
838
|
+
sent_offset: Duration,
|
|
839
|
+
rtt: Duration,
|
|
840
|
+
) -> BBRv2CongestionEvent {
|
|
841
|
+
ack_with_rtt_util(
|
|
842
|
+
model,
|
|
843
|
+
params,
|
|
844
|
+
pkt_num,
|
|
845
|
+
base,
|
|
846
|
+
sent_offset,
|
|
847
|
+
rtt,
|
|
848
|
+
100_000,
|
|
849
|
+
1200,
|
|
850
|
+
)
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
/// As `ack_with_rtt`, but with explicit cwnd and inflight inputs.
|
|
854
|
+
// Test harness: the extra cwnd/inflight knobs push this one over the
|
|
855
|
+
// argument-count lint, which is not worth a builder struct in tests.
|
|
856
|
+
#[allow(clippy::too_many_arguments)]
|
|
857
|
+
fn ack_with_rtt_util(
|
|
858
|
+
model: &mut BBRv2NetworkModel,
|
|
859
|
+
params: &Params,
|
|
860
|
+
pkt_num: u64,
|
|
861
|
+
base: Instant,
|
|
862
|
+
sent_offset: Duration,
|
|
863
|
+
rtt: Duration,
|
|
864
|
+
prior_cwnd: usize,
|
|
865
|
+
prior_in_flight: usize,
|
|
866
|
+
) -> BBRv2CongestionEvent {
|
|
867
|
+
let bytes = 1200;
|
|
868
|
+
let sent_time = base + sent_offset;
|
|
869
|
+
model.on_packet_sent(sent_time, 0, pkt_num, bytes, true);
|
|
870
|
+
|
|
871
|
+
let ack_time = sent_time + rtt;
|
|
872
|
+
let acked = [Acked {
|
|
873
|
+
pkt_num,
|
|
874
|
+
time_sent: sent_time,
|
|
875
|
+
}];
|
|
876
|
+
let mut event = BBRv2CongestionEvent::new(ack_time, prior_cwnd, prior_in_flight, false);
|
|
877
|
+
model.on_congestion_event_start(&acked, &[], &mut event, params);
|
|
878
|
+
event
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
fn rtt_jump_params(detector: BbrRttJumpDetector) -> Params {
|
|
882
|
+
Params {
|
|
883
|
+
rtt_jump_detector: detector,
|
|
884
|
+
..DEFAULT_PARAMS
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
#[test]
|
|
889
|
+
fn rtt_jump_detector_is_disabled_by_default() {
|
|
890
|
+
let params = &DEFAULT_PARAMS;
|
|
891
|
+
let mut model = BBRv2NetworkModel::new(params, RTT);
|
|
892
|
+
let base = Instant::now();
|
|
893
|
+
|
|
894
|
+
for pkt in 1..5 {
|
|
895
|
+
ack_with_rtt(&mut model, params, pkt, base, ms(pkt * 10), RTT);
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
let mut offset = 100;
|
|
899
|
+
for pkt in 5..20 {
|
|
900
|
+
ack_with_rtt(&mut model, params, pkt, base, ms(offset), RTT_3X);
|
|
901
|
+
offset += 100;
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
assert_eq!(model.rtt_persistent_jump_count(), 0);
|
|
905
|
+
assert!(!model.is_rtt_jump_active());
|
|
906
|
+
assert_eq!(model.last_persistent_jump_time(), None);
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
#[test]
|
|
910
|
+
fn global_min_detector_can_be_enabled() {
|
|
911
|
+
let params = &rtt_jump_params(BbrRttJumpDetector::GlobalMin);
|
|
912
|
+
let mut model = BBRv2NetworkModel::new(params, RTT);
|
|
913
|
+
let base = Instant::now();
|
|
914
|
+
|
|
915
|
+
for pkt in 1..5 {
|
|
916
|
+
ack_with_rtt(&mut model, params, pkt, base, ms(pkt * 10), RTT);
|
|
917
|
+
}
|
|
918
|
+
model.set_full_bandwidth_reached();
|
|
919
|
+
|
|
920
|
+
ack_with_rtt(&mut model, params, 5, base, ms(100), RTT_JUMP);
|
|
921
|
+
ack_with_rtt(&mut model, params, 6, base, ms(110), RTT_JUMP);
|
|
922
|
+
ack_with_rtt(&mut model, params, 7, base, ms(300), RTT_JUMP);
|
|
923
|
+
|
|
924
|
+
assert_eq!(model.rtt_persistent_jump_count(), 1);
|
|
925
|
+
assert!(model.is_rtt_jump_persistent());
|
|
926
|
+
assert!(model.last_persistent_jump_time().is_some());
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
#[test]
|
|
930
|
+
fn hmm_detector_can_be_enabled() {
|
|
931
|
+
let params = &rtt_jump_params(BbrRttJumpDetector::Hmm);
|
|
932
|
+
let mut model = BBRv2NetworkModel::new(params, RTT);
|
|
933
|
+
let base = Instant::now();
|
|
934
|
+
|
|
935
|
+
for pkt in 1..9u64 {
|
|
936
|
+
ack_with_rtt(&mut model, params, pkt, base, ms(pkt * 10), RTT);
|
|
937
|
+
}
|
|
938
|
+
model.set_full_bandwidth_reached();
|
|
939
|
+
|
|
940
|
+
let mut offset = 200u64;
|
|
941
|
+
for pkt in 9u64..40 {
|
|
942
|
+
ack_with_rtt(&mut model, params, pkt, base, ms(offset), RTT_3X);
|
|
943
|
+
offset += 100;
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
assert_eq!(model.rtt_persistent_jump_count(), 1);
|
|
947
|
+
assert!(model.is_rtt_jump_persistent());
|
|
948
|
+
assert!(model.last_persistent_jump_time().is_some());
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
#[test]
|
|
952
|
+
fn global_min_detector_sustained_step_becomes_persistent() {
|
|
953
|
+
let params = &rtt_jump_params(BbrRttJumpDetector::GlobalMin);
|
|
954
|
+
let mut model = BBRv2NetworkModel::new(params, RTT);
|
|
955
|
+
let base = Instant::now();
|
|
956
|
+
|
|
957
|
+
for pkt in 1..5 {
|
|
958
|
+
ack_with_rtt(&mut model, params, pkt, base, ms(pkt * 10), RTT);
|
|
959
|
+
}
|
|
960
|
+
model.set_full_bandwidth_reached();
|
|
961
|
+
|
|
962
|
+
ack_with_rtt(&mut model, params, 5, base, ms(100), RTT_JUMP);
|
|
963
|
+
assert!(model.is_rtt_jump_active());
|
|
964
|
+
assert!(!model.is_rtt_jump_persistent());
|
|
965
|
+
|
|
966
|
+
ack_with_rtt(&mut model, params, 6, base, ms(110), RTT_JUMP);
|
|
967
|
+
assert!(!model.is_rtt_jump_persistent());
|
|
968
|
+
|
|
969
|
+
ack_with_rtt(&mut model, params, 7, base, ms(300), RTT_JUMP);
|
|
970
|
+
assert!(model.is_rtt_jump_persistent());
|
|
971
|
+
assert_eq!(model.rtt_persistent_jump_count(), 1);
|
|
972
|
+
assert!(model.last_persistent_jump_time().is_some());
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
#[test]
|
|
976
|
+
fn global_min_detector_uses_strict_3x_threshold() {
|
|
977
|
+
let params = &rtt_jump_params(BbrRttJumpDetector::GlobalMin);
|
|
978
|
+
let base = Instant::now();
|
|
979
|
+
|
|
980
|
+
let mut at_edge = BBRv2NetworkModel::new(params, RTT);
|
|
981
|
+
ack_with_rtt(&mut at_edge, params, 1, base, ms(10), RTT);
|
|
982
|
+
at_edge.set_full_bandwidth_reached();
|
|
983
|
+
ack_with_rtt(&mut at_edge, params, 2, base, ms(20), RTT_3X);
|
|
984
|
+
assert!(!at_edge.is_rtt_jump_active());
|
|
985
|
+
|
|
986
|
+
let mut just_above = BBRv2NetworkModel::new(params, RTT);
|
|
987
|
+
ack_with_rtt(&mut just_above, params, 1, base, ms(10), RTT);
|
|
988
|
+
just_above.set_full_bandwidth_reached();
|
|
989
|
+
ack_with_rtt(&mut just_above, params, 2, base, ms(20), RTT_JUMP);
|
|
990
|
+
assert!(just_above.is_rtt_jump_active());
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
#[test]
|
|
994
|
+
fn global_min_detector_tracks_downward_baseline() {
|
|
995
|
+
let params = &rtt_jump_params(BbrRttJumpDetector::GlobalMin);
|
|
996
|
+
let mut model = BBRv2NetworkModel::new(params, RTT);
|
|
997
|
+
let base = Instant::now();
|
|
998
|
+
|
|
999
|
+
ack_with_rtt(&mut model, params, 1, base, ms(100), ms(100));
|
|
1000
|
+
ack_with_rtt(&mut model, params, 2, base, ms(200), ms(299));
|
|
1001
|
+
assert!(!model.is_rtt_jump_active());
|
|
1002
|
+
|
|
1003
|
+
ack_with_rtt(&mut model, params, 3, base, ms(300), RTT);
|
|
1004
|
+
assert!(!model.is_rtt_jump_active());
|
|
1005
|
+
|
|
1006
|
+
model.set_full_bandwidth_reached();
|
|
1007
|
+
ack_with_rtt(&mut model, params, 4, base, ms(400), RTT_JUMP);
|
|
1008
|
+
assert!(model.is_rtt_jump_active());
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
#[test]
|
|
1012
|
+
fn global_min_detector_ignores_startup_rtt_jump_until_full_bandwidth() {
|
|
1013
|
+
let params = &rtt_jump_params(BbrRttJumpDetector::GlobalMin);
|
|
1014
|
+
let mut model = BBRv2NetworkModel::new(params, RTT);
|
|
1015
|
+
let base = Instant::now();
|
|
1016
|
+
|
|
1017
|
+
ack_with_rtt(&mut model, params, 1, base, ms(10), RTT);
|
|
1018
|
+
ack_with_rtt(&mut model, params, 2, base, ms(20), RTT_JUMP);
|
|
1019
|
+
ack_with_rtt(&mut model, params, 3, base, ms(30), RTT_JUMP);
|
|
1020
|
+
ack_with_rtt(&mut model, params, 4, base, ms(200), RTT_JUMP);
|
|
1021
|
+
|
|
1022
|
+
assert_eq!(model.rtt_persistent_jump_count(), 0);
|
|
1023
|
+
assert!(!model.is_rtt_jump_active());
|
|
1024
|
+
|
|
1025
|
+
model.set_full_bandwidth_reached();
|
|
1026
|
+
ack_with_rtt(&mut model, params, 5, base, ms(210), RTT_JUMP);
|
|
1027
|
+
ack_with_rtt(&mut model, params, 6, base, ms(220), RTT_JUMP);
|
|
1028
|
+
ack_with_rtt(&mut model, params, 7, base, ms(360), RTT_JUMP);
|
|
1029
|
+
|
|
1030
|
+
assert_eq!(model.rtt_persistent_jump_count(), 1);
|
|
1031
|
+
assert!(model.is_rtt_jump_persistent());
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
#[test]
|
|
1035
|
+
fn hmm_detector_ignores_startup_rtt_jump_until_full_bandwidth() {
|
|
1036
|
+
let params = &rtt_jump_params(BbrRttJumpDetector::Hmm);
|
|
1037
|
+
let mut model = BBRv2NetworkModel::new(params, RTT);
|
|
1038
|
+
let base = Instant::now();
|
|
1039
|
+
|
|
1040
|
+
for pkt in 1..9u64 {
|
|
1041
|
+
ack_with_rtt(&mut model, params, pkt, base, ms(pkt * 10), RTT);
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
for pkt in 9u64..20 {
|
|
1045
|
+
ack_with_rtt(&mut model, params, pkt, base, ms(pkt * 100), RTT_3X);
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
assert_eq!(model.rtt_persistent_jump_count(), 0);
|
|
1049
|
+
assert!(!model.is_rtt_jump_active());
|
|
1050
|
+
|
|
1051
|
+
model.set_full_bandwidth_reached();
|
|
1052
|
+
ack_with_rtt(&mut model, params, 20, base, ms(2100), RTT_3X);
|
|
1053
|
+
|
|
1054
|
+
assert_eq!(model.rtt_persistent_jump_count(), 0);
|
|
1055
|
+
assert!(!model.is_rtt_jump_persistent());
|
|
1056
|
+
}
|
|
1057
|
+
}
|