OSI & TCP/IP Models
A mental map of how network communication is layered, from cables to applications.
Networking is layered so each layer only worries about its own job and talks to the layers above and below it. The OSI model has 7 layers; the practical TCP/IP model collapses them into 4. Data is encapsulated as it goes down the stack (each layer adds a header) and decapsulated on the way up.
The layers you reference most in operations:
- L7 Application — HTTP, DNS, SSH (what apps speak)
- L4 Transport — TCP/UDP, ports (reliable streams vs. fast datagrams)
- L3 Network — IP, routing (addressing across networks)
- L2 Data Link — MAC, switches (the local segment)
When you troubleshoot, you walk the layers: cable/link → IP → routing → DNS → application.
graph TD A["L7 Application — HTTP, DNS, SSH"] --> B["L6 Presentation — TLS, encoding"] B --> C["L5 Session"] C --> D["L4 Transport — TCP / UDP, ports"] D --> E["L3 Network — IP, routing"] E --> F["L2 Data Link — MAC, switches"] F --> G["L1 Physical — cables, radio"]
- List which layer each protocol belongs to: HTTP, IP, TCP, Ethernet.
- Explain what “encapsulation” adds at each layer going down the stack.
- Map the 7 OSI layers onto the 4 TCP/IP layers.
- Given “the website loads but is slow”, name two layers you’d investigate.
Cheat Sheet▾
| OSI Layer | Example | Unit |
|---|---|---|
| 7 Application | HTTP, DNS | Data |
| 4 Transport | TCP, UDP | Segment |
| 3 Network | IP | Packet |
| 2 Data Link | Ethernet, MAC | Frame |
| 1 Physical | Cable, Wi-Fi | Bits |
Common Interview Questions▾
Why is networking organized into layers?
Layering separates concerns: each layer has a single job and a clean interface to its neighbors, so protocols can change independently and troubleshooting is systematic.
At which layers do TCP and IP operate?
TCP is Layer 4 (Transport); IP is Layer 3 (Network). TCP provides reliable ordered delivery; IP provides addressing and routing between networks.