Menu

Earn Premium with Referrals

Invite your friends and earn Premium rewards through our referral program.

See how it works and start inviting friends.

TCP vs UDP
CN

TCP vs UDP

Connection-oriented vs Connectionless: Master the differences between the two most important protocols of the internet.

TCP (Transmission Control Protocol)

Connection-oriented, reliable, ordered. Before sending data, TCP establishes a connection via a three-way handshake.

PropertyDetails
Connection3-way handshake (SYN, SYN-ACK, ACK)
ReliabilityACKs every segment, retransmits lost ones
OrderingSequence numbers ensure in-order delivery
Flow controlPrevents overwhelming the receiver
Congestion controlPrevents overwhelming the network
Header size20-60 bytes
Use casesHTTP, SMTP, FTP, SSH

UDP (User Datagram Protocol)

Connectionless, best-effort, no ordering. “Fire and forget.”

PropertyDetails
ConnectionNone — just send
ReliabilityNo ACKs, no retransmission
OrderingNo guarantee
Flow/congestion controlNone
Header size8 bytes
Use casesDNS, VoIP, video streaming, gaming

Comparison

FeatureTCPUDP
Connection setup3-way handshakeNone
ReliabilityGuaranteed deliveryBest effort
SpeedSlower (overhead)Fast (minimal overhead)
Data orderingPreservedNot preserved
Header overhead20+ bytes8 bytes
Use whenAccuracy mattersSpeed/latency matters

Why Games Use UDP

In a fast-paced game, a lost packet containing a player’s position is obsolete a few milliseconds later. TCP would pause and retransmit the old data, causing lag (“rubber banding”). UDP keeps sending the latest position, accepting occasional loss for lower latency.

Q: Key differences between TCP and UDP?

A: TCP is connection-oriented, reliable, and ordered — but slower. UDP is connectionless, best-effort, and faster. Use TCP for accuracy (web, email). Use UDP for speed (streaming, gaming, DNS queries).

Q: Why do online games use UDP?

A: Because a new player position is more important than an old one. TCP retransmitting a lost packet would introduce lag. UDP accepts packet loss for speed — the game just uses the most recent update.

Q: Can UDP be made reliable?

A: Yes — the application layer can add ACKs, sequence numbers, and retransmission on top of UDP. QUIC (HTTP/3) does exactly this: reliable data over UDP, avoiding TCP head-of-line blocking.

My Private Notes

Notes are auto-saved locally to this device.