Networks are enormously complex. Layered models tame this complexity by dividing responsibilities into independent layers. Each layer provides services to the layer above and uses services from the layer below — without needing to know how those services are implemented.
Key benefit: You can swap out a layer's implementation (e.g., switch from Wi-Fi to Ethernet) without changing layers above or below.
| # | Layer | Unit | Key protocols / examples |
|---|---|---|---|
| 7 | Application | Message | HTTP, FTP, DNS, SMTP |
| 6 | Presentation | Message | TLS/SSL encryption, JPEG compression |
| 5 | Session | Message | Session management, RPC |
| 4 | Transport | Segment | TCP, UDP |
| 3 | Network | Packet | IP, ICMP, routing |
| 2 | Data Link | Frame | Ethernet, Wi-Fi (802.11), ARP |
| 1 | Physical | Bit | Cables, fiber, radio waves, voltage levels |
Mnemonic (top to bottom): All People Seem To Need Data Processing
The practical Internet model collapses OSI layers 5–7 into one:
| TCP/IP Layer | Maps to OSI | Examples |
|---|---|---|
| Application | 7, 6, 5 | HTTP, DNS, SMTP, SSH |
| Transport | 4 | TCP, UDP |
| Internet | 3 | IPv4, IPv6, ICMP |
| Link (Network Access) | 2, 1 | Ethernet, Wi-Fi, PPP |
GET /index.html HTTP/1.1
Host: example.com
As data travels down the sending stack, each layer encapsulates the data by wrapping it with a header (and sometimes a trailer). Going up the receiving stack, each layer decapsulates by removing its header.
Example: HTTP body → [TCP hdr | HTTP body] → [IP hdr | TCP hdr | HTTP body] → [ETH hdr | IP hdr | TCP hdr | HTTP body | ETH trailer]
A packet arrives at a router. The router examines the destination IP address and forwards it toward the destination. Which OSI layer is the router primarily operating at?
Match each protocol to its OSI layer: HTTPS, TCP, IPv6, Ethernet, 802.11 Wi-Fi.
Which OSI layer is responsible for end-to-end reliable delivery between processes?
Data Link (Layer 2) handles delivery between directly connected nodes using MAC addresses. End-to-end process delivery is Transport (Layer 4).
IP (Layer 3) routes packets between hosts but is best-effort — no reliability guarantee. TCP (Layer 4) adds reliability and port-based process addressing.
Application layer protocols like HTTP rely on TCP for reliability. The Application layer itself doesn't manage retransmissions or ordering.
Encapsulation in networking means:
Encapsulation = wrapping data with headers at each layer. Encryption is one specific transformation done by TLS, not the general concept of encapsulation.
Compression reduces size; encapsulation adds headers. They are different operations, though both can occur.
Fragmentation divides oversized packets. Encapsulation adds headers to whatever size data is passed down from above.
A switch operates at which OSI layer?
Hubs broadcast every bit to all ports (Layer 1). Switches read MAC addresses (Layer 2) to forward frames only to the correct port.
Routers examine IP addresses (Layer 3). Switches use MAC address tables (Layer 2). Layer-3 switches exist but are essentially routers.
Standard switches operate at Layer 2. Layer-4 load balancers inspect TCP/UDP ports but are specialized devices.
In the TCP/IP model, which layer corresponds to OSI layers 5, 6, AND 7?
TCP/IP Transport covers OSI Layer 4 (TCP, UDP). OSI Layers 5–7 are all collapsed into TCP/IP's Application layer.
TCP/IP Internet covers OSI Layer 3 (IP, ICMP, routing). Layers 5–7 collapse into TCP/IP Application.
TCP/IP Link layer combines OSI Physical (1) and Data Link (2). Application combines OSI 5, 6, 7.
The purpose of a port number in TCP/UDP is to:
MAC addresses are used at Layer 2 to identify network interfaces. Port numbers at Layer 4 identify which process/service on a host should receive a packet.
IP addresses route packets to the correct machine. Port numbers then direct the packet to the correct process (e.g., port 80 = HTTP, port 443 = HTTPS).
Port numbers are addresses for processes (HTTP=80, SSH=22). Packet priority uses DSCP bits in the IP header.