From 5cbf671cd739049065fb75141e64b200a1bffb79 Mon Sep 17 00:00:00 2001 From: thedevbirb Date: Mon, 5 Feb 2024 16:17:12 +0100 Subject: [PATCH] chore(msg-sim,linux): spin up loopback device on namespaced environment --- msg-sim/src/lib.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/msg-sim/src/lib.rs b/msg-sim/src/lib.rs index af3817a..85ea5d5 100644 --- a/msg-sim/src/lib.rs +++ b/msg-sim/src/lib.rs @@ -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"), @@ -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);