pub struct NetworkSimulator<D> {
in_flight: VecDeque<AntiEntropyMessage<D>>,
lost: Vec<AntiEntropyMessage<D>>,
config: NetworkConfig,
rng_state: u64,
}Expand description
A network simulator for testing anti-entropy under various conditions
Fields§
§in_flight: VecDeque<AntiEntropyMessage<D>>Messages in flight
lost: Vec<AntiEntropyMessage<D>>Messages that were “lost”
config: NetworkConfigConfiguration
rng_state: u64Random seed for deterministic testing
Implementations§
Source§impl<D: Clone> NetworkSimulator<D>
impl<D: Clone> NetworkSimulator<D>
pub fn new(config: NetworkConfig) -> Self
Sourcefn next_random(&mut self) -> f64
fn next_random(&mut self) -> f64
Simple LCG random number generator
Sourcepub fn send(&mut self, msg: AntiEntropyMessage<D>)
pub fn send(&mut self, msg: AntiEntropyMessage<D>)
Send a message through the network
Sourcepub fn receive(&mut self) -> Option<AntiEntropyMessage<D>>
pub fn receive(&mut self) -> Option<AntiEntropyMessage<D>>
Receive the next message (if any)
Sourcepub fn retransmit_lost(&mut self)
pub fn retransmit_lost(&mut self)
Re-send lost messages (simulates retransmission)
Sourcepub fn in_flight_count(&self) -> usize
pub fn in_flight_count(&self) -> usize
Number of messages in flight
Sourcepub fn lost_count(&self) -> usize
pub fn lost_count(&self) -> usize
Number of lost messages
Trait Implementations§
Auto Trait Implementations§
impl<D> Freeze for NetworkSimulator<D>
impl<D> RefUnwindSafe for NetworkSimulator<D>where
D: RefUnwindSafe,
impl<D> Send for NetworkSimulator<D>where
D: Send,
impl<D> Sync for NetworkSimulator<D>where
D: Sync,
impl<D> Unpin for NetworkSimulator<D>where
D: Unpin,
impl<D> UnwindSafe for NetworkSimulator<D>where
D: UnwindSafe,
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