pub struct NetworkSimulator { /* private fields */ }Expand description
Network simulator for multi-node testing
Implementations§
Source§impl NetworkSimulator
impl NetworkSimulator
Sourcepub fn new(default_config: ChaosConfig) -> Self
pub fn new(default_config: ChaosConfig) -> Self
Create a new network simulator
Sourcepub fn send(&mut self, from: NodeId, to: NodeId, data: Vec<u8>)
pub fn send(&mut self, from: NodeId, to: NodeId, data: Vec<u8>)
Send a packet from one node to another
Sourcepub fn tick(&mut self, dt: Duration) -> Vec<(NodeId, NodeId, Vec<u8>)>
pub fn tick(&mut self, dt: Duration) -> Vec<(NodeId, NodeId, Vec<u8>)>
Advance simulation time and collect delivered packets
Sourcepub fn current_time(&self) -> Duration
pub fn current_time(&self) -> Duration
Get current simulation time
Sourcepub fn set_link_config(&mut self, from: NodeId, to: NodeId, config: ChaosConfig)
pub fn set_link_config(&mut self, from: NodeId, to: NodeId, config: ChaosConfig)
Set custom config for a specific link
Sourcepub fn link_stats(&self, from: NodeId, to: NodeId) -> Option<&ChaosStats>
pub fn link_stats(&self, from: NodeId, to: NodeId) -> Option<&ChaosStats>
Get statistics for a link
Auto Trait Implementations§
impl Freeze for NetworkSimulator
impl RefUnwindSafe for NetworkSimulator
impl Send for NetworkSimulator
impl Sync for NetworkSimulator
impl Unpin for NetworkSimulator
impl UnsafeUnpin for NetworkSimulator
impl UnwindSafe for NetworkSimulator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more