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: u64Counter for generating unique connection IDs.
next_listener_id: u64Counter for generating unique listener IDs.
config: NetworkConfigurationNetwork 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: DurationLast 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
impl NetworkState
Sourcepub fn new(config: NetworkConfiguration) -> Self
pub fn new(config: NetworkConfiguration) -> Self
Create a new network state with the given configuration.
Sourcepub fn parse_ip_from_addr(addr: &str) -> Option<IpAddr>
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.
Sourcepub fn is_partitioned(
&self,
from_ip: IpAddr,
to_ip: IpAddr,
current_time: Duration,
) -> bool
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
Sourcepub fn is_connection_partitioned(
&self,
connection_id: ConnectionId,
current_time: Duration,
) -> bool
pub fn is_connection_partitioned( &self, connection_id: ConnectionId, current_time: Duration, ) -> bool
Check if a connection is partitioned (cannot send messages)