# Q4B · TCP connection lifecycle

Subject: Computer Networks

Exam: TEE

Reader: https://deep-learning-study-room.vercel.app/cn/#tee/papers/tee-paper-reexam/q4b

Canonical: https://deep-learning-study-room.vercel.app/read/cn/tee/papers/tee-paper-reexam--q4b/

TEE · Actual TEE paper · all questions · current syllabus 702AI0C023

### Actual PYQ · Q4B. What is the TCP three-way handshaking mechanism? Describe connection establishment, data transfer and connection termination in detail with the help of a diagram. [10 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.

Swipe across the diagram to read its labels ↔

![TCP: handshake, data and orderly close](https://deep-learning-study-room.vercel.app/cn/fig/tee-handshake.e053246177.svg)

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.

SYN and FIN each consume one sequence number; pure ACK consumes none.

| 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

1. Assume client’s next data sequence is 1201. It sends FIN with Seq=1201, meaning it has finished sending.
2. Server sends ACK=1202. The connection is half closed: the server can still send data until its application finishes.
3. Assume server has sent no data since the handshake. It sends FIN with Seq=5001.
4. 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.
5. 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.

#### Practical example

A client can finish uploading a request and close its sending direction while still receiving the server’s response. Full-duplex directions do not have to end at the same instant.

Source: Re-exam · 4 February 2026, original question paper page 2. Original marks retained; solution independently authored.
