Networking Fundamentals

TCP vs UDP — Key Differences Explained

G Gurpreet Singh July 28, 2026 4 min read
TCP vs UDP — Key Differences Explained

TCP vs UDP: What’s the Difference?

TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) are the two main protocols operating at Layer 4 (Transport layer) of the OSI model. Both deliver data between applications using port numbers, but they do it in fundamentally different ways. TCP is connection-oriented and reliable — it guarantees delivery. UDP is connectionless and fast — it sends data without confirmation.

TCP vs UDP Comparison Table

FeatureTCPUDP
Connection typeConnection-oriented (3-way handshake)Connectionless
ReliabilityGuaranteed deliveryNo guarantee
OrderingOrdered delivery (sequence numbers)No ordering
Error checkingYes — checksum + retransmissionChecksum only, no retransmission
Flow controlYes (windowing)No
Congestion controlYesNo
SpeedSlower (overhead)Faster (no overhead)
Header size20–60 bytes8 bytes
Use casesWeb, email, file transfer, SSHDNS, VoIP, streaming, gaming, DHCP
OSI LayerLayer 4Layer 4

How TCP Works — The 3-Way Handshake

Before TCP can send data, it establishes a connection using the 3-way handshake:

  1. SYN: Client sends a SYN (synchronize) packet to the server requesting a connection.
  2. SYN-ACK: Server responds with SYN-ACK (synchronize-acknowledge) confirming receipt and readiness.
  3. ACK: Client sends ACK (acknowledge) to complete the connection.

Data transfer begins after the handshake. When the session ends, TCP uses a 4-way FIN/ACK process to gracefully close the connection.

TCP Key Features

Sequence Numbers

Every byte of data is assigned a sequence number, allowing the receiver to reorder segments that arrive out of order and request retransmission of missing ones.

Acknowledgments

The receiver sends ACK numbers confirming which bytes have been received. If the sender doesn’t receive an ACK within a timeout period, it retransmits the segment.

Flow Control (Windowing)

TCP uses a sliding window mechanism to control how much data can be sent before requiring an acknowledgment, preventing the sender from overwhelming the receiver.

Congestion Control

TCP monitors network congestion and reduces transmission rate when congestion is detected (algorithms: slow start, congestion avoidance, fast retransmit, fast recovery).

How UDP Works

UDP is dramatically simpler than TCP. It adds only port numbers, length, and a checksum to the data before sending. There is no connection establishment, no acknowledgment, no retransmission, and no ordering guarantee. This simplicity makes UDP extremely fast and lightweight — but at the cost of reliability.

Applications that use UDP either don’t need guaranteed delivery (DNS), can tolerate some loss (voice/video streaming), or implement their own reliability mechanisms at the application layer (QUIC protocol used by HTTP/3).

TCP vs UDP Port Numbers

ProtocolTransportPortUse
HTTPTCP80Web browsing
HTTPSTCP443Secure web browsing
FTP (data)TCP20File transfer data
FTP (control)TCP21File transfer control
SSHTCP22Secure remote access
TelnetTCP23Remote access (insecure)
SMTPTCP25Email sending
DNSUDP (TCP for zone transfers)53Domain name resolution
DHCPUDP67/68IP address assignment
TFTPUDP69Simple file transfer
SNMPUDP161Network management
VoIP (RTP)UDPVariesVoice over IP
NTPUDP123Time synchronization
RDPTCP3389Remote desktop

When to Use TCP vs UDP

Use TCP when:

  • Data integrity is critical (financial transactions, file downloads, email).
  • Order of delivery matters (database queries, web pages).
  • The application cannot tolerate data loss.

Use UDP when:

  • Speed is more important than reliability (live video streaming, online gaming).
  • Small transactions where overhead is unjustifiable (DNS queries).
  • Broadcasting or multicasting (DHCP discovery, routing protocols like RIP).
  • The application handles its own reliability (QUIC/HTTP3).

Real-World Examples

  • Netflix streaming: Uses TCP for HTTP/HTTPS delivery of video segments (adaptive bitrate streaming via HTTP).
  • Zoom video calls: Uses UDP for real-time audio/video — a dropped frame is better than a delayed one.
  • DNS lookup: Uses UDP for queries (fast, single request-response), TCP for zone transfers (large, must be complete).
  • Online gaming: Typically UDP — a missing game state update is acceptable; waiting for retransmission would cause lag.
  • File download (FTP/SFTP): TCP — every byte must arrive correctly.

QUIC — The Future of Transport Protocols

QUIC (Quick UDP Internet Connections) is a modern transport protocol developed by Google, now standardized as the basis for HTTP/3. It runs over UDP but implements its own reliability, congestion control, and encryption at the application layer — combining the speed of UDP with reliability closer to TCP. QUIC significantly reduces connection setup time (0-RTT for returning connections) and handles connection migration (e.g., switching from WiFi to cellular).

Frequently Asked Questions

Is UDP faster than TCP?

Yes. UDP has significantly less overhead — no handshake, no acknowledgments, no flow control. For applications where speed matters more than reliability (live streaming, gaming, VoIP), UDP is the better choice.

Can UDP be made reliable?

Yes, at the application layer. QUIC is the best example — it uses UDP but implements reliability, ordering, and encryption in the application layer. Many modern protocols (DTLS, WebRTC) also add reliability on top of UDP.

Does ping use TCP or UDP?

Neither. Ping uses ICMP (Internet Control Message Protocol) which operates at Layer 3 (Network layer) and is not a Layer 4 protocol.

Which is more secure — TCP or UDP?

Neither is inherently more secure. Security is handled by encryption protocols (TLS/DTLS) that run on top of TCP or UDP. HTTPS uses TLS over TCP. DTLS provides TLS-equivalent security for UDP-based protocols.

Related: TCP Complete Guide | OSI Model Guide | IP Address Guide | Firewall Guide

GU
Written by

Gurpreet Singh

Hey! I"m Gurpreet Singh and I Have 7+ Years of experience in the Network & Security Domain as well as the Cloud Infra Domain. I am Certified with Cisco ( CCNA ), CheckPoint ( CCSA ), 1xAWS, 3xAZURE, and 3xNSE. So I love to share my tech knowledge with you.

Leave a Reply

Your email address will not be published. Required fields are marked *