TcpState

Namespace inet::tcp

TcpState

enum

TCP FSM states

Brief descriptions (cf RFC 793, page 20):

LISTEN - waiting for a connection request SYN-SENT - part of 3-way handshake (waiting for peer's SYN+ACK or SYN) SYN-RECEIVED - part of 3-way handshake (we sent SYN too, waiting for it to be acked) ESTABLISHED - normal data transfer FIN-WAIT-1 - FIN sent, waiting for its ACK (or peer's FIN) FIN-WAIT-2 - our side of the connection closed (our FIN acked), waiting for peer's FIN CLOSE-WAIT - FIN received and acked, waiting for local user to close LAST-ACK - remote side closed, FIN sent, waiting for its ACK CLOSING - simultaneous close: sent FIN, then got peer's FIN TIME-WAIT - both FIN's acked, waiting for some time to be sure remote TCP received our ACK CLOSED - represents no connection state at all.

Note: FIN-WAIT-1, FIN-WAIT-2, CLOSING, TIME-WAIT represents active close (that is, local user closes first), and CLOSE-WAIT and LAST-ACK represents passive close.

Source code

//
// TCP FSM states
//
// Brief descriptions (cf RFC 793, page 20):
//
// LISTEN - waiting for a connection request
// SYN-SENT - part of 3-way handshake (waiting for peer's SYN+ACK or SYN)
// SYN-RECEIVED - part of 3-way handshake (we sent SYN too, waiting for it to be acked)
// ESTABLISHED - normal data transfer
// FIN-WAIT-1 - FIN sent, waiting for its ACK (or peer's FIN)
// FIN-WAIT-2 - our side of the connection closed (our FIN acked), waiting for peer's FIN
// CLOSE-WAIT - FIN received and acked, waiting for local user to close
// LAST-ACK - remote side closed, FIN sent, waiting for its ACK
// CLOSING - simultaneous close: sent FIN, then got peer's FIN
// TIME-WAIT - both FIN's acked, waiting for some time to be sure remote TCP received our ACK
// CLOSED - represents no connection state at all.
//
// Note: FIN-WAIT-1, FIN-WAIT-2, CLOSING, TIME-WAIT represents active close (that is,
// local user closes first), and CLOSE-WAIT and LAST-ACK represents passive close.
//
enum TcpState
{
    TCP_S_INIT = 0;
    TCP_S_CLOSED = 1;
    TCP_S_LISTEN = 2;
    TCP_S_SYN_SENT = 3;
    TCP_S_SYN_RCVD = 4;
    TCP_S_ESTABLISHED = 5;
    TCP_S_CLOSE_WAIT = 6;
    TCP_S_LAST_ACK = 7;
    TCP_S_FIN_WAIT_1 = 8;
    TCP_S_FIN_WAIT_2 = 9;
    TCP_S_CLOSING = 10;
    TCP_S_TIME_WAIT = 11;
}

File: src/inet/transportlayer/tcp/TcpConnectionState.msg