From 799298084261405337fc48ae57d6e2a6777531e8 Mon Sep 17 00:00:00 2001 From: Junho Choi Date: Fri, 18 Mar 2022 22:07:59 -0700 Subject: [PATCH] recovery: add tx_in_flight and lost in packet {Sent|Acked}.{tx_in_flight|lost} is current bytes_in_flight and bytes_lost counter when the packet is sent. This is needed for BBR2 module. --- quiche/src/lib.rs | 2 + quiche/src/recovery/bbr/mod.rs | 14 +++++++ quiche/src/recovery/cubic.rs | 52 ++++++++++++++++++++++++++ quiche/src/recovery/delivery_rate.rs | 14 ++++++- quiche/src/recovery/mod.rs | 55 +++++++++++++++++++++++++++- quiche/src/recovery/reno.rs | 18 +++++++++ 6 files changed, 152 insertions(+), 3 deletions(-) diff --git a/quiche/src/lib.rs b/quiche/src/lib.rs index d77d947bb1..3fbb259afb 100644 --- a/quiche/src/lib.rs +++ b/quiche/src/lib.rs @@ -4270,6 +4270,8 @@ impl Connection { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, has_data, }; diff --git a/quiche/src/recovery/bbr/mod.rs b/quiche/src/recovery/bbr/mod.rs index 6d4676f240..07683dc0ae 100644 --- a/quiche/src/recovery/bbr/mod.rs +++ b/quiche/src/recovery/bbr/mod.rs @@ -429,6 +429,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, has_data: false, }; @@ -497,6 +499,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, has_data: false, }; @@ -564,6 +568,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, has_data: false, }; @@ -613,6 +619,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, has_data: false, }; @@ -683,6 +691,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, has_data: false, }; @@ -752,6 +762,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, has_data: false, }; @@ -804,6 +816,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, has_data: false, }; diff --git a/quiche/src/recovery/cubic.rs b/quiche/src/recovery/cubic.rs index 7a7118e810..345ba96de7 100644 --- a/quiche/src/recovery/cubic.rs +++ b/quiche/src/recovery/cubic.rs @@ -487,6 +487,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, has_data: false, }; @@ -505,6 +507,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, rtt: Duration::ZERO, }]; @@ -535,6 +539,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, has_data: false, }; @@ -554,6 +560,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, rtt: Duration::ZERO, }, Acked { @@ -564,6 +572,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, rtt: Duration::ZERO, }, Acked { @@ -574,6 +584,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, rtt: Duration::ZERO, }, ]; @@ -607,6 +619,8 @@ mod tests { first_sent_time: now, is_app_limited: false, has_data: false, + tx_in_flight: 0, + lost: 0, }; r.congestion_event( @@ -649,6 +663,8 @@ mod tests { first_sent_time: now, is_app_limited: false, has_data: false, + tx_in_flight: 0, + lost: 0, }; // Trigger congestion event to update ssthresh @@ -685,6 +701,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, rtt: Duration::ZERO, }]; @@ -721,6 +739,8 @@ mod tests { first_sent_time: now, is_app_limited: false, has_data: false, + tx_in_flight: 0, + lost: 0, }; r.congestion_event( @@ -746,6 +766,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, rtt: Duration::ZERO, }]; @@ -781,6 +803,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, has_data: false, }; @@ -812,6 +836,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, rtt: Duration::ZERO, }]; @@ -849,6 +875,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, rtt: Duration::ZERO, }]; @@ -889,6 +917,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, rtt: Duration::ZERO, }]; @@ -929,6 +959,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, has_data: false, }; @@ -960,6 +992,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, rtt: Duration::ZERO, }]; @@ -997,6 +1031,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, rtt: Duration::ZERO, }]; @@ -1035,6 +1071,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, rtt: Duration::ZERO, }]; @@ -1076,6 +1114,8 @@ mod tests { first_sent_time: now, is_app_limited: false, has_data: false, + tx_in_flight: 0, + lost: 0, }; r.congestion_event( @@ -1100,6 +1140,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, rtt: Duration::ZERO, }]; @@ -1133,6 +1175,8 @@ mod tests { first_sent_time: now, is_app_limited: false, has_data: false, + tx_in_flight: 0, + lost: 0, }; let prev_cwnd = r.cwnd(); @@ -1158,6 +1202,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, rtt: Duration::ZERO, }]; @@ -1204,6 +1250,8 @@ mod tests { first_sent_time: now, is_app_limited: false, has_data: false, + tx_in_flight: 0, + lost: 0, }; r.congestion_event( @@ -1238,6 +1286,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, rtt: Duration::ZERO, }]; @@ -1266,6 +1316,8 @@ mod tests { first_sent_time: now, is_app_limited: false, has_data: false, + tx_in_flight: 0, + lost: 0, }; r.congestion_event( diff --git a/quiche/src/recovery/delivery_rate.rs b/quiche/src/recovery/delivery_rate.rs index 0f20fa61bf..590bac22cb 100644 --- a/quiche/src/recovery/delivery_rate.rs +++ b/quiche/src/recovery/delivery_rate.rs @@ -79,7 +79,9 @@ impl Default for Rate { } impl Rate { - pub fn on_packet_sent(&mut self, pkt: &mut Sent, bytes_in_flight: usize) { + pub fn on_packet_sent( + &mut self, pkt: &mut Sent, bytes_in_flight: usize, bytes_lost: u64, + ) { // No packets in flight. if bytes_in_flight == 0 { self.first_sent_time = pkt.time_sent; @@ -90,6 +92,8 @@ impl Rate { pkt.delivered_time = self.delivered_time; pkt.delivered = self.delivered; pkt.is_app_limited = self.app_limited(); + pkt.tx_in_flight = bytes_in_flight; + pkt.lost = bytes_lost; self.last_sent_packet = pkt.pkt_num; } @@ -238,6 +242,8 @@ mod tests { first_sent_time: now, is_app_limited: false, has_data: false, + tx_in_flight: 0, + lost: 0, }; r.on_packet_sent( @@ -263,6 +269,8 @@ mod tests { delivered_time: now, first_sent_time: now.checked_sub(rtt).unwrap(), is_app_limited: false, + tx_in_flight: 0, + lost: 0, }; r.delivery_rate.update_rate_sample(&acked, now); @@ -302,6 +310,8 @@ mod tests { first_sent_time: now, is_app_limited: false, has_data: false, + tx_in_flight: 0, + lost: 0, }; r.on_packet_sent( @@ -341,6 +351,8 @@ mod tests { first_sent_time: now, is_app_limited: false, has_data: false, + tx_in_flight: 0, + lost: 0, }; r.on_packet_sent( diff --git a/quiche/src/recovery/mod.rs b/quiche/src/recovery/mod.rs index 71d25882b7..1997c6fd31 100644 --- a/quiche/src/recovery/mod.rs +++ b/quiche/src/recovery/mod.rs @@ -383,8 +383,11 @@ impl Recovery { pkt.time_sent = self.get_packet_send_time(); // bytes_in_flight is already updated. Use previous value. - self.delivery_rate - .on_packet_sent(&mut pkt, self.bytes_in_flight - sent_bytes); + self.delivery_rate.on_packet_sent( + &mut pkt, + self.bytes_in_flight - sent_bytes, + self.bytes_lost, + ); self.sent[epoch].push_back(pkt); @@ -548,6 +551,10 @@ impl Recovery { first_sent_time: unacked.first_sent_time, is_app_limited: unacked.is_app_limited, + + tx_in_flight: unacked.tx_in_flight, + + lost: unacked.lost, }); trace!("{} packet newly acked {}", trace_id, unacked.pkt_num); @@ -1251,6 +1258,10 @@ pub struct Sent { pub is_app_limited: bool, + pub tx_in_flight: usize, + + pub lost: u64, + pub has_data: bool, } @@ -1263,6 +1274,8 @@ impl std::fmt::Debug for Sent { write!(f, "delivered_time={:?} ", self.delivered_time)?; write!(f, "first_sent_time={:?} ", self.first_sent_time)?; write!(f, "is_app_limited={} ", self.is_app_limited)?; + write!(f, "tx_in_flight={} ", self.tx_in_flight)?; + write!(f, "lost={} ", self.lost)?; write!(f, "has_data={} ", self.has_data)?; Ok(()) @@ -1286,6 +1299,10 @@ pub struct Acked { pub first_sent_time: Instant, pub is_app_limited: bool, + + pub tx_in_flight: usize, + + pub lost: u64, } #[derive(Clone, Copy, Debug)] @@ -1488,6 +1505,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, has_data: false, }; @@ -1514,6 +1533,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, has_data: false, }; @@ -1540,6 +1561,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, has_data: false, }; @@ -1566,6 +1589,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, has_data: false, }; @@ -1625,6 +1650,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, has_data: false, }; @@ -1651,6 +1678,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, has_data: false, }; @@ -1723,6 +1752,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, has_data: false, }; @@ -1749,6 +1780,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, has_data: false, }; @@ -1775,6 +1808,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, has_data: false, }; @@ -1801,6 +1836,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, has_data: false, }; @@ -1884,6 +1921,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, has_data: false, }; @@ -1910,6 +1949,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, has_data: false, }; @@ -1936,6 +1977,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, has_data: false, }; @@ -1962,6 +2005,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, has_data: false, }; @@ -2058,6 +2103,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, has_data: false, }; @@ -2116,6 +2163,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, has_data: false, }; @@ -2147,6 +2196,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, has_data: false, }; diff --git a/quiche/src/recovery/reno.rs b/quiche/src/recovery/reno.rs index c3dc277278..db1a471207 100644 --- a/quiche/src/recovery/reno.rs +++ b/quiche/src/recovery/reno.rs @@ -217,6 +217,8 @@ mod tests { delivered_time: std::time::Instant::now(), first_sent_time: std::time::Instant::now(), is_app_limited: false, + tx_in_flight: 0, + lost: 0, has_data: false, }; @@ -235,6 +237,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, rtt: Duration::ZERO, }]; @@ -266,6 +270,8 @@ mod tests { delivered_time: std::time::Instant::now(), first_sent_time: std::time::Instant::now(), is_app_limited: false, + tx_in_flight: 0, + lost: 0, has_data: false, }; @@ -285,6 +291,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, rtt: Duration::ZERO, }, Acked { @@ -295,6 +303,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, rtt: Duration::ZERO, }, Acked { @@ -305,6 +315,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, rtt: Duration::ZERO, }, ]; @@ -340,6 +352,8 @@ mod tests { first_sent_time: std::time::Instant::now(), is_app_limited: false, has_data: false, + tx_in_flight: 0, + lost: 0, }; r.congestion_event( @@ -379,6 +393,8 @@ mod tests { first_sent_time: std::time::Instant::now(), is_app_limited: false, has_data: false, + tx_in_flight: 0, + lost: 0, }; // Trigger congestion event to update ssthresh @@ -406,6 +422,8 @@ mod tests { delivered_time: now, first_sent_time: now, is_app_limited: false, + tx_in_flight: 0, + lost: 0, rtt: Duration::ZERO, }];