๐๏ธ Introduction
Hey Reader โ welcome back
The opening line already sounds like an NPC, never mind.
This networking series has been stretching my brain in the best way possible.
Every post peels back another layer of how the internet actually works โ not the magical version we imagine, but the engineered one.
So far, weโve talked about:
Blog 1: Understanding Network Devices - DEV Community
Blog 2: How DNS Resolution Works - DEV Community
Blog 3: DNS Record Types Explained - DEV Community
Now comes the next question:
Once the destination is knownโฆ how does data actually travel?
Thatโs where TCP and UDP come in โ the rules of the internet.
๐ TCP vs UDP โ Two Ways Data Travels
Humans love rules.
Turns out, the internet does too.
Once computers started talking to each other at scale, rules became unavoidable.
Without rules, data would:
- Get lost
- Arrive out of order
- Or never arrive at all
TCP and UDP are the transport-layer rules that prevent that chaos.
๐ Why Internet Needs Rules?
The internet is like a busy highway.
Without traffic rules:
- Cars would crash
- Some would never reach their destination
- Others would arrive completely out of order
On the internet, those โcarsโ are data packets, and the rules they follow live in the transport layer.
๐ What happens After DNS
When DNS finishes its job, a human-readable domain like example.com is resolved into an IP address like 93.184.216.34
Once thatโs done:
The destination is known
Now the real work begins: moving data
At this point, the transport layer decides:
Should this data arrive reliably and in order?
Or should it arrive as fast as possible, even if some is lost?
The answer determines whether TCP or UDP is used.
๐ What are TCP and UDP?
The transport layer includes several protocols, but the internet mostly relies on two:
- TCP โ Transmission Control Protocol
- UDP โ User Datagram Protocol
They solve the same problem โ moving data โ but with very different priorities.
โ TCP: Transmission Control Protocol
Before jumping into a definition, the name itself explains a lot.
Transmission
- Sending data from one system to another
- Data is split into smaller packets
Control
- TCP doesnโt send data blindly
- It controls the flow using:
- Sequencing (ordering packets)
- Error checking
- Acknowledgements
- Flow control
Protocol
- A shared set of rules that both sides understand
In short:
TCP is a rulebook that ensures data is transmitted reliably, in order, and correctly, even if it means being slower.
โก UDP: User Datagram Protocol
UDP takes a very different approach.
User
- Refers to the application sending or receiving data
- The application decides how to handle loss
Datagram
- Each packet is independent
- No guarantee of order or delivery
Protocol
- A lightweight set of rules for fast communication
In short:
UDP is a fast, connectionless protocol that sacrifices reliability for speed โ ideal for real-time communication.
๐ Key Differences
| Feature | TCP | UDP |
|---|---|---|
| Connection | Connection-oriented | Connectionless |
| Reliability | Guaranteed delivery | Best-effort |
| Ordering | Maintained | Not guaranteed |
| Speed | Slower | Faster |
| Overhead | Higher | Minimal |
| Common Uses | Web, email, files | Streaming, gaming, calls |
In short:
TCP โ safe and reliable, but slower
UDP โ fast and lightweight, but less reliable
๐งญ When to use TCP vs UDP
The choice depends on one question:
What matters more โ correctness or speed?
๐ฅ๏ธ When to Use TCP
Use TCP when correctness matters more than speed:
- ๐ Web browsing (HTTP/HTTPS)
- ๐ File transfers (FTP, SFTP)
- ๐ง Emails (SMTP, IMAP, POP3)
- ๐ฅ๏ธ Remote access (SSH)
If losing or reordering data breaks meaning, TCP is the right choice.
๐ฎ When to Use UDP
Use UDP when speed matters more than perfection:
- ๐ฅ Video streaming
- ๐ฎ Online gaming
- ๐ Voice and video calls
- ๐ DNS lookups
In real-time systems, late data is often worse than missing data.
๐ What HTTP Fits
Hereโs where beginners often get confused
HTTP is not a transport protocol.
- HTTP operates at the application layer
- It defines how clients and servers communicate
- It relies on transport protocols underneath
๐งฉ What HTTP Is (and Isnโt)
- โ A protocol for clientโserver communication
- โ Not responsible for packet delivery
- โ Not the same as TCP or UDP
HTTP defines:
- Request methods (GET, POST)
- Headers and status codes
- Requestโresponse structure
๐ How HTTP Relates to TCP
HTTP does not replace TCP โ it runs on top of it.
The flow looks like this:
- Browser creates an HTTP request
- HTTP passes data to TCP
- TCP ensures reliable delivery
- IP routes packets across the network
In simple terms:
HTTP defines what is said.
TCP defines how it safely arrives.
This is why:
- HTTP โ TCP
- HTTP depends on a transport protocol
-
Most HTTP traffic uses TCP
(HTTP/3 uses QUIC over UDP โ a story for later)
๐คฏ Ending Thought
The beauty of the internet lies in its layers.
Each protocol focuses on one responsibility:
- DNS finds where
- TCP and UDP decide how
- HTTP defines what
So the next time a webpage loads, a video streams, or a game responds instantly โ remember:
Itโs not magic.
Itโs rules, layers, and very good engineering.
See you in the next blog. ๐



Top comments (0)