---
title: "TCP connection establishment and release"
subject: "Computer Networks and Security"
chapter: 5
key: "semester_7/computer_networks_and_security:tcp-establish-release"
source: https://www.bctengineer.com/q/semester_7/computer_networks_and_security/tcp-establish-release
site: BCT Engineering
---

# TCP connection establishment and release

Computer Networks and Security · Chapter 5: Transport Layer

- Asked in: 2074 Chaitra, 4 marks
- Video: [Lec-71: TCP connection Establishment and connection Termination | Transport layer](https://www.youtube.com/watch?v=qIEHUUt2Wfc) — Gate Smashers
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_7/computer_networks_and_security/tcp-establish-release
- Whole chapter: https://www.bctengineer.com/md/semester_7/computer_networks_and_security/chapter-5

## Question

How is a connection established and released in TCP?

## Short answer

Connection establishment uses a three-way handshake: client sends SYN, server replies SYN+ACK, client sends ACK. Release is four-way: each side independently sends FIN and receives ACK, with the final endpoint in TIME_WAIT (2×MSL) to discard old segments and retransmit lost ACKs.

## Answer

TCP is connection-oriented, so a connection is opened with a three-way handshake and closed with a four-step exchange.

#### Connection establishment (three-way handshake)
```text
  Client                         Server
    |-------- SYN, seq=x -------->|   (server in LISTEN)
    |<--- SYN+ACK, seq=y, ack=x+1-|
    |-------- ACK, ack=y+1 ------>|
    |        ESTABLISHED          |
```
1. Client sends SYN with its initial sequence number x.
2. Server replies SYN+ACK with its own number y and acknowledges x+1.
3. Client sends ACK y+1. Data transfer can begin.

#### Connection release (four-way)
```text
  Client                         Server
    |------------ FIN ----------->|
    |<----------- ACK ------------|  (client -> server closed)
    |<----------- FIN ------------|
    |------------ ACK ----------->|
    | TIME_WAIT (2 x MSL), closed |
```
Each direction is closed independently by a FIN and acknowledged by an ACK. After the last ACK the client waits 2 × MSL in TIME_WAIT so a lost ACK can be resent and old segments die out. An abrupt close uses RST.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Which sequence correctly describes TCP connection establishment?
   A. SYN, ACK, SYN+ACK
   B. SYN, SYN+ACK, ACK
   C. SYN, ACK, ACK
   D. SYN+ACK, SYN, ACK
   Answer: B. Client sends SYN, server replies SYN+ACK, client finishes with ACK. (Key point: Three-way handshake)

2. Why does TCP release a connection with four segments?
   A. Each direction is closed independently by its own FIN and ACK
   B. The server must retransmit every segment twice
   C. RST is required in every close
   D. Sequence numbers must be reset in four steps
   Answer: A. The connection is full duplex, so each direction gets a FIN acknowledged by an ACK. (Key point: Four-step release)

3. Why does the client wait 2 x MSL in TIME_WAIT after the last ACK?
   A. To let the server choose a new ISN
   B. So a lost ACK can be resent and old segments die out
   C. To increase the window size
   D. To wait for the SYN+ACK
   Answer: B. The wait allows retransmission of a lost final ACK and lets delayed segments disappear. (Key point: TIME_WAIT)

## Related in Computer Networks and Security

- [TCP connection establishment](https://www.bctengineer.com/question.md?key=semester_7%2Fcomputer_networks_and_security%3Atcp-connection-establishment) — Computer Networks and Security, chapter 5
- [TCP connection and graceful termination](https://www.bctengineer.com/question.md?key=semester_7%2Fcomputer_networks_and_security%3Atcp-connection-termination) — Computer Networks and Security, chapter 5

## Related in other subjects

- [Rod released from horizontal position](https://www.bctengineer.com/question.md?key=semester_3%2Fengineering_mechanics%3Arod-release-from-horizontal-reaction) — Engineering Mechanics, chapter 6
