The OSI (Open Systems Interconnection) Model is a 7-layer conceptual model that describes how two computers talk to each other over a network. It’s a teaching tool, not a real implementation.
In simple language: it slices the messy work of “send data from my laptop to a server” into 7 neat layers, where each layer has one job and only talks to the layer above and below it.
Why We Need It
Networking is hard. Cables, signals, IPs, ports, encryption, formats — all of that has to work together. The OSI model splits the chaos into chunks so we can reason about each piece independently.
When something breaks, we can ask: “is this a Layer 2 issue (switch) or a Layer 7 issue (the API)?”
The 7 Layers (Top to Bottom)
Layer-by-Layer
Layer 1 — Physical. The actual hardware. Copper cables, fiber strands, radio antennas. It deals with raw 0s and 1s as voltages or light pulses.
Layer 2 — Data Link. Moves frames between two devices on the same network. Each frame has a source and destination MAC address. A switch operates here.
Layer 3 — Network. Routes packets between different networks. IP addresses live here. Routers operate here. This is where “the internet” starts feeling like the internet.
Layer 4 — Transport. Delivers data to the right process (port) on the destination machine. TCP gives us reliability. UDP gives us speed.
Layer 5 — Session. Manages the conversation — opening, keeping alive, and closing the dialogue between two apps.
Layer 6 — Presentation. Translates the data format. Encrypts (TLS), compresses (gzip), or converts (UTF-8 ↔ ASCII).
Layer 7 — Application. What we actually code against. HTTP, DNS lookups, SMTP for email, SSH for shell access.
The Mnemonic
Top to bottom: All People Seem To Need Data Processing.
Bottom to top: Please Do Not Throw Sausage Pizza Away (the classic interview one).
7 Application - Pizza
6 Presentation - Sausage
5 Session - Throw
4 Transport - Not
3 Network - Do
2 Data Link - Please (wait, reverse it)
1 Physical - Away
Read top-down: Away Pizza Sausage Throw Not Do Please — bottom up the mnemonic, top down the layer numbers.
A Quick Real-World Trace
When we open https://example.com:
- L7 — browser builds an HTTP GET request
- L6 — TLS encrypts it
- L5 — a TCP session is established
- L4 — TCP segments the data, adds port 443
- L3 — IP wraps each segment in a packet with src/dst IP
- L2 — Ethernet wraps each packet in a frame with src/dst MAC
- L1 — bits go out as electrical signals on the cable
The receiver does the reverse — strip headers from the bottom up.
Interview Tip
Don’t memorize layers in isolation. Pair each layer with a protocol example and a device example (router for L3, switch for L2). Interviewers often ask “which layer does TLS sit at?” — the answer is L6 conceptually, though in practice it bridges L5/L6/L7.