Skip to main content

naia_shared/connection/
connection_stats.rs

1/// Snapshot of per-connection network diagnostics.
2///
3/// All fields are rolling averages or short-window estimates; they are
4/// computed on demand (poll-style) and incur no per-tick allocation.
5/// Obtain via `Server::connection_stats(&user_key)` or `Client::connection_stats()`.
6#[derive(Clone, Debug)]
7pub struct ConnectionStats {
8    /// Round-trip time in milliseconds (EWMA).
9    pub rtt_ms: f32,
10    /// RTT 50th-percentile in milliseconds, estimated from the last 32 samples.
11    pub rtt_p50_ms: f32,
12    /// RTT 99th-percentile in milliseconds, estimated from the last 32 samples.
13    pub rtt_p99_ms: f32,
14    /// Jitter in milliseconds (EWMA of half the absolute RTT deviation).
15    pub jitter_ms: f32,
16    /// Fraction of sent data-packets that were not acknowledged in the last
17    /// 64-packet window. Range: 0.0 (no loss) – 1.0 (total loss).
18    pub packet_loss_pct: f32,
19    /// Rolling-average outgoing bandwidth in kilobits per second.
20    pub kbps_sent: f32,
21    /// Rolling-average incoming bandwidth in kilobits per second.
22    pub kbps_recv: f32,
23}