Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
What is the TCP Connection Establishment?
TCP Connection Establishment is the process by which two hosts create a reliable, connection-oriented session before transmitting data. This process ensures both sides are ready to communicate and agree on initial parameters for data exchange.
To make transport services reliable, TCP uses a three-way handshake mechanism to establish connections. This mechanism synchronizes both ends of a network by enabling both sides to agree upon original sequence numbers and confirm readiness for data transmission.
How the Three-Way Handshake Works
The three-way handshake prevents packets from being shared or retransmitted during session establishment. Each host randomly selects a sequence number to track bytes within the data stream it sends and receives.
Step-by-Step Process
-
Step 1 − SYN: The requesting host (Client) sends a SYN segment with its initial sequence number (x) to the server's port.
-
Step 2 − SYN-ACK: The server acknowledges the client's SYN by sending SYN-ACK with its own sequence number (y) and acknowledgment number (x+1).
-
Step 3 − ACK: The client acknowledges the server's SYN by sending ACK with sequence number (x+1) and acknowledgment number (y+1).
Connection Termination Protocol
While three segments establish a connection, four segments are required to terminate a TCP connection. Since TCP connections are full-duplex (data flows independently in each direction), each direction must be shut down separately using a four-way handshake.
Either end can send a FIN (finish) segment when it finishes sending data. The end that sends the first FIN performs an active close, while the receiving end performs a passive close. A FIN indicates no more data will flow in that direction, but the connection can still receive data from the other direction.
Key Features
| Aspect | Connection Establishment | Connection Termination |
|---|---|---|
| Segments Required | 3 segments (three-way handshake) | 4 segments (four-way handshake) |
| Purpose | Synchronize sequence numbers | Gracefully close each direction |
| Control Flags | SYN, ACK | FIN, ACK |
Conclusion
TCP connection establishment uses a three-way handshake to synchronize sequence numbers and confirm both hosts are ready for data transmission. Connection termination requires a four-way handshake to gracefully close each direction of the full-duplex connection independently.
