kernelry

TCP vs UDP

At the Transport Layer (Layer 4) of the OSI model, TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) are the two foundational protocols of the internet. Choosing between them involves a fundamental trade-off between reliability (TCP) and speed/low-overhead (UDP).

TCP

Reliable and Connection-Oriented

Strengths

  • •Guarantees delivery of packets (retransmits lost data)
  • •Guarantees ordered delivery (reassembles packets in sequence)
  • •Congestion control and flow control mechanisms
  • •Connection-oriented (Three-way handshake)

Weaknesses

  • •Higher latency due to handshakes and acknowledgments
  • •Larger header size (20+ bytes) and higher overhead
  • •Head-of-line blocking (one lost packet delays all subsequent data)

Best For:

Web browsing (HTTP/HTTPS), email (SMTP), file transfers (FTP, SSH), and any scenario where data integrity is paramount.

UDP

Fast and Connectionless

Strengths

  • •Low latency (no handshake required to start sending)
  • •Low overhead (smaller header size of 8 bytes)
  • •Supports multicast and broadcast broadcasting
  • •No head-of-line blocking (packets are independent)

Weaknesses

  • •No guarantee of delivery (packets can be dropped silently)
  • •No guarantee of order (packets arrive as they arrive)
  • •No built-in congestion or flow control

Best For:

Video streaming, VoIP/voice calls, online gaming, DNS queries, and real-time metrics collection.

Feature Comparison

AspectTCPUDP
Connection TypeConnection-oriented (Requires handshake)Connectionless (Fire and forget)
ReliabilityHigh (Guarantees delivery)Low (Best effort)
OrderingGuaranteed in sequenceNot guaranteed
Speed / LatencySlower (Overhead from ACKs and handshakes)Faster (Minimal overhead)
Header Size20 bytes (minimum)8 bytes
Flow/Congestion ControlYes built-inNo (Must be handled at application layer if needed)

Architecture Rule of Thumb

When deciding between UDP and TCP, evaluate whether *freshness* of data takes priority over *completeness*. In live streaming or VoIP, a dropped packet retransmitted seconds later is worthless (TCP overhead); dropping the packet to render current frames is preferable (UDP). Modern protocols like QUIC (HTTP/3) run atop UDP to achieve zero-RTT handshakes and mitigate head-of-line blocking.

Common Mistakes

  • •Assuming UDP is entirely unreliable (it just leaves reliability to the application layer).
  • •Forgetting the TCP 3-way handshake (SYN, SYN-ACK, ACK).
  • •Thinking DNS only uses UDP (it uses UDP for standard queries, but TCP for zone transfers or large responses).

Related Topics

Interactive Scenario Drills

That's where we come in.

Being able to explain when you would choose TCP or UDP is different from reading a comparison table.

Kernelry helps you rehearse technical questions, evidence-led debugging, safe next steps, and the clear communication teams expect. The drills adapt to your answer, so you practice the reasoning rather than memorize a company-specific script. During early access, free accounts include ten daily scenarios across our mixed question pool, with no credit card required.