Build a TCP/IP Stack from Scratch · Module 00
OSI vs TCP/IP — The 60-Second Map
OSI vs TCP/IP — The 60-Second Map
Networking is often explained with the OSI model, a neat seven-layer diagram you've probably seen in textbooks.
Real networks, however, usually follow the TCP/IP model, which condenses those layers into four practical ones.
The Comparison
| OSI Layer | Typical Purpose | TCP/IP Equivalent | Example Protocols |
|---|---|---|---|
| 7 Application | User programs | Application | HTTP, DNS, SSH |
| 6 Presentation | Data formatting | (often folded in) | TLS, MIME |
| 5 Session | Connection state | (folded into Transport) | RPC |
| 4 Transport | End-to-end delivery | Transport | TCP, UDP |
| 3 Network | Routing packets | Internet | IPv4, IPv6, ICMP |
| 2 Data Link | Local delivery | Link | Ethernet, ARP |
| 1 Physical | Signals and media | (host hardware) | Cables, Wi-Fi |
In Practice
- Layers 1–2 (move bits inside a local network) → handled by hardware and drivers
- Layers 3–4 (route and deliver packets end-to-end) → that's our focus
- Layers 5–7 (applications) → we'll build simple examples (HTTP server, DNS responder)
What You Actually See
When you inspect a packet in Wireshark or print your own debug trace, you'll recognize:
Ethernet (L2)
└─ IP (L3)
└─ TCP or UDP (L4)
└─ Application data (L7)
Info: Those are the headers you'll parse, modify, and generate by hand. By the end of the project you'll be able to look at any packet capture and identify exactly which layer produced each byte.