Walk me through the OSI model, layer by layer.
Show the answer
Say this first
Seven layers, bottom to top. 1 Physical moves bits as signals over copper, fiber or radio. 2 Data link frames those bits and delivers them on one segment using MAC addresses (Ethernet, Wi-Fi). 3 Network gives logical addresses and routes packets between networks (IP). 4 Transport carries data between processes using ports, with or without reliability (TCP, UDP). 5 Session, 6 Presentation and 7 Application cover dialog control, data formats and encryption, and the protocols users touch (HTTP, DNS, SMTP).
Go deeper
Layer by layer
| Layer | Name | Job | PDU | Examples | Devices |
|---|---|---|---|---|---|
| 7 | Application | Protocols the application speaks | Data | HTTP, DNS, SMTP, SSH | Proxies, L7 load balancers |
| 6 | Presentation | Encoding, compression, encryption | Data | TLS (often placed here), ASCII, JPEG | |
| 5 | Session | Opening, managing and closing dialogs | Data | RPC, NetBIOS sessions | |
| 4 | Transport | Process to process delivery, ports, reliability, flow control | Segment (TCP), datagram (UDP) | TCP, UDP | Stateful firewalls, L4 load balancers |
| 3 | Network | Logical addressing, routing between networks | Packet | IPv4, IPv6, ICMP | Routers, L3 switches |
| 2 | Data link | Framing, MAC addressing, error detection on one link | Frame | Ethernet, 802.11, PPP | Switches, bridges, APs |
| 1 | Physical | Bits as electrical, light or radio signals | Bits | 1000BASE-T, 10GBASE-LR | Hubs, repeaters, cables, transceivers |
How I say it in the room
I describe each layer by what problem it solves, not by memorized names. Layer 2 answers "how do I get this frame to the next box on this wire". Layer 3 answers "how do I get this packet to the right network anywhere". Layer 4 answers "which program gets it, and does it arrive complete and in order".
A common mnemonic from the bottom is "Please Do Not Throw Sausage Pizza Away". Use it to recall the order, then talk about function.
They will ask next
Which layer adds error detection, and does it correct errors?
Layer 2 adds the 4-byte FCS (a CRC-32) to every Ethernet frame. A receiver that finds a bad FCS drops the frame and counts a CRC error. Nothing at layer 2 in Ethernet retransmits it. Recovery, if any, comes from TCP at layer 4 or from the application.
Where does a VLAN tag live?
At layer 2. The 802.1Q tag is 4 bytes inserted after the source MAC address in the Ethernet header.
What is the difference between a segment and a datagram?
Both are layer 4 PDUs. Segment is the TCP term, datagram the UDP term. People also say "IP datagram" for a layer 3 packet, so be ready to clarify which one you mean.
Traps
- Reciting the names without saying what each layer does. Interviewers want function and examples.
- Putting switches at layer 3 by default. A plain switch is layer 2. A layer 3 switch also routes.