Networks are designed in layers so each layer handles one concern and talks only to the layers next to it. The OSI model has 7 layers (a teaching reference); the TCP/IP model has 4 (what the internet actually uses). Interviews expect you to name the layers and place common protocols correctly.
Why layering
Layering gives separation of concerns: the application doesn't worry about cables, and the wire doesn't worry about web pages. Each layer adds its own header (encapsulation) as data goes down the sender's stack and is stripped going up the receiver's stack.
The OSI 7 layers (top to bottom)
| Layer | Job | Example |
|---|---|---|
| Application | user-facing services | HTTP, DNS, SMTP |
| Presentation | format, encrypt, compress | TLS, JPEG |
| Session | manage sessions | sockets |
| Transport | end-to-end delivery | TCP, UDP |
| Network | routing across networks | IP, routers |
| Data Link | node-to-node frames | Ethernet, MAC, switches |
| Physical | raw bits on the medium | cables, signals |
⚡ The edge
- A mnemonic for OSI top-to-bottom: All People Seem To Need Data Processing (Application, Presentation, Session, Transport, Network, Data Link, Physical).
- Place the protocols: HTTP/DNS = Application; TCP/UDP = Transport; IP = Network; Ethernet/MAC = Data Link. That mapping answers a large share of networking questions.
Worked example
'What is the difference between the OSI and TCP/IP models?'
- OSI is a 7-layer conceptual/reference model; TCP/IP is the 4-layer model the internet actually runs on.
- TCP/IP collapses OSI's top three (Application, Presentation, Session) into one Application layer, and the bottom two into a Network Access layer.
- So OSI is for teaching/standardising; TCP/IP is practical and protocol-driven.
Answer: OSI is a 7-layer reference model; TCP/IP is the practical 4-layer model that merges several OSI layers.
Worked example
'What happens when you type a URL and press Enter?' (layered view)
- DNS (Application) resolves the domain to an IP; a TCP connection (Transport) is set up to that IP.
- IP (Network) routes the packets across routers; Data Link/Physical carry the frames hop to hop.
- The HTTP request travels up the server's stack, the response comes back, and the browser renders it.
Answer: DNS resolves -> TCP connects -> IP routes -> HTTP request/response -> browser renders.
⚠ Watch out
- Switches operate at the Data Link layer (MAC addresses); routers at the Network layer (IP) — don't swap them.
- TCP and UDP are Transport layer; IP is Network layer — a very common mix-up.
- OSI is a reference model; the internet doesn't literally implement all 7 layers separately.