TCP

Transmission Control Protocol

Initiation

Operates through a 3 way opening handshake

  • Client Syn --> Server
  • Server Syn-Ack --> Client
  • Client Ack --> Server

  1. The client sends a Syn segment to the server with a randomly generated sequence number. The client enters the Syn state.
  2. The server, currently in the LISTEN state (assuming it is online), responds with a Syn/Ack segment, containing its own randomly generated sequence number. The server enters the Syn state.
  3. The client responds with an Ack segment. The client assumes the connection is ESTABLISHED.
  4. The server opens a connection with the client and enters the ESTABLISHED state.

Termination - Abrupt

Terminates communication abruptly with an Rst segment

Termination - Graceful

Graceful exit to the connection is done through a 4-way handshake consisting of:

  • Client Fin (enters Fin-WAIT1 state) --> Server
  • Server Ack (enters CLOSE-WAIT state) --> Client
  • Client (Receives Ack and enters Fin-WAIT2 state) --> Server
  • Server Fin (enters LAST-Ack state) --> Client
  • Client Ack (enters TIME-WAIT state) --> Server

  1. The client sends a Fin segment to the server and enters the Fin-WAIT1 state.
  2. The server responds with an Ack segment and enters the CLOSE-WAIT state.
  3. The client receives the Ack segment and enters the Fin-WAIT2 state. The server sends its own Fin segment to the client and goes to the LAST-Ack state.
  4. The client responds with an Ack and enters the TIME-WAIT state. After a defined period, the client closes its connection.
  5. The server closes the connection when it receives the Ack from the client.

Backlinks