Networking

TCP vs UDP: Networking Protocols, Reliability & Speed Compared

TCP guarantees reliable, ordered packet delivery with error checking; UDP prioritizes minimum latency and maximum speed without handshakes.

Comparison Matrix

Feature / Criterion Option A Option B
Connection Type Connection-oriented (requires 3-way SYN-ACK handshake) Connectionless (sends packets immediately without handshake)
Delivery Guarantee Guaranteed delivery; lost packets are automatically retransmitted Best-effort delivery; dropped packets are ignored
Order Guarantee Packets arrive strictly in the order they were transmitted Packets may arrive out of order or duplicated
Speed & Latency Higher latency due to acknowledgments and retransmissions Lowest possible latency with lightweight 8-byte header
Real-World Uses Web browsing (HTTP/HTTPS), Email (SMTP), File transfer (FTP) Live video streaming, VoIP calls, online multiplayer gaming, DNS

Advantages & Limitations

Key Advantages

  • 100% reliable data transmission without packet loss
  • Automatic congestion control and flow control
  • Guaranteed sequential data reconstruction

Trade-offs & Pitfalls

  • Three-way handshake introduces latency
  • Retransmission of lost packets creates head-of-line blocking

Engineering Verdict & Best Practices

Use TCP whenever complete data integrity is mandatory (e.g. web pages, APIs, payments). Use UDP whenever speed and real-time delivery outweigh the loss of occasional packets (e.g. video conferencing or gaming).

Frequently Asked Questions

Does HTTP/3 use TCP or UDP?

HTTP/3 uses QUIC, which runs on top of UDP to achieve zero-round-trip handshakes and eliminate head-of-line blocking while adding its own encryption and reliability!

Learn Real Architecture

Master both low-level systems and high-level web frameworks in DoxaTech Hub's 10-month bootcamp.

Start Learning Today