pub enum TcpState {
Closed,
SynSent,
SynReceived,
Established,
FinWait1,
FinWait2,
CloseWait,
Closing,
LastAck,
TimeWait,
Unknown,
}Expand description
TCP connection state as defined in RFC 793.
Variants§
Closed
Initial state, connection not yet established
SynSent
Connection attempt sent, waiting for ACK
SynReceived
Received SYN, sent SYN+ACK, waiting for ACK
Established
Connection established, data transfer possible
FinWait1
Application initiated close, waiting for ACK
FinWait2
Received ACK for FIN, waiting for remote FIN
CloseWait
Received remote FIN, waiting for application to close
Closing
Application closed, sent FIN, waiting for ACK
LastAck
Sent FIN and received ACK, waiting for remote FIN
TimeWait
Received FIN and sent ACK, waiting for application to close
Unknown
Unknown or invalid state
Implementations§
Source§impl TcpState
impl TcpState
Sourcepub fn color(&self) -> &str
pub fn color(&self) -> &str
Get the color name for UI rendering of this state.
Returns a color name that can be used with ratatui’s Color.
Sourcepub fn short_name(&self) -> &str
pub fn short_name(&self) -> &str
Get a short display name for the state.
Sourcepub fn short_name_3char(&self) -> &str
pub fn short_name_3char(&self) -> &str
Get an ultra-short display name (3 characters max) for compact UI.
Sourcepub fn transition(&self, syn: bool, ack: bool, fin: bool, rst: bool) -> Self
pub fn transition(&self, syn: bool, ack: bool, fin: bool, rst: bool) -> Self
Determine the next state based on current state and TCP flags.
This implements a simplified TCP state machine transition logic.
Sourcepub fn from_flags(syn: bool, ack: bool, fin: bool, rst: bool) -> Self
pub fn from_flags(syn: bool, ack: bool, fin: bool, rst: bool) -> Self
Create a TcpState from TCP flags directly.
This is a simpler alternative that maps flag combinations to states without full state machine tracking.
Note: ACK-only packets (ack=true, syn=false, fin=false) indicate an established connection, which handles the mid-connection monitoring scenario where we start tracking after the handshake.