What are the 7 OSI layers and what does each do?
The OSI (Open Systems Interconnection) model is a conceptual framework that divides network communication into 7 ordered layers, each providing services to the layer above and consuming services from the layer below. While real protocols (TCP/IP) don't map cleanly onto OSI, the model remains the standard reference for discussing network behavior.
**Layer 1 — Physical**: Transmits raw bits over a physical medium (copper, fiber, radio). Defines electrical signals, cable specs, pin layouts. Examples: Ethernet physical layer, USB, Wi-Fi radio.
**Layer 2 — Data Link**: Frames bits into data units, handles node-to-node delivery on a single network segment. Provides MAC addressing and error detection (CRC). Examples: Ethernet (MAC frames), Wi-Fi (802.11), ARP. Switches operate here.
**Layer 3 — Network**: Routes packets across multiple networks using logical (IP) addresses. Handles path selection and packet forwarding. Examples: IP (v4/v6), ICMP, routing protocols (OSPF, BGP). Routers operate here.
**Layer 4 — Transport**: Provides end-to-end communication between processes. TCP gives reliable, ordered, connection-oriented delivery with flow control and congestion control. UDP gives unreliable, connectionless, low-latency delivery. Port numbers live here—they identify the receiving process.
**Layer 5 — Session**: Manages sessions between applications—establishing, maintaining, and terminating dialogues. Handles session recovery after interruptions. In practice, this layer is mostly subsumed by Layer 7 protocols or TLS. Examples: NetBIOS, RPC session management.
**Layer 6 — Presentation**: Translates data between network format and application format: character encoding (UTF-8 vs. ASCII), encryption/decryption, compression. TLS encryption is sometimes placed here. In practice, often merged with Layer 7.
**Layer 7 — Application**: The topmost layer—the protocol the application directly uses. Examples: HTTP, HTTPS, DNS, SMTP, FTP, WebSocket.
The practical interview framing: when debugging network issues, OSI layers guide troubleshooting from physical connectivity up. 'Is it a Layer 3 problem (routing)? Layer 4 (port blocked by firewall)? Layer 7 (application misconfiguration)?' Load balancers operating at Layer 4 route by IP/port; Layer 7 load balancers inspect HTTP headers for smarter routing.
Correctly names and describes all 7 layers with examples, distinguishes Layer 3 (routing) from Layer 4 (ports/transport), explains TCP vs. UDP at Layer 4.
Correctly places real protocols at their layers, explains where switches vs. routers operate, describes TCP reliability mechanisms at Layer 4, explains Layer 5/6 are practically merged into 7, and applies the model to a practical troubleshooting or load-balancer scenario.
Reading the answer is step one. Explaining it unprompted — under interview pressure — is what actually matters. Get AI-graded feedback on your answer with follow-up probes on your weak points.
Get Graded — Free Assessment