The cast
| # | Who | Address | Job in this story | Chapters |
|---|---|---|---|---|
| 1 | Your laptop | 192.168.1.23 · a4:83:e7:2b:91:0c | The client | 1-5, 7 |
| 2 | Home router | 192.168.1.1 (LAN) · 203.0.113.45 (WAN) · 3c:84:6a:10:ee:01 | DHCP server, DNS forwarder, gateway, NAT, firewall | 5, 10, 27 |
| 3 | LankaNet resolver | 203.0.113.53 | Recursive DNS with a cache | 22 |
| 4 | Cloud DNS | ns-cloud-a1…a4.googledomains.com | Authoritative for kade.lk | 22-23 |
| 5 | Internet routers | ISP, transit, Google's edge | Forward by longest prefix; BGP picks the path | 12 |
| 6 | Google front end | 34.120.88.10 (anycast) | Load balancer: ends TCP and TLS, picks a backend | 25, 33 |
| 7 | kade-api-2 | 10.10.1.11:8080 · 42:01:0a:0a:01:0b | Runs the Node app | 21, 31 |
| 8 | kade-db | 10.10.2.5:5432 | PostgreSQL | 3, 21 |
Before the click: joining the network
Some work happens once, when the laptop joins the home WiFi, long before any page is opened:
After this, the laptop has an address, a mask, a gateway, a DNS server, and the gateway's MAC in its ARP cache (chapters 3, 5, 9, 27). About 5 ms of work, reused for hours.
The journey, step by step
Step through the whole request. The map shows where the action is; the card shows the packet exactly as it looks at that point, layer by layer. Watch which values change and which stay the same.
earlierJoining WiFi: DHCPchapter 27
When the laptop rejoined the home WiFi, it asked to keep its old address. The router said yes and sent the mask, the gateway (192.168.1.1), the DNS server (also 192.168.1.1) and a 24-hour lease.
- Frame
- a4:83:e7:2b:91:0c → ff:ff:ff:ff:ff:ff (broadcast)
- IP
- 0.0.0.0 → 255.255.255.255
- Transport
- UDP 68 → 67
- Inside
- DHCPREQUEST: "may I keep 192.168.1.23?"
Bold values changed compared with the packet before.
The timeline
Here are the same steps on a time axis. The whole first request takes about 176 ms:
| # | Phase | From → to | Round trips | Time | Chapters |
|---|---|---|---|---|---|
| 1 | DNS lookup | 0 → 42 ms | laptop ⇄ resolver ⇄ Cloud DNS | 42 ms | 14, 22 |
| 2 | TCP handshake | 42 → 83 ms | 1 | 41 ms | 16 |
| 3 | TLS 1.3 handshake | 83 → 126 ms | 1 + ~2 ms of crypto | 43 ms | 25 |
| 4 | Request → first byte | 126 → 175 ms | 1 + ~8 ms in Google and Kadé | 49 ms | 24, 33 |
| 5 | Download | 175 → 176 ms | 0 (2.8 KB fits in the first window) | 1 ms | 20 |
| Total | 4 round trips | 176 ms |
Change the conditions and see which round trips disappear:
Total about 176 ms · 4 round trips · 93% of the time is distance
A simple model with a 50 Mbps line. Larger responses need extra round trips while slow start grows the congestion window from 10 segments (chapter 20).
| # | Situation | Round trips saved | Time (41 ms RTT) | Why |
|---|---|---|---|---|
| 1 | First visit, as above | - | ~176 ms | |
| 2 | DNS already cached (within 300 s TTL) | DNS | ~134 ms | Chapter 22's caches |
| 3 | HTTP/3 (QUIC) | 1 | ~135 ms | Transport and TLS handshakes combined (chapter 24) |
| 4 | TLS 1.2 instead of 1.3 | −1 (costs one more) | ~218 ms | Chapter 25's timeline |
| 5 | Next request on the same connection | DNS + TCP + TLS | ~49 ms | Keep-alive and pools (chapter 21) |
Measure your own real timings
A model is useful; a measurement is better. curl can print when each phase finished:
curl -so /dev/null -w 'dns %{time_namelookup}\nconnect %{time_connect}\ntls %{time_appconnect}\nttfb %{time_starttransfer}\ntotal %{time_total}\n' https://www.google.comRun it twice (the second run usually has DNS cached), against any HTTPS site, and paste the output here:
- DNS took 42 ms: the resolver probably had to look the name up (a cold cache), or your resolver is far away. Run again and it should drop.
- The TCP handshake is one round trip, so your RTT to this server is about 41 ms.
- TLS took about one round trip: TLS 1.3.
- The server itself answered fast: about 7 ms beyond one round trip.
What changed at each hop
The request travelled over three separate connections: laptop ⇄ Google front end, front end ⇄ kade-api, and kade-api ⇄ kade-db. Here is the first request packet at every point:
| # | Where | Frame src → dst MAC | IP src → dst | TTL | Ports | Inside |
|---|---|---|---|---|---|---|
| 1 | Laptop → home router (WiFi) | a4:83:e7:2b:91:0c → 3c:84:6a:10:ee:01 | 192.168.1.23 → 34.120.88.10 | 64 | 52814 → 443 | TLS (encrypted HTTP/2) |
| 2 | Home router → ISP | router WAN → ISP gateway | 203.0.113.45 → 34.120.88.10 | 63 | 40001 → 443 | same bytes |
| 3 | Across the internet | new at every hop | same | 62, 61 … | same | same bytes |
| 4 | Arrives at Google's edge | - | 203.0.113.45 → 34.120.88.10 | ~55 | 40001 → 443 | connection 1 ends: decrypted here |
| 5 | Google front end → kade-api-2 | 42:01:0a:0a:01:01 → 42:01:0a:0a:01:0b | 35.191.12.34 → 10.10.1.11 | 64 | 51277 → 8080 | HTTP/1.1 + X-Forwarded-For (connection 2) |
| 6 | kade-api-2 → kade-db | 42:01:0a:0a:01:0b → 42:01:0a:0a:01:01 (VPC gateway) | 10.10.1.11 → 10.10.2.5 | 64 | 41822 → 5432 | SQL query (connection 3, from the pool) |
One packet, all the layers
The packet carrying the HTTP request (step 12 in the journey) on the WiFi, byte by byte:
| # | Layer | Bytes | Carries | Chapter |
|---|---|---|---|---|
| 1 | Frame header | 14 | MACs (laptop → router), type 0x0800 = IPv4 | 7-8 |
| 2 | IPv4 header | 20 | 192.168.1.23 → 34.120.88.10, TTL 64, protocol 6 (TCP), DF | 12 |
| 3 | TCP header | 32 | 52814 → 443, seq/ack, window, timestamps option | 17-19 |
| 4 | TLS record header | 5 | type "application data", length | 25 |
| 5 | HTTP/2 HEADERS | ~64 | GET /orders/1042, api.kade.lk, the token; compressed (HPACK) and encrypted | 24 |
| 6 | TLS auth tag | 16 | Proves nobody changed the bytes | 25 |
| 7 | Frame check sequence | 4 | Detects damage on the link | 7 |
When it breaks: a map of where to look
Every step is also a place where things fail. Find the symptom, and you know the layer and the chapter:
| # | Step | Symptom | Likely cause | Check with | Ch |
|---|---|---|---|---|---|
| 1 | DHCP | Address 169.254.x.x; "no internet" | No DHCP server reply | ipconfig getifaddr en0 | 27 |
| 2 | ARP / gateway | Can't even ping 192.168.1.1 | WiFi, cable, wrong network | arp -a, ping 192.168.1.1 | 5, 9 |
| 3 | DNS | "Could not resolve host" / NXDOMAIN / SERVFAIL | Missing record, broken DNSSEC, resolver down | dig api.kade.lk, dig @8.8.8.8 … | 22-23 |
| 4 | Routing | Timeouts; traceroute stops at one hop | A route or peering problem | traceroute -T -p 443 api.kade.lk | 12-13 |
| 5 | TCP | "Connection refused" vs "timed out" | Nothing listening vs firewall drop | nc -vz api.kade.lk 443 | 16, 31 |
| 6 | MTU | Handshake works, big responses hang | PMTUD black hole (VPNs) | ping -D -s 1472 … | 18 |
| 7 | TLS | Certificate errors; handshake failure | Expired cert, wrong name, missing chain, TLS inspection | openssl s_client -connect api.kade.lk:443 -servername api.kade.lk | 25 |
| 8 | Browser rules | Works in curl, fails in the browser | CORS, mixed content, HSTS | DevTools console | 28 |
| 9 | Load balancer | 502 / 503 / 504 | Keep-alive race, no healthy backend, timeout | LB logs statusDetails, get-health | 33 |
| 10 | App | 500, 401, 404 | Your code, auth, routes | App logs (with the real client IP, thanks to trust proxy) | 24 |
| 11 | Speed | Slow but working | Round trips, loss, bufferbloat, no connection reuse | curl -w (section 5), mtr | 13, 20, 21 |
ping 192.168.1.1 fails, nothing above it matters yet. Each passing check clears a whole layer.How the course fits together
| # | Journey step | Built on |
|---|---|---|
| 1 | Getting on the network | IP addresses (2), subnets and masks (3-4), gateways (5), MACs and hex (7), DHCP (27), IPv6 SLAAC (30) |
| 2 | Finding the server | UDP (14-15), DNS (22), records (23), anycast (12) |
| 3 | Reaching the server | Frames and hops (8), ARP (9), NAT (10), layers (11), routing and BGP (12), ICMP and traceroute (13), switches and routers (32) |
| 4 | A reliable connection | TCP (16), sequence numbers (17), segments and MTU (18), flow control (19), congestion control (20), sockets and ports (21, 31) |
| 5 | A private connection | TLS and certificates (25), SSH for admin access (29) |
| 6 | The conversation | HTTP and its versions (24), CORS (28), WebSockets (26) |
| 7 | The server side | Kadé's GCP network (6, 0), load balancers (33), time sync (27) |
Summary
| # | Idea | In one line |
|---|---|---|
| 2 | Joining | DHCP, ARP and an IPv6 router advertisement happen once, before any request |
| 3 | The journey | DNS → ARP (cached) → TCP → TLS → HTTP → load balancer → kade-api → kade-db → back |
| 4 | Timing | ~176 ms first request: 4 round trips of 41 ms + ~12 ms of work; ~49 ms on a reused connection |
| 5 | Measuring | curl -w and DevTools Timing show the same phases |
| 6 | Hops | MACs change every hop; IP/ports change only at NAT and proxies; three separate connections |
| 7 | Layers | ~155 bytes on the wire for ~64 bytes of request |
| 8 | Debugging | Check layer by layer, from the bottom up |
Try it yourself: the whole journey from your laptop
| # | Command | Step it shows | What to look for |
|---|---|---|---|
| 2 | ipconfig getpacket en0macOS · Linux: nmcli dev show | Your DHCP lease | Your IP, router, DNS server, lease time. |
| 2 | arp -a | grep '192.168.1.1)' | The gateway's MAC | 3c:84:… style MAC, cached. |
| 3 | dig +trace www.google.com | The full DNS walk | Root → TLD → authoritative. |
| 3 | traceroute -T -p 443 www.google.comLinux (sudo) · macOS: traceroute -P tcp -p 443 | The routers on the way | Your router, the ISP, then Google's edge. |
| 3 | openssl s_client -connect www.google.com:443 -servername www.google.com </dev/null | head -20 | The TLS handshake and certificate chain | Subject, issuer, TLSv1.3. |
| 3 | curl -v https://www.google.com -o /dev/null | TCP, TLS, HTTP in one go | "Connected to", "SSL connection using TLSv1.3", ALPN h2, the request and response headers. |
| 5 | The curl -w command from section 5 | Real timings per phase | Paste into the tool; compare a first run with a second. |
| 3 | sudo tcpdump -n -i en0 host www.google.com while running curl in another window | Every packet of the journey | SYN, SYN-ACK, ACK, TLS records, FIN. |