Skip to content

Commit

Permalink
feat(model): add SawtoothBw model
Browse files Browse the repository at this point in the history
  • Loading branch information
BobAnkh committed Jul 28, 2023
1 parent 5f2a446 commit 27d237d
Show file tree
Hide file tree
Showing 3 changed files with 370 additions and 3 deletions.
78 changes: 77 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ mod test {
use super::*;
use crate::mahimahi::MahimahiExt;
use crate::model::{
BwTraceConfig, NormalizedBwConfig, RepeatedBwPatternConfig, StaticBwConfig,
BwTraceConfig, NormalizedBwConfig, RepeatedBwPatternConfig, SawtoothBwConfig,
StaticBwConfig,
};

#[test]
Expand Down Expand Up @@ -228,6 +229,81 @@ mod test {
);
}

#[test]
fn test_sawtooth_bw_model() {
let mut sawtooth_bw = SawtoothBwConfig::new()
.bottom(Bandwidth::from_mbps(12))
.top(Bandwidth::from_mbps(16))
.duration(Duration::from_secs(1))
.step(Duration::from_millis(100))
.interval(Duration::from_millis(500))
.duty_ratio(0.8)
.build();
assert_eq!(
sawtooth_bw.next_bw(),
Some((Bandwidth::from_mbps(12), Duration::from_millis(100)))
);
assert_eq!(
sawtooth_bw.next_bw(),
Some((Bandwidth::from_mbps(13), Duration::from_millis(100)))
);
assert_eq!(
sawtooth_bw.next_bw(),
Some((Bandwidth::from_mbps(14), Duration::from_millis(100)))
);
assert_eq!(
sawtooth_bw.next_bw(),
Some((Bandwidth::from_mbps(15), Duration::from_millis(100)))
);
assert_eq!(
sawtooth_bw.next_bw(),
Some((Bandwidth::from_mbps(16), Duration::from_millis(100)))
);
assert_eq!(
sawtooth_bw.next_bw(),
Some((Bandwidth::from_mbps(12), Duration::from_millis(100)))
);
assert_eq!(
sawtooth_bw.next_bw(),
Some((Bandwidth::from_mbps(13), Duration::from_millis(100)))
);
assert_eq!(
sawtooth_bw.next_bw(),
Some((Bandwidth::from_mbps(14), Duration::from_millis(100)))
);
assert_eq!(
sawtooth_bw.next_bw(),
Some((Bandwidth::from_mbps(15), Duration::from_millis(100)))
);
let mut sawtooth_bw = SawtoothBwConfig::new()
.bottom(Bandwidth::from_mbps(12))
.top(Bandwidth::from_mbps(16))
.duration(Duration::from_secs(1))
.step(Duration::from_millis(100))
.interval(Duration::from_millis(500))
.duty_ratio(0.8)
.std_dev(Bandwidth::from_mbps(5))
.upper_noise_bound(Bandwidth::from_mbps(1))
.lower_noise_bound(Bandwidth::from_kbps(500))
.build();
assert_eq!(
sawtooth_bw.next_bw(),
Some((Bandwidth::from_bps(12347139), Duration::from_millis(100)))
);
assert_eq!(
sawtooth_bw.next_bw(),
Some((Bandwidth::from_bps(13664690), Duration::from_millis(100)))
);
assert_eq!(
sawtooth_bw.next_bw(),
Some((Bandwidth::from_mbps(15), Duration::from_millis(100)))
);
assert_eq!(
sawtooth_bw.next_bw(),
Some((Bandwidth::from_bps(14500000), Duration::from_millis(100)))
);
}

#[test]
fn test_mahimahi() {
let mut static_bw = StaticBwConfig::new()
Expand Down
Loading

0 comments on commit 27d237d

Please sign in to comment.