TCP Connection Management

Before exchanging data, sender and receiver process handshake to:

  • agree to establish connection (each knowing the other is willing to establish connection).
  • agree on connection parameters (e.g., starting sequence #).
  • decides buffer size for flow control.

2-way handshake problem

  • The server may receive extraneous connection request due to delay.
  • This holds server resources wastefully, not knowing what happended on the client side.
  • This can be used as DDos attack by invoking many hanging connections.

TCP 3-way handshake


  • Client chooses initial sequence number x and sends TCP SYN(synchronization) message to the client.
    • This doesn’t involve ACK yet.
  • Server also chooses initial sequence number y and sends TCP SYNACK message, acknowledging client’s SYN.
    • Server doesn’t commit to connection yet.
  • Client receives SYNACK(x) which indicates the server is alive, and sends ACK for server’s SYNACK.
    • This segment can contain client-to-server data.
  • Server receives ACK(y) which indicates the client is alive.
  • Then, connection establishment is agreed.

Closing a TCP connection

  • Client and server each close their side of connection.
    • each sends TCP segement with FIN bit = 1.
  • Receiver responds to received FIN with ACK.
    • on receiving FIN, ACK can be combined with own FIN to agree on closing the connection.
  • Simultaneous FIN exchanges can be handled.
  • This means that client has to send “close request” and receive ACK for reliable termination.