aboutsummaryrefslogtreecommitdiffstats
path: root/src/simtest/bench.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-05 00:41:07 +0100
committertv <tv@krebsco.de>2026-11-05 00:41:07 +0100
commit4bb6282d6c439c40bceb3024afbc875f14aa4a9b (patch)
tree7fb3b948ebb85985294deb2eb924bc24a19f3584 /src/simtest/bench.rs
parent52e307d7b95dda735d1afbc4fe2dcffaa87512a4 (diff)
bench mycelium round trips
Diffstat (limited to 'src/simtest/bench.rs')
-rw-r--r--src/simtest/bench.rs32
1 files changed, 32 insertions, 0 deletions
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)]