netem-trace
A library for generating network emulation trace. Now only supported mahimahi.
Attention: This library is still under development. The API is not stable.
MSRV: 1.60
Examples
Use bandwidth model directly (model or bw-model feature should be enabled):
use ;
use ;
let mut static_bw = new
.bw
.duration
.build;
assert_eq!;
let mut normal_bw = new
.mean
.std_dev
.duration
.step
.seed
.build;
assert_eq!;
assert_eq!;
let mut normal_bw = new
.mean
.std_dev
.duration
.step
.seed
.upper_bound
.lower_bound
.build;
assert_eq!;
assert_eq!;
Produce traces in mahimahi format (mahimahi feature should also be enabled):
use ;
use ;
use ;
let mut static_bw = new
.bw
.duration
.build;
assert_eq!;
let mut static_bw = new
.bw
.duration
.build;
assert_eq!;
let a = vec!;
let mut c = Boxnew.into_model;
assert_eq!;
Load traces in mahimahi format (mahimahi feature should also be enabled):
use load_mahimahi_trace;
use ;
let trace = vec!;
let mut bw = load_mahimahi_trace.unwrap.build;
// first cycle
assert_eq!;
assert_eq!;
assert_eq!;
// second cycle
assert_eq!;
Work with configuration files (serde feature should also be enabled):
use ;
use ;
let a = vec!;
let ser =
Boxnew as ;
let ser_str = to_string.unwrap;
let des_str = "{\"RepeatedBwPatternConfig\":{\"pattern\":[{\"StaticBwConfig\":{\"bw\":{\"gbps\":0,\"bps\":12000000},\"duration\":{\"secs\":1,\"nanos\":0}}},{\"StaticBwConfig\":{\"bw\":{\"gbps\":0,\"bps\":24000000},\"duration\":{\"secs\":1,\"nanos\":0}}}],\"count\":2}}";
// The content would be "{\"RepeatedBwPatternConfig\":{\"pattern\":[{\"StaticBwConfig\":{\"bw\":\"12Mbps\",\"duration\":\"1s\"}},{\"StaticBwConfig\":{\"bw\":\"24Mbps\",\"duration\":\"1s\"}}],\"count\":2}}"
// if the `human` feature is also enabled.
assert_eq!;
let des: = from_str.unwrap;
let mut model = des.into_model;
assert_eq!;
Plotting and Visualization
The series module (requires trace-ext feature) allows you to expand trace models into time series data for plotting and analysis.
Quick Example
use StaticBwConfig;
use ;
use ;
// Create and expand a trace
let mut trace = new
.bw
.duration
.build;
let series = expand_bw_trace;
// Export to JSON or CSV
write_bw_series_json.unwrap;
write_bw_series_csv.unwrap;
Supported Trace Types
- Bandwidth traces:
expand_bw_trace()→BwSeriesPoint(start_time, bandwidth, duration) - Delay traces:
expand_delay_trace()→DelaySeriesPoint(start_time, delay, duration) - Per-packet delay:
expand_delay_per_packet_trace()→DelayPerPacketSeriesPoint(packet_index, delay) - Loss/Duplicate traces:
expand_loss_trace(),expand_duplicate_trace()
Export Formats
JSON: Full structure with nested fields
CSV: Flat format for easy plotting
start_time_secs,bandwidth_bps,duration_secs
0.0,10000000,1.0
Plotting in Python
=
, = ,
=
=
= / 1_000_000
See examples/plot_traces.rs and examples/plot_example.py for complete examples. Run with:
Maintainer
How to contribute
You should follow our Code of Conduct.
See CONTRIBUTING GUIDELINES for contributing conventions.
Make sure to pass all the tests before submitting your code.