In examples, trace the packets being dropped by the fault injector.

v0.7.x
whitequark 2017-06-26 08:26:42 +00:00
parent 02abd7a983
commit 62c9b7d6fa
2 changed files with 6 additions and 2 deletions

View File

@ -159,6 +159,10 @@ implement fault injection, available through command-line options:
A good starting value for `--drop-chance` and `--corrupt-chance` is 15%. A good starting
value for `--?x-rate-limit` is 4 and `--shaping-interval` is 50 ms.
Note that packets dropped by the fault injector still get traced;
the `rx: randomly dropping a packet` message indicates that the packet *above* it got dropped,
and the `tx: randomly dropping a packet` message indicates that the packet *below* it was.
### examples/tcpdump.rs
_examples/tcpdump.rs_ is a tiny clone of the _tcpdump_ utility.

View File

@ -36,7 +36,7 @@ pub fn setup_logging() {
}
pub fn setup_device(more_args: &[&str])
-> (Tracer<FaultInjector<TapInterface>, EthernetFrame<&'static [u8]>>,
-> (FaultInjector<Tracer<TapInterface, EthernetFrame<&'static [u8]>>>,
Vec<String>) {
let mut opts = getopts::Options::new();
opts.optopt("", "drop-chance", "Chance of dropping a packet (%)", "CHANCE");
@ -77,6 +77,7 @@ pub fn setup_device(more_args: &[&str])
}
let device = TapInterface::new(&matches.free[0]).unwrap();
let device = Tracer::<_, EthernetFrame<&'static [u8]>>::new(device, trace_writer);
let mut device = FaultInjector::new(device, seed);
device.set_drop_chance(drop_chance);
device.set_corrupt_chance(corrupt_chance);
@ -84,7 +85,6 @@ pub fn setup_device(more_args: &[&str])
device.set_max_tx_rate(tx_rate_limit);
device.set_max_rx_rate(rx_rate_limit);
device.set_bucket_interval(Duration::from_millis(shaping_interval as u64));
let device = Tracer::<_, EthernetFrame<&'static [u8]>>::new(device, trace_writer);
(device, matches.free[1..].to_owned())
}