Skip to main content

Network

Struct Network 

Source
pub struct Network { /* private fields */ }
Expand description

The virtual network: links, cuts, the flight queue, and per-node inboxes.

Implementations§

Source§

impl Network

Source

pub fn new(default_link: LinkConfig) -> Self

A fully connected network using default_link for pairs without an explicit configuration.

Overrides the configuration of one directed link.

Source

pub fn partition( &mut self, group_a: impl IntoIterator<Item = NodeId>, group_b: impl IntoIterator<Item = NodeId>, )

Cuts connectivity between two node sets, in both directions. Messages already in flight are unaffected.

Source

pub fn heal(&mut self)

Restores full connectivity.

Source

pub fn connected(&self, a: NodeId, b: NodeId) -> bool

Whether a send between the two nodes would go through.

Source

pub fn send( &mut self, from: NodeId, to: NodeId, payload: Vec<u8>, now: Micros, rng: &mut SimRng, ) -> SendOutcome

Queues a message for delivery, applying the link’s latency, drop, and duplication behavior. All randomness comes from rng.

Source

pub fn deliver_due( &mut self, now: Micros, crashed: &BTreeSet<NodeId>, ) -> Vec<Delivery>

Moves every message due at or before now into destination inboxes. Messages addressed to crashed nodes are discarded.

Source

pub fn next_delivery(&self) -> Option<Micros>

The earliest pending delivery time, if any.

Source

pub fn try_recv(&mut self, node: NodeId) -> Option<Message>

Pops the oldest message from a node’s inbox.

Source

pub fn inbox_len(&self, node: NodeId) -> usize

Number of messages waiting in a node’s inbox.

Source

pub fn clear_inbox(&mut self, node: NodeId)

Drops every buffered message of a node (its volatile state).

Source

pub fn stats(&self) -> NetworkStats

Cumulative delivery counters.

Trait Implementations§

Source§

impl Debug for Network

Source§

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

Formats the value using the given formatter. 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.