Skip to main content

NetworkModel

Struct NetworkModel 

Source
pub struct NetworkModel {
    pub peers: HashMap<NodeId, PeerNetworkModel>,
    pub latency_mean: f64,
    pub jitter: f64,
    pub reorder_depth: u32,
    pub loss_rate: f64,
    pub stability_score: f64,
}
Expand description

Aggregate network model across all peers

Fields§

§peers: HashMap<NodeId, PeerNetworkModel>

Per-peer models

§latency_mean: f64

Aggregate latency mean (seconds)

§jitter: f64

Aggregate jitter (seconds)

§reorder_depth: u32

Estimated reorder depth

§loss_rate: f64

Estimated loss rate (0.0 - 1.0)

§stability_score: f64

Overall stability score (0.0 - 1.0)

Implementations§

Source§

impl NetworkModel

Source

pub fn new() -> Self

Source

pub fn update_from_packet( &mut self, peer: NodeId, local_time: f64, remote_time: f64, _seq: u16, )

Update model from a received packet

Source

pub fn record_reorder(&mut self, depth: u32)

Record a detected reorder

Source

pub fn record_loss(&mut self, lost_count: u32, total_count: u32)

Record packet loss

Source

pub fn get_peer(&self, peer: NodeId) -> Option<&PeerNetworkModel>

Get peer model

Trait Implementations§

Source§

impl Debug for NetworkModel

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for NetworkModel

Source§

fn default() -> NetworkModel

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.