Skip to content

Commit

Permalink
recovery: add tx_in_flight and lost in packet
Browse files Browse the repository at this point in the history
{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.
  • Loading branch information
junhochoi authored and ghedo committed Aug 29, 2023
1 parent 9b52397 commit 7992980
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 3 deletions.
2 changes: 2 additions & 0 deletions quiche/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
14 changes: 14 additions & 0 deletions quiche/src/recovery/bbr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down Expand Up @@ -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,
};

Expand Down Expand Up @@ -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,
};

Expand Down Expand Up @@ -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,
};

Expand Down Expand Up @@ -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,
};

Expand Down Expand Up @@ -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,
};

Expand Down Expand Up @@ -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,
};

Expand Down
52 changes: 52 additions & 0 deletions quiche/src/recovery/cubic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand All @@ -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,
}];

Expand Down Expand Up @@ -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,
};

Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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,
},
];
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
}];

Expand Down Expand Up @@ -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(
Expand All @@ -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,
}];

Expand Down Expand Up @@ -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,
};

Expand Down Expand Up @@ -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,
}];

Expand Down Expand Up @@ -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,
}];

Expand Down Expand Up @@ -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,
}];

Expand Down Expand Up @@ -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,
};

Expand Down Expand Up @@ -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,
}];

Expand Down Expand Up @@ -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,
}];

Expand Down Expand Up @@ -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,
}];

Expand Down Expand Up @@ -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(
Expand All @@ -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,
}];

Expand Down Expand Up @@ -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();
Expand All @@ -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,
}];

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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,
}];

Expand Down Expand Up @@ -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(
Expand Down
14 changes: 13 additions & 1 deletion quiche/src/recovery/delivery_rate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down Expand Up @@ -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(
Expand All @@ -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);
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
Loading

0 comments on commit 7992980

Please sign in to comment.