pub struct SimNet { /* private fields */ }Expand description
A simulated network: a virtual clock, a set of nodes, and the datagrams between them.
Implementations§
Source§impl SimNet
impl SimNet
Sourcepub fn impair(&self, impairment: Impairment)
pub fn impair(&self, impairment: Impairment)
Sets what the link does to datagrams from now on.
Sourcepub fn node(&self, index: u8) -> SimNode<'_>
pub fn node(&self, index: u8) -> SimNode<'_>
A handle for the node with the given index, whose address is fd00::<index>.
Sourcepub const fn rng(&self) -> &SimRng
pub const fn rng(&self) -> &SimRng
The generator the network’s own choices come from, also usable as an Rng.
Sourcepub fn sent(&self) -> u32
pub fn sent(&self) -> u32
How many datagrams have been handed to Udp::send_to.
Sourcepub fn delivered(&self) -> u32
pub fn delivered(&self) -> u32
How many datagrams have been returned from Udp::recv_from.
Sourcepub fn duplicated(&self) -> u32
pub fn duplicated(&self) -> u32
How many datagrams the impairment duplicated.
Sourcepub fn advance_to_next_event(&self) -> bool
pub fn advance_to_next_event(&self) -> bool
Moves virtual time to the earliest thing that is waiting — a sleeping task or a datagram in flight — and returns whether there was anything to move to.
false means nothing can make progress: every task is blocked on something that
will never happen. That is a deadlock, and in a simulation it is a bug in the code
under test rather than a reason to wait longer.
Trait Implementations§
Source§impl Clock for SimNet
impl Clock for SimNet
Source§fn utc(&self) -> Option<u64>
fn utc(&self) -> Option<u64>
None when the
node does not know the time.Source§fn granularity(&self) -> Granularity
fn granularity(&self) -> Granularity
Clock::utc is, as the Time Synchronization cluster’s
Granularity enumeration.