From 4bb6282d6c439c40bceb3024afbc875f14aa4a9b Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 5 Nov 2026 00:41:07 +0100 Subject: bench mycelium round trips --- src/simtest/bench.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/simtest/bench.rs') diff --git a/src/simtest/bench.rs b/src/simtest/bench.rs index d5ca624..06b557e 100644 --- a/src/simtest/bench.rs +++ b/src/simtest/bench.rs @@ -105,6 +105,28 @@ fn lossy(sim: &Sim, _: &[String]) { }); } +/// As `lossy`, but each link with a latency of its own, as over Mycelium: round trips +/// from 20 to 250 ms, each message within a fifth of its link's. So what the uniform +/// 50–500 ms of `lossy` gives that real links don't: messages on one link overtake each +/// other only within the jitter, and the fast links to a node are fast every time. +fn mycelium_like(sim: &Sim, ids: &[String]) { + let mut rng = crate::testrand::Rng::new(7); + for (i, from) in ids.iter().enumerate() { + for to in &ids[i + 1..] { + let rtt_ms = 20.0 + rng.next_f64() * 230.0; + let half = Duration::from_secs_f64(rtt_ms / 2.0 / 1000.0); + let link = LinkParams { + loss: 0.02, + duplicate: 0.01, + delay: (half * 4 / 5, half * 6 / 5), + ..LinkParams::default() + }; + sim.net.set_link(from, to, link.clone()); + sim.net.set_link(to, from, link); + } + } +} + const SCENARIOS: &[Scenario] = &[ Scenario { name: "full mesh, 13 nodes", @@ -178,6 +200,16 @@ const SCENARIOS: &[Scenario] = &[ away: None, joining: 5, }, + // Last, so the others keep their seeds. + Scenario { + name: "partial mesh, lossy links with Mycelium's round trips, 50 nodes", + nodes: 50, + on: sim_only, + net: mycelium_like, + writer: 1, + away: None, + joining: 0, + }, ]; #[tokio::test(flavor = "multi_thread", worker_threads = 16)] -- cgit v1.3.1