- 2071 Shrawan · 5 marks
TCP connection establishment
Short answer
TCP establishes a connection via a three-way handshake: client sends SYN with its initial sequence number (ISN), server responds with SYN+ACK carrying its ISN and ack=ISN+1, client then sends ACK acknowledging the server's ISN+1. This synchronises sequence numbers and confirms readiness.
How is a TCP connection established? Explain.
TCP establishes a connection by the three-way handshake, which synchronises the sequence numbers of both sides and confirms that both are ready. The server must first do a passive open (listen), then the client does an active open (connect).
Client Server
CLOSED LISTEN
|--- SYN, seq=1000 ------------------>| SYN_RCVD
SYN_SENT |
|<-- SYN+ACK, seq=5000, ack=1001 ------|
|--- ACK, seq=1001, ack=5001 --------->|
ESTABLISHED ESTABLISHED
Steps (with example numbers)
- SYN: the client chooses an initial sequence number (ISN), say 1000, and sends a segment with SYN = 1. A SYN consumes one sequence number.
- SYN + ACK: the server chooses its own ISN (5000), sets SYN = 1 and ACK = 1, with ack number = 1000 + 1 = 1001. It also announces its window size and MSS.
- ACK: the client sends ACK = 1 with ack number 5000 + 1 = 5001. This segment can already carry data. The connection is now ESTABLISHED.
Why three steps?
- Two steps would not let the server know the client received its ISN.
- Random ISNs prevent old duplicate segments from being accepted by a new connection.
Notes
- If the SYN is lost, the client retransmits after a timeout.
- A SYN flood attack sends many SYNs without the final ACK to fill the server's half-open connection queue; SYN cookies are a defence.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- TCP connection establishment and release · Computer Networks and Security, chapter 5
- TCP connection and graceful termination · Computer Networks and Security, chapter 5