Skip to main content

Config

Struct Config 

Source
pub struct Config {
    pub seed: u64,
    pub loss: f64,
    pub duplication: f64,
    pub reorder: f64,
    pub latency_min: Duration,
    pub latency_max: Duration,
    pub reorder_delay: Duration,
    pub synchronous: Option<Duration>,
    pub sessions: bool,
    pub reconnect_interval: Duration,
    pub max_steps: u64,
}
Expand description

Network conditions and run limits.

Every knob is consulted through the run’s seeded generator, so a configuration plus a seed determines a run completely.

Fields§

§seed: u64

Seed for every random decision in the run — faults, latency, and protocol randomness.

§loss: f64

Probability in 0.0..=1.0 that a message is dropped rather than delivered.

§duplication: f64

Probability in 0.0..=1.0 that a message is delivered twice.

§reorder: f64

Probability in 0.0..=1.0 that a message is delayed far beyond normal latency, forcing it behind messages sent after it.

§latency_min: Duration

Shortest delivery delay.

§latency_max: Duration

Longest delivery delay. Jitter between the two produces ordinary reordering.

§reorder_delay: Duration

Extra delay applied to a message selected for reordering.

§synchronous: Option<Duration>

When set, the run is synchronous: delivery between connected, uncrashed processes is guaranteed within this bound, and nothing is lost, duplicated or given a reordering spike.

This is what a perfect failure detector needs and what the asynchronous default cannot offer: without a known bound, a live process whose messages are unlucky is indistinguishable from a crashed one. It constrains timing only — crashes and partitions still stop delivery.

§sessions: bool

When true, communication happens within sessions: between each pair of processes there is a session in which delivery is reliable, ordered and free of duplicates — what TCP or QUIC gives. A partition, a crash, or an explicit break ends it, losing an unknown suffix of what was in flight, and a new session begins at a higher epoch.

This is the model a deployed stack would run on. The fair-loss default is what you have if you build reliability yourself, which is the simulator’s own situation and not production’s.

§reconnect_interval: Duration

How often a session-based run retries establishing sessions that are not up.

A deployed link keeps trying to reconnect on its own rather than waiting for the layers above to transmit, so the model does too. The value stands in for a retry interval, with or without backoff; no protocol may depend on it.

§max_steps: u64

Safety valve: a run stops after this many events, whatever the clock says.

Protocols such as the stubborn link retransmit forever by design, so a run is bounded by time or by this, never by quiescence.

Implementations§

Source§

impl Config

Source

pub fn seed(self, seed: u64) -> Self

Source

pub fn loss(self, p: f64) -> Self

Drop messages with probability p.

Source

pub fn duplication(self, p: f64) -> Self

Deliver messages twice with probability p.

Source

pub fn reorder(self, p: f64) -> Self

Delay messages far beyond normal latency with probability p, forcing reordering.

Source

pub fn latency(self, min: Duration, max: Duration) -> Self

Deliver after a delay drawn uniformly from min..=max.

Jitter here is itself a source of reordering; reorder forces the extreme case.

Source

pub fn synchronous(self, bound: Duration) -> Self

Run synchronously: every message between connected, uncrashed processes is delivered within bound, and none is lost or duplicated.

The bound is readable afterwards through Config::delivery_bound, so a protocol whose correctness depends on it can be configured from the same value rather than from a guess. Setting this overrides the fault knobs, and the override is enforced at delivery time — calling loss afterwards will not quietly reintroduce loss.

Source

pub fn delivery_bound(&self) -> Option<Duration>

The upper bound on delivery, when the run is synchronous.

Source

pub fn is_synchronous(&self) -> bool

Whether this run makes a timing guarantee.

Source

pub fn sessions(self) -> Self

Communicate within sessions: reliable, ordered, duplicate-free delivery while a session holds, and an unknown lost suffix when one ends.

Overrides the loss and duplication knobs, enforced at delivery time so builder order cannot reintroduce them. Latency still applies, but a message is never delivered before one sent earlier to the same peer.

Source

pub fn reconnect_interval(self, d: Duration) -> Self

How often to retry establishing sessions that are not up.

Source

pub fn is_session_based(&self) -> bool

Whether this run communicates within sessions.

Source

pub fn max_steps(self, n: u64) -> Self

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Config

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Config

Source§

fn eq(&self, other: &Config) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Config

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more