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
|
@@ -80,6 +80,18 @@ impl RangeSet {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
/// Returns true if the collection contains the given value.
|
|
84
|
+
pub fn contains(&self, item: u64) -> bool {
|
|
85
|
+
match self {
|
|
86
|
+
RangeSet::Inline(set) => set
|
|
87
|
+
.inner
|
|
88
|
+
.iter()
|
|
89
|
+
.any(|&(start, end)| start <= item && item < end),
|
|
90
|
+
|
|
91
|
+
RangeSet::BTree(set) => set.prev_to(item).is_some_and(|range| item < range.end),
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
83
95
|
/// Converts the inner representation from a BTree to Inline and vice versa
|
|
84
96
|
/// when the proper conditions are met. Keeps the stored data intact.
|
|
85
97
|
#[inline(always)]
|
|
@@ -91,7 +103,7 @@ impl RangeSet {
|
|
|
91
103
|
inner: old_inner.into_inner().expect("At capacity").into(),
|
|
92
104
|
capacity: set.capacity,
|
|
93
105
|
});
|
|
94
|
-
}
|
|
106
|
+
}
|
|
95
107
|
|
|
96
108
|
RangeSet::BTree(set) if set.inner.len() <= MIN_TO_INLINE => {
|
|
97
109
|
let old_inner = std::mem::take(&mut set.inner);
|
|
@@ -99,9 +111,9 @@ impl RangeSet {
|
|
|
99
111
|
inner: SmallVec::from_iter(old_inner),
|
|
100
112
|
capacity: set.capacity,
|
|
101
113
|
})
|
|
102
|
-
}
|
|
114
|
+
}
|
|
103
115
|
|
|
104
|
-
_ => {}
|
|
116
|
+
_ => {}
|
|
105
117
|
}
|
|
106
118
|
}
|
|
107
119
|
|
|
@@ -121,16 +133,11 @@ impl RangeSet {
|
|
|
121
133
|
}
|
|
122
134
|
|
|
123
135
|
/// Iterate over the stored ranges in incremental order.
|
|
124
|
-
pub fn iter(
|
|
125
|
-
&self,
|
|
126
|
-
) -> impl DoubleEndedIterator<Item = Range<u64>> + ExactSizeIterator + '_
|
|
127
|
-
{
|
|
136
|
+
pub fn iter(&self) -> impl DoubleEndedIterator<Item = Range<u64>> + ExactSizeIterator + '_ {
|
|
128
137
|
match self {
|
|
129
|
-
RangeSet::BTree(set) =>
|
|
130
|
-
Either::Left(set.inner.iter().map(|(k, v)| *k..*v)),
|
|
138
|
+
RangeSet::BTree(set) => Either::Left(set.inner.iter().map(|(k, v)| *k..*v)),
|
|
131
139
|
|
|
132
|
-
RangeSet::Inline(set) =>
|
|
133
|
-
Either::Right(set.inner.iter().map(|(s, e)| *s..*e)),
|
|
140
|
+
RangeSet::Inline(set) => Either::Right(set.inner.iter().map(|(s, e)| *s..*e)),
|
|
134
141
|
}
|
|
135
142
|
}
|
|
136
143
|
|
|
@@ -139,11 +146,9 @@ impl RangeSet {
|
|
|
139
146
|
#[cfg(test)]
|
|
140
147
|
pub fn flatten(&self) -> impl DoubleEndedIterator<Item = u64> + '_ {
|
|
141
148
|
match self {
|
|
142
|
-
RangeSet::BTree(set) =>
|
|
143
|
-
Either::Left(set.inner.iter().flat_map(|(k, v)| *k..*v)),
|
|
149
|
+
RangeSet::BTree(set) => Either::Left(set.inner.iter().flat_map(|(k, v)| *k..*v)),
|
|
144
150
|
|
|
145
|
-
RangeSet::Inline(set) =>
|
|
146
|
-
Either::Right(set.inner.iter().flat_map(|(s, e)| *s..*e)),
|
|
151
|
+
RangeSet::Inline(set) => Either::Right(set.inner.iter().flat_map(|(s, e)| *s..*e)),
|
|
147
152
|
}
|
|
148
153
|
}
|
|
149
154
|
|
|
@@ -162,8 +167,7 @@ impl RangeSet {
|
|
|
162
167
|
match self {
|
|
163
168
|
RangeSet::Inline(set) => set.inner.last().map(|(_, e)| *e - 1),
|
|
164
169
|
|
|
165
|
-
RangeSet::BTree(set) =>
|
|
166
|
-
set.inner.last_key_value().map(|(_, v)| *v - 1),
|
|
170
|
+
RangeSet::BTree(set) => set.inner.last_key_value().map(|(_, v)| *v - 1),
|
|
167
171
|
}
|
|
168
172
|
}
|
|
169
173
|
|
|
@@ -209,22 +213,22 @@ impl InlineRangeSet {
|
|
|
209
213
|
return;
|
|
210
214
|
}
|
|
211
215
|
|
|
212
|
-
// At this point
|
|
216
|
+
// At this point, `start <= *e`.
|
|
213
217
|
if start < *s {
|
|
214
218
|
// We know we are completely past the previous range, so
|
|
215
|
-
// we can simply adjust the lower bound
|
|
219
|
+
// we can simply adjust the lower bound.
|
|
216
220
|
*s = start;
|
|
217
221
|
}
|
|
218
222
|
|
|
219
223
|
if end > *e {
|
|
220
|
-
//
|
|
221
|
-
//
|
|
224
|
+
// Check for overlap between the expanded range and the
|
|
225
|
+
// next range.
|
|
222
226
|
*e = end;
|
|
223
227
|
break;
|
|
224
228
|
} else {
|
|
225
229
|
return;
|
|
226
230
|
}
|
|
227
|
-
}
|
|
231
|
+
}
|
|
228
232
|
|
|
229
233
|
None => {
|
|
230
234
|
if self.inner.len() == self.capacity {
|
|
@@ -233,7 +237,7 @@ impl InlineRangeSet {
|
|
|
233
237
|
|
|
234
238
|
self.inner.push((start, end));
|
|
235
239
|
return;
|
|
236
|
-
}
|
|
240
|
+
}
|
|
237
241
|
}
|
|
238
242
|
}
|
|
239
243
|
|
|
@@ -386,14 +390,93 @@ impl std::fmt::Debug for RangeSet {
|
|
|
386
390
|
}
|
|
387
391
|
|
|
388
392
|
fn range_overlaps(r: &Range<u64>, other: &Range<u64>) -> bool {
|
|
389
|
-
other.start >= r.start && other.start <= r.end ||
|
|
390
|
-
other.end >= r.start && other.end <= r.end
|
|
393
|
+
other.start >= r.start && other.start <= r.end || other.end >= r.start && other.end <= r.end
|
|
391
394
|
}
|
|
392
395
|
|
|
393
396
|
#[cfg(test)]
|
|
394
397
|
mod tests {
|
|
395
398
|
use super::*;
|
|
396
399
|
|
|
400
|
+
#[test]
|
|
401
|
+
fn contains_inline() {
|
|
402
|
+
let mut r = RangeSet::default();
|
|
403
|
+
assert!(!r.contains(0));
|
|
404
|
+
assert!(!r.contains(u64::MAX));
|
|
405
|
+
|
|
406
|
+
r.insert(4..7);
|
|
407
|
+
r.insert(9..12);
|
|
408
|
+
r.insert(u64::MAX - 2..u64::MAX);
|
|
409
|
+
assert!(matches!(r, RangeSet::Inline(_)));
|
|
410
|
+
|
|
411
|
+
for item in 0..15 {
|
|
412
|
+
assert_eq!(
|
|
413
|
+
r.contains(item),
|
|
414
|
+
(4..7).contains(&item) || (9..12).contains(&item)
|
|
415
|
+
);
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
assert!(!r.contains(u64::MAX - 3));
|
|
419
|
+
assert!(r.contains(u64::MAX - 2));
|
|
420
|
+
assert!(r.contains(u64::MAX - 1));
|
|
421
|
+
assert!(!r.contains(u64::MAX));
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
#[test]
|
|
425
|
+
fn contains_btree() {
|
|
426
|
+
let mut r = RangeSet::default();
|
|
427
|
+
|
|
428
|
+
for start in [4, 9, 14, u64::MAX - 3] {
|
|
429
|
+
r.insert(start..start + 3);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
assert!(matches!(r, RangeSet::BTree(_)));
|
|
433
|
+
|
|
434
|
+
for item in 0..20 {
|
|
435
|
+
assert_eq!(
|
|
436
|
+
r.contains(item),
|
|
437
|
+
(4..7).contains(&item) || (9..12).contains(&item) || (14..17).contains(&item)
|
|
438
|
+
);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
assert!(!r.contains(u64::MAX - 4));
|
|
442
|
+
assert!(r.contains(u64::MAX - 3));
|
|
443
|
+
assert!(r.contains(u64::MAX - 1));
|
|
444
|
+
assert!(!r.contains(u64::MAX));
|
|
445
|
+
|
|
446
|
+
r.remove_until(13);
|
|
447
|
+
assert!(matches!(r, RangeSet::Inline(_)));
|
|
448
|
+
assert!(!r.contains(12));
|
|
449
|
+
assert!(r.contains(14));
|
|
450
|
+
assert!(r.contains(16));
|
|
451
|
+
assert!(!r.contains(17));
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
#[test]
|
|
455
|
+
fn adjacent_singletons_merge() {
|
|
456
|
+
let mut r = RangeSet::default();
|
|
457
|
+
|
|
458
|
+
for item in [0, 2, 4, 6] {
|
|
459
|
+
r.push_item(item);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
assert!(matches!(r, RangeSet::BTree(_)));
|
|
463
|
+
|
|
464
|
+
for item in [5, 1, 3] {
|
|
465
|
+
assert!(!r.contains(item));
|
|
466
|
+
r.push_item(item);
|
|
467
|
+
assert!(r.contains(item));
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
assert_eq!(r, 0..7);
|
|
471
|
+
assert!(matches!(r, RangeSet::Inline(_)));
|
|
472
|
+
|
|
473
|
+
for item in 0..7 {
|
|
474
|
+
assert!(r.contains(item));
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
assert!(!r.contains(7));
|
|
478
|
+
}
|
|
479
|
+
|
|
397
480
|
#[test]
|
|
398
481
|
fn insert_non_overlapping() {
|
|
399
482
|
let mut r = RangeSet::default();
|
|
@@ -453,27 +536,31 @@ mod tests {
|
|
|
453
536
|
|
|
454
537
|
r.insert(10..15);
|
|
455
538
|
assert_eq!(r.len(), 2);
|
|
456
|
-
assert_eq!(
|
|
457
|
-
|
|
458
|
-
|
|
539
|
+
assert_eq!(
|
|
540
|
+
&r.flatten().collect::<Vec<u64>>(),
|
|
541
|
+
&[3, 4, 5, 6, 9, 10, 11, 12, 13, 14]
|
|
542
|
+
);
|
|
459
543
|
|
|
460
544
|
r.insert(2..5);
|
|
461
545
|
assert_eq!(r.len(), 2);
|
|
462
|
-
assert_eq!(
|
|
463
|
-
|
|
464
|
-
|
|
546
|
+
assert_eq!(
|
|
547
|
+
&r.flatten().collect::<Vec<u64>>(),
|
|
548
|
+
&[2, 3, 4, 5, 6, 9, 10, 11, 12, 13, 14]
|
|
549
|
+
);
|
|
465
550
|
|
|
466
551
|
r.insert(8..10);
|
|
467
552
|
assert_eq!(r.len(), 2);
|
|
468
|
-
assert_eq!(
|
|
469
|
-
|
|
470
|
-
|
|
553
|
+
assert_eq!(
|
|
554
|
+
&r.flatten().collect::<Vec<u64>>(),
|
|
555
|
+
&[2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14]
|
|
556
|
+
);
|
|
471
557
|
|
|
472
558
|
r.insert(6..10);
|
|
473
559
|
assert_eq!(r.len(), 1);
|
|
474
|
-
assert_eq!(
|
|
475
|
-
|
|
476
|
-
|
|
560
|
+
assert_eq!(
|
|
561
|
+
&r.flatten().collect::<Vec<u64>>(),
|
|
562
|
+
&[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
|
|
563
|
+
);
|
|
477
564
|
}
|
|
478
565
|
|
|
479
566
|
#[test]
|
|
@@ -482,32 +569,36 @@ mod tests {
|
|
|
482
569
|
|
|
483
570
|
r.insert(3..6);
|
|
484
571
|
r.insert(16..20);
|
|
485
|
-
assert_eq!(
|
|
486
|
-
|
|
487
|
-
|
|
572
|
+
assert_eq!(
|
|
573
|
+
&r.flatten().collect::<Vec<u64>>(),
|
|
574
|
+
&[3, 4, 5, 16, 17, 18, 19]
|
|
575
|
+
);
|
|
488
576
|
|
|
489
577
|
r.insert(10..11);
|
|
490
578
|
assert_eq!(r.len(), 3);
|
|
491
|
-
assert_eq!(
|
|
492
|
-
|
|
493
|
-
|
|
579
|
+
assert_eq!(
|
|
580
|
+
&r.flatten().collect::<Vec<u64>>(),
|
|
581
|
+
&[3, 4, 5, 10, 16, 17, 18, 19]
|
|
582
|
+
);
|
|
494
583
|
|
|
495
584
|
assert!(matches!(r, RangeSet::Inline(_)));
|
|
496
585
|
|
|
497
586
|
r.insert(13..14);
|
|
498
587
|
assert_eq!(r.len(), 4);
|
|
499
|
-
assert_eq!(
|
|
500
|
-
|
|
501
|
-
|
|
588
|
+
assert_eq!(
|
|
589
|
+
&r.flatten().collect::<Vec<u64>>(),
|
|
590
|
+
&[3, 4, 5, 10, 13, 16, 17, 18, 19]
|
|
591
|
+
);
|
|
502
592
|
|
|
503
593
|
// Make sure it converted to a btree at capacity
|
|
504
594
|
assert!(matches!(r, RangeSet::BTree(_)));
|
|
505
595
|
|
|
506
596
|
r.insert(4..17);
|
|
507
597
|
assert_eq!(r.len(), 1);
|
|
508
|
-
assert_eq!(
|
|
509
|
-
|
|
510
|
-
|
|
598
|
+
assert_eq!(
|
|
599
|
+
&r.flatten().collect::<Vec<u64>>(),
|
|
600
|
+
&[3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
|
|
601
|
+
);
|
|
511
602
|
|
|
512
603
|
// Make sure it converted back to inline
|
|
513
604
|
assert!(matches!(r, RangeSet::Inline(_)));
|
|
@@ -558,44 +649,50 @@ mod tests {
|
|
|
558
649
|
|
|
559
650
|
r.push_item(15);
|
|
560
651
|
assert_eq!(r.len(), 3);
|
|
561
|
-
assert_eq!(
|
|
562
|
-
|
|
563
|
-
|
|
652
|
+
assert_eq!(
|
|
653
|
+
&r.flatten().collect::<Vec<u64>>(),
|
|
654
|
+
&[4, 5, 6, 9, 10, 11, 15]
|
|
655
|
+
);
|
|
564
656
|
|
|
565
657
|
r.push_item(15);
|
|
566
658
|
assert_eq!(r.len(), 3);
|
|
567
|
-
assert_eq!(
|
|
568
|
-
|
|
569
|
-
|
|
659
|
+
assert_eq!(
|
|
660
|
+
&r.flatten().collect::<Vec<u64>>(),
|
|
661
|
+
&[4, 5, 6, 9, 10, 11, 15]
|
|
662
|
+
);
|
|
570
663
|
|
|
571
664
|
r.push_item(1);
|
|
572
665
|
assert_eq!(r.len(), 4);
|
|
573
|
-
assert_eq!(
|
|
574
|
-
|
|
575
|
-
|
|
666
|
+
assert_eq!(
|
|
667
|
+
&r.flatten().collect::<Vec<u64>>(),
|
|
668
|
+
&[1, 4, 5, 6, 9, 10, 11, 15]
|
|
669
|
+
);
|
|
576
670
|
|
|
577
671
|
r.push_item(12);
|
|
578
672
|
r.push_item(13);
|
|
579
673
|
r.push_item(14);
|
|
580
674
|
|
|
581
675
|
assert_eq!(r.len(), 3);
|
|
582
|
-
assert_eq!(
|
|
583
|
-
|
|
584
|
-
|
|
676
|
+
assert_eq!(
|
|
677
|
+
&r.flatten().collect::<Vec<u64>>(),
|
|
678
|
+
&[1, 4, 5, 6, 9, 10, 11, 12, 13, 14, 15]
|
|
679
|
+
);
|
|
585
680
|
|
|
586
681
|
r.push_item(2);
|
|
587
682
|
r.push_item(3);
|
|
588
683
|
assert_eq!(r.len(), 2);
|
|
589
|
-
assert_eq!(
|
|
590
|
-
|
|
591
|
-
|
|
684
|
+
assert_eq!(
|
|
685
|
+
&r.flatten().collect::<Vec<u64>>(),
|
|
686
|
+
&[1, 2, 3, 4, 5, 6, 9, 10, 11, 12, 13, 14, 15]
|
|
687
|
+
);
|
|
592
688
|
|
|
593
689
|
r.push_item(8);
|
|
594
690
|
r.push_item(7);
|
|
595
691
|
assert_eq!(r.len(), 1);
|
|
596
|
-
assert_eq!(
|
|
597
|
-
|
|
598
|
-
|
|
692
|
+
assert_eq!(
|
|
693
|
+
&r.flatten().collect::<Vec<u64>>(),
|
|
694
|
+
&[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
|
|
695
|
+
);
|
|
599
696
|
}
|
|
600
697
|
|
|
601
698
|
#[test]
|
|
@@ -614,9 +711,10 @@ mod tests {
|
|
|
614
711
|
r.insert(9..12);
|
|
615
712
|
assert_eq!(r.len(), 2);
|
|
616
713
|
assert_eq!(&r.flatten().collect::<Vec<u64>>(), &[4, 5, 6, 9, 10, 11]);
|
|
617
|
-
assert_eq!(
|
|
618
|
-
|
|
619
|
-
|
|
714
|
+
assert_eq!(
|
|
715
|
+
&r.flatten().rev().collect::<Vec<u64>>(),
|
|
716
|
+
&[11, 10, 9, 6, 5, 4]
|
|
717
|
+
);
|
|
620
718
|
}
|
|
621
719
|
|
|
622
720
|
#[test]
|
|
@@ -641,24 +739,28 @@ mod tests {
|
|
|
641
739
|
r.insert(9..11);
|
|
642
740
|
r.insert(13..14);
|
|
643
741
|
r.insert(16..20);
|
|
644
|
-
assert_eq!(
|
|
645
|
-
|
|
646
|
-
|
|
742
|
+
assert_eq!(
|
|
743
|
+
&r.flatten().collect::<Vec<u64>>(),
|
|
744
|
+
&[3, 4, 5, 9, 10, 13, 16, 17, 18, 19]
|
|
745
|
+
);
|
|
647
746
|
|
|
648
747
|
r.remove_until(2);
|
|
649
|
-
assert_eq!(
|
|
650
|
-
|
|
651
|
-
|
|
748
|
+
assert_eq!(
|
|
749
|
+
&r.flatten().collect::<Vec<u64>>(),
|
|
750
|
+
&[3, 4, 5, 9, 10, 13, 16, 17, 18, 19]
|
|
751
|
+
);
|
|
652
752
|
|
|
653
753
|
r.remove_until(4);
|
|
654
|
-
assert_eq!(
|
|
655
|
-
|
|
656
|
-
|
|
754
|
+
assert_eq!(
|
|
755
|
+
&r.flatten().collect::<Vec<u64>>(),
|
|
756
|
+
&[5, 9, 10, 13, 16, 17, 18, 19]
|
|
757
|
+
);
|
|
657
758
|
|
|
658
759
|
r.remove_until(6);
|
|
659
|
-
assert_eq!(
|
|
660
|
-
|
|
661
|
-
|
|
760
|
+
assert_eq!(
|
|
761
|
+
&r.flatten().collect::<Vec<u64>>(),
|
|
762
|
+
&[9, 10, 13, 16, 17, 18, 19]
|
|
763
|
+
);
|
|
662
764
|
|
|
663
765
|
r.remove_until(10);
|
|
664
766
|
assert_eq!(&r.flatten().collect::<Vec<u64>>(), &[13, 16, 17, 18, 19]);
|
|
@@ -39,6 +39,7 @@ gcongestion/ Next-gen CC (BBR2)
|
|
|
39
39
|
probe_bw.rs ProbeBW mode (bandwidth probing cycles)
|
|
40
40
|
probe_rtt.rs ProbeRTT mode (min RTT measurement)
|
|
41
41
|
network_model.rs Bandwidth/RTT model, BbrParams application
|
|
42
|
+
rtt_jump_detector/ RTT jump detection (global-min + HMM)
|
|
42
43
|
bbr.rs BBR (v1, not actively used)
|
|
43
44
|
```
|
|
44
45
|
|
|
@@ -73,8 +74,10 @@ gcongestion/ Next-gen CC (BBR2)
|
|
|
73
74
|
## NOTES
|
|
74
75
|
|
|
75
76
|
- Constants cite RFC 9002: `INITIAL_TIME_THRESHOLD = 9.0/8.0`, `GRANULARITY = 1ms`.
|
|
76
|
-
- `CongestionControlAlgorithm` values: Reno=0, CUBIC=1, Bbr2Gcongestion=4
|
|
77
|
-
|
|
77
|
+
- `CongestionControlAlgorithm` values: Reno=0, CUBIC=1, Bbr2Gcongestion=4,
|
|
78
|
+
CongestionWindowUnchecked=5 when enabled. Gaps are intentional (removed variants).
|
|
79
|
+
- `Recovery::new_with_config` tries `GRecovery::new` first; falls back to
|
|
80
|
+
`LegacyRecovery` for Reno, CUBIC, and CongestionWindowUnchecked.
|
|
78
81
|
- `bbr2/` is a deeply nested state machine -- changes require understanding all six substates.
|
|
79
82
|
- `enable_relaxed_loss_threshold` experiment adjusts time thresholds dynamically on spurious loss.
|
|
80
83
|
- `gcongestion/bbr.rs` is BBRv1 -- mostly vestigial alongside BBR2.
|
|
@@ -85,9 +85,7 @@ impl std::ops::Mul<Duration> for Bandwidth {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
impl Bandwidth {
|
|
88
|
-
pub const fn from_bytes_and_time_delta(
|
|
89
|
-
bytes: usize, time_delta: Duration,
|
|
90
|
-
) -> Self {
|
|
88
|
+
pub const fn from_bytes_and_time_delta(bytes: usize, time_delta: Duration) -> Self {
|
|
91
89
|
if bytes == 0 {
|
|
92
90
|
return Bandwidth { bits_per_second: 0 };
|
|
93
91
|
}
|
|
@@ -218,7 +216,7 @@ impl std::fmt::Debug for Bandwidth {
|
|
|
218
216
|
x if x < 1_000_000 => write!(f, "{:.2} Kbps", x as f64 / 1_000.),
|
|
219
217
|
x if x < 1_000_000_000 => {
|
|
220
218
|
write!(f, "{:.2} Mbps", x as f64 / 1_000_000.)
|
|
221
|
-
}
|
|
219
|
+
}
|
|
222
220
|
x => write!(f, "{:.2} Gbps", x as f64 / 1_000_000_000.),
|
|
223
221
|
}
|
|
224
222
|
}
|
|
@@ -288,21 +286,15 @@ mod tests {
|
|
|
288
286
|
#[test]
|
|
289
287
|
fn from_bytes_and_time_delta() {
|
|
290
288
|
assert_eq!(
|
|
291
|
-
Bandwidth::from_bytes_and_time_delta(10, Duration::from_millis(1000))
|
|
292
|
-
.bits_per_second,
|
|
289
|
+
Bandwidth::from_bytes_and_time_delta(10, Duration::from_millis(1000)).bits_per_second,
|
|
293
290
|
80
|
|
294
291
|
);
|
|
295
292
|
assert_eq!(
|
|
296
|
-
Bandwidth::from_bytes_and_time_delta(10, Duration::from_millis(100))
|
|
297
|
-
.bits_per_second,
|
|
293
|
+
Bandwidth::from_bytes_and_time_delta(10, Duration::from_millis(100)).bits_per_second,
|
|
298
294
|
800
|
|
299
295
|
);
|
|
300
296
|
assert_eq!(
|
|
301
|
-
Bandwidth::from_bytes_and_time_delta(
|
|
302
|
-
100,
|
|
303
|
-
Duration::from_millis(1000)
|
|
304
|
-
)
|
|
305
|
-
.bits_per_second,
|
|
297
|
+
Bandwidth::from_bytes_and_time_delta(100, Duration::from_millis(1000)).bits_per_second,
|
|
306
298
|
800
|
|
307
299
|
);
|
|
308
300
|
}
|
|
@@ -508,57 +500,84 @@ mod tests {
|
|
|
508
500
|
"0.00 Kbps"
|
|
509
501
|
);
|
|
510
502
|
assert_eq!(
|
|
511
|
-
format!(
|
|
512
|
-
|
|
513
|
-
|
|
503
|
+
format!(
|
|
504
|
+
"{:?}",
|
|
505
|
+
Bandwidth {
|
|
506
|
+
bits_per_second: 12
|
|
507
|
+
}
|
|
508
|
+
),
|
|
514
509
|
"0.01 Kbps"
|
|
515
510
|
);
|
|
516
511
|
assert_eq!(
|
|
517
|
-
format!(
|
|
518
|
-
|
|
519
|
-
|
|
512
|
+
format!(
|
|
513
|
+
"{:?}",
|
|
514
|
+
Bandwidth {
|
|
515
|
+
bits_per_second: 123
|
|
516
|
+
}
|
|
517
|
+
),
|
|
520
518
|
"0.12 Kbps"
|
|
521
519
|
);
|
|
522
520
|
assert_eq!(
|
|
523
|
-
format!(
|
|
524
|
-
|
|
525
|
-
|
|
521
|
+
format!(
|
|
522
|
+
"{:?}",
|
|
523
|
+
Bandwidth {
|
|
524
|
+
bits_per_second: 1234
|
|
525
|
+
}
|
|
526
|
+
),
|
|
526
527
|
"1.23 Kbps"
|
|
527
528
|
);
|
|
528
529
|
assert_eq!(
|
|
529
|
-
format!(
|
|
530
|
-
|
|
531
|
-
|
|
530
|
+
format!(
|
|
531
|
+
"{:?}",
|
|
532
|
+
Bandwidth {
|
|
533
|
+
bits_per_second: 12345
|
|
534
|
+
}
|
|
535
|
+
),
|
|
532
536
|
"12.35 Kbps"
|
|
533
537
|
);
|
|
534
538
|
assert_eq!(
|
|
535
|
-
format!(
|
|
536
|
-
|
|
537
|
-
|
|
539
|
+
format!(
|
|
540
|
+
"{:?}",
|
|
541
|
+
Bandwidth {
|
|
542
|
+
bits_per_second: 123456
|
|
543
|
+
}
|
|
544
|
+
),
|
|
538
545
|
"123.46 Kbps"
|
|
539
546
|
);
|
|
540
547
|
assert_eq!(
|
|
541
|
-
format!(
|
|
542
|
-
|
|
543
|
-
|
|
548
|
+
format!(
|
|
549
|
+
"{:?}",
|
|
550
|
+
Bandwidth {
|
|
551
|
+
bits_per_second: 1234567
|
|
552
|
+
}
|
|
553
|
+
),
|
|
544
554
|
"1.23 Mbps"
|
|
545
555
|
);
|
|
546
556
|
assert_eq!(
|
|
547
|
-
format!(
|
|
548
|
-
|
|
549
|
-
|
|
557
|
+
format!(
|
|
558
|
+
"{:?}",
|
|
559
|
+
Bandwidth {
|
|
560
|
+
bits_per_second: 12345678
|
|
561
|
+
}
|
|
562
|
+
),
|
|
550
563
|
"12.35 Mbps"
|
|
551
564
|
);
|
|
552
565
|
assert_eq!(
|
|
553
|
-
format!(
|
|
554
|
-
|
|
555
|
-
|
|
566
|
+
format!(
|
|
567
|
+
"{:?}",
|
|
568
|
+
Bandwidth {
|
|
569
|
+
bits_per_second: 123456789
|
|
570
|
+
}
|
|
571
|
+
),
|
|
556
572
|
"123.46 Mbps"
|
|
557
573
|
);
|
|
558
574
|
assert_eq!(
|
|
559
|
-
format!(
|
|
560
|
-
|
|
561
|
-
|
|
575
|
+
format!(
|
|
576
|
+
"{:?}",
|
|
577
|
+
Bandwidth {
|
|
578
|
+
bits_per_second: 1234567890
|
|
579
|
+
}
|
|
580
|
+
),
|
|
562
581
|
"1.23 Gbps"
|
|
563
582
|
);
|
|
564
583
|
}
|
|
@@ -150,8 +150,8 @@ mod tests {
|
|
|
150
150
|
now += Duration::from_secs(5);
|
|
151
151
|
bytes_in_flight.saturating_subtract(10, now);
|
|
152
152
|
assert_eq!(bytes_in_flight.get(), 0);
|
|
153
|
-
//
|
|
154
|
-
//
|
|
153
|
+
// The two in-flight intervals lasted seven and five seconds, for an
|
|
154
|
+
// expected total of twelve seconds.
|
|
155
155
|
assert_eq!(bytes_in_flight.get_duration(), Duration::from_secs(12));
|
|
156
156
|
}
|
|
157
157
|
|