Transmission Control Protocol (TCP)

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.

  • It works at the Transport Layer (Layer 4) of the OSI model and is an essential part of the TCP/IP protocol suite used for Internet communication.
  • TCP establishes a logical connection between the sender and receiver before data transmission begins.
  • It ensures that data is delivered accurately and in the same order in which it was sent using acknowledgements and sequence numbers.
  • TCP detects errors using checksums and retransmits lost or corrupted packets to maintain data integrity.
  • It controls the data transmission rate to avoid overwhelming the receiver and adapts to network congestion for efficient communication.

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

  • When an application sends data (like an email or file), TCP breaks the data into smaller chunks called segments.
  • Each segment has a header containing information like sequence numbers, ports, and flags.
  • This makes it easier to send large amounts of data over the network reliably.

2. Routing via IP

  • Once TCP creates segments, they are handed to IP (Internet Protocol).
  • IP is responsible for delivering the segments from the sender to the receiver, possibly through multiple routers.
  • TCP doesn’t care about the path—IP handles routing and addressing.

3. Reassembly at Receiver

  • Segments may arrive out of order because they can take different paths through the network.
  • TCP at the receiver uses sequence numbers to reassemble the segments into the correct order to reconstruct the original message.

4. Acknowledgments (ACKs)

  • The receiver sends an ACK for every segment (or group of segments) it receives correctly.
  • This tells the sender that the data has arrived safely.
  • If an ACK is not received, TCP assumes the segment was lost and triggers retransmission.

5. Retransmission

  • If the sender does not receive an acknowledgment within a certain time, it resends the missing segment.
  • This ensures no data is lost, making TCP reliable.

6. Flow & Error Control

  • Flow Control: TCP prevents the sender from sending too much data too quickly for the receiver to handle, using a sliding window mechanism.
  • Error Control: TCP checks for corrupted segments using checksums and requests retransmission if needed.
  • Together, these mechanisms ensure data is delivered reliably and efficiently, without overloading the network or the receiver.

Applications

1. Web Browsing (HTTP/HTTPS)

  • Websites send and receive data in small chunks called packets.
  • TCP ensures these packets arrive in order and completely, so pages load correctly without missing images or broken content.
  • HTTPS adds encryption, but TCP still handles reliability under the hood.

2. Email (SMTP, IMAP, POP3)

  • Sending and receiving emails requires all message data to arrive intact.
  • TCP ensures no part of the email is lost or corrupted, so attachments and text are received correctly.

3. File Transfer (FTP, SFTP)

  • Transferring files over a network involves large amounts of data.
  • TCP divides files into segments, reorders them at the destination, and retransmits lost segments, ensuring the file is received exactly as sent.

4. Remote Terminal Access (SSH, Telnet)

  • When you connect to a remote computer, you send commands and receive responses in real time.
  • TCP ensures that every keystroke or command is reliably transmitted and arrives in order, maintaining a stable connection for remote management.

Advantages

  • Error-Free Data Transfer: TCP detects errors during transmission and retransmits lost or corrupted data, ensuring accurate delivery.
  • Ordered Delivery: Data packets are received in the same sequence in which they were sent, maintaining data consistency.
  • Flow Control: Prevents the sender from overwhelming the receiver by controlling the rate of data transmission.
  • Congestion Control: Adjusts the sending speed based on network traffic conditions to reduce packet loss and congestion.
  • Reliable Communication: Ensures complete and dependable data transfer, making it suitable for critical applications.
  • Widely Supported and Standardized: TCP is a globally accepted protocol, supported by all major operating systems and network devices.
Comment

Explore