Skip to main content

ConnectionState

Struct ConnectionState 

Source
pub struct ConnectionState {
Show 15 fields 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 next_send_time: Duration, pub flags: ConnectionFlags, 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 half_open_error_at: Option<Duration>, pub last_data_delivery_scheduled_at: Option<Duration>,
}
Expand description

Internal connection state for simulation

Fields§

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

§next_send_time: Duration

Next available time for sending messages from this connection.

§flags: ConnectionFlags

Boolean flags (closure, chaos, send-in-progress) packed into a bitfield. Use the named accessor methods on ConnectionFlags to inspect or update individual bits.

§cut_expiry: Option<Duration>

When the cut expires and the connection is restored (in simulation time). Only meaningful when flags.is_cut() is true.

§close_reason: CloseReason

Reason for connection closure - distinguishes FIN vs RST semantics. When flags.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.

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

§last_data_delivery_scheduled_at: Option<Duration>

Time of the most recently scheduled DataDelivery event from this connection. Used to ensure FinDelivery is scheduled after the last data arrives at the peer.

Trait Implementations§

Source§

impl Clone for ConnectionState

Source§

fn clone(&self) -> ConnectionState

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 ConnectionState

Source§

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

Formats the value using the given formatter. Read more

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

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

Source§

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.

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
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.

Source§

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.
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