Skip to content

Commit 595f6a6

Browse files
committedMar 5, 2020
expose delivery rate in Stats
1 parent 81cd217 commit 595f6a6

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed
 

‎include/quiche.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,11 @@ typedef struct {
313313
// The estimated round-trip time of the connection (in nanoseconds).
314314
uint64_t rtt;
315315

316-
// The size in bytes of the connection's congestion window.
316+
// The size of the connection's congestion window in bytes.
317317
size_t cwnd;
318+
319+
// The estimated data delivery rate in bytes/s.
320+
uint64_t delivery_rate;
318321
} quiche_stats;
319322

320323
// Collects and returns statistics about the connection.

‎src/ffi.rs

+2
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,7 @@ pub struct Stats {
624624
pub lost: usize,
625625
pub rtt: u64,
626626
pub cwnd: usize,
627+
pub delivery_rate: u64,
627628
}
628629

629630
#[no_mangle]
@@ -635,6 +636,7 @@ pub extern fn quiche_conn_stats(conn: &Connection, out: &mut Stats) {
635636
out.lost = stats.lost;
636637
out.rtt = stats.rtt.as_nanos() as u64;
637638
out.cwnd = stats.cwnd;
639+
out.delivery_rate = stats.delivery_rate as u64;
638640
}
639641

640642
#[no_mangle]

‎src/lib.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -2651,6 +2651,7 @@ impl Connection {
26512651
lost: self.recovery.lost_count,
26522652
cwnd: self.recovery.cc.cwnd(),
26532653
rtt: self.recovery.rtt(),
2654+
delivery_rate: self.recovery.delivery_rate(),
26542655
}
26552656
}
26562657

@@ -3154,16 +3155,24 @@ pub struct Stats {
31543155
/// The estimated round-trip time of the connection.
31553156
pub rtt: time::Duration,
31563157

3157-
/// The size in bytes of the connection's congestion window.
3158+
/// The size of the connection's congestion window in bytes.
31583159
pub cwnd: usize,
3160+
3161+
/// The estimated data delivery rate in bytes/s.
3162+
pub delivery_rate: f64,
31593163
}
31603164

31613165
impl std::fmt::Debug for Stats {
31623166
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
31633167
write!(
31643168
f,
3165-
"recv={} sent={} lost={} rtt={:?} cwnd={}",
3166-
self.recv, self.sent, self.lost, self.rtt, self.cwnd
3169+
"recv={} sent={} lost={} rtt={:?} cwnd={} delivery_rate={}",
3170+
self.recv,
3171+
self.sent,
3172+
self.lost,
3173+
self.rtt,
3174+
self.cwnd,
3175+
self.delivery_rate
31673176
)
31683177
}
31693178
}

‎src/recovery.rs

+4
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,10 @@ impl Recovery {
376376
self.rtt() + cmp::max(self.rttvar * 4, GRANULARITY) + self.max_ack_delay
377377
}
378378

379+
pub fn delivery_rate(&self) -> f64 {
380+
self.rate_sample.delivery_rate
381+
}
382+
379383
fn update_rtt(&mut self, latest_rtt: Duration, ack_delay: Duration) {
380384
self.latest_rtt = latest_rtt;
381385

0 commit comments

Comments
 (0)
Please sign in to comment.