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.

TCP Three-Way Handshake Client Server 1. SYN (seq=x) Connection request 2. SYN-ACK (seq=y, ack=x+1) Connection acknowledgment 3. ACK (seq=x+1, ack=y+1) Final acknowledgment Connection Established

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.

TCP Connection Termination Client Server 1. FIN 2. ACK 3. FIN 4. ACK Connection Closed

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.

Updated on: 2026-03-16T23:36:12+05:30

38K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements