aboutsummaryrefslogtreecommitdiffstats
path: root/src/transport
diff options
context:
space:
mode:
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) {