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 LayerTypical PurposeTCP/IP EquivalentExample Protocols
7 ApplicationUser programsApplicationHTTP, DNS, SSH
6 PresentationData formatting(often folded in)TLS, MIME
5 SessionConnection state(folded into Transport)RPC
4 TransportEnd-to-end deliveryTransportTCP, UDP
3 NetworkRouting packetsInternetIPv4, IPv6, ICMP
2 Data LinkLocal deliveryLinkEthernet, ARP
1 PhysicalSignals 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.