How the Internet Delivers a Packet
You type a web address and a page appears. Here's the full chain of DNS, TCP, TLS and HTTP that makes it happen.
Type a web address and press Enter. A few hundred milliseconds later, the page appears.
A lot happens in between. This post follows one request from start to finish and names every step.
Layers, because nobody can solve it all at once
The internet works because the job is split into layers. Each layer does one part of the job and relies on the layer below it for the rest. The OSI (Open Systems Interconnection) model describes seven layers. The TCP (Transmission Control Protocol)/IP (Internet Protocol) model, which is the one the internet actually uses, has four.
| TCP/IP layer | Job | Example |
|---|---|---|
| Application | What the data means | HTTP, DNS, TLS |
| Transport | Delivery between processes | TCP, UDP |
| Internet | Routing packets between hosts | IP |
| Link | Moving bits on the physical wire | Ethernet, Wi-Fi |
The data travels in small pieces called packets. Each layer adds its own header, a short block of information, in front of the data it gets from the layer above. So an HTTP (Hypertext Transfer Protocol) request gets a TCP header, then an IP header, then an Ethernet header, and then it's sent. It works like putting a letter in an envelope, then that envelope in a bigger envelope, and so on. The receiver opens them in reverse order.
This separation is why HTTP works the same over Wi-Fi or over a fibre cable. HTTP doesn't need to know which one is underneath.
Step 1: DNS, turning a name into a number
The network finds machines by IP address, not by name. So first, your computer has to turn the name into a number such as 203.0.113.42. This step is called resolving the name.
$ dig +short negensystems.com
203.0.113.42
Your computer asks a resolver, a server whose job is to look up names. The answer may already be saved, or cached, on your computer or at the resolver. If it isn't, the resolver asks the DNS (Domain Name System) servers in order. First it asks a root server, then the servers for the ending of the name, such as .com, and finally the domain's own server, which has the real answer.
DNS normally uses UDP (User Datagram Protocol) on port 53. The questions and answers are small, and if one gets lost, the computer simply asks again. For large answers, DNS uses TCP instead. Each answer comes with a time to live, which says how long it may be cached. Until then, the next lookup of the same name is instant.
Step 2: TCP, opening a reliable channel
Next, your computer opens a TCP connection to that address, on port 443, the port for HTTPS (Hypertext Transfer Protocol Secure).
A port is a number that picks one service on a machine. That's how one IP address can offer many services. 443 is HTTPS, 80 is HTTP, 22 is SSH (Secure Shell), and 53 is DNS.
The connection starts with the three-way handshake.
client server
| ── SYN (seq=x) ─────────────▶ | "let's talk, my seq is x"
| ◀──── SYN-ACK (seq=y, ack=x+1) | "ok, my seq is y, got yours"
| ── ACK (ack=y+1) ───────────▶ | "got yours, go"
That's three messages, taking one round trip, and afterwards both sides agree on their starting sequence numbers. These numbers count the bytes sent, so each side can tell what has arrived. From then on, TCP makes sure the bytes arrive in the right order, and sends again anything that was lost.
Step 3: TLS, making it private
Plain TCP isn't encrypted, so anyone along the way can read it. TLS (Transport Layer Security) adds encryption on top of TCP.
In a TLS 1.3 handshake, the browser and the server do three things.
- They agree on which encryption methods to use.
- They create a shared secret key. They use a method called Diffie-Hellman key exchange, which lets two sides build the same secret by exchanging only public values. Someone who watches the exchange can't work out the secret.
- The server proves who it is with a certificate. The certificate is signed by a Certificate Authority, an organization your computer already trusts.
TLS 1.3 does all of that in one round trip. After that, every byte is encrypted and protected from changes. The padlock in your browser's address bar means this worked and the certificate was valid.
Step 4: HTTP, actually asking for the page
Only now does the browser send the request the user wanted.
GET / HTTP/1.1
Host: negensystems.com
User-Agent: Mozilla/5.0 ...
Accept: text/html
The server replies.
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 5120
<!DOCTYPE html>...
The first line of the reply holds the status code. 200 OK means success. The Host line in the request matters a lot, because it lets one server with one IP address host many different websites. The server reads it to decide which site should answer.
All of this travels inside the encrypted TLS connection, which travels inside TCP, which travels inside IP packets.
Step 5: IP routing, how packets cross the world
The data is split into IP packets and handed to the network. Each packet carries a source address and a destination address, and each one travels on its own, one step at a time, through routers. A router is a device that passes packets towards their destination.
No single machine knows the whole route. Each router looks at the destination address, checks its routing table, and sends the packet one step closer. It works like a postal system, where each post office only needs to know which direction each postcode is in.
$ traceroute negensystems.com
1 router.lan 0.4 ms
2 isp-gateway 8 ms
3 backbone-1 14 ms
...
9 203.0.113.42 22 ms
traceroute lists the routers a packet passes through, with the time each step took. Packets can take different routes, arrive in a different order, or be thrown away when a link is too busy. The IP layer promises nothing, and this is called best effort delivery. Reliability is TCP's job. TCP sits one layer above IP and puts everything back in order.
The whole trip, in order
Here is one page load, from start to finish.
- DNS turns the name into an IP address, usually from a cache.
- The TCP handshake takes three packets and opens a reliable connection.
- The TLS handshake takes about one round trip. It creates the keys and checks the certificate.
- The HTTP request and response finally fetch the page, all of it encrypted.
- IP routing happens underneath all of these steps, moving packets from router to router as best it can.
The page you see is HTTP data, wrapped in TLS, carried by TCP, addressed by IP, and sent over Ethernet or Wi-Fi. Each layer knows nothing about the details of the others, and that separation is why the internet could grow so large.
My Take
When I'm debugging a slow Go service, knowing these layers tells me where to look.
If the first byte arrives slowly but the rest is fast, the delay is probably in TLS or DNS. "Connection refused" means the wrong port, or nothing is listening on it. Connections that fail now and then point to a problem on the network path, not in your application.
Three tools each show one part of this. dig shows DNS, traceroute shows IP routing, and curl -v shows TLS and HTTP.
Check yourself
3 questions · nothing is savedReferences & Primary Sources
Official specifications, standards, and documentation cited in this post.
- [1]
DARPA Internet Protocol specification defining packet fragmentation, addressing, and routing
RFCrfc-editor.org - [2]
Modern 1-RTT cryptographic handshake and forward secrecy for web encryption
RFCrfc-editor.org - [3]
Core DNS resolution mechanisms, message formats, and record types
RFCrfc-editor.org
- Written
- Nov 20, 2025
- Length
- 1,266 words · 6 min
- Built
- …
- Served by
- …
- Delivered
- …
- Over the wire
- …
- Go's share
- …
TCP vs UDP, and Why It Matters
One protocol makes sure every byte arrives, the other gets data there fast, and choosing between them affects everything from games to QUIC.
