Computer Networks · TEE · mocks
Q4B · Transport-layer mechanism
TEE mock A · full paper
TEE · 100 attempted marks · solutions for every choice · current syllabus 702AI0C023
TEE practice mock · Q4B. What is TCP three-way handshaking? Explain establishment, data transfer and termination with labelled diagrams. [10 mock marks]
Answer
A TCP connection establishes each endpoint’s initial sequence number and confirms that both can receive. Use client initial sequence x=1000 and server initial sequence y=5000; assume no payload in the handshake.
Diagram: TCP: handshake, data and orderly close. Labels: TCP: handshake, data and orderly close | TCP: handshake, data and orderly close | Client | Server | SYN Seq=1000 | SYN+ACK Seq=5000, Ack=1001 | ACK Seq=1001, Ack=5001 | 200 data bytes: Seq=1001, last=1200 | ACK=1201 (next expected byte) | FIN Seq=1201 | ACK=1202; server may still send | FIN Seq=5001 (no server data here) | ACK=5002; common active-close TIME-WAIT | Pure ACK uses no sequence space. SYN and FIN each use one.
| Step | Segment | Meaning |
|---|---|---|
| 1 Client → server | SYN, Seq=1000 | Client proposes its starting sequence |
| 2 Server → client | SYN+ACK, Seq=5000, Ack=1001 | Server acknowledges client SYN and supplies its own start |
| 3 Client → server | ACK, Seq=1001, Ack=5001 | Client acknowledges server SYN; connection is established |
Data transfer
Client sends 200 bytes beginning at Seq=1001, so byte numbers are 1001…1200. The receiver acknowledges Ack=1201, the next byte expected. If bytes starting at 1201 are missing but later bytes arrive, the cumulative ACK remains 1201 until the gap is repaired. TCP may buffer out-of-order bytes; it delivers the byte stream in order. Each direction counts independently.
Orderly termination
- Assume client’s next data sequence is 1201. It sends FIN with Seq=1201, meaning it has finished sending.
- Server sends ACK=1202. The connection is half closed: the server can still send data until its application finishes.
- Assume server has sent no data since the handshake. It sends FIN with Seq=5001.
- Client responds with ACK=5002. In a common active-close path the client enters TIME-WAIT so delayed segments and retransmitted FINs can be handled before the tuple is reused.
- These are commonly four segments, but ACK and FIN can be combined and simultaneous close is possible. RST is an abort, not the same as the orderly FIN exchange.