Mental Model: Hosts, Routers, and Layers
Mental Model — Hosts, Routers, and Layers
Before writing a single line of code, it helps to picture where your stack sits in the grand scheme of the Internet.
Every packet travels through a chain of machines. Each machine looks at only the information it needs for its role:
[ Your client ] → [ Router / Gateway ] → [ Remote host ]
↑ ↑ ↑
TCP/UDP, App IP + Routing TCP/UDP, App
(L4–L7) (L3) (L4–L7)
Roles in the Network
A Host
Like your laptop or a web server, runs all layers up to the application. It creates TCP connections, talks HTTP, DNS, SSH, and so on.
A Router
Operates mostly at Layer 3 (Network). It doesn't "understand" HTTP or TCP streams; it just forwards IP packets between networks, maybe adjusting headers or performing NAT.
Your Stack Will Be Both
In this course, your code will act as:
- A router/gateway when it forwards traffic from one interface to another
- A host when it terminates packets destined for itself (e.g., replying to ping or serving HTTP)
The Packet Journey
So when you run:
curl http://10.10.0.1:8080/The request leaves the client's kernel stack as real Ethernet frames, crosses a virtual network bridge, and lands in your container.
Your stack then walks the packet up the layers:
Ethernet → IP → TCP → HTTP
And the response goes back down the same path in reverse.
Success: That's the journey you'll trace and implement, step by step.