TCP vs. UDP: What's the Difference?

TCP and UDP are both transport-layer protocols, yet they move data in almost opposite ways β€” here is how, step by step.

  1. What Are TCP and UDP?

    TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) are both transport-layer protocols that carry data across the internet. They operate at the same layer but handle data in almost opposite ways.

  2. Connection-Oriented vs. Connectionless

    TCP establishes a connection first through a three-way handshake β€” SYN, then SYN/ACK, then ACK β€” before sending any data. UDP skips that setup entirely and sends data immediately, with no connection established beforehand.

  3. Reliability and Ordering

    TCP confirms delivery, reorders packets that arrive out of sequence, and retransmits anything lost. UDP does none of that β€” if a packet is lost or arrives out of order, it simply stays that way.

  4. Header Overhead

    TCP's header is at least 20 bytes, carrying sequence numbers, acknowledgment numbers, and other control data. UDP's header is a mere 8 bytes, which makes it lighter and faster to process.

  5. Flow Control and Congestion Control

    TCP automatically adjusts its transmission rate to match network conditions using a sliding window and congestion-control algorithms. UDP has no such built-in mechanism β€” if rate control is needed, the application itself has to handle it.

  6. Where Each One Is Actually Used

    Web browsing (HTTP/HTTPS), email (SMTP), and file transfer (FTP) all rely on TCP, where accurate delivery matters most. DNS lookups, video streaming, online gaming, and VoIP calls mostly use UDP instead, where speed matters more than guaranteed delivery.

  7. QUIC: A New Protocol Built on Top of UDP

    More recently, QUIC has emerged β€” a protocol that layers its own reliability and encryption on top of UDP's speed. As the foundation for HTTP/3, QUIC is already used by Chrome, YouTube, and many other services.

Port numbers make this easier to understand

Both TCP and UDP use port numbers to identify which service a packet belongs to. Learning the common port numbers for everyday services β€” 80 and 443 for web traffic, 53 for DNS, and so on β€” makes the TCP/UDP distinction click much faster.

Curious about call quality on UDP-based services?

Internet calling (VoIP) is one of the best-known UDP-based services. Looking into how its SIP and RTP protocols actually operate is a good next step for understanding why VoIP tolerates some packet loss but not high latency.

Frequently Asked Questions

Is a DNS lookup TCP or UDP?

It uses UDP by default for speed. But it can fall back to TCP when the response is too large for a single UDP packet, or in situations like zone transfers where reliability matters more than speed.

Why do most online games use UDP?

Because real-time responsiveness matters more than anything else. Waiting for a lost packet to be retransmitted would make character movement feel even more unnatural, so games accept some packet loss in exchange for always pushing the latest state through as fast as possible.