Skip to content

Commit

Permalink
Maintain DATAGRAM sent/received statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
hendrikcech committed Dec 2, 2024
1 parent 4671176 commit bd24bc9
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
25 changes: 25 additions & 0 deletions quiche/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1408,6 +1408,12 @@ pub struct Connection {
/// Total number of packets sent with data retransmitted.
retrans_count: usize,

/// Total number of sent DATAGRAM frames.
dgram_sent_count: usize,

/// Total number of received DATAGRAM frames.
dgram_recv_count: usize,

/// Total number of bytes received from the peer.
rx_data: u64,

Expand Down Expand Up @@ -1903,6 +1909,8 @@ impl Connection {
sent_count: 0,
lost_count: 0,
retrans_count: 0,
dgram_sent_count: 0,
dgram_recv_count: 0,
sent_bytes: 0,
recv_bytes: 0,
acked_bytes: 0,
Expand Down Expand Up @@ -4306,6 +4314,8 @@ impl Connection {
ack_eliciting = true;
in_flight = true;
dgram_emitted = true;
let _ = self.dgram_sent_count.saturating_add(1);
let _ = path.dgram_sent_count.saturating_add(1);
}
},

Expand Down Expand Up @@ -6577,6 +6587,8 @@ impl Connection {
acked_bytes: self.acked_bytes,
lost_bytes: self.lost_bytes,
stream_retrans_bytes: self.stream_retrans_bytes,
dgram_recv: self.dgram_recv_count,
dgram_sent: self.dgram_sent_count,
paths_count: self.paths.len(),
reset_stream_count_local: self.reset_stream_local_count,
stopped_stream_count_local: self.stopped_stream_local_count,
Expand Down Expand Up @@ -7399,6 +7411,13 @@ impl Connection {
}

self.dgram_recv_queue.push(data)?;

let _ = self.dgram_recv_count.saturating_add(1);
let _ = self
.paths
.get_mut(recv_path_id)?
.dgram_recv_count
.saturating_add(1);
},

frame::Frame::DatagramHeader { .. } => unreachable!(),
Expand Down Expand Up @@ -7946,6 +7965,12 @@ pub struct Stats {
/// The number of stream bytes retransmitted.
pub stream_retrans_bytes: u64,

/// The number of DATAGRAM frames received.
pub dgram_recv: usize,

/// The number of DATAGRAM frames sent.
pub dgram_sent: usize,

/// The number of known paths for the connection.
pub paths_count: usize,

Expand Down
16 changes: 16 additions & 0 deletions quiche/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ pub struct Path {
/// Total number of packets sent with data retransmitted from this path.
pub retrans_count: usize,

/// Number of DATAGRAM frames sent on this path.
pub dgram_sent_count: usize,

/// Number of DATAGRAM frames received on this path.
pub dgram_recv_count: usize,

/// Total number of sent bytes over this path.
pub sent_bytes: u64,

Expand Down Expand Up @@ -236,6 +242,8 @@ impl Path {
sent_count: 0,
recv_count: 0,
retrans_count: 0,
dgram_sent_count: 0,
dgram_recv_count: 0,
sent_bytes: 0,
recv_bytes: 0,
stream_retrans_bytes: 0,
Expand Down Expand Up @@ -483,6 +491,8 @@ impl Path {
sent: self.sent_count,
lost: self.recovery.lost_count(),
retrans: self.retrans_count,
dgram_recv: self.dgram_recv_count,
dgram_sent: self.dgram_sent_count,
rtt: self.recovery.rtt(),
min_rtt: self.recovery.min_rtt(),
rttvar: self.recovery.rttvar(),
Expand Down Expand Up @@ -856,6 +866,12 @@ pub struct PathStats {
/// The number of sent QUIC packets with retransmitted data.
pub retrans: usize,

/// The number of DATAGRAM frames received.
pub dgram_recv: usize,

/// The number of DATAGRAM frames sent.
pub dgram_sent: usize,

/// The estimated round-trip time of the connection.
pub rtt: time::Duration,

Expand Down

0 comments on commit bd24bc9

Please sign in to comment.