Skip to content

Commit 6b56e30

Browse files
committed
Maintain DATAGRAM sent/received statistics
1 parent 4671176 commit 6b56e30

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

quiche/src/lib.rs

+27
Original file line numberDiff line numberDiff line change
@@ -1408,6 +1408,12 @@ pub struct Connection {
14081408
/// Total number of packets sent with data retransmitted.
14091409
retrans_count: usize,
14101410

1411+
/// Total number of sent DATAGRAM frames.
1412+
dgram_sent_count: usize,
1413+
1414+
/// Total number of received DATAGRAM frames.
1415+
dgram_recv_count: usize,
1416+
14111417
/// Total number of bytes received from the peer.
14121418
rx_data: u64,
14131419

@@ -1903,6 +1909,8 @@ impl Connection {
19031909
sent_count: 0,
19041910
lost_count: 0,
19051911
retrans_count: 0,
1912+
dgram_sent_count: 0,
1913+
dgram_recv_count: 0,
19061914
sent_bytes: 0,
19071915
recv_bytes: 0,
19081916
acked_bytes: 0,
@@ -4306,6 +4314,10 @@ impl Connection {
43064314
ack_eliciting = true;
43074315
in_flight = true;
43084316
dgram_emitted = true;
4317+
let _ =
4318+
self.dgram_sent_count.saturating_add(1);
4319+
let _ =
4320+
path.dgram_sent_count.saturating_add(1);
43094321
}
43104322
},
43114323

@@ -6577,6 +6589,8 @@ impl Connection {
65776589
acked_bytes: self.acked_bytes,
65786590
lost_bytes: self.lost_bytes,
65796591
stream_retrans_bytes: self.stream_retrans_bytes,
6592+
dgram_recv: self.dgram_recv_count,
6593+
dgram_sent: self.dgram_sent_count,
65806594
paths_count: self.paths.len(),
65816595
reset_stream_count_local: self.reset_stream_local_count,
65826596
stopped_stream_count_local: self.stopped_stream_local_count,
@@ -7399,6 +7413,13 @@ impl Connection {
73997413
}
74007414

74017415
self.dgram_recv_queue.push(data)?;
7416+
7417+
let _ = self.dgram_recv_count.saturating_add(1);
7418+
let _ = self
7419+
.paths
7420+
.get_mut(recv_path_id)?
7421+
.dgram_recv_count
7422+
.saturating_add(1);
74027423
},
74037424

74047425
frame::Frame::DatagramHeader { .. } => unreachable!(),
@@ -7946,6 +7967,12 @@ pub struct Stats {
79467967
/// The number of stream bytes retransmitted.
79477968
pub stream_retrans_bytes: u64,
79487969

7970+
/// The number of DATAGRAM frames received.
7971+
pub dgram_recv: usize,
7972+
7973+
/// The number of DATAGRAM frames sent.
7974+
pub dgram_sent: usize,
7975+
79497976
/// The number of known paths for the connection.
79507977
pub paths_count: usize,
79517978

quiche/src/path.rs

+16
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@ pub struct Path {
167167
/// Total number of packets sent with data retransmitted from this path.
168168
pub retrans_count: usize,
169169

170+
/// Number of DATAGRAM frames sent on this path.
171+
pub dgram_sent_count: usize,
172+
173+
/// Number of DATAGRAM frames received on this path.
174+
pub dgram_recv_count: usize,
175+
170176
/// Total number of sent bytes over this path.
171177
pub sent_bytes: u64,
172178

@@ -236,6 +242,8 @@ impl Path {
236242
sent_count: 0,
237243
recv_count: 0,
238244
retrans_count: 0,
245+
dgram_sent_count: 0,
246+
dgram_recv_count: 0,
239247
sent_bytes: 0,
240248
recv_bytes: 0,
241249
stream_retrans_bytes: 0,
@@ -483,6 +491,8 @@ impl Path {
483491
sent: self.sent_count,
484492
lost: self.recovery.lost_count(),
485493
retrans: self.retrans_count,
494+
dgram_recv: self.dgram_recv_count,
495+
dgram_sent: self.dgram_sent_count,
486496
rtt: self.recovery.rtt(),
487497
min_rtt: self.recovery.min_rtt(),
488498
rttvar: self.recovery.rttvar(),
@@ -856,6 +866,12 @@ pub struct PathStats {
856866
/// The number of sent QUIC packets with retransmitted data.
857867
pub retrans: usize,
858868

869+
/// The number of DATAGRAM frames received.
870+
pub dgram_recv: usize,
871+
872+
/// The number of DATAGRAM frames sent.
873+
pub dgram_sent: usize,
874+
859875
/// The estimated round-trip time of the connection.
860876
pub rtt: time::Duration,
861877

0 commit comments

Comments
 (0)