pub struct ConnectionState {Show 21 fields
pub id: ConnectionId,
pub addr: String,
pub local_ip: Option<IpAddr>,
pub remote_ip: Option<IpAddr>,
pub peer_address: String,
pub receive_buffer: VecDeque<u8>,
pub paired_connection: Option<ConnectionId>,
pub send_buffer: VecDeque<Vec<u8>>,
pub send_in_progress: bool,
pub next_send_time: Duration,
pub is_closed: bool,
pub send_closed: bool,
pub recv_closed: bool,
pub is_cut: bool,
pub cut_expiry: Option<Duration>,
pub close_reason: CloseReason,
pub send_buffer_capacity: usize,
pub send_delay: Option<Duration>,
pub recv_delay: Option<Duration>,
pub is_half_open: bool,
pub half_open_error_at: Option<Duration>,
}Expand description
Internal connection state for simulation
Fields§
§id: ConnectionIdUnique identifier for this connection within the simulation.
addr: StringNetwork address this connection is associated with.
local_ip: Option<IpAddr>Local IP address for this connection
remote_ip: Option<IpAddr>Remote IP address for this connection
peer_address: StringPeer address as seen by this connection.
FDB Pattern (sim2.actor.cpp:1149-1175):
- For client-side connections: the destination address (server’s listening address)
- For server-side connections: synthesized ephemeral address (random IP + port 40000-60000)
This simulates real TCP behavior where servers see client ephemeral ports, not the client’s identity address. As FDB notes: “In the case of an incoming connection, this may not be an address we can connect to!”
receive_buffer: VecDeque<u8>FIFO buffer for incoming data that hasn’t been read by the application yet.
paired_connection: Option<ConnectionId>Reference to the other end of this bidirectional TCP connection.
send_buffer: VecDeque<Vec<u8>>FIFO buffer for outgoing data waiting to be sent over the network.
send_in_progress: boolFlag indicating whether a ProcessSendBuffer event is currently scheduled.
next_send_time: DurationNext available time for sending messages from this connection.
is_closed: boolWhether this connection has been permanently closed by one of the endpoints
send_closed: boolWhether the send side is closed (writes will fail) - for asymmetric closure FDB: closeInternal() on self closes send capability
recv_closed: boolWhether the receive side is closed (reads return EOF) - for asymmetric closure FDB: closeInternal() on peer closes recv capability
is_cut: boolWhether this connection is temporarily cut (will be restored).
Unlike is_closed, a cut connection can be restored after a duration.
This simulates temporary network outages where the connection is not
permanently severed but temporarily unavailable.
cut_expiry: Option<Duration>When the cut expires and the connection is restored (in simulation time).
Only meaningful when is_cut is true.
close_reason: CloseReasonReason for connection closure - distinguishes FIN vs RST semantics.
When is_closed is true, this indicates whether it was graceful or aborted.
send_buffer_capacity: usizeSend buffer capacity in bytes. When the send buffer reaches this limit, poll_write returns Pending. Calculated from BDP (Bandwidth-Delay Product): latency × bandwidth.
send_delay: Option<Duration>Per-connection send delay override (asymmetric latency). If set, this delay is applied when sending data from this connection. If None, the global write_latency from NetworkConfiguration is used.
recv_delay: Option<Duration>Per-connection receive delay override (asymmetric latency). If set, this delay is applied when receiving data on this connection. If None, the global read_latency from NetworkConfiguration is used.
is_half_open: boolWhether this connection is in a half-open state (peer crashed). In this state:
- Local side still thinks it’s connected
- Writes succeed but data is silently discarded
- Reads block waiting for data that will never come
- After
half_open_error_at, errors start manifesting
half_open_error_at: Option<Duration>When a half-open connection starts returning errors (in simulation time). Before this time: writes succeed (data dropped), reads block. After this time: both read and write return ECONNRESET.
Trait Implementations§
Source§impl Clone for ConnectionState
impl Clone for ConnectionState
Source§fn clone(&self) -> ConnectionState
fn clone(&self) -> ConnectionState
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ConnectionState
impl RefUnwindSafe for ConnectionState
impl Send for ConnectionState
impl Sync for ConnectionState
impl Unpin for ConnectionState
impl UnwindSafe for ConnectionState
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)