The OSI model — seven layers, one mental model
12 min
The OSI model is a way of slicing what a network does into seven layers, each with a tightly-scoped job. You'll never meet a piece of equipment that maps perfectly onto OSI — real networks are messy — but the model is the shared vocabulary engineers use to talk about where a problem lives.
Why seven layers?
Because separating concerns lets independent teams (and independent vendors) work on independent pieces. A new Wi-Fi standard at Layer 1 shouldn't break TCP at Layer 4. A new web protocol at Layer 7 shouldn't break Ethernet at Layer 2. Layering is what makes "the network" upgradable.
The layers
Click the arrows to reorder. Goal: L1 at the bottom, L7 at the top (we show top-down here).
- L7Transport
- L6Data Link
- L5Network
- L4Physical
- L3Session
- L2Application
- L1Presentation
| # | Layer | What it does | Example PDU | Example protocols | |---|---|---|---|---| | 7 | Application | The thing the user actually sees | Data | HTTP, SMTP, DNS, SSH | | 6 | Presentation | Encoding, encryption, compression | Data | TLS, JPEG, ASN.1 | | 5 | Session | Conversations between hosts | Data | NetBIOS, RPC, QUIC streams | | 4 | Transport | Reliable or unreliable end-to-end delivery | Segment (TCP) / Datagram (UDP) | TCP, UDP, SCTP | | 3 | Network | Logical addressing and routing between networks | Packet | IPv4, IPv6, ICMP, OSPF | | 2 | Data Link | Addressing and framing on one link | Frame | Ethernet, 802.11, PPP | | 1 | Physical | Bits on a wire (or fiber, or air) | Bits | Cat6, OS2 fiber, 1000BASE-T |
TCP/IP is OSI for grown-ups
The TCP/IP model collapses OSI's top three layers into one "Application" layer and combines L1 + L2 into a "Network Access" layer. It's the one we actually use day to day:
| TCP/IP | OSI | |---|---| | Application | 5, 6, 7 | | Transport | 4 | | Internet | 3 | | Network Access | 1, 2 |
Both models are useful: OSI for where in the stack a problem lives, TCP/IP for what a packet actually looks like on the wire.
Encapsulation, in one sentence
As data goes down the stack, each layer wraps the layer above in its own header. As data goes up the stack on the receiving side, each layer strips its header back off. That's the whole show.
[ Ethernet | IP | TCP | HTTP "GET /" ]
What to remember
- Seven layers, top to bottom: Application, Presentation, Session, Transport, Network, Data Link, Physical. A common mnemonic is "All People Seem To Need Data Processing."
- Real protocols don't always fit neatly. The model is a tool, not a law.
- TCP/IP is the simplified, working model. OSI is the language for talking about it.