Skip to main content

moq_ext_adaptive/
network.rs

1//! What a transport tells a player about the link it plays over.
2
3use std::time::Duration;
4
5/// One reading of the link a broadcast arrives over.
6///
7/// Transports measure different things, so most fields are optional. A field
8/// left `None` means unmeasured, not zero.
9#[derive(Debug, Clone, Copy, Default, PartialEq)]
10pub struct NetworkSample {
11    /// The round trip to the peer.
12    pub rtt: Option<Duration>,
13    /// The smallest recent round trip on the current path.
14    ///
15    /// This is the path's delay with nothing queued.
16    pub min_rtt: Option<Duration>,
17    /// The fraction of this endpoint's packets lost, in `0.0..=1.0`.
18    ///
19    /// On a subscriber these packets are mostly acknowledgements. The figure
20    /// matches loss on the media's direction only when both directions are
21    /// impaired alike.
22    pub loss: Option<f64>,
23    /// The sender's estimate of what the path delivers, in bits per second.
24    ///
25    /// The estimate is for the path to this endpoint. It is the only field
26    /// that measures capacity. Adaptation caps the rendition's bitrate with
27    /// it.
28    pub delivery: Option<u64>,
29    /// A counter that changes whenever the path changes.
30    ///
31    /// Adaptation drops its history when it changes.
32    pub path_generation: u64,
33    /// The rate bytes arrived at, in bits per second.
34    ///
35    /// The count includes packet overhead and duplicates, so it is no
36    /// capacity. Adaptation does not read it.
37    pub throughput: Option<u64>,
38    /// The rate bytes left this endpoint at, in bits per second.
39    ///
40    /// Like [`throughput`](Self::throughput), the count includes packet
41    /// overhead and retransmissions. On a publisher it is the uplink the media
42    /// uses. Adaptation does not read it.
43    pub send_rate: Option<u64>,
44    /// Whether the path goes through an iroh relay rather than straight to the peer.
45    pub relayed: bool,
46}