Skip to main content

Module rwnd

Module rwnd 

Source
Expand description

This module contains some predefined rwnd trace models.

Enabled with feature rwnd-model or model.

§Predefined models

§Examples

An example to build model from configuration:

let mut static_rwnd = StaticRwndConfig::new()
    .set_rcv_buf(65536)
    .app_read(1024)
    .duration(Duration::from_secs(1))
    .build();
let (decision, duration) = static_rwnd.next_rwnd().unwrap();
assert_eq!(decision.set_rcv_buf, Some(65536));
assert_eq!(decision.action, Some(RwndAction::AppRead { bytes: 1024 }));
assert_eq!(duration, Duration::from_secs(1));
assert_eq!(static_rwnd.next_rwnd(), None);

A more common use case is to build model from a configuration file (e.g. json file):

// The content would be "{\"RepeatedRwndPatternConfig\":{\"pattern\":[{\"StaticRwndConfig\":{\"duration\":{\"secs\":1,\"nanos\":0},\"set_rcv_buf\":65536,\"app_read_bytes\":1024}},{\"StaticRwndConfig\":{\"duration\":{\"secs\":1,\"nanos\":0},\"rwnd_remaining\":32768}}],\"count\":2}}"
// if the `human` feature is not enabled.
let config_file_content = "{\"RepeatedRwndPatternConfig\":{\"pattern\":[{\"StaticRwndConfig\":{\"duration\":{\"secs\":1,\"nanos\":0},\"set_rcv_buf\":65536,\"app_read_bytes\":1024}},{\"StaticRwndConfig\":{\"duration\":{\"secs\":1,\"nanos\":0},\"rwnd_remaining\":32768}}],\"count\":2}}";
let des: Box<dyn RwndTraceConfig> = serde_json::from_str(config_file_content).unwrap();
let mut model = des.into_model();
let (decision, _) = model.next_rwnd().unwrap();
assert_eq!(decision.action, Some(RwndAction::AppRead { bytes: 1024 }));
let (decision, _) = model.next_rwnd().unwrap();
assert_eq!(decision.action, Some(RwndAction::Remaining { rwnd: 32768 }));
let (decision, _) = model.next_rwnd().unwrap();
assert_eq!(decision.action, Some(RwndAction::AppRead { bytes: 1024 }));
let (decision, _) = model.next_rwnd().unwrap();
assert_eq!(decision.action, Some(RwndAction::Remaining { rwnd: 32768 }));
assert_eq!(model.next_rwnd(), None);

At most one of app_read_bytes or rwnd_remaining may be set per step — never both. A step with neither produces RwndDecision::action as None, which is valid for steps that only reconfigure the receive buffer.

Structs§

RepeatedRwndPattern
The model contains an array of rwnd trace models.
RepeatedRwndPatternConfig
The configuration struct for RepeatedRwndPattern.
StaticRwnd
The model of a static rwnd trace: a single decision valid for one duration.
StaticRwndConfig
The configuration struct for StaticRwnd.

Traits§

RwndTraceConfig
This trait is used to convert a rwnd trace configuration into a rwnd trace model.