Skip to content

Commit

Permalink
Report number of bytes acked in stats
Browse files Browse the repository at this point in the history
  • Loading branch information
vkrasnov authored and ghedo committed May 20, 2024
1 parent 8420d27 commit cfc06de
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 28 deletions.
3 changes: 3 additions & 0 deletions quiche/include/quiche.h
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,9 @@ typedef struct {
// The number of received bytes.
uint64_t recv_bytes;

// The number of bytes acked.
uint64_t acked_bytes;

// The number of bytes lost.
uint64_t lost_bytes;

Expand Down
2 changes: 2 additions & 0 deletions quiche/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,7 @@ pub struct Stats {
retrans: usize,
sent_bytes: u64,
recv_bytes: u64,
acked_bytes: u64,
lost_bytes: u64,
stream_retrans_bytes: u64,
paths_count: usize,
Expand Down Expand Up @@ -1245,6 +1246,7 @@ pub extern fn quiche_conn_stats(conn: &Connection, out: &mut Stats) {
out.retrans = stats.retrans;
out.sent_bytes = stats.sent_bytes;
out.recv_bytes = stats.recv_bytes;
out.acked_bytes = stats.acked_bytes;
out.lost_bytes = stats.lost_bytes;
out.stream_retrans_bytes = stats.stream_retrans_bytes;
out.paths_count = stats.paths_count;
Expand Down
28 changes: 19 additions & 9 deletions quiche/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1442,6 +1442,9 @@ pub struct Connection {
/// Total number of bytes received over the connection.
recv_bytes: u64,

/// Total number of bytes sent acked over the connection.
acked_bytes: u64,

/// Total number of bytes sent lost over the connection.
lost_bytes: u64,

Expand Down Expand Up @@ -1905,6 +1908,7 @@ impl Connection {
retrans_count: 0,
sent_bytes: 0,
recv_bytes: 0,
acked_bytes: 0,
lost_bytes: 0,

rx_data: 0,
Expand Down Expand Up @@ -6575,6 +6579,7 @@ impl Connection {
retrans: self.retrans_count,
sent_bytes: self.sent_bytes,
recv_bytes: self.recv_bytes,
acked_bytes: self.acked_bytes,
lost_bytes: self.lost_bytes,
stream_retrans_bytes: self.stream_retrans_bytes,
paths_count: self.paths.len(),
Expand Down Expand Up @@ -6956,18 +6961,20 @@ impl Connection {
p.recovery.delivery_rate_update_app_limited(true);
}

let (lost_packets, lost_bytes) = p.recovery.on_ack_received(
&ranges,
ack_delay,
epoch,
handshake_status,
now,
&self.trace_id,
&mut self.newly_acked,
)?;
let (lost_packets, lost_bytes, acked_bytes) =
p.recovery.on_ack_received(
&ranges,
ack_delay,
epoch,
handshake_status,
now,
&self.trace_id,
&mut self.newly_acked,
)?;

self.lost_count += lost_packets;
self.lost_bytes += lost_bytes as u64;
self.acked_bytes += acked_bytes as u64;
}
},

Expand Down Expand Up @@ -7936,6 +7943,9 @@ pub struct Stats {
/// The number of received bytes.
pub recv_bytes: u64,

/// The number of bytes sent acked.
pub acked_bytes: u64,

/// The number of bytes sent lost.
pub lost_bytes: u64,

Expand Down
16 changes: 8 additions & 8 deletions quiche/src/recovery/bbr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ mod tests {
"",
&mut Vec::new(),
),
Ok((0, 0)),
Ok((0, 0, mss * 5)),
);

assert_eq!(r.bbr_state.state, BBRStateMachine::Startup);
Expand Down Expand Up @@ -514,7 +514,7 @@ mod tests {
let mut acked = ranges::RangeSet::default();
acked.insert(4..5);

// 2 acked, 2 x MSS lost.
// 1 acked, 2 x MSS lost.
assert_eq!(
r.on_ack_received(
&acked,
Expand All @@ -525,7 +525,7 @@ mod tests {
"",
&mut Vec::new(),
),
Ok((2, 2400)),
Ok((2, 2 * mss, mss)),
);

// Sent: 0, 1, 2, 3, 4, Acked 4.
Expand Down Expand Up @@ -595,7 +595,7 @@ mod tests {
"",
&mut Vec::new(),
),
Ok((0, 0)),
Ok((0, 0, mss)),
);
}

Expand Down Expand Up @@ -650,7 +650,7 @@ mod tests {
"",
&mut Vec::new(),
),
Ok((0, 0)),
Ok((0, 0, mss)),
);

// Now we are in Drain state.
Expand Down Expand Up @@ -717,7 +717,7 @@ mod tests {
"",
&mut Vec::new(),
),
Ok((0, 0)),
Ok((0, 0, mss)),
);
}

Expand Down Expand Up @@ -791,7 +791,7 @@ mod tests {
"",
&mut Vec::new(),
),
Ok((0, 0)),
Ok((0, 0, mss)),
);
}

Expand Down Expand Up @@ -848,7 +848,7 @@ mod tests {
"",
&mut Vec::new(),
),
Ok((0, 0)),
Ok((0, 0, mss)),
);

assert_eq!(r.bbr_state.state, BBRStateMachine::ProbeRTT);
Expand Down
2 changes: 1 addition & 1 deletion quiche/src/recovery/delivery_rate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ mod tests {
"",
&mut Vec::new(),
),
Ok((0, 0)),
Ok((0, 0, mss * 5)),
);

assert!(r.app_limited());
Expand Down
20 changes: 10 additions & 10 deletions quiche/src/recovery/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ impl Recovery {
&mut self, ranges: &ranges::RangeSet, ack_delay: u64,
epoch: packet::Epoch, handshake_status: HandshakeStatus, now: Instant,
trace_id: &str, newly_acked: &mut Vec<Acked>,
) -> Result<(usize, usize)> {
) -> Result<(usize, usize, usize)> {
let largest_acked = ranges.last().unwrap();

// Update the largest acked packet.
Expand Down Expand Up @@ -694,7 +694,7 @@ impl Recovery {
}

if newly_acked.is_empty() {
return Ok((0, 0));
return Ok((0, 0, 0));
}

// Check if largest packet is newly acked.
Expand Down Expand Up @@ -725,7 +725,7 @@ impl Recovery {
self.epochs[epoch]
.drain_acked_and_lost_packets(now - self.rtt_stats.rtt());

Ok(loss)
Ok((loss.0, loss.1, acked_bytes))
}

pub fn on_loss_detection_timeout(
Expand Down Expand Up @@ -1642,7 +1642,7 @@ mod tests {
"",
&mut Vec::new(),
),
Ok((0, 0))
Ok((0, 0, 2 * 1000))
);

assert_eq!(r.epochs[packet::Epoch::Application].sent_packets.len(), 2);
Expand Down Expand Up @@ -1734,7 +1734,7 @@ mod tests {
"",
&mut Vec::new(),
),
Ok((2, 2000))
Ok((2, 2000, 2 * 1000))
);

assert_eq!(r.epochs[packet::Epoch::Application].sent_packets.len(), 4);
Expand Down Expand Up @@ -1896,7 +1896,7 @@ mod tests {
"",
&mut Vec::new(),
),
Ok((0, 0))
Ok((0, 0, 3 * 1000))
);

assert_eq!(r.epochs[packet::Epoch::Application].sent_packets.len(), 2);
Expand Down Expand Up @@ -2068,7 +2068,7 @@ mod tests {
"",
&mut Vec::new(),
),
Ok((1, 1000))
Ok((1, 1000, 1000 * 2))
);

now += Duration::from_millis(10);
Expand All @@ -2088,7 +2088,7 @@ mod tests {
"",
&mut Vec::new(),
),
Ok((0, 0))
Ok((0, 0, 1000))
);

assert_eq!(r.epochs[packet::Epoch::Application].sent_packets.len(), 0);
Expand Down Expand Up @@ -2171,7 +2171,7 @@ mod tests {
"",
&mut Vec::new(),
),
Ok((0, 0))
Ok((0, 0, 12000))
);

assert_eq!(r.epochs[packet::Epoch::Application].sent_packets.len(), 0);
Expand Down Expand Up @@ -2408,7 +2408,7 @@ mod tests {
"",
&mut Vec::new(),
),
Ok((0, 0))
Ok((0, 0, 2 * 1000))
);

assert_eq!(r.epochs[packet::Epoch::Application].sent_packets.len(), 2);
Expand Down

0 comments on commit cfc06de

Please sign in to comment.