Skip to main content

Command Palette

Search for a command to run...

TCP vs UDP

How Data Actually Moves on the Internet

Published
4 min readView as Markdown
TCP vs UDP
S

I learn things, break them, fix them, and write about it so you don’t have to.

Why the Internet Needs Rules to Send Data

The internet is not one single network. It’s a massive collection of networks connected together.
When your app sends data, that data is broken into packets and travels through many unknown paths.

Without rules, packets would:

  • Get lost

  • Arrive out of order

  • Overwhelm receivers

  • Corrupt data

That’s why the internet uses transport protocols.
Two of the most important ones are TCP and UDP.

Exploring the OSI Transport Layer's TCP and UDP | Medium

What Are TCP and UDP

Both TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) live at the transport layer.

Their job is simple:

Move data from one application to another across the network.

But they do it in very different ways.

Comprehensive Guide to the OSI Model, TCP/IP Model, and Application Layer -  DEV Community

TCP: Safe, Reliable, and Careful

TCP is connection-oriented and reliable.

Before sending data, TCP:

  • Establishes a connection

  • Checks that the receiver is ready

  • Sends data in order

  • Confirms delivery

  • Retransmits lost data

Analogy

TCP is like a phone call:

  • You say “Hello”

  • The other person confirms

  • You speak in order

  • If something isn’t heard, you repeat it

Key Behaviour

  • Guaranteed delivery

  • Ordered packets

  • Error detection and correction

  • Flow control and congestion control

  • Slightly slower due to checks and confirmations

What is the User Datagram Protocol (UDP)? Full Guide | TechTarget

UDP: Fast, Simple, and Risky

UDP is connectionless and unreliable.

UDP:

  • Does not establish a connection

  • Sends data immediately

  • Does not wait for confirmation

  • Does not retransmit lost packets

Analogy

UDP is like a public announcement:

  • You broadcast the message

  • Whoever hears it, hears it

  • If someone misses it, too bad

Key Behaviour

  • No delivery guarantee

  • No ordering

  • No retransmission

  • Very low overhead

  • Extremely fast

Key Differences Between TCP and UDP

FeatureTCPUDP
ConnectionRequiredNot required
ReliabilityGuaranteedNot guaranteed
Packet orderMaintainedNot maintained
Error handlingYesOptional
SpeedSlower (but stable)Faster
OverheadHighLow

Introductory Guide to Tuning Your TCP and UDP Performance

When to Use TCP

Use TCP when:

  • Data accuracy matters

  • Missing even one byte is unacceptable

  • Order of data is critical

Common TCP Use Cases

  • Web pages (HTTP/HTTPS)

  • File transfers (FTP)

  • Emails (SMTP)

  • Software downloads

  • APIs

If data must be correct, TCP is the right choice.

When to Use UDP

Use UDP when:

  • Speed matters more than accuracy

  • Occasional data loss is acceptable

  • Real-time communication is needed

Common UDP Use Cases

  • Video streaming

  • Online gaming

  • Voice calls (VoIP)

  • Live broadcasts

  • DNS queries

If data must be fast, UDP is the right choice.

Common Real-World Examples

Watching a Website

Uses TCP
Every byte of HTML, CSS, and JavaScript must arrive correctly.

Video Calls or Live Streaming

Uses UDP
A small glitch is acceptable. Delay is not.

DNS Lookups

Uses UDP
Fast request, fast response. If it fails, retry.

What Is HTTP and Where It Fits

This is where beginners often get confused.

HTTP is NOT a transport protocol.

HTTP is an application-layer protocol.

Its job is to define:

  • Requests (GET, POST)

  • Responses (status codes, headers, body)

HTTP does not send data itself.

Understanding the Journey of HTTP Requests Over TCP Connections | by  Sesmiat | Medium

Relationship Between HTTP and TCP

HTTP runs on top of TCP.

Think of it like this:

  • TCP = delivery truck

  • HTTP = package format and rules

HTTP depends on TCP to:

  • Ensure reliable delivery

  • Maintain order

  • Handle retransmissions

That’s why HTTP does not replace TCP.

Clearing a Common Confusion

“Is HTTP the same as TCP?”

No.

  • TCP moves data safely

  • HTTP defines what the data means

They solve different problems at different layers.

Final Takeaway

  • TCP is safe and reliable

  • UDP is fast and lightweight

Modern systems use both, depending on the problem they’re solving.

Understanding when and why each is used helps you:

  • Debug network issues

  • Design better systems

  • Choose the right protocol for the job

More from this blog

Learn With Sneha

23 posts

Learn with Sneha is a personal tech blog focused on learning in public. Breaking down concepts, sharing mistakes, and explaining things clearly once they finally make sense.