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
|
@@ -113,6 +113,10 @@ pub struct Congestion {
|
|
|
113
113
|
/// Initial congestion window size in terms of packet count.
|
|
114
114
|
pub(crate) initial_congestion_window_packets: usize,
|
|
115
115
|
|
|
116
|
+
#[cfg(feature = "congestion_window_unchecked_available")]
|
|
117
|
+
/// Fixed congestion window in bytes for the unchecked controller.
|
|
118
|
+
pub(crate) unchecked_congestion_window: usize,
|
|
119
|
+
|
|
116
120
|
max_datagram_size: usize,
|
|
117
121
|
|
|
118
122
|
pub(crate) lost_count: usize,
|
|
@@ -122,8 +126,8 @@ pub struct Congestion {
|
|
|
122
126
|
|
|
123
127
|
impl Congestion {
|
|
124
128
|
pub(crate) fn from_config(recovery_config: &RecoveryConfig) -> Self {
|
|
125
|
-
let initial_congestion_window = recovery_config.max_send_udp_payload_size
|
|
126
|
-
recovery_config.initial_congestion_window_packets;
|
|
129
|
+
let initial_congestion_window = recovery_config.max_send_udp_payload_size
|
|
130
|
+
* recovery_config.initial_congestion_window_packets;
|
|
127
131
|
|
|
128
132
|
let mut cc = Congestion {
|
|
129
133
|
congestion_window: initial_congestion_window,
|
|
@@ -144,8 +148,9 @@ impl Congestion {
|
|
|
144
148
|
|
|
145
149
|
lost_count: 0,
|
|
146
150
|
|
|
147
|
-
initial_congestion_window_packets: recovery_config
|
|
148
|
-
|
|
151
|
+
initial_congestion_window_packets: recovery_config.initial_congestion_window_packets,
|
|
152
|
+
#[cfg(feature = "congestion_window_unchecked_available")]
|
|
153
|
+
unchecked_congestion_window: recovery_config.unchecked_congestion_window,
|
|
149
154
|
|
|
150
155
|
max_datagram_size: recovery_config.max_send_udp_payload_size,
|
|
151
156
|
|
|
@@ -157,8 +162,7 @@ impl Congestion {
|
|
|
157
162
|
|
|
158
163
|
prr: prr::PRR::default(),
|
|
159
164
|
|
|
160
|
-
enable_cubic_idle_restart_fix: recovery_config
|
|
161
|
-
.enable_cubic_idle_restart_fix,
|
|
165
|
+
enable_cubic_idle_restart_fix: recovery_config.enable_cubic_idle_restart_fix,
|
|
162
166
|
};
|
|
163
167
|
|
|
164
168
|
(cc.cc_ops.on_init)(&mut cc);
|
|
@@ -168,8 +172,7 @@ impl Congestion {
|
|
|
168
172
|
|
|
169
173
|
pub(crate) fn in_congestion_recovery(&self, sent_time: Instant) -> bool {
|
|
170
174
|
match self.congestion_recovery_start_time {
|
|
171
|
-
Some(congestion_recovery_start_time) =>
|
|
172
|
-
sent_time <= congestion_recovery_start_time,
|
|
175
|
+
Some(congestion_recovery_start_time) => sent_time <= congestion_recovery_start_time,
|
|
173
176
|
|
|
174
177
|
None => false,
|
|
175
178
|
}
|
|
@@ -194,22 +197,23 @@ impl Congestion {
|
|
|
194
197
|
|
|
195
198
|
#[allow(clippy::too_many_arguments)]
|
|
196
199
|
pub(crate) fn on_packet_sent(
|
|
197
|
-
&mut self,
|
|
198
|
-
|
|
200
|
+
&mut self,
|
|
201
|
+
bytes_in_flight: usize,
|
|
202
|
+
sent_bytes: usize,
|
|
203
|
+
now: Instant,
|
|
204
|
+
pkt: &mut Sent,
|
|
205
|
+
bytes_lost: u64,
|
|
206
|
+
in_flight: bool,
|
|
199
207
|
) {
|
|
200
208
|
if in_flight {
|
|
201
|
-
self.update_app_limited(
|
|
202
|
-
(bytes_in_flight + sent_bytes) < self.congestion_window,
|
|
203
|
-
);
|
|
209
|
+
self.update_app_limited((bytes_in_flight + sent_bytes) < self.congestion_window);
|
|
204
210
|
|
|
205
211
|
(self.cc_ops.on_packet_sent)(self, sent_bytes, bytes_in_flight, now);
|
|
206
212
|
|
|
207
213
|
self.prr.on_packet_sent(sent_bytes);
|
|
208
214
|
|
|
209
215
|
// HyStart++: Start of the round in a slow start.
|
|
210
|
-
if self.hystart.enabled() &&
|
|
211
|
-
self.congestion_window < self.ssthresh.get()
|
|
212
|
-
{
|
|
216
|
+
if self.hystart.enabled() && self.congestion_window < self.ssthresh.get() {
|
|
213
217
|
self.hystart.start_round(pkt.pkt_num);
|
|
214
218
|
}
|
|
215
219
|
}
|
|
@@ -222,8 +226,11 @@ impl Congestion {
|
|
|
222
226
|
}
|
|
223
227
|
|
|
224
228
|
pub(crate) fn on_packets_acked(
|
|
225
|
-
&mut self,
|
|
226
|
-
|
|
229
|
+
&mut self,
|
|
230
|
+
bytes_in_flight: usize,
|
|
231
|
+
acked: &mut Vec<Acked>,
|
|
232
|
+
rtt_stats: &RttStats,
|
|
233
|
+
now: Instant,
|
|
227
234
|
) {
|
|
228
235
|
// Update delivery rate sample per acked packet.
|
|
229
236
|
for pkt in acked.iter() {
|
|
@@ -234,25 +241,18 @@ impl Congestion {
|
|
|
234
241
|
self.delivery_rate.generate_rate_sample(*rtt_stats.min_rtt);
|
|
235
242
|
|
|
236
243
|
// Call congestion control hooks.
|
|
237
|
-
(self.cc_ops.on_packets_acked)(
|
|
238
|
-
self,
|
|
239
|
-
bytes_in_flight,
|
|
240
|
-
acked,
|
|
241
|
-
now,
|
|
242
|
-
rtt_stats,
|
|
243
|
-
);
|
|
244
|
+
(self.cc_ops.on_packets_acked)(self, bytes_in_flight, acked, now, rtt_stats);
|
|
244
245
|
}
|
|
245
246
|
}
|
|
246
247
|
|
|
247
248
|
pub(crate) struct CongestionControlOps {
|
|
248
249
|
pub on_init: fn(r: &mut Congestion),
|
|
249
250
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
now: Instant,
|
|
255
|
-
),
|
|
251
|
+
/// Updates controller state after the packet-size limit changes.
|
|
252
|
+
pub on_mtu_update: fn(congestion: &mut Congestion),
|
|
253
|
+
|
|
254
|
+
pub on_packet_sent:
|
|
255
|
+
fn(r: &mut Congestion, sent_bytes: usize, bytes_in_flight: usize, now: Instant),
|
|
256
256
|
|
|
257
257
|
pub on_packets_acked: fn(
|
|
258
258
|
r: &mut Congestion,
|
|
@@ -277,10 +277,29 @@ pub(crate) struct CongestionControlOps {
|
|
|
277
277
|
#[cfg(feature = "qlog")]
|
|
278
278
|
pub state_str: fn(r: &Congestion, now: Instant) -> &'static str,
|
|
279
279
|
|
|
280
|
-
pub debug_fmt: fn(
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
280
|
+
pub debug_fmt: fn(r: &Congestion, formatter: &mut std::fmt::Formatter) -> std::fmt::Result,
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
#[cfg(feature = "congestion_window_unchecked_available")]
|
|
284
|
+
static CONGESTION_WINDOW_UNCHECKED: CongestionControlOps = CongestionControlOps {
|
|
285
|
+
on_init: reset_unchecked_congestion_window,
|
|
286
|
+
on_mtu_update: reset_unchecked_congestion_window,
|
|
287
|
+
on_packet_sent: |congestion, _, _, _| reset_unchecked_congestion_window(congestion),
|
|
288
|
+
on_packets_acked: |congestion, _, _, _, _| reset_unchecked_congestion_window(congestion),
|
|
289
|
+
congestion_event: |congestion, _, _, _, _| reset_unchecked_congestion_window(congestion),
|
|
290
|
+
checkpoint: reset_unchecked_congestion_window,
|
|
291
|
+
rollback: |congestion| {
|
|
292
|
+
reset_unchecked_congestion_window(congestion);
|
|
293
|
+
true
|
|
294
|
+
},
|
|
295
|
+
#[cfg(feature = "qlog")]
|
|
296
|
+
state_str: |_, _| "congestion_window_unchecked",
|
|
297
|
+
debug_fmt: |_, _| Ok(()),
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
#[cfg(feature = "congestion_window_unchecked_available")]
|
|
301
|
+
fn reset_unchecked_congestion_window(congestion: &mut Congestion) {
|
|
302
|
+
congestion.congestion_window = congestion.unchecked_congestion_window;
|
|
284
303
|
}
|
|
285
304
|
|
|
286
305
|
impl From<CongestionControlAlgorithm> for &'static CongestionControlOps {
|
|
@@ -293,6 +312,8 @@ impl From<CongestionControlAlgorithm> for &'static CongestionControlOps {
|
|
|
293
312
|
// LegacyRecovery never gets a RecoveryConfig with the
|
|
294
313
|
// Bbr2Gcongestion algorithm.
|
|
295
314
|
CongestionControlAlgorithm::Bbr2Gcongestion => unreachable!(),
|
|
315
|
+
#[cfg(feature = "congestion_window_unchecked_available")]
|
|
316
|
+
CongestionControlAlgorithm::CongestionWindowUnchecked => &CONGESTION_WINDOW_UNCHECKED,
|
|
296
317
|
}
|
|
297
318
|
}
|
|
298
319
|
}
|
|
@@ -300,6 +321,57 @@ impl From<CongestionControlAlgorithm> for &'static CongestionControlOps {
|
|
|
300
321
|
#[cfg(test)]
|
|
301
322
|
mod tests {
|
|
302
323
|
use super::*;
|
|
324
|
+
#[cfg(feature = "congestion_window_unchecked_available")]
|
|
325
|
+
use crate::test_utils;
|
|
326
|
+
#[cfg(feature = "congestion_window_unchecked_available")]
|
|
327
|
+
use crate::Config;
|
|
328
|
+
#[cfg(feature = "congestion_window_unchecked_available")]
|
|
329
|
+
use rstest::rstest;
|
|
330
|
+
#[cfg(feature = "congestion_window_unchecked_available")]
|
|
331
|
+
use std::time::Duration;
|
|
332
|
+
|
|
333
|
+
#[cfg(feature = "congestion_window_unchecked_available")]
|
|
334
|
+
#[rstest]
|
|
335
|
+
fn unchecked_window_is_restored_by_callbacks(
|
|
336
|
+
#[values(usize::MAX, 40 * 1024 * 1024)] window: usize,
|
|
337
|
+
) {
|
|
338
|
+
let mut config =
|
|
339
|
+
Config::new(crate::PROTOCOL_VERSION).expect("create transport configuration");
|
|
340
|
+
config.set_cc_algorithm(CongestionControlAlgorithm::CongestionWindowUnchecked);
|
|
341
|
+
config.set_unchecked_congestion_window(window);
|
|
342
|
+
let mut congestion = Congestion::from_config(&RecoveryConfig::from_config(&config));
|
|
343
|
+
assert_eq!(congestion.congestion_window(), window);
|
|
344
|
+
|
|
345
|
+
let callbacks: [fn(&mut Congestion); 5] = [
|
|
346
|
+
|congestion| {
|
|
347
|
+
(congestion.cc_ops.on_packet_sent)(congestion, 1_200, 0, Instant::now());
|
|
348
|
+
},
|
|
349
|
+
|congestion| {
|
|
350
|
+
(congestion.cc_ops.on_packets_acked)(
|
|
351
|
+
congestion,
|
|
352
|
+
0,
|
|
353
|
+
&mut Vec::new(),
|
|
354
|
+
Instant::now(),
|
|
355
|
+
&RttStats::new(Duration::from_millis(100), Duration::from_millis(25)),
|
|
356
|
+
);
|
|
357
|
+
},
|
|
358
|
+
|congestion| {
|
|
359
|
+
let now = Instant::now();
|
|
360
|
+
let packet = test_utils::helper_packet_sent(0, now, 1_200);
|
|
361
|
+
(congestion.cc_ops.congestion_event)(congestion, 1_200, 1_200, &packet, now);
|
|
362
|
+
},
|
|
363
|
+
|congestion| (congestion.cc_ops.checkpoint)(congestion),
|
|
364
|
+
|congestion| {
|
|
365
|
+
assert!((congestion.cc_ops.rollback)(congestion));
|
|
366
|
+
},
|
|
367
|
+
];
|
|
368
|
+
|
|
369
|
+
for callback in callbacks {
|
|
370
|
+
congestion.congestion_window = 0;
|
|
371
|
+
callback(&mut congestion);
|
|
372
|
+
assert_eq!(congestion.congestion_window(), window);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
303
375
|
|
|
304
376
|
#[test]
|
|
305
377
|
fn ssthresh_init() {
|
|
@@ -310,11 +382,8 @@ mod tests {
|
|
|
310
382
|
|
|
311
383
|
#[test]
|
|
312
384
|
fn ssthresh_in_css() {
|
|
313
|
-
let expected_startup_exit =
|
|
314
|
-
1000,
|
|
315
|
-
None,
|
|
316
|
-
StartupExitReason::ConservativeSlowStartRounds,
|
|
317
|
-
);
|
|
385
|
+
let expected_startup_exit =
|
|
386
|
+
StartupExit::new(1000, None, StartupExitReason::ConservativeSlowStartRounds);
|
|
318
387
|
let mut ssthresh: SsThresh = Default::default();
|
|
319
388
|
ssthresh.update(1000, true);
|
|
320
389
|
assert_eq!(ssthresh.get(), 1000);
|
|
@@ -332,8 +401,7 @@ mod tests {
|
|
|
332
401
|
|
|
333
402
|
#[test]
|
|
334
403
|
fn ssthresh_in_slow_start() {
|
|
335
|
-
let expected_startup_exit =
|
|
336
|
-
StartupExit::new(1000, None, StartupExitReason::Loss);
|
|
404
|
+
let expected_startup_exit = StartupExit::new(1000, None, StartupExitReason::Loss);
|
|
337
405
|
let mut ssthresh: SsThresh = Default::default();
|
|
338
406
|
ssthresh.update(1000, false);
|
|
339
407
|
assert_eq!(ssthresh.get(), 1000);
|
|
@@ -65,7 +65,10 @@ impl PRR {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
pub fn on_packet_acked(
|
|
68
|
-
&mut self,
|
|
68
|
+
&mut self,
|
|
69
|
+
delivered_data: usize,
|
|
70
|
+
pipe: usize,
|
|
71
|
+
ssthresh: usize,
|
|
69
72
|
max_datagram_size: usize,
|
|
70
73
|
) {
|
|
71
74
|
self.prr_delivered += delivered_data;
|