rwebtransport 0.2.3 → 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.
Files changed (96) hide show
  1. package/Cargo.lock +153 -226
  2. package/Cargo.toml +5 -5
  3. package/README.md +4 -4
  4. package/crates/echo-server/src/bin/gen-test-cert.rs +1 -1
  5. package/crates/native/Cargo.toml +1 -1
  6. package/crates/native/src/config.rs +13 -1
  7. package/crates/native/src/driver.rs +249 -91
  8. package/crates/native/src/lib.rs +9 -10
  9. package/crates/native/src/parser_memory.rs +1 -0
  10. package/crates/native/src/server.rs +197 -182
  11. package/crates/native/src/session.rs +329 -177
  12. package/crates/native/src/test_support.rs +2 -2
  13. package/crates/wtcore/src/h3.rs +166 -10
  14. package/dist/index.js +92 -45
  15. package/dist/index.js.map +2 -2
  16. package/dist/index.mjs +92 -45
  17. package/dist/index.mjs.map +2 -2
  18. package/dist/native.d.ts +9 -4
  19. package/package.json +14 -11
  20. package/prebuilds/darwin-arm64/rwebtransport.node +0 -0
  21. package/prebuilds/linux-arm64/rwebtransport.node +0 -0
  22. package/prebuilds/linux-x64/rwebtransport.node +0 -0
  23. package/prebuilds/win32-x64/rwebtransport.node +0 -0
  24. package/scripts/build-linux-prebuilt.sh +46 -0
  25. package/scripts/build.js +10 -3
  26. package/vendor/quiche/AGENTS.md +10 -0
  27. package/vendor/quiche/Cargo.lock +239 -248
  28. package/vendor/quiche/Cargo.toml +23 -10
  29. package/vendor/quiche/examples/Makefile +4 -4
  30. package/vendor/quiche/examples/client.rs +10 -28
  31. package/vendor/quiche/examples/http3-client.rs +20 -34
  32. package/vendor/quiche/examples/http3-server.rs +47 -78
  33. package/vendor/quiche/examples/server.rs +19 -49
  34. package/vendor/quiche/include/quiche.h +35 -4
  35. package/vendor/quiche/src/build.rs +17 -0
  36. package/vendor/quiche/src/cid.rs +129 -61
  37. package/vendor/quiche/src/crypto/boringssl.rs +98 -86
  38. package/vendor/quiche/src/crypto/mod.rs +64 -77
  39. package/vendor/quiche/src/dgram.rs +2 -3
  40. package/vendor/quiche/src/error.rs +22 -20
  41. package/vendor/quiche/src/ffi.rs +558 -280
  42. package/vendor/quiche/src/flowcontrol.rs +0 -7
  43. package/vendor/quiche/src/frame.rs +134 -135
  44. package/vendor/quiche/src/h3/ffi.rs +73 -60
  45. package/vendor/quiche/src/h3/frame.rs +70 -90
  46. package/vendor/quiche/src/h3/mod.rs +1024 -593
  47. package/vendor/quiche/src/h3/qpack/decoder.rs +248 -34
  48. package/vendor/quiche/src/h3/qpack/dynamic_table.rs +859 -0
  49. package/vendor/quiche/src/h3/qpack/encoder.rs +14 -17
  50. package/vendor/quiche/src/h3/qpack/mod.rs +48 -0
  51. package/vendor/quiche/src/h3/qpack/static_table.rs +86 -73
  52. package/vendor/quiche/src/h3/stream.rs +1009 -194
  53. package/vendor/quiche/src/lib.rs +1346 -1195
  54. package/vendor/quiche/src/minmax.rs +2 -6
  55. package/vendor/quiche/src/packet.rs +420 -552
  56. package/vendor/quiche/src/path.rs +202 -72
  57. package/vendor/quiche/src/pmtud.rs +18 -16
  58. package/vendor/quiche/src/ranges.rs +184 -82
  59. package/vendor/quiche/src/recovery/AGENTS.md +5 -2
  60. package/vendor/quiche/src/recovery/bandwidth.rs +59 -40
  61. package/vendor/quiche/src/recovery/bytes_in_flight.rs +2 -2
  62. package/vendor/quiche/src/recovery/congestion/cubic.rs +38 -47
  63. package/vendor/quiche/src/recovery/congestion/delivery_rate.rs +54 -60
  64. package/vendor/quiche/src/recovery/congestion/hystart.rs +6 -10
  65. package/vendor/quiche/src/recovery/congestion/mod.rs +110 -42
  66. package/vendor/quiche/src/recovery/congestion/prr.rs +4 -1
  67. package/vendor/quiche/src/recovery/congestion/recovery.rs +91 -95
  68. package/vendor/quiche/src/recovery/congestion/reno.rs +17 -12
  69. package/vendor/quiche/src/recovery/congestion/test_sender.rs +8 -27
  70. package/vendor/quiche/src/recovery/gcongestion/bbr/bandwidth_sampler.rs +159 -247
  71. package/vendor/quiche/src/recovery/gcongestion/bbr/windowed_filter.rs +9 -14
  72. package/vendor/quiche/src/recovery/gcongestion/bbr2/drain.rs +18 -15
  73. package/vendor/quiche/src/recovery/gcongestion/bbr2/mode.rs +43 -28
  74. package/vendor/quiche/src/recovery/gcongestion/bbr2/network_model.rs +349 -76
  75. package/vendor/quiche/src/recovery/gcongestion/bbr2/probe_bw.rs +147 -195
  76. package/vendor/quiche/src/recovery/gcongestion/bbr2/probe_rtt.rs +29 -27
  77. package/vendor/quiche/src/recovery/gcongestion/bbr2/rtt_jump_detector/global_min.rs +180 -0
  78. package/vendor/quiche/src/recovery/gcongestion/bbr2/rtt_jump_detector/global_min_tests.rs +221 -0
  79. package/vendor/quiche/src/recovery/gcongestion/bbr2/rtt_jump_detector/hmm.rs +395 -0
  80. package/vendor/quiche/src/recovery/gcongestion/bbr2/rtt_jump_detector/hmm_tests.rs +473 -0
  81. package/vendor/quiche/src/recovery/gcongestion/bbr2/rtt_jump_detector/mod.rs +175 -0
  82. package/vendor/quiche/src/recovery/gcongestion/bbr2/startup.rs +33 -26
  83. package/vendor/quiche/src/recovery/gcongestion/bbr2.rs +107 -60
  84. package/vendor/quiche/src/recovery/gcongestion/mod.rs +64 -11
  85. package/vendor/quiche/src/recovery/gcongestion/pacer.rs +34 -25
  86. package/vendor/quiche/src/recovery/gcongestion/recovery.rs +81 -86
  87. package/vendor/quiche/src/recovery/mod.rs +414 -173
  88. package/vendor/quiche/src/recovery/rtt.rs +8 -5
  89. package/vendor/quiche/src/stream/mod.rs +864 -133
  90. package/vendor/quiche/src/stream/recv_buf.rs +471 -172
  91. package/vendor/quiche/src/stream/send_buf.rs +338 -81
  92. package/vendor/quiche/src/test_utils.rs +78 -64
  93. package/vendor/quiche/src/tests.rs +2559 -1335
  94. package/vendor/quiche/src/tls/boringssl.rs +60 -63
  95. package/vendor/quiche/src/tls/mod.rs +146 -193
  96. package/vendor/quiche/src/transport_params.rs +87 -103
@@ -64,7 +64,6 @@ use crate::recovery::INITIAL_PACKET_THRESHOLD;
64
64
  use crate::recovery::INITIAL_TIME_THRESHOLD;
65
65
  use crate::recovery::MAX_OUTSTANDING_NON_ACK_ELICITING;
66
66
  use crate::recovery::MAX_PACKET_THRESHOLD;
67
- use crate::recovery::MAX_PTO_EXPONENT;
68
67
  use crate::recovery::MAX_PTO_PROBES_COUNT;
69
68
  use crate::recovery::PACKET_REORDER_TIME_THRESHOLD;
70
69
 
@@ -119,8 +118,12 @@ struct LossDetectionResult {
119
118
  impl RecoveryEpoch {
120
119
  // `peer_sent_ack_ranges` should not be used without validation.
121
120
  fn detect_and_remove_acked_packets(
122
- &mut self, now: Instant, peer_sent_ack_ranges: &RangeSet,
123
- newly_acked: &mut Vec<Acked>, rtt_stats: &RttStats, skip_pn: Option<u64>,
121
+ &mut self,
122
+ now: Instant,
123
+ peer_sent_ack_ranges: &RangeSet,
124
+ newly_acked: &mut Vec<Acked>,
125
+ rtt_stats: &RttStats,
126
+ skip_pn: Option<u64>,
124
127
  trace_id: &str,
125
128
  ) -> Result<AckedDetectionResult> {
126
129
  newly_acked.clear();
@@ -174,8 +177,7 @@ impl RecoveryEpoch {
174
177
  } else if unacked.time_lost.is_some() {
175
178
  // An acked packet was already declared lost.
176
179
  spurious_losses += 1;
177
- spurious_pkt_thresh
178
- .get_or_insert(largest_acked - unacked.pkt_num + 1);
180
+ spurious_pkt_thresh.get_or_insert(largest_acked - unacked.pkt_num + 1);
179
181
  unacked.time_acked = Some(now);
180
182
 
181
183
  if unacked.in_flight {
@@ -222,8 +224,12 @@ impl RecoveryEpoch {
222
224
  }
223
225
 
224
226
  fn detect_lost_packets(
225
- &mut self, loss_delay: Duration, pkt_thresh: u64, now: Instant,
226
- trace_id: &str, epoch: Epoch,
227
+ &mut self,
228
+ loss_delay: Duration,
229
+ pkt_thresh: u64,
230
+ now: Instant,
231
+ trace_id: &str,
232
+ epoch: Epoch,
227
233
  ) -> LossDetectionResult {
228
234
  self.loss_time = None;
229
235
 
@@ -240,17 +246,17 @@ impl RecoveryEpoch {
240
246
 
241
247
  let mut largest_lost_pkt = None;
242
248
 
243
- let unacked_iter = self.sent_packets
244
- .iter_mut()
245
- // Skip packets that follow the largest acked packet.
246
- .take_while(|p| p.pkt_num <= largest_acked)
247
- // Skip packets that have already been acked or lost.
248
- .filter(|p| p.time_acked.is_none() && p.time_lost.is_none());
249
+ let unacked_iter = self
250
+ .sent_packets
251
+ .iter_mut()
252
+ // Skip packets that follow the largest acked packet.
253
+ .take_while(|p| p.pkt_num <= largest_acked)
254
+ // Skip packets that have already been acked or lost.
255
+ .filter(|p| p.time_acked.is_none() && p.time_lost.is_none());
249
256
 
250
257
  for unacked in unacked_iter {
251
258
  // Mark packet as lost, or set time when it should be marked.
252
- if unacked.time_sent <= lost_send_time ||
253
- largest_acked >= unacked.pkt_num + pkt_thresh
259
+ if unacked.time_sent <= lost_send_time || largest_acked >= unacked.pkt_num + pkt_thresh
254
260
  {
255
261
  self.lost_frames_ack.extend(unacked.frames.drain(..));
256
262
 
@@ -286,8 +292,7 @@ impl RecoveryEpoch {
286
292
  let loss_time = match self.loss_time {
287
293
  None => unacked.time_sent + loss_delay,
288
294
 
289
- Some(loss_time) =>
290
- cmp::min(loss_time, unacked.time_sent + loss_delay),
295
+ Some(loss_time) => cmp::min(loss_time, unacked.time_sent + loss_delay),
291
296
  };
292
297
 
293
298
  self.loss_time = Some(loss_time);
@@ -400,10 +405,7 @@ impl LegacyRecovery {
400
405
 
401
406
  pto_count: 0,
402
407
 
403
- rtt_stats: RttStats::new(
404
- recovery_config.initial_rtt,
405
- recovery_config.max_ack_delay,
406
- ),
408
+ rtt_stats: RttStats::new(recovery_config.initial_rtt, recovery_config.max_ack_delay),
407
409
 
408
410
  lost_spurious_count: 0,
409
411
 
@@ -455,10 +457,11 @@ impl LegacyRecovery {
455
457
  }
456
458
 
457
459
  fn pto_time_and_space(
458
- &self, handshake_status: HandshakeStatus, now: Instant,
460
+ &self,
461
+ handshake_status: HandshakeStatus,
462
+ now: Instant,
459
463
  ) -> (Option<Instant>, Epoch) {
460
- let mut duration =
461
- self.pto() * 2_u32.pow(self.pto_count.min(MAX_PTO_EXPONENT));
464
+ let mut duration = self.pto() * 2_u32.saturating_pow(self.pto_count);
462
465
 
463
466
  // Arm PTO from now when there are no inflight packets.
464
467
  if self.bytes_in_flight.is_zero() {
@@ -486,8 +489,7 @@ impl LegacyRecovery {
486
489
  }
487
490
 
488
491
  // Include max_ack_delay and backoff for Application Data.
489
- duration += self.rtt_stats.max_ack_delay *
490
- 2_u32.pow(self.pto_count.min(MAX_PTO_EXPONENT));
492
+ duration += self.rtt_stats.max_ack_delay * 2_u32.saturating_pow(self.pto_count);
491
493
  }
492
494
 
493
495
  let new_time = epoch
@@ -503,9 +505,7 @@ impl LegacyRecovery {
503
505
  (pto_timeout, pto_space)
504
506
  }
505
507
 
506
- fn set_loss_detection_timer(
507
- &mut self, handshake_status: HandshakeStatus, now: Instant,
508
- ) {
508
+ fn set_loss_detection_timer(&mut self, handshake_status: HandshakeStatus, now: Instant) {
509
509
  let (earliest_loss_time, _) = self.loss_time_and_space();
510
510
 
511
511
  if let Some(to) = earliest_loss_time {
@@ -514,16 +514,13 @@ impl LegacyRecovery {
514
514
  return;
515
515
  }
516
516
 
517
- if self.bytes_in_flight.is_zero() &&
518
- handshake_status.peer_verified_address
519
- {
517
+ if self.bytes_in_flight.is_zero() && handshake_status.peer_verified_address {
520
518
  self.loss_timer.clear();
521
519
  return;
522
520
  }
523
521
 
524
522
  // PTO timer.
525
- if let (Some(timeout), _) = self.pto_time_and_space(handshake_status, now)
526
- {
523
+ if let (Some(timeout), _) = self.pto_time_and_space(handshake_status, now) {
527
524
  self.loss_timer.update(timeout);
528
525
  } else {
529
526
  self.loss_timer.clear();
@@ -531,10 +528,12 @@ impl LegacyRecovery {
531
528
  }
532
529
 
533
530
  fn detect_lost_packets(
534
- &mut self, epoch: Epoch, now: Instant, trace_id: &str,
531
+ &mut self,
532
+ epoch: Epoch,
533
+ now: Instant,
534
+ trace_id: &str,
535
535
  ) -> (usize, usize) {
536
- let loss_delay = cmp::max(self.rtt_stats.latest_rtt, self.rtt())
537
- .mul_f64(self.time_thresh);
536
+ let loss_delay = cmp::max(self.rtt_stats.latest_rtt, self.rtt()).mul_f64(self.time_thresh);
538
537
 
539
538
  let loss = self.epochs[epoch].detect_lost_packets(
540
539
  loss_delay,
@@ -564,8 +563,7 @@ impl LegacyRecovery {
564
563
  self.bytes_in_flight
565
564
  .saturating_subtract(loss.pmtud_lost_bytes, now);
566
565
 
567
- self.epochs[epoch]
568
- .drain_acked_and_lost_packets(now - self.rtt_stats.rtt());
566
+ self.epochs[epoch].drain_acked_and_lost_packets(now - self.rtt_stats.rtt());
569
567
 
570
568
  self.congestion.lost_count += loss.lost_packets;
571
569
 
@@ -577,9 +575,8 @@ impl RecoveryOps for LegacyRecovery {
577
575
  /// Returns whether or not we should elicit an ACK even if we wouldn't
578
576
  /// otherwise have constructed an ACK eliciting packet.
579
577
  fn should_elicit_ack(&self, epoch: Epoch) -> bool {
580
- self.epochs[epoch].loss_probes > 0 ||
581
- self.outstanding_non_ack_eliciting >=
582
- MAX_OUTSTANDING_NON_ACK_ELICITING
578
+ self.epochs[epoch].loss_probes > 0
579
+ || self.outstanding_non_ack_eliciting >= MAX_OUTSTANDING_NON_ACK_ELICITING
583
580
  }
584
581
 
585
582
  fn next_acked_frame(&mut self, epoch: Epoch) -> Option<frame::Frame> {
@@ -613,13 +610,16 @@ impl RecoveryOps for LegacyRecovery {
613
610
  }
614
611
 
615
612
  fn ping_sent(&mut self, epoch: Epoch) {
616
- self.epochs[epoch].loss_probes =
617
- self.epochs[epoch].loss_probes.saturating_sub(1);
613
+ self.epochs[epoch].loss_probes = self.epochs[epoch].loss_probes.saturating_sub(1);
618
614
  }
619
615
 
620
616
  fn on_packet_sent(
621
- &mut self, mut pkt: Sent, epoch: Epoch,
622
- handshake_status: HandshakeStatus, now: Instant, trace_id: &str,
617
+ &mut self,
618
+ mut pkt: Sent,
619
+ epoch: Epoch,
620
+ handshake_status: HandshakeStatus,
621
+ now: Instant,
622
+ trace_id: &str,
623
623
  ) {
624
624
  let ack_eliciting = pkt.ack_eliciting;
625
625
  let in_flight = pkt.in_flight;
@@ -655,8 +655,7 @@ impl RecoveryOps for LegacyRecovery {
655
655
 
656
656
  #[cfg(test)]
657
657
  {
658
- self.epochs[epoch].test_largest_sent_pkt_num_on_path = self.epochs
659
- [epoch]
658
+ self.epochs[epoch].test_largest_sent_pkt_num_on_path = self.epochs[epoch]
660
659
  .test_largest_sent_pkt_num_on_path
661
660
  .max(Some(pkt.pkt_num));
662
661
  }
@@ -672,8 +671,13 @@ impl RecoveryOps for LegacyRecovery {
672
671
 
673
672
  // `peer_sent_ack_ranges` should not be used without validation.
674
673
  fn on_ack_received(
675
- &mut self, peer_sent_ack_ranges: &RangeSet, ack_delay: u64, epoch: Epoch,
676
- handshake_status: HandshakeStatus, now: Instant, skip_pn: Option<u64>,
674
+ &mut self,
675
+ peer_sent_ack_ranges: &RangeSet,
676
+ ack_delay: u64,
677
+ epoch: Epoch,
678
+ handshake_status: HandshakeStatus,
679
+ now: Instant,
680
+ skip_pn: Option<u64>,
677
681
  trace_id: &str,
678
682
  ) -> Result<OnAckReceivedOutcome> {
679
683
  let AckedDetectionResult {
@@ -693,8 +697,7 @@ impl RecoveryOps for LegacyRecovery {
693
697
 
694
698
  self.lost_spurious_count += spurious_losses;
695
699
  if let Some(thresh) = spurious_pkt_thresh {
696
- self.pkt_thresh =
697
- self.pkt_thresh.max(thresh.min(MAX_PACKET_THRESHOLD));
700
+ self.pkt_thresh = self.pkt_thresh.max(thresh.min(MAX_PACKET_THRESHOLD));
698
701
  self.time_thresh = PACKET_REORDER_TIME_THRESHOLD;
699
702
  }
700
703
 
@@ -718,9 +721,7 @@ impl RecoveryOps for LegacyRecovery {
718
721
  self.epochs[epoch].largest_acked_packet = Some(largest_acked_pkt_num);
719
722
 
720
723
  // Check if largest packet is newly acked.
721
- if largest_newly_acked.pkt_num == largest_acked_pkt_num &&
722
- has_ack_eliciting
723
- {
724
+ if largest_newly_acked.pkt_num == largest_acked_pkt_num && has_ack_eliciting {
724
725
  let latest_rtt = now - largest_newly_acked.time_sent;
725
726
  self.rtt_stats.update_rtt(
726
727
  latest_rtt,
@@ -732,8 +733,7 @@ impl RecoveryOps for LegacyRecovery {
732
733
 
733
734
  // Detect and mark lost packets without removing them from the sent
734
735
  // packets list.
735
- let (lost_packets, lost_bytes) =
736
- self.detect_lost_packets(epoch, now, trace_id);
736
+ let (lost_packets, lost_bytes) = self.detect_lost_packets(epoch, now, trace_id);
737
737
 
738
738
  self.congestion.on_packets_acked(
739
739
  self.bytes_in_flight.get(),
@@ -748,8 +748,7 @@ impl RecoveryOps for LegacyRecovery {
748
748
 
749
749
  self.set_loss_detection_timer(handshake_status, now);
750
750
 
751
- self.epochs[epoch]
752
- .drain_acked_and_lost_packets(now - self.rtt_stats.rtt());
751
+ self.epochs[epoch].drain_acked_and_lost_packets(now - self.rtt_stats.rtt());
753
752
 
754
753
  Ok(OnAckReceivedOutcome {
755
754
  lost_packets,
@@ -760,15 +759,16 @@ impl RecoveryOps for LegacyRecovery {
760
759
  }
761
760
 
762
761
  fn on_loss_detection_timeout(
763
- &mut self, handshake_status: HandshakeStatus, now: Instant,
762
+ &mut self,
763
+ handshake_status: HandshakeStatus,
764
+ now: Instant,
764
765
  trace_id: &str,
765
766
  ) -> OnLossDetectionTimeoutOutcome {
766
767
  let (earliest_loss_time, epoch) = self.loss_time_and_space();
767
768
 
768
769
  if earliest_loss_time.is_some() {
769
770
  // Time threshold loss detection.
770
- let (lost_packets, lost_bytes) =
771
- self.detect_lost_packets(epoch, now, trace_id);
771
+ let (lost_packets, lost_bytes) = self.detect_lost_packets(epoch, now, trace_id);
772
772
 
773
773
  self.set_loss_detection_timer(handshake_status, now);
774
774
 
@@ -800,8 +800,7 @@ impl RecoveryOps for LegacyRecovery {
800
800
 
801
801
  let epoch = &mut self.epochs[epoch];
802
802
 
803
- epoch.loss_probes =
804
- cmp::min(self.pto_count as usize, MAX_PTO_PROBES_COUNT);
803
+ epoch.loss_probes = cmp::min(self.pto_count as usize, MAX_PTO_PROBES_COUNT);
805
804
 
806
805
  let sent_packets_iter_limit = if !epoch.lost_frames_pto.is_empty() {
807
806
  // Skip the search for frames to add to PTO probes if frames
@@ -811,7 +810,8 @@ impl RecoveryOps for LegacyRecovery {
811
810
  usize::MAX
812
811
  };
813
812
 
814
- let unacked_iter = epoch.sent_packets
813
+ let unacked_iter = epoch
814
+ .sent_packets
815
815
  .iter()
816
816
  .take(sent_packets_iter_limit)
817
817
  // Skip packets that have already been acked or lost, and packets
@@ -843,16 +843,17 @@ impl RecoveryOps for LegacyRecovery {
843
843
  }
844
844
 
845
845
  fn on_pkt_num_space_discarded(
846
- &mut self, epoch: Epoch, handshake_status: HandshakeStatus, now: Instant,
846
+ &mut self,
847
+ epoch: Epoch,
848
+ handshake_status: HandshakeStatus,
849
+ now: Instant,
847
850
  ) {
848
851
  let epoch = &mut self.epochs[epoch];
849
852
 
850
853
  let unacked_bytes = epoch
851
854
  .sent_packets
852
855
  .iter()
853
- .filter(|p| {
854
- p.in_flight && p.time_acked.is_none() && p.time_lost.is_none()
855
- })
856
+ .filter(|p| p.in_flight && p.time_acked.is_none() && p.time_lost.is_none())
856
857
  .fold(0, |acc, p| acc + p.size);
857
858
 
858
859
  self.bytes_in_flight.saturating_subtract(unacked_bytes, now);
@@ -869,9 +870,7 @@ impl RecoveryOps for LegacyRecovery {
869
870
  self.set_loss_detection_timer(handshake_status, now);
870
871
  }
871
872
 
872
- fn on_path_change(
873
- &mut self, epoch: Epoch, now: Instant, trace_id: &str,
874
- ) -> (usize, usize) {
873
+ fn on_path_change(&mut self, epoch: Epoch, now: Instant, trace_id: &str) -> (usize, usize) {
875
874
  // Time threshold loss detection.
876
875
  self.detect_lost_packets(epoch, now, trace_id)
877
876
  }
@@ -885,14 +884,8 @@ impl RecoveryOps for LegacyRecovery {
885
884
  }
886
885
 
887
886
  fn cwnd_available(&self) -> usize {
888
- // Ignore cwnd when sending probe packets.
889
- if self.epochs.iter().any(|e| e.loss_probes > 0) {
890
- return usize::MAX;
891
- }
892
-
893
887
  // Open more space (snd_cnt) for PRR when allowed.
894
- self.cwnd().saturating_sub(self.bytes_in_flight.get()) +
895
- self.congestion.prr.snd_cnt
888
+ self.cwnd().saturating_sub(self.bytes_in_flight.get()) + self.congestion.prr.snd_cnt
896
889
  }
897
890
 
898
891
  fn rtt(&self) -> Duration {
@@ -925,6 +918,16 @@ impl RecoveryOps for LegacyRecovery {
925
918
  None
926
919
  }
927
920
 
921
+ fn rtt_persistent_jump_count(&self) -> u64 {
922
+ // Persistent RTT jump counts are produced by the BBR2 RTT jump
923
+ // detector. Legacy Reno/CUBIC recovery does not own a BBR2 network
924
+ // model or run that detector, but it still implements
925
+ // RecoveryOps so PathStats can be populated through one shared
926
+ // interface. Report zero to indicate that no detector is active on
927
+ // this path.
928
+ 0
929
+ }
930
+
928
931
  /// Statistics from when a CCA first exited the startup phase.
929
932
  fn startup_exit(&self) -> Option<StartupExit> {
930
933
  self.congestion.ssthresh.startup_exit()
@@ -937,24 +940,20 @@ impl RecoveryOps for LegacyRecovery {
937
940
  fn pmtud_update_max_datagram_size(&mut self, new_max_datagram_size: usize) {
938
941
  // Congestion Window is updated only when it's not updated already.
939
942
  // Update cwnd if it hasn't been updated yet.
940
- if self.cwnd() ==
941
- self.max_datagram_size *
942
- self.congestion.initial_congestion_window_packets
943
+ if self.cwnd() == self.max_datagram_size * self.congestion.initial_congestion_window_packets
943
944
  {
944
- self.congestion.congestion_window = new_max_datagram_size *
945
- self.congestion.initial_congestion_window_packets;
945
+ self.congestion.congestion_window =
946
+ new_max_datagram_size * self.congestion.initial_congestion_window_packets;
946
947
  }
947
948
 
948
949
  self.max_datagram_size = new_max_datagram_size;
950
+ (self.congestion.cc_ops.on_mtu_update)(&mut self.congestion);
949
951
  }
950
952
 
951
953
  fn update_max_datagram_size(&mut self, new_max_datagram_size: usize) {
952
- self.pmtud_update_max_datagram_size(
953
- self.max_datagram_size.min(new_max_datagram_size),
954
- )
954
+ self.pmtud_update_max_datagram_size(self.max_datagram_size.min(new_max_datagram_size))
955
955
  }
956
956
 
957
- #[cfg(test)]
958
957
  fn sent_packets_len(&self, epoch: Epoch) -> usize {
959
958
  self.epochs[epoch].sent_packets.len()
960
959
  }
@@ -998,9 +997,7 @@ impl RecoveryOps for LegacyRecovery {
998
997
  }
999
998
 
1000
999
  #[cfg(test)]
1001
- fn detect_lost_packets_for_test(
1002
- &mut self, epoch: Epoch, now: Instant,
1003
- ) -> (usize, usize) {
1000
+ fn detect_lost_packets_for_test(&mut self, epoch: Epoch, now: Instant) -> (usize, usize) {
1004
1001
  self.detect_lost_packets(epoch, now, "")
1005
1002
  }
1006
1003
 
@@ -1015,7 +1012,7 @@ impl RecoveryOps for LegacyRecovery {
1015
1012
  self.epochs[epoch].test_largest_sent_pkt_num_on_path
1016
1013
  }
1017
1014
 
1018
- #[cfg(test)]
1015
+ #[cfg(any(test, feature = "qlog"))]
1019
1016
  fn app_limited(&self) -> bool {
1020
1017
  self.congestion.app_limited
1021
1018
  }
@@ -1052,6 +1049,7 @@ impl RecoveryOps for LegacyRecovery {
1052
1049
  lost_packets: Some(self.congestion.lost_count as u64),
1053
1050
  lost_bytes: Some(self.bytes_lost),
1054
1051
  pto_count: Some(self.pto_count),
1052
+ app_limited: Some(self.app_limited()),
1055
1053
  ..Default::default()
1056
1054
  };
1057
1055
 
@@ -1059,9 +1057,7 @@ impl RecoveryOps for LegacyRecovery {
1059
1057
  }
1060
1058
 
1061
1059
  #[cfg(feature = "qlog")]
1062
- fn get_updated_qlog_cc_state(
1063
- &mut self, now: Instant,
1064
- ) -> Option<&'static str> {
1060
+ fn get_updated_qlog_cc_state(&mut self, now: Instant) -> Option<&'static str> {
1065
1061
  let cc_state = self.state_str(now);
1066
1062
  if cc_state != self.qlog_prev_cc_state {
1067
1063
  self.qlog_prev_cc_state = cc_state;
@@ -42,6 +42,7 @@ use crate::recovery::MINIMUM_WINDOW_PACKETS;
42
42
 
43
43
  pub(crate) static RENO: CongestionControlOps = CongestionControlOps {
44
44
  on_init,
45
+ on_mtu_update: |_| {},
45
46
  on_packet_sent,
46
47
  on_packets_acked,
47
48
  congestion_event,
@@ -55,23 +56,26 @@ pub(crate) static RENO: CongestionControlOps = CongestionControlOps {
55
56
  pub fn on_init(_r: &mut Congestion) {}
56
57
 
57
58
  pub fn on_packet_sent(
58
- _r: &mut Congestion, _sent_bytes: usize, _bytes_in_flight: usize,
59
+ _r: &mut Congestion,
60
+ _sent_bytes: usize,
61
+ _bytes_in_flight: usize,
59
62
  _now: Instant,
60
63
  ) {
61
64
  }
62
65
 
63
66
  fn on_packets_acked(
64
- r: &mut Congestion, _bytes_in_flight: usize, packets: &mut Vec<Acked>,
65
- now: Instant, rtt_stats: &RttStats,
67
+ r: &mut Congestion,
68
+ _bytes_in_flight: usize,
69
+ packets: &mut Vec<Acked>,
70
+ now: Instant,
71
+ rtt_stats: &RttStats,
66
72
  ) {
67
73
  for pkt in packets.drain(..) {
68
74
  on_packet_acked(r, &pkt, now, rtt_stats);
69
75
  }
70
76
  }
71
77
 
72
- fn on_packet_acked(
73
- r: &mut Congestion, packet: &Acked, now: Instant, rtt_stats: &RttStats,
74
- ) {
78
+ fn on_packet_acked(r: &mut Congestion, packet: &Acked, now: Instant, rtt_stats: &RttStats) {
75
79
  if r.in_congestion_recovery(packet.time_sent) {
76
80
  return;
77
81
  }
@@ -107,8 +111,11 @@ fn on_packet_acked(
107
111
  }
108
112
 
109
113
  fn congestion_event(
110
- r: &mut Congestion, _bytes_in_flight: usize, _lost_bytes: usize,
111
- largest_lost_pkt: &Sent, now: Instant,
114
+ r: &mut Congestion,
115
+ _bytes_in_flight: usize,
116
+ _lost_bytes: usize,
117
+ largest_lost_pkt: &Sent,
118
+ now: Instant,
112
119
  ) {
113
120
  // Start a new congestion event if packet was sent after the
114
121
  // start of the previous congestion recovery period.
@@ -117,16 +124,14 @@ fn congestion_event(
117
124
  if !r.in_congestion_recovery(time_sent) {
118
125
  r.congestion_recovery_start_time = Some(now);
119
126
 
120
- r.congestion_window =
121
- (r.congestion_window as f64 * LOSS_REDUCTION_FACTOR) as usize;
127
+ r.congestion_window = (r.congestion_window as f64 * LOSS_REDUCTION_FACTOR) as usize;
122
128
 
123
129
  r.congestion_window = cmp::max(
124
130
  r.congestion_window,
125
131
  r.max_datagram_size * MINIMUM_WINDOW_PACKETS,
126
132
  );
127
133
 
128
- r.bytes_acked_ca =
129
- (r.congestion_window as f64 * LOSS_REDUCTION_FACTOR) as usize;
134
+ r.bytes_acked_ca = (r.congestion_window as f64 * LOSS_REDUCTION_FACTOR) as usize;
130
135
 
131
136
  r.ssthresh.update(r.congestion_window, r.hystart.in_css());
132
137
 
@@ -59,10 +59,7 @@ impl TestSender {
59
59
  next_ack: 0,
60
60
  bytes_in_flight: 0,
61
61
  time: Instant::now(),
62
- rtt_stats: RttStats::new(
63
- DEFAULT_INITIAL_RTT,
64
- Duration::from_micros(0),
65
- ),
62
+ rtt_stats: RttStats::new(DEFAULT_INITIAL_RTT, Duration::from_micros(0)),
66
63
  cc: Congestion::from_config(&RecoveryConfig::from_config(&cfg)),
67
64
  sent_packets: VecDeque::new(),
68
65
  }
@@ -88,14 +85,8 @@ impl TestSender {
88
85
  is_pmtud_probe: false,
89
86
  };
90
87
 
91
- self.cc.on_packet_sent(
92
- self.bytes_in_flight,
93
- bytes,
94
- self.time,
95
- &mut sent,
96
- 0,
97
- true,
98
- );
88
+ self.cc
89
+ .on_packet_sent(self.bytes_in_flight, bytes, self.time, &mut sent, 0, true);
99
90
 
100
91
  self.sent_packets.push_back(sent);
101
92
 
@@ -106,12 +97,8 @@ impl TestSender {
106
97
  pub(crate) fn inject_ack(&mut self, acked: Acked, now: Instant) {
107
98
  let _ = self.sent_packets.pop_front().unwrap();
108
99
 
109
- self.cc.on_packets_acked(
110
- self.bytes_in_flight,
111
- &mut vec![acked],
112
- &self.rtt_stats,
113
- now,
114
- );
100
+ self.cc
101
+ .on_packets_acked(self.bytes_in_flight, &mut vec![acked], &self.rtt_stats, now);
115
102
  }
116
103
 
117
104
  pub(crate) fn ack_n_packets(&mut self, n: usize, bytes: usize) {
@@ -135,19 +122,13 @@ impl TestSender {
135
122
  self.next_ack += 1;
136
123
  }
137
124
 
138
- self.cc.on_packets_acked(
139
- self.bytes_in_flight,
140
- &mut acked,
141
- &self.rtt_stats,
142
- self.time,
143
- );
125
+ self.cc
126
+ .on_packets_acked(self.bytes_in_flight, &mut acked, &self.rtt_stats, self.time);
144
127
 
145
128
  self.bytes_in_flight -= n * bytes;
146
129
  }
147
130
 
148
- pub(crate) fn lose_n_packets(
149
- &mut self, n: usize, bytes: usize, time_sent: Option<Instant>,
150
- ) {
131
+ pub(crate) fn lose_n_packets(&mut self, n: usize, bytes: usize, time_sent: Option<Instant>) {
151
132
  let mut unacked = None;
152
133
 
153
134
  for _ in 0..n {