OSI Model
Updated June 6, 2026Why Does the OSI Model Exist?
Here's the thing: when you send a message on WhatsApp, a staggering number of things happen between you tapping "send" and your friend reading it. Your phone needs to break up the message, encrypt it, address it, route it across the internet, and then reverse that whole process on the other end.
The OSI (Open Systems Interconnection) model is how we make sense of that chaos. It's a conceptual framework that divides network communication into 7 distinct layers, each with a specific job. Think of it like an assembly line, where each layer does one thing, hands it off to the next, and doesn't need to care about what the other layers are doing.
Key Insight: You won't find the "OSI stack" running literally on your machine. It's a model, a way of thinking, not a direct implementation. But it maps closely enough to real-world networking that it's the universal language engineers use to talk about network problems.
The OSI model is a direct implementation that runs as software on modern computers.
The 7 Layers, Top to Bottom
How an HTTP request travels through the OSI model layers
It's easiest to remember OSI layers from top (closest to the user) to bottom (closest to the physical wire). The classic mnemonic: All People Seem To Need Data Processing.
Layer 7 — Application
This is the layer you interact with. HTTP, HTTPS, FTP, SMTP, DNS; these all live here. When your browser makes a request, it's operating at Layer 7. This layer doesn't mean "the application itself" but rather the protocol the application uses to communicate.
Layer 6 — Presentation
The translator of the stack. It handles data encoding, encryption, and compression. When TLS encrypts your HTTPS traffic, that's conceptually happening at Layer 6. It ensures data sent by one system can be understood by another, regardless of internal format differences.
Layer 5 — Session
Manages the lifecycle of a connection, which includes opening it, keeping it alive, and tearing it down. If you've ever seen a web app that automatically reconnects after a dropped connection, session management is the concept at work. In practice, modern protocols often merge Layer 5 and 6 concerns.
Layer 4 — Transport
This is where TCP and UDP live. The Transport layer is responsible for end-to-end communication between processes (not machines, but processes identified by port numbers). It handles:
- Segmentation: breaking large data into chunks
- Reliability: TCP ensures packets arrive and are reassembled in order; UDP doesn't
- Flow control: preventing a fast sender from overwhelming a slow receiver
At which OSI layer do TCP and UDP operate?
Layer 3 — Network
IP (Internet Protocol) lives here. The Network layer is about logical addressing and routing, figuring out the best path to get a packet from one machine to another across potentially thousands of hops. Your IP address is a Layer 3 construct. Routers operate at this layer.
IP addresses are a construct of which OSI layer?
Layer 2 — Data Link
Where MAC addresses come in. This layer handles communication between directly connected nodes on the same network segment. It packages raw bits into frames, adds error detection, and manages access to the shared physical medium. Ethernet and Wi-Fi operate at Layer 2. Switches operate here.
Layer 1 — Physical
The raw electrical signals, light pulses, or radio waves carrying your data. This layer is about the actual transmission medium: coaxial cable, fiber optic, copper wire, or radio frequencies. No addressing, no logic, just bits as physical signals.
A Visual Reference
| Layer | Name | Protocols / Examples | Unit |
|---|---|---|---|
| 7 | Application | HTTP, DNS, FTP, SMTP | Data |
| 6 | Presentation | TLS/SSL, JPEG, ASCII | Data |
| 5 | Session | NetBIOS, RPC | Data |
| 4 | Transport | TCP, UDP | Segment |
| 3 | Network | IP, ICMP, OSPF | Packet |
| 2 | Data Link | Ethernet, Wi-Fi (802.11) | Frame |
| 1 | Physical | Cables, Radio waves, Fiber | Bit |
How Data Actually Travels
Encapsulation and decapsulation - how data actually travels
When you send data, it travels down the stack on the sender's side (each layer adds a header, a process called encapsulation), then up the stack on the receiver's side (each layer strips its header, which is decapsulation).
So when you make an HTTP request:
- Layer 7: HTTP creates the request message
- Layer 4: TCP wraps it in a segment with source/destination ports
- Layer 3: IP wraps it in a packet with source/destination IPs
- Layer 2: Ethernet wraps it in a frame with source/destination MACs
- Layer 1: Transmitted as electrical signals over the wire
On the other end, the process reverses. The web server strips each wrapper and ultimately hands the raw HTTP request to your application.
When data travels down the OSI stack from sender to receiver, each layer adds a header in a process called what?
Where Real Protocols Fit
- TCP/IP spans Layers 3 and 4. It's a protocol suite (IP for network, TCP for transport). This is the actual internet protocol stack most systems implement.
- HTTP/HTTPS is Layer 7. HTTP is the application protocol; HTTPS is HTTP with TLS.
- TLS is conceptually Layer 6, though in practice it sits between Layer 4 and 7 in the TCP/IP model.
- DNS is Layer 7, uses UDP at Layer 4, IP at Layer 3.
- Ethernet is Layer 2.
The TCP/IP Model vs OSI: In practice, the internet runs on the TCP/IP model which has only 4 layers (Application, Transport, Internet, Network Access). OSI is the theoretical framework; TCP/IP is the real implementation. Engineers use OSI terminology because it's more precise.
Why This Matters for System Design
Layer 4 vs Layer 7 load balancing in system design
Understanding OSI layers helps you:
Debug network issues faster. Is it a DNS problem (Layer 7)? A routing issue (Layer 3)? A physical connectivity problem (Layer 1)? Knowing which layer to look at cuts troubleshooting time dramatically.
Design better systems. Load balancers can operate at Layer 4 (forwarding TCP connections) or Layer 7 (inspecting HTTP requests). A Layer 7 load balancer can route /api/* requests differently from /static/* requests. A Layer 4 one can't.
Talk to other engineers clearly. When someone says "this is a Layer 3 issue" or "we need a Layer 7 firewall," you know exactly what they mean.
Understand security. Firewalls, TLS, DDoS protection; they all operate at specific layers. A firewall blocking ports is Layer 4. WAFs (Web Application Firewalls) work at Layer 7.
A Layer 7 load balancer can route requests differently based on URL paths, while a Layer 4 load balancer cannot.
Summary
The OSI model splits network communication into 7 layers, each with a focused responsibility, from raw electrical signals at the bottom (Physical) to user-facing protocols at the top (Application). In the real world, TCP/IP is what actually runs the internet, but OSI gives you the vocabulary and mental model to reason about networking at any level. As a system designer, you'll constantly think in terms of "what layer is this problem happening at?" and that question alone will save you hours of confusion.
Saved on this device only
Sign in to sync progress across devices