pub struct FaultInjector<D: Device> { /* private fields */ }
Expand description
A fault injector device.
A fault injector is a device that alters packets traversing through it to simulate adverse network conditions (such as random packet loss or corruption), or software or hardware limitations (such as a limited number or size of usable network buffers).
Implementations§
Source§impl<D: Device> FaultInjector<D>
impl<D: Device> FaultInjector<D>
Sourcepub fn new(inner: D, seed: u32) -> FaultInjector<D>
pub fn new(inner: D, seed: u32) -> FaultInjector<D>
Create a fault injector device, using the given random number generator seed.
Sourcepub fn into_inner(self) -> D
pub fn into_inner(self) -> D
Return the underlying device, consuming the fault injector.
Sourcepub fn corrupt_chance(&self) -> u8
pub fn corrupt_chance(&self) -> u8
Return the probability of corrupting a packet, in percents.
Sourcepub fn drop_chance(&self) -> u8
pub fn drop_chance(&self) -> u8
Return the probability of dropping a packet, in percents.
Sourcepub fn max_packet_size(&self) -> usize
pub fn max_packet_size(&self) -> usize
Return the maximum packet size, in octets.
Sourcepub fn max_tx_rate(&self) -> u64
pub fn max_tx_rate(&self) -> u64
Return the maximum packet transmission rate, in packets per second.
Sourcepub fn max_rx_rate(&self) -> u64
pub fn max_rx_rate(&self) -> u64
Return the maximum packet reception rate, in packets per second.
Sourcepub fn bucket_interval(&self) -> Duration
pub fn bucket_interval(&self) -> Duration
Return the interval for packet rate limiting, in milliseconds.
Sourcepub fn set_corrupt_chance(&mut self, pct: u8)
pub fn set_corrupt_chance(&mut self, pct: u8)
Set the probability of corrupting a packet, in percents.
§Panics
This function panics if the probability is not between 0% and 100%.
Sourcepub fn set_drop_chance(&mut self, pct: u8)
pub fn set_drop_chance(&mut self, pct: u8)
Set the probability of dropping a packet, in percents.
§Panics
This function panics if the probability is not between 0% and 100%.
Sourcepub fn set_max_packet_size(&mut self, size: usize)
pub fn set_max_packet_size(&mut self, size: usize)
Set the maximum packet size, in octets.
Sourcepub fn set_max_tx_rate(&mut self, rate: u64)
pub fn set_max_tx_rate(&mut self, rate: u64)
Set the maximum packet transmission rate, in packets per interval.
Sourcepub fn set_max_rx_rate(&mut self, rate: u64)
pub fn set_max_rx_rate(&mut self, rate: u64)
Set the maximum packet reception rate, in packets per interval.
Sourcepub fn set_bucket_interval(&mut self, interval: Duration)
pub fn set_bucket_interval(&mut self, interval: Duration)
Set the interval for packet rate limiting, in milliseconds.