ConnectionState

Struct ConnectionState 

Source
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: ConnectionId

Unique identifier for this connection within the simulation.

§addr: String

Network 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: String

Peer 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: bool

Flag indicating whether a ProcessSendBuffer event is currently scheduled.

§next_send_time: Duration

Next available time for sending messages from this connection.

§is_closed: bool

Whether this connection has been permanently closed by one of the endpoints

§send_closed: bool

Whether the send side is closed (writes will fail) - for asymmetric closure FDB: closeInternal() on self closes send capability

§recv_closed: bool

Whether the receive side is closed (reads return EOF) - for asymmetric closure FDB: closeInternal() on peer closes recv capability

§is_cut: bool

Whether 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: CloseReason

Reason for connection closure - distinguishes FIN vs RST semantics. When is_closed is true, this indicates whether it was graceful or aborted.

§send_buffer_capacity: usize

Send 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: bool

Whether 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

Source§

fn clone(&self) -> ConnectionState

Returns a duplicate of the value. Read more
1.0.0§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ConnectionState

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> CloneToUninit for T
where T: Clone,

§

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
§

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

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

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

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

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