Skip to content

Commit

Permalink
chore(msg-sim,linux): spin up loopback device on namespaced environment
Browse files Browse the repository at this point in the history
  • Loading branch information
thedevbirb committed Feb 5, 2024
1 parent 2566114 commit 5cbf671
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions msg-sim/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,22 @@ impl Simulation {
.status()?;
assert_status(status, "Failed to set up the namespaced veth device")?;

// Spin up also the loopback interface on namespaced environment
let status = Command::new("sudo")
.args([
"ip",
"netns",
"exec",
&network_namespace,
"ip",
"link",
"set",
"lo",
"up",
])
.status()?;
assert_status(status, "Failed to set up the namespaced loopback device")?;

// Add network emulation parameters (delay, loss) on namespaced veth device
//
// The behaviour is specified on the top-level ("root"),
Expand Down Expand Up @@ -348,11 +364,11 @@ mod test {
#[test]
fn start_simulation() {
let config = SimulationConfig {
latency: Some(Duration::new(3, 0)),
latency: Some(Duration::new(0, 5_000_000)),
bw: Some(1_000),
burst: Some(32),
limit: None,
plr: Some(50_f64),
plr: Some(10_f64),
protocols: vec![Protocol::TCP],
};
let simulation = Simulation::new(1, IpAddr::V4(Ipv4Addr::new(192, 168, 1, 1)), config);
Expand Down

0 comments on commit 5cbf671

Please sign in to comment.