OSI model explained simply for web developers
OSI seven layers, encapsulation, physical layer, network layer, transport layer, application layer, practical developer relevance
The OSI Model: Only the Layers That Matter
The OSI model is seven layers of abstraction that describe how data moves from your code to the wire and back. You will not memorize all seven — but you need three of them constantly.
The layers that matter to web developers
Layer 7 — Application. Where your code lives. HTTP, WebSockets, DNS, SMTP all operate here. This is the only layer you directly write.
Layer 4 — Transport. TCP and UDP. Handles segmentation, reliability, and ports. A port number is a Layer 4 concept — it tells the OS which application gets the incoming data.
Layer 3 — Network. IP addresses and routing. Routers live here. An IP address identifies a machine; a port identifies a process on that machine.
Encapsulation
When you send an HTTP request, each lower layer wraps the data with its own header:
HTTP request body
→ wrapped in TCP segment (adds source/dest port)
→ wrapped in IP packet (adds source/dest IP)
→ wrapped in Ethernet frame (adds MAC addresses)
→ transmitted as electrical signals / light pulsesThe receiving side unwraps in reverse. This layering is why you can swap Ethernet for WiFi without changing HTTP — each layer is independent.
When you see a Connection refused error, that is Layer 4 (no process listening on that port). A Network unreachable error is Layer 3 (no route to the IP).
