The OSI model (Open Systems Interconnection) is a conceptual framework that divides network communication into 7 distinct layers. Created by ISO in 1984, it gives engineers a universal language to describe how data travels from an application on one computer to an application on another — regardless of the underlying hardware or software.
You'll encounter it in every networking exam, job interview, and troubleshooting scenario. This guide explains every layer with real-world examples, protocols, and the data unit (PDU) at each stage.
OSI model quick reference
| Layer | Name | PDU | Key protocols | Devices |
|---|---|---|---|---|
| 7 | Application | Data | HTTP, HTTPS, FTP, SMTP, DNS, SSH | — |
| 6 | Presentation | Data | SSL/TLS, JPEG, MPEG, ASCII, encryption | — |
| 5 | Session | Data | NetBIOS, RPC, PPTP | — |
| 4 | Transport | Segment (TCP) / Datagram (UDP) | TCP, UDP | Firewall, load balancer |
| 3 | Network | Packet | IP, ICMP, OSPF, BGP | Router |
| 2 | Data Link | Frame | Ethernet, Wi-Fi (802.11), PPP, ARP | Switch, bridge |
| 1 | Physical | Bit | USB, DSL, 10BASE-T, Bluetooth | Hub, repeater, cable |
Mnemonic (top→bottom): All People Seem To Need Data Processing
Mnemonic (bottom→top): Please Do Not Throw Sausage Pizza Away
Why the OSI model matters
Before OSI, network vendors used proprietary, incompatible protocols. A device from Vendor A couldn't talk to one from Vendor B. The OSI model solved this by:
- Standardising interfaces between layers so you can swap implementations
- Isolating troubleshooting — a Layer 3 problem (routing) is separate from a Layer 1 problem (broken cable)
- Enabling specialisation — switch engineers focus on Layers 1–2; application developers focus on Layers 5–7
- Defining PDUs — the precise data unit each layer handles (bits → frames → packets → segments)
In practice, the real Internet runs on the TCP/IP model (4 layers), but OSI is the gold standard for analysis and education.
Layer 1 — Physical
PDU: Bit
The Physical layer deals with raw bit transmission — electrical signals, light pulses, or radio waves over a physical medium. It defines:
- Voltage levels (how a 1 differs from a 0)
- Cable types (Cat5e, Cat6, fibre optic, coaxial)
- Connector shapes (RJ45, BNC, LC/SC fibre)
- Modulation (how bits are encoded on radio waves)
- Transmission speed (baud rate)
Real-world examples:
| Medium | Technology | Speed |
|---|---|---|
| Twisted pair copper | Cat6a Ethernet | 10 Gbps |
| Fibre optic (single-mode) | 100GBASE-LR4 | 100 Gbps |
| Radio frequency | Wi-Fi 6 (802.11ax) | up to 9.6 Gbps |
| Coaxial cable | DOCSIS 3.1 (cable internet) | up to 10 Gbps |
Devices: Hubs, repeaters, network cables, access points (radio element), modems.
Troubleshooting: Flashing link lights on a NIC, checking cable integrity with a cable tester, ethtool eth0 to inspect speed/duplex.
Layer 2 — Data Link
PDU: Frame
The Data Link layer takes raw bits from Layer 1 and groups them into frames — adding MAC addresses, error detection (CRC), and flow control. It splits into two sub-layers:
- LLC (Logical Link Control) — multiplexing protocols, flow control
- MAC (Media Access Control) — addressing and media access (who can transmit when)
Frame structure (Ethernet II):
| Preamble | Dest MAC | Src MAC | EtherType | Payload | FCS (CRC) |
Key responsibilities:
| Function | Description |
|---|---|
| MAC addressing | 48-bit hardware address (AA:BB:CC:DD:EE:FF) uniquely identifies each NIC |
| Framing | Encapsulates packets with header/trailer |
| Error detection | CRC catches bit errors; corrupted frames are dropped |
| Media access | CSMA/CD (Ethernet) or CSMA/CA (Wi-Fi) prevents collisions |
| VLAN tagging | 802.1Q inserts a 4-byte tag to segment traffic |
Protocols: Ethernet (802.3), Wi-Fi (802.11), PPP, ARP (maps IP → MAC), VLAN (802.1Q), STP (Spanning Tree).
Devices: Switches (Layer 2), bridges. Switches use MAC address tables to forward frames only to the correct port.
# View MAC address table on a Linux bridge
bridge fdb show
# ARP table (Layer 2 ↔ Layer 3 mapping)
arp -n
ip neigh show
Layer 3 — Network
PDU: Packet
The Network layer handles logical addressing and routing — deciding the best path for a packet to travel across multiple networks. Unlike Layer 2 (local delivery within one network), Layer 3 enables inter-network communication (the Internet).
IP address structure (IPv4):
192.168.1.100 / 24
│ │
└─ Host part └─ Network prefix (subnet mask 255.255.255.0)
Key responsibilities:
| Function | Description |
|---|---|
| Logical addressing | IP addresses (IPv4 32-bit, IPv6 128-bit) |
| Routing | Selecting the best path via routing tables and protocols |
| Fragmentation | Splitting packets that exceed MTU (1500 bytes for Ethernet) |
| TTL / Hop limit | Prevents packets looping forever |
| QoS marking | DSCP bits for traffic prioritisation |
Routing protocols:
| Protocol | Type | Use case |
|---|---|---|
| OSPF | Link-state IGP | Large enterprise networks |
| BGP | Path-vector EGP | Internet backbone (between ASes) |
| EIGRP | Advanced distance-vector | Cisco enterprise |
| RIP | Distance-vector IGP | Small/legacy networks |
| IS-IS | Link-state IGP | ISP networks |
Devices: Routers, Layer 3 switches, firewalls (packet filtering), NAT devices.
# View routing table
ip route show
# Trace the Layer 3 path to a destination
traceroute google.com # Linux/macOS
tracert google.com # Windows
# ICMP ping (Layer 3 protocol)
ping -c 4 8.8.8.8
Layer 4 — Transport
PDU: Segment (TCP) / Datagram (UDP)
The Transport layer provides end-to-end communication between processes (identified by port numbers). It handles reliability, flow control, and multiplexing.
TCP vs UDP:
| Feature | TCP | UDP |
|---|---|---|
| Connection | Connection-oriented (3-way handshake) | Connectionless |
| Reliability | Guaranteed delivery, retransmission | Best-effort, no retransmission |
| Ordering | In-order delivery | No ordering guarantee |
| Flow control | Yes (sliding window) | No |
| Congestion control | Yes (AIMD) | No |
| Speed | Slower (overhead) | Faster (minimal overhead) |
| Header size | 20–60 bytes | 8 bytes |
| Use cases | HTTP, SMTP, SSH, FTP | DNS, video streaming, VoIP, gaming |
TCP 3-way handshake:
Client Server
│── SYN ──────────────────►│
│◄── SYN-ACK ──────────────│
│── ACK ──────────────────►│
│ [Connection established]
Common port numbers:
| Port | Protocol | Service |
|---|---|---|
| 20/21 | TCP | FTP (data/control) |
| 22 | TCP | SSH |
| 25 | TCP | SMTP |
| 53 | TCP/UDP | DNS |
| 80 | TCP | HTTP |
| 443 | TCP | HTTPS |
| 3306 | TCP | MySQL |
| 5432 | TCP | PostgreSQL |
| 6379 | TCP | Redis |
| 27017 | TCP | MongoDB |
# View active connections and listening ports
ss -tlnp # Linux
netstat -ano # Windows
# Check if a port is open
nc -zv google.com 443
Layer 5 — Session
PDU: Data
The Session layer establishes, manages, and terminates sessions (logical connections) between applications. It handles:
| Function | Description |
|---|---|
| Session establishment | Negotiating parameters before data exchange |
| Session maintenance | Keeping the session alive (heartbeats, tokens) |
| Session termination | Graceful close of a connection |
| Checkpointing | Resuming large transfers after interruption |
| Dialog control | Half-duplex vs full-duplex negotiation |
Protocols: NetBIOS (Windows file sharing session), RPC (Remote Procedure Call), PPTP (VPN sessions), SQL sessions, SIP (VoIP session initiation).
In practice, modern protocols like HTTP/1.1 (keep-alive), HTTP/2 (multiplexed streams), and WebSockets implement session-layer concepts directly in the Application layer. The Session layer is the most abstract and least distinctly implemented of the seven.
Layer 6 — Presentation
PDU: Data
The Presentation layer translates data between the format the network uses and the format the application needs. Think of it as the "translator" or "serialiser" of the stack.
Key functions:
| Function | Examples |
|---|---|
| Encryption/decryption | TLS/SSL encrypts data before transmission |
| Compression | gzip, Brotli compress HTTP responses |
| Data format translation | Converting between ASCII and EBCDIC, UTF-8 encoding |
| Serialisation | JSON ↔ binary, XML ↔ native objects |
| Media encoding | JPEG image format, MPEG video, MP3 audio |
Common formats at Layer 6:
| Category | Examples |
|---|---|
| Text encoding | ASCII, UTF-8, UTF-16, EBCDIC |
| Image formats | JPEG, PNG, GIF, WebP |
| Video formats | MPEG-4, H.264, H.265 |
| Encryption | TLS 1.3, SSL (deprecated) |
| Compression | gzip, zlib, Brotli, LZ4 |
| Serialisation | JSON, XML, Protobuf, MessagePack |
Like Layer 5, the Presentation layer's functions are often handled by the Application layer in TCP/IP implementations (TLS lives conceptually here but is implemented at Layer 7 in practice).
Layer 7 — Application
PDU: Data
The Application layer is the user-facing interface to the network — it provides the protocols that applications directly use to send and receive data. This is the layer you interact with every time you browse the web, send an email, or query a DNS server.
Common Layer 7 protocols:
| Protocol | Port | Purpose |
|---|---|---|
| HTTP | 80 | Web page transfer (plain) |
| HTTPS | 443 | Encrypted web (HTTP + TLS) |
| FTP | 21 | File transfer |
| SMTP | 25/587 | Send email |
| IMAP | 143/993 | Receive/sync email |
| POP3 | 110/995 | Download email |
| DNS | 53 | Domain → IP resolution |
| SSH | 22 | Encrypted remote shell |
| SNMP | 161 | Network device monitoring |
| DHCP | 67/68 | Automatic IP assignment |
| LDAP | 389 | Directory services |
| NTP | 123 | Time synchronisation |
What Layer 7 does NOT do: It doesn't know about cables, IP addresses, or routing. It hands data to Layer 6 (Presentation) and trusts the lower layers to deliver it.
Data encapsulation — how data travels down (and up) the stack
When you send an HTTP request, each layer wraps the data from the layer above with its own header (and sometimes trailer). This process is called encapsulation.
Layer 7 (App) HTTP Request
│ add HTTP headers
Layer 6 (Pres) [HTTP data] (possibly encrypted by TLS)
│ TLS record
Layer 5 (Session) [TLS data]
│ session metadata
Layer 4 (Trans) [TCP header | HTTP data] ← Segment
│ add source/dest port
Layer 3 (Network) [IP header | TCP | HTTP] ← Packet
│ add source/dest IP
Layer 2 (Data) [ETH hdr | IP | TCP | HTTP | FCS] ← Frame
│ add MAC addresses + CRC
Layer 1 (Phys) 101001110101... ← Bits
On the receiving end, each layer decapsulates (strips) its header and passes the remainder upward.
OSI model vs TCP/IP model
The Internet runs on the TCP/IP model (also called the Internet model or DoD model). Here's how the two map:
| TCP/IP Layer | OSI Equivalent Layers | Protocols |
|---|---|---|
| Application | Application (7) + Presentation (6) + Session (5) | HTTP, DNS, SMTP, SSH |
| Transport | Transport (4) | TCP, UDP |
| Internet | Network (3) | IP, ICMP, ARP |
| Network Access | Data Link (2) + Physical (1) | Ethernet, Wi-Fi |
Key differences:
| Dimension | OSI | TCP/IP |
|---|---|---|
| Layers | 7 | 4 |
| Development | Conceptual standard (ISO) | Practical (DARPA) |
| Adoption | Theory / education | Actual Internet |
| Session & Presentation | Distinct layers | Merged into Application |
| Protocol dependency | Protocol-independent | TCP/IP specific |
When to use which: Use OSI to analyse, describe, and troubleshoot networks. Use TCP/IP to implement and configure systems.
OSI model in troubleshooting
Working from bottom to top is the systematic approach:
Layer 1 — Is the cable plugged in? Link lights on?
Layer 2 — Is the switch seeing the MAC address? Any broadcast storm?
Layer 3 — Can you ping the default gateway? Is there a route?
Layer 4 — Is the port open? Is the service listening? (ss -tlnp)
Layer 5 — Is the session being established and maintained?
Layer 6 — Is there a TLS certificate error? Encoding mismatch?
Layer 7 — Is the application returning an error? Check app logs.
Practical commands per layer:
| Layer | Command |
|---|---|
| 1 — Physical | ethtool eth0, check cable, link light |
| 2 — Data Link | ip link show, bridge fdb show, arp -n |
| 3 — Network | ip route show, ping, traceroute |
| 4 — Transport | ss -tlnp, nc -zv host port, tcpdump |
| 7 — Application | curl -v, dig, app logs |
OSI model and network security
Understanding layers is essential for placing security controls correctly:
| Layer | Security control | Example |
|---|---|---|
| 1 | Physical security | Locked server rooms, cable locks |
| 2 | 802.1X port authentication | Only authorised devices get a port |
| 3 | Firewall (packet filtering), VPN | Block IPs; IPsec tunnel |
| 4 | Stateful firewall, IDS/IPS | TCP SYN flood protection |
| 5-6 | TLS/SSL | Encrypt sessions in transit |
| 7 | WAF, input validation, authentication | Block SQLi, XSS; OAuth |
DDoS attacks by layer:
| Attack | Layer | Method |
|---|---|---|
| SYN flood | 4 | Exhaust TCP connection state |
| UDP flood | 4 | Saturate bandwidth |
| HTTP flood | 7 | Overwhelm web server with requests |
| DNS amplification | 3–4 | Reflect/amplify via open resolvers |
| Slowloris | 7 | Hold open partial HTTP connections |
Common OSI model interview questions
| Question | Quick answer |
|---|---|
| What PDU does Layer 4 use? | Segment (TCP) or Datagram (UDP) |
| Which layer adds MAC addresses? | Layer 2 (Data Link) |
| Which layer does a router operate at? | Layer 3 (Network) |
| Which layer does a switch operate at? | Layer 2 (Data Link) — though Layer 3 switches exist |
| Where does TLS/SSL operate? | Layer 6 (Presentation) conceptually; implemented at Layer 7 |
| What is the difference between a hub and a switch? | Hub = Layer 1 (broadcasts bits); Switch = Layer 2 (forwards frames by MAC) |
| What protocol resolves IP to MAC? | ARP — operates at Layer 2/3 boundary |
| Which layer is responsible for end-to-end error recovery? | Layer 4 (Transport — TCP) |
Common mistakes
| Mistake | Reality |
|---|---|
| Thinking OSI is what the Internet uses | The Internet uses TCP/IP; OSI is a reference model |
| Confusing MAC (L2) with IP (L3) addresses | MAC = hardware, local delivery; IP = logical, global routing |
| Assuming switches only work at Layer 2 | Layer 3 switches route between VLANs |
| Placing TLS at Layer 4 | TLS is Layer 6 (Presentation) conceptually, though often grouped at 7 |
| Thinking ARP is Layer 3 | ARP maps IP (L3) to MAC (L2) — sits at the L2/L3 boundary |
| Saying UDP is "unreliable" without context | UDP is intentionally lightweight; reliability is added by the application if needed |
| Forgetting that Layer 1 includes wireless | Wi-Fi signals (radio waves) are a Physical-layer medium |
| Treating OSI as 7 independent silos | Layers communicate through well-defined interfaces, not in isolation |
OSI vs TCP/IP vs other models
| Dimension | OSI (ISO) | TCP/IP (DoD) | Hybrid (5-layer) |
|---|---|---|---|
| Layers | 7 | 4 | 5 |
| Used for | Education / analysis | Real Internet | Textbooks (Kurose & Ross) |
| App-level | 3 layers (5, 6, 7) | 1 layer (Application) | 1 layer |
| Data Link split | 2 sub-layers (LLC/MAC) | Merged | Merged |
| Physical layer | Yes | Merged into Network Access | Yes |
| Protocol agnostic | Yes | TCP/IP specific | Yes |
Frequently asked questions
Do I need to memorise all 7 layers?
Yes, especially in networking and sysadmin roles. Use the mnemonic "Please Do Not Throw Sausage Pizza Away" (Physical, Data Link, Network, Transport, Session, Presentation, Application — bottom to top). Most interviews expect you to name them in order and describe each.
Does the OSI model apply to Wi-Fi?
Yes. Wi-Fi (802.11) maps to Layer 1 (radio transmission / physical signals) and Layer 2 (MAC addressing, CSMA/CA, framing). The upper layers are identical for wired and wireless traffic.
Where does ARP fit in the OSI model?
ARP (Address Resolution Protocol) operates at the boundary between Layer 2 and Layer 3. It takes an IP address (Layer 3) and resolves it to a MAC address (Layer 2). Some references classify it as Layer 2, others as 2.5.
Why does the TCP/IP model have only 4 layers instead of 7?
TCP/IP was designed pragmatically for the ARPANET before OSI existed. It merges OSI Layers 5–7 into "Application" because real protocols (HTTP, SSH, etc.) handle session and presentation functions themselves. It also merges Layers 1–2 into "Network Access."
Is OSI still relevant in 2025?
Absolutely. It's the universal vocabulary for discussing networks — used in certifications (CompTIA Network+, CCNA, CCNP), security frameworks (NIST, MITRE ATT&CK), and troubleshooting. Every network engineer needs to understand it.
What layer does a firewall operate at?
It depends on the firewall type. Packet-filtering firewalls operate at Layer 3–4 (IP/port rules). Stateful firewalls track TCP state at Layer 4. Next-generation firewalls (NGFW) with deep packet inspection operate at Layer 7 (Application) to identify applications regardless of port.