Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

What Is TCP? How Reliable Network Connections Work

Follow the TCP handshake, see how sequence numbers and acknowledgments recover lost data, and understand how TCP differs from IP and UDP.

Table of Contents

TCP, or Transmission Control Protocol, gives two applications a reliable, ordered stream of bytes over an IP network. IP addresses and routes packets. TCP uses ports, sequence numbers, acknowledgments, and retransmission to manage delivery between the applications.

What is TCP? Advantages and How Does it Work? Picture 1

How TCP opens and closes a connection

  1. The client sends SYN with its starting sequence number.
  2. The server sends SYN-ACK to acknowledge it and provide its own starting number.
  3. The client sends ACK, completing the normal three-way handshake.

Each direction of the connection can close separately. A FIN means one side has finished sending, and the other side can still send until it closes its direction. RST resets a connection rather than closing it gracefully.

What is TCP? Advantages and How Does it Work? Picture 2
TCP manages communication between application endpoints over IP.

How TCP keeps bytes in order

TCP divides outgoing data into segments. Sequence numbers track bytes in the stream. A cumulative acknowledgment identifies the next byte the receiver expects, so it can cover many bytes at once. If parts arrive out of order, the receiver can hold them while waiting for the missing bytes. TCP can retransmit when it detects loss or a timer expires.

The receive window limits how many bytes the sender can have in flight based on the receiver’s capacity. Congestion control separately adjusts sending to account for network conditions. These mechanisms help recover from loss, but TCP does not guarantee delivery within a fixed time. Applications still need timeouts and error handling.

What is in a TCP header?

The header is at least 20 bytes and grows when options are present. Common fields include:

  • Source and destination ports: Identify application endpoints. The pair of IP addresses and pair of ports identify a TCP connection.
  • Sequence and acknowledgment numbers: Track positions in the byte stream.
  • Flags: Indicate events such as opening, acknowledging, closing, or resetting the connection.
  • Data offset, receive window, and checksum: Give the header size, advertised receive capacity, and a way to detect accidental corruption.

For the exact layout, see RFC 9293. The TCP checksum does not encrypt or authenticate your traffic. A protocol such as TLS can provide those protections.

Where TCP fits

SSH and HTTP/1.1 or HTTP/2 commonly use TCP. UDP provides datagrams and leaves any delivery guarantees to the application or a higher-level protocol. For example, HTTP/3 uses QUIC over UDP. Read more about TCP versus UDP and how IP routers move packets between networks.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.