pub struct SimNetwork { /* private fields */ }Expand description
Simulated network that intercepts all inter-node communication.
Fully deterministic given the same seed. Supports partitions, drops, latency, jitter, reordering, and message duplication.
Implementations§
Source§impl SimNetwork
impl SimNetwork
Sourcepub fn set_link_config(&mut self, from: NodeId, to: NodeId, config: LinkConfig)
pub fn set_link_config(&mut self, from: NodeId, to: NodeId, config: LinkConfig)
Set the link configuration between two nodes.
Sourcepub fn set_all_links(&mut self, nodes: &[NodeId], config: LinkConfig)
pub fn set_all_links(&mut self, nodes: &[NodeId], config: LinkConfig)
Configure all links between the given nodes symmetrically.
Sourcepub fn inject_partition(&mut self, a: NodeId, b: NodeId)
pub fn inject_partition(&mut self, a: NodeId, b: NodeId)
Inject a symmetric partition: all messages between a and b are dropped.
Sourcepub fn heal_partition(&mut self, a: NodeId, b: NodeId)
pub fn heal_partition(&mut self, a: NodeId, b: NodeId)
Heal a symmetric partition.
Sourcepub fn inject_one_way_partition(&mut self, from: NodeId, to: NodeId)
pub fn inject_one_way_partition(&mut self, from: NodeId, to: NodeId)
Inject a one-way partition: from→to dropped, to→from delivered.
Sourcepub fn heal_one_way_partition(&mut self, from: NodeId, to: NodeId)
pub fn heal_one_way_partition(&mut self, from: NodeId, to: NodeId)
Heal a one-way partition.
Sourcepub fn heal_all_partitions(&mut self)
pub fn heal_all_partitions(&mut self)
Heal all partitions.
Sourcepub fn send(&mut self, from: NodeId, to: NodeId, payload: Vec<u8>)
pub fn send(&mut self, from: NodeId, to: NodeId, payload: Vec<u8>)
Submit a message into the network.
Sourcepub fn drain(&mut self, node_id: NodeId) -> Vec<(NodeId, Vec<u8>)>
pub fn drain(&mut self, node_id: NodeId) -> Vec<(NodeId, Vec<u8>)>
Drain delivered messages for a specific node.
Sourcepub fn current_tick(&self) -> u64
pub fn current_tick(&self) -> u64
Current simulation tick.
Sourcepub fn in_flight_count(&self) -> usize
pub fn in_flight_count(&self) -> usize
Number of messages currently in-flight.
Sourcepub fn total_sent(&self) -> u64
pub fn total_sent(&self) -> u64
Stats: total messages sent.
Sourcepub fn total_dropped(&self) -> u64
pub fn total_dropped(&self) -> u64
Stats: total messages dropped.
Sourcepub fn total_delivered(&self) -> u64
pub fn total_delivered(&self) -> u64
Stats: total messages delivered.
Sourcepub fn total_corrupted(&self) -> u64
pub fn total_corrupted(&self) -> u64
Stats: total messages corrupted.
Sourcepub fn total_throttled(&self) -> u64
pub fn total_throttled(&self) -> u64
Stats: total messages throttled (delayed due to bandwidth limit).
Sourcepub fn partition_pairs(&self) -> Vec<(NodeId, NodeId)>
pub fn partition_pairs(&self) -> Vec<(NodeId, NodeId)>
Get all active partition pairs.