NetworkState

Struct NetworkState 

Source
pub struct NetworkState {
Show 13 fields pub next_connection_id: u64, pub next_listener_id: u64, pub config: NetworkConfiguration, pub connections: HashMap<ConnectionId, ConnectionState>, pub listeners: HashMap<ListenerId, ListenerState>, pub pending_connections: HashMap<String, ConnectionId>, pub connection_clogs: HashMap<ConnectionId, ClogState>, pub read_clogs: HashMap<ConnectionId, ClogState>, pub ip_partitions: HashMap<(IpAddr, IpAddr), PartitionState>, pub send_partitions: HashMap<IpAddr, Duration>, pub recv_partitions: HashMap<IpAddr, Duration>, pub last_random_close_time: Duration, pub pair_latencies: HashMap<(IpAddr, IpAddr), Duration>,
}
Expand description

Network-related state management

Fields§

§next_connection_id: u64

Counter for generating unique connection IDs.

§next_listener_id: u64

Counter for generating unique listener IDs.

§config: NetworkConfiguration

Network configuration for this simulation.

§connections: HashMap<ConnectionId, ConnectionState>

Active connections indexed by their ID.

§listeners: HashMap<ListenerId, ListenerState>

Active listeners indexed by their ID.

§pending_connections: HashMap<String, ConnectionId>

Connections pending acceptance, indexed by address.

§connection_clogs: HashMap<ConnectionId, ClogState>

Write clog state (temporary write blocking).

§read_clogs: HashMap<ConnectionId, ClogState>

Read clog state (temporary read blocking, symmetric with write clogging).

§ip_partitions: HashMap<(IpAddr, IpAddr), PartitionState>

Partitions between specific IP pairs (from, to) -> partition state

§send_partitions: HashMap<IpAddr, Duration>

Send partitions - IP cannot send to anyone

§recv_partitions: HashMap<IpAddr, Duration>

Receive partitions - IP cannot receive from anyone

§last_random_close_time: Duration

Last time a random close was triggered (global cooldown tracking) FDB: g_simulator->lastConnectionFailure - see sim2.actor.cpp:583

§pair_latencies: HashMap<(IpAddr, IpAddr), Duration>

Per-IP-pair base latencies for consistent connection behavior. Once set on first connection, all subsequent connections between the same IP pair will use this base latency (with optional jitter on top).

Implementations§

Source§

impl NetworkState

Source

pub fn new(config: NetworkConfiguration) -> Self

Create a new network state with the given configuration.

Source

pub fn parse_ip_from_addr(addr: &str) -> Option<IpAddr>

Extract IP address from a network address string. Supports formats like “127.0.0.1:8080”, “[::1]:8080”, etc.

Source

pub fn is_partitioned( &self, from_ip: IpAddr, to_ip: IpAddr, current_time: Duration, ) -> bool

Check if communication from source IP to destination IP is partitioned

Source

pub fn is_connection_partitioned( &self, connection_id: ConnectionId, current_time: Duration, ) -> bool

Check if a connection is partitioned (cannot send messages)

Trait Implementations§

Source§

impl Debug for NetworkState

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

fn in_current_span(self) -> Instrumented<Self>

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

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

§

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, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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