aboutsummaryrefslogtreecommitdiffstats
path: root/src/transport
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-05 05:26:34 +0100
committertv <tv@krebsco.de>2026-11-05 05:26:34 +0100
commitc1cb16be7894885ec5066dafc25b92f348ced11a (patch)
tree2a4aeef9469e65b938ad5f3c711b433077e32ef2 /src/transport
parent40f0274a6686336bd8ca7c15446681449dbc739e (diff)
tree latency measured
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/sim.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/transport/sim.rs b/src/transport/sim.rs
index d218d5c..12f3885 100644
--- a/src/transport/sim.rs
+++ b/src/transport/sim.rs
@@ -170,6 +170,16 @@ impl SimNet {
.insert((from.to_owned(), to.to_owned()), params);
}
+ /// The mean delay from `from` to `to` (one way): its link's, or the default's.
+ pub(crate) fn mean_delay(&self, from: &str, to: &str) -> Duration {
+ let inner = self.lock();
+ let link = inner
+ .links
+ .get(&(from.to_owned(), to.to_owned()))
+ .unwrap_or(&inner.default_link);
+ (link.delay.0 + link.delay.1) / 2
+ }
+
/// Everything to and from `id` is lost until [`bring_up`](Self::bring_up), including
/// messages already on their way. The node itself keeps running.
pub(crate) fn take_down(&self, id: &str) {