cc: pass largest_lost_packet to congestion_event
Pass a whole lost packet (Sent) to congestion_event() hook,
to use some of the information of lost packet.
diff --git a/quiche/src/recovery/cubic.rs b/quiche/src/recovery/cubic.rs
index 090a8f4d..fdd2718 100644
--- a/quiche/src/recovery/cubic.rs
+++ b/quiche/src/recovery/cubic.rs
@@ -43,6 +43,7 @@
use crate::recovery::Acked;
use crate::recovery::CongestionControlOps;
use crate::recovery::Recovery;
+use crate::recovery::Sent;
pub static CUBIC: CongestionControlOps = CongestionControlOps {
on_init,
@@ -342,9 +343,10 @@
}
fn congestion_event(
- r: &mut Recovery, _lost_bytes: usize, time_sent: Instant,
+ r: &mut Recovery, _lost_bytes: usize, largest_lost_pkt: &Sent,
epoch: packet::Epoch, now: Instant,
) {
+ let time_sent = largest_lost_pkt.time_sent;
let in_congestion_recovery = r.in_congestion_recovery(time_sent);
// Start a new congestion event if packet was sent after the
@@ -583,9 +585,25 @@
let now = Instant::now();
let prev_cwnd = r.cwnd();
+ let p = recovery::Sent {
+ pkt_num: 0,
+ frames: vec![],
+ time_sent: now,
+ time_acked: None,
+ time_lost: None,
+ size: r.max_datagram_size,
+ ack_eliciting: true,
+ in_flight: true,
+ delivered: 0,
+ delivered_time: now,
+ first_sent_time: now,
+ is_app_limited: false,
+ has_data: false,
+ };
+
r.congestion_event(
r.max_datagram_size,
- now,
+ &p,
packet::EPOCH_APPLICATION,
now,
);
@@ -609,10 +627,26 @@
r.on_packet_sent_cc(r.max_datagram_size, now);
}
+ let p = recovery::Sent {
+ pkt_num: 0,
+ frames: vec![],
+ time_sent: now,
+ time_acked: None,
+ time_lost: None,
+ size: r.max_datagram_size,
+ ack_eliciting: true,
+ in_flight: true,
+ delivered: 0,
+ delivered_time: now,
+ first_sent_time: now,
+ is_app_limited: false,
+ has_data: false,
+ };
+
// Trigger congestion event to update ssthresh
r.congestion_event(
r.max_datagram_size,
- now,
+ &p,
packet::EPOCH_APPLICATION,
now,
);
@@ -665,9 +699,25 @@
r.on_packet_sent_cc(30000, now);
// Trigger congestion event to update ssthresh
+ let p = recovery::Sent {
+ pkt_num: 0,
+ frames: vec![],
+ time_sent: now,
+ time_acked: None,
+ time_lost: None,
+ size: r.max_datagram_size,
+ ack_eliciting: true,
+ in_flight: true,
+ delivered: 0,
+ delivered_time: now,
+ first_sent_time: now,
+ is_app_limited: false,
+ has_data: false,
+ };
+
r.congestion_event(
r.max_datagram_size,
- now,
+ &p,
packet::EPOCH_APPLICATION,
now,
);
@@ -1004,9 +1054,25 @@
}
// Trigger congestion event to update ssthresh
+ let p = recovery::Sent {
+ pkt_num: 0,
+ frames: vec![],
+ time_sent: now,
+ time_acked: None,
+ time_lost: None,
+ size: r.max_datagram_size,
+ ack_eliciting: true,
+ in_flight: true,
+ delivered: 0,
+ delivered_time: now,
+ first_sent_time: now,
+ is_app_limited: false,
+ has_data: false,
+ };
+
r.congestion_event(
r.max_datagram_size,
- now,
+ &p,
packet::EPOCH_APPLICATION,
now,
);
@@ -1045,10 +1111,26 @@
let now = now + rtt;
// Trigger another congestion event.
+ let p = recovery::Sent {
+ pkt_num: 0,
+ frames: vec![],
+ time_sent: now,
+ time_acked: None,
+ time_lost: None,
+ size: r.max_datagram_size,
+ ack_eliciting: true,
+ in_flight: true,
+ delivered: 0,
+ delivered_time: now,
+ first_sent_time: now,
+ is_app_limited: false,
+ has_data: false,
+ };
+
let prev_cwnd = r.cwnd();
r.congestion_event(
r.max_datagram_size,
- now,
+ &p,
packet::EPOCH_APPLICATION,
now,
);
@@ -1100,9 +1182,25 @@
}
// Trigger congestion event to update ssthresh
+ let p = recovery::Sent {
+ pkt_num: 0,
+ frames: vec![],
+ time_sent: now,
+ time_acked: None,
+ time_lost: None,
+ size: r.max_datagram_size,
+ ack_eliciting: true,
+ in_flight: true,
+ delivered: 0,
+ delivered_time: now,
+ first_sent_time: now,
+ is_app_limited: false,
+ has_data: false,
+ };
+
r.congestion_event(
r.max_datagram_size,
- now,
+ &p,
packet::EPOCH_APPLICATION,
now,
);
@@ -1146,9 +1244,25 @@
// Fast convergence: now there is 2nd congestion event and
// cwnd is not fully recovered to w_max, w_max will be
// further reduced.
+ let p = recovery::Sent {
+ pkt_num: 0,
+ frames: vec![],
+ time_sent: now,
+ time_acked: None,
+ time_lost: None,
+ size: r.max_datagram_size,
+ ack_eliciting: true,
+ in_flight: true,
+ delivered: 0,
+ delivered_time: now,
+ first_sent_time: now,
+ is_app_limited: false,
+ has_data: false,
+ };
+
r.congestion_event(
r.max_datagram_size,
- now,
+ &p,
packet::EPOCH_APPLICATION,
now,
);
diff --git a/quiche/src/recovery/mod.rs b/quiche/src/recovery/mod.rs
index fc526d2..bcaa8f9 100644
--- a/quiche/src/recovery/mod.rs
+++ b/quiche/src/recovery/mod.rs
@@ -917,7 +917,7 @@
) {
self.bytes_in_flight = self.bytes_in_flight.saturating_sub(lost_bytes);
- self.congestion_event(lost_bytes, largest_lost_pkt.time_sent, epoch, now);
+ self.congestion_event(lost_bytes, largest_lost_pkt, epoch, now);
if self.in_persistent_congestion(largest_lost_pkt.pkt_num) {
self.collapse_cwnd();
@@ -925,14 +925,22 @@
}
fn congestion_event(
- &mut self, lost_bytes: usize, time_sent: Instant, epoch: packet::Epoch,
- now: Instant,
+ &mut self, lost_bytes: usize, largest_lost_pkt: &Sent,
+ epoch: packet::Epoch, now: Instant,
) {
+ let time_sent = largest_lost_pkt.time_sent;
+
if !self.in_congestion_recovery(time_sent) {
(self.cc_ops.checkpoint)(self);
}
- (self.cc_ops.congestion_event)(self, lost_bytes, time_sent, epoch, now);
+ (self.cc_ops.congestion_event)(
+ self,
+ lost_bytes,
+ largest_lost_pkt,
+ epoch,
+ now,
+ );
}
fn collapse_cwnd(&mut self) {
@@ -1015,7 +1023,7 @@
pub congestion_event: fn(
r: &mut Recovery,
lost_bytes: usize,
- time_sent: Instant,
+ largest_lost_packet: &Sent,
epoch: packet::Epoch,
now: Instant,
),
diff --git a/quiche/src/recovery/reno.rs b/quiche/src/recovery/reno.rs
index eb8942b..540c572 100644
--- a/quiche/src/recovery/reno.rs
+++ b/quiche/src/recovery/reno.rs
@@ -37,6 +37,7 @@
use crate::recovery::Acked;
use crate::recovery::CongestionControlOps;
use crate::recovery::Recovery;
+use crate::recovery::Sent;
pub static RENO: CongestionControlOps = CongestionControlOps {
on_init,
@@ -104,11 +105,13 @@
}
fn congestion_event(
- r: &mut Recovery, _lost_bytes: usize, time_sent: Instant,
+ r: &mut Recovery, _lost_bytes: usize, largest_lost_pkt: &Sent,
epoch: packet::Epoch, now: Instant,
) {
// Start a new congestion event if packet was sent after the
// start of the previous congestion recovery period.
+ let time_sent = largest_lost_pkt.time_sent;
+
if !r.in_congestion_recovery(time_sent) {
r.congestion_recovery_start_time = Some(now);
@@ -318,9 +321,25 @@
let now = Instant::now();
+ let p = recovery::Sent {
+ pkt_num: 0,
+ frames: vec![],
+ time_sent: now,
+ time_acked: None,
+ time_lost: None,
+ size: r.max_datagram_size,
+ ack_eliciting: true,
+ in_flight: true,
+ delivered: 0,
+ delivered_time: std::time::Instant::now(),
+ first_sent_time: std::time::Instant::now(),
+ is_app_limited: false,
+ has_data: false,
+ };
+
r.congestion_event(
r.max_datagram_size,
- now,
+ &p,
packet::EPOCH_APPLICATION,
now,
);
@@ -341,10 +360,26 @@
// Fill up bytes_in_flight to avoid app_limited=true
r.on_packet_sent_cc(20000, now);
+ let p = recovery::Sent {
+ pkt_num: 0,
+ frames: vec![],
+ time_sent: now,
+ time_acked: None,
+ time_lost: None,
+ size: r.max_datagram_size,
+ ack_eliciting: true,
+ in_flight: true,
+ delivered: 0,
+ delivered_time: std::time::Instant::now(),
+ first_sent_time: std::time::Instant::now(),
+ is_app_limited: false,
+ has_data: false,
+ };
+
// Trigger congestion event to update ssthresh
r.congestion_event(
r.max_datagram_size,
- now,
+ &p,
packet::EPOCH_APPLICATION,
now,
);