Transmission Control Protocol (TCP) (original) (raw)

Last Updated : 11 Feb, 2026

TCP (Transmission Control Protocol) is a protocol that allows devices to communicate reliably over a network. It ensures that data reaches the destination correctly and in the right order, even if parts of the network are slow or unreliable.

Connection Establishment and Termination

Connection establishment and termination describe how two devices start and end a reliable communication session (mainly in TCP).

**1. Connection Establishment (Three-Way Handshake)

TCP is connection-orientated, meaning a connection must be established before any data is sent. This is done using a three-way handshake:

tcp_handshake_process

  1. **SYN (Synchronize): The sender sends a SYN segment to the receiver to request a connection.
  2. **SYN-ACK (Synchronize-Acknowledge): The receiver responds with a SYN-ACK segment, acknowledging the request and agreeing to the connection.
  3. **ACK (Acknowledge): The sender replies with an ACK, confirming the connection is established.

This process ensures both sender and receiver are ready and synchronized, preventing lost or misordered data at the start.

**2. Connection Termination (Four-Way Handshake)

Closing a TCP connection requires a four-step handshake to ensure both sides finish transmitting data safely:

  1. **FIN (Finish): The sender who wants to close the connection sends a FIN segment to the receiver.
  2. **ACK (Acknowledge): The receiver acknowledges the FIN with an ACK.
  3. **FIN (Finish) from Receiver: The receiver then sends its own FIN when it is ready to close the connection.
  4. **ACK (Acknowledge): The sender responds with an ACK, completing the termination.

This ensures that all remaining data is transmitted before the connection is fully closed.

Working

1. **Segmenting

2. **Routing via IP

3. Reassembly at Receiver

4. Acknowledgments (ACKs)

5. Retransmission

**6. Flow & Error Control

**Applications

1. **Web Browsing (HTTP/HTTPS)

2. **Email (SMTP, IMAP, POP3)

3. **File Transfer (FTP, SFTP)

4. **Remote Terminal Access (SSH, Telnet)

**Advantages