OSI Model Explained: The 7 OSI Layers (Layer-by-Layer) With Real-World Examples
The OSI model explained: what each of the 7 layers does, PDU names, encapsulation, device mapping, and how to troubleshoot issues layer by layer.
Long Nguyen
Fullstack Developer · AI Engineer · Researcher
What Is the OSI Model, and Why Does It Still Matter?
The OSI (Open Systems Interconnection) model is a 7-layer reference framework that splits everything a network does into distinct, stackable responsibilities: moving raw bits, addressing devices on a local segment, routing between networks, delivering data reliably, and finally handing usable data to an application. It was formalized as ITU-T Recommendation X.200, the same text published as ISO/IEC 7498-1, and it predates the internet protocol suite most networks actually run today.
No real network stack — not Ethernet, not TCP/IP, not Wi-Fi — implements the OSI model layer-for-layer. That is the single most misunderstood fact about it, and it is also why the model has survived for decades: it is not an implementation spec, it is a shared vocabulary for isolating problems. When a request fails, "is this a Layer 2, 3, or 4 problem?" narrows the search space faster than staring at an error message. That is the practical reason engineers, support teams, and certification exams (Network+, CCNA, Security+) still lean on it in 2026, long after TCP/IP won the architecture war.
The 7 OSI Layers at a Glance
Each layer has one job, a name for the data unit it works with (the PDU), and a small set of protocols people actually associate with it. Use this table as the map; the sections below go one layer deeper.
| Layer | Name | PDU | Core job | Common protocols/examples |
|---|---|---|---|---|
| 7 | Application | Data | Expose services to the end user or client app | HTTP/HTTPS, DNS, SMTP, SSH, FTP |
| 6 | Presentation | Data | Translate, encrypt, compress | TLS, gzip/Brotli, JSON/UTF-8 encoding |
| 5 | Session | Data | Open, manage, and tear down a dialogue between hosts | SMB/RPC session setup, application login sessions |
| 4 | Transport | Segments (TCP) / Datagrams (UDP) | End-to-end delivery: reliable and ordered, or fast and connectionless | TCP, UDP, port numbers |
| 3 | Network | Packets | Logical addressing and routing between subnets | IPv4, IPv6, ICMP, OSPF/BGP |
| 2 | Data Link | Frames | Local delivery on one physical segment, MAC addressing | Ethernet, 802.1Q VLANs, ARP, STP |
| 1 | Physical | Bits | Put signal on the medium | Copper/fiber cabling, SFPs, Wi-Fi radios |
A quick way to read this table: as data leaves your application, it travels down from 7 to 1, gaining a header at nearly every layer. As it arrives at the destination, it travels back up from 1 to 7, and each layer strips off its own header before handing the rest upward. That round trip is encapsulation and decapsulation, covered in detail further down.
Layer 1 — Physical Layer
Responsibilities: electrical, optical, or radio signaling; media type (copper, fiber, wireless); connectors, transceivers, and how a 0 or 1 is actually encoded onto the medium. PDU: bits.
Examples: Cat5e/Cat6 Ethernet cabling, SFP/SFP+ transceivers, NIC ports, Wi-Fi radio frequencies and channels.
Where it actually breaks: Layer 1 faults masquerade as "the network is slow" far more often than teams expect — a marginal cable or a bad transceiver doesn't always take a link fully down, it just corrupts enough frames to force retransmits at Layer 2 and 4, which looks like an application problem until someone checks the physical layer.
- Check link lights and SFP/transceiver detection first — a green light doesn't guarantee a clean signal, only that one exists.
- Confirm negotiated speed and duplex on both ends; an auto-negotiation mismatch (one side forced to full-duplex, the other auto) silently produces late collisions and throughput that looks capped at a fraction of line rate.
- Pull interface error counters (CRC errors, runts, giants) — rising CRC counts on an otherwise "up" link point straight at cabling or a failing transceiver.
- For wireless, check signal-to-noise ratio (SNR) and co-channel interference before blaming the access point's configuration.
Layer 2 — Data Link Layer
Responsibilities: framing, MAC addressing for delivery within one broadcast domain, error detection via the frame check sequence (FCS), switch forwarding, and VLAN tagging (802.1Q). PDU: frames.
Examples: Ethernet frames, 802.1Q VLAN tags, Spanning Tree Protocol (STP), ARP (technically sits at the L2/L3 boundary — it resolves an L3 IP address to an L2 MAC address).
Where it actually breaks: almost every "device has an IP but can't reach anything" ticket that isn't a Layer 3 misconfiguration turns out to be a VLAN mismatch or a trunk that isn't carrying the tag it needs to.
- Verify VLAN membership on the port and whether it's configured as access or trunk — a device plugged into the wrong VLAN gets an IP from DHCP and still can't reach its default gateway.
- Check the switch's MAC address table to confirm learning/forwarding is happening on the port you expect.
- Inspect STP port state — a port stuck in blocking (after a topology change or a misconfigured priority) drops all traffic even though the link light is green.
- Review port security violations and error counters; a port that's err-disabled from a security violation looks identical to a dead cable from the host's point of view.
Layer 3 — Network Layer
Responsibilities: logical addressing and routing between subnets. PDU: packets.
Examples: IPv4 and IPv6 addressing, ICMP for diagnostics (ping, traceroute rely on it), routing protocols conceptually (OSPF, BGP).
Where it actually breaks: the classic "I can ping the gateway but nothing past it" pattern is a routing or NAT problem, not a local network problem — don't waste time re-checking cables once ICMP confirms Layer 1–2 are fine.
- Confirm IP address, subnet mask, and default gateway on the host — a wrong mask silently makes some "local" hosts look remote and vice versa.
- Inspect the route table on both the host and the router; a missing or incorrect route is invisible until you look for it directly.
- Use
pingto confirm reachability andtraceroute/tracertto find exactly which hop drops the packet. - Check ACLs, firewall rules, and NAT behavior — a route can be perfectly correct and traffic still gets dropped or translated in a way that breaks the return path.
Layer 4 — Transport Layer
Responsibilities: segmentation and reassembly, end-to-end reliability, ordering, and flow control (TCP), or connectionless best-effort delivery (UDP). PDU: TCP segments and UDP datagrams.
Examples: TCP carries HTTP, SSH, and most reliable streams; UDP carries DNS queries, VoIP media, and DHCP.
Where it actually breaks: "ping works but the app times out" is the signature of a Layer 4 or stateful-firewall problem — ICMP and TCP are handled by completely different code paths on most firewalls, so one succeeding tells you nothing about the other.
- Test the specific port with
nc -zv host portortelnet host portrather than assuming a passing ping means the service port is reachable. - Capture the handshake: a SYN with no SYN-ACK means something between client and server is silently dropping the packet (often a stateful firewall or security group rule); a SYN followed immediately by RST means the port is reachable but nothing is listening.
- Watch for retransmits in a packet capture — steady retransmits with no resets usually point to loss on the path, not the application.
- Remember NAT and stateful firewalls track connections by the 4-tuple (source IP, source port, destination IP, destination port); an asymmetric route that sends the return packet through a different firewall breaks the session even though routing "works."
Layer 5 — Session Layer
Responsibilities: establishing, maintaining, and tearing down a session between two communicating hosts; checkpointing and recovery concepts for long-lived interactions.
Examples: application login sessions, SMB/RPC session handshakes, keepalives and idle-timeout semantics.
Where it actually breaks: Layer 5 is the layer most modern engineers skip, because TCP/IP doesn't have a distinct session protocol for most traffic — the "session" concept usually lives inside the application (a cookie, a token, a WebSocket) rather than as a separate wire protocol. When something is described as OSI Layer 5, it's almost always this kind of application-managed state, not a standalone session-layer packet.
Troubleshooting angle: check idle timeouts and expired tokens/cookies first; then check session-table exhaustion on middleboxes (load balancers and firewalls that track session state can silently drop new sessions once a table fills up); then check for failed session re-establishment after a network blip.
Layer 6 — Presentation Layer
Responsibilities: translating data into a format both ends understand — encryption/decryption, compression, and character encoding.
Examples: TLS encryption, JSON/XML serialization, gzip/Brotli compression, UTF-8/ASCII encoding.
Where it actually breaks: in practice, "Layer 6" in a modern stack is almost entirely TLS. Certificate expiry, a cipher-suite mismatch after a security hardening change, or a client that only supports an older TLS version than the server now requires are the three most common real-world Layer 6 incidents. Compression and character-encoding bugs (a page that "looks garbled") are the second most common — usually a missing or wrong Content-Encoding/charset header, not a network fault at all.
Layer 7 — Application Layer
Responsibilities: the network-facing services and protocols end users and client applications interact with directly. PDU: application data (messages/objects).
Examples: HTTP/HTTPS for the web, DNS for name resolution, DHCP for IP assignment, SMTP for email, SSH for remote shells, FTP/SFTP for file transfer.
Where it actually breaks: this is where most tickets land regardless of the real cause, because "the app is broken" is what a user reports. Isolate it properly before assuming it's actually a Layer 7 bug:
- Use
curl -v,dig, ornslookupto probe the service directly and read the exact stage where it fails. - Check application logs for authentication or request errors — a 401/403 is an application decision, not a network fault.
- Inspect request/response headers and payloads; a wrong
Hostheader on a shared IP, or a missing API key, produces symptoms that look identical to "the network is down" from the user's chair.
Encapsulation and PDU Names: How Data Actually Moves Through the Layers
Encapsulation is the process of wrapping data in a new header (and sometimes a trailer) at every layer it passes through on the way down the stack. Decapsulation is the reverse, happening on the receiving host. Knowing the PDU name at each layer is what lets you say "this is an L2 problem" instead of just "the network is broken":
- Layer 7: application data (an HTTP message, for example)
- Layer 4: TCP segment — adds source/destination ports, sequence and acknowledgment numbers
- Layer 3: IP packet — adds source/destination IP addresses
- Layer 2: Ethernet frame — adds source/destination MAC addresses and, if present, an 802.1Q VLAN tag
- Layer 1: bits on the wire
The header sizes are fixed and worth memorizing, because they explain real-world numbers like MTU and MSS:
| Header | Typical size | Key fields |
|---|---|---|
| Ethernet II | 14 bytes (+ 4-byte FCS trailer) | Destination MAC (6), Source MAC (6), EtherType (2) |
| IPv4 | 20 bytes (no options) | Version/IHL, Total Length, TTL, Protocol, Source IP, Destination IP |
| TCP | 20 bytes (no options) | Source/Destination Port, Sequence Number, Ack Number, Flags, Window Size |
That's why a standard 1500-byte Ethernet MTU leaves roughly 1460 bytes for actual application data once IP (20 bytes) and TCP (20 bytes) headers are subtracted — the number every TCP maximum segment size (MSS) calculation starts from, and the reason a VPN or tunnel that adds its own header on top has to reduce MTU further or start fragmenting.
Tracing One HTTP Request Through All 7 Layers
The fastest way to make the OSI model click is to watch it happen in a tool you already use. Run curl -v against any HTTPS site and map the output to layers as it streams past:
$ curl -v https://example.com
* Trying 93.184.216.34:443...
* Connected to example.com (93.184.216.34) port 443
* ALPN: offers h2,http/1.1
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN: server accepted h2
> GET / HTTP/2
> Host: example.com
> user-agent: curl/8.4.0
> accept: */*
>
< HTTP/2 200
< content-type: text/html; charset=UTF-8
< content-length: 1256
Reading it top to bottom against the model:
- "Trying ... Connected" is Layers 1–4: DNS already resolved a name to an IP (Layer 7/3 boundary), the TCP three-way handshake completed on port 443 (Layer 4), riding on IP packets (Layer 3) inside Ethernet frames and physical signaling you don't see from curl.
- The TLS handshake lines are Layer 6 — negotiating encryption before any application data moves.
- The
GET / HTTP/2block and the response headers are Layer 7 — the actual application protocol semantics.
This is also the fastest real diagnostic split: if curl hangs at "Trying," suspect Layers 1–4 (routing, firewall, or the port isn't open). If it connects but stalls on the TLS handshake, it's Layer 6 (certificate, cipher, or TLS version mismatch). If you get a fast HTTP error code, the network stack did its job and the problem is Layer 7 — the application itself.
Where Network Devices Operate: Switches vs Routers vs Firewalls vs Load Balancers
| Device | Primary layer | What it does |
|---|---|---|
| Switch | Layer 2 (many are also multilayer L3-capable) | Forwards frames based on MAC address tables within a broadcast domain |
| Router | Layer 3 | Routes IP packets between subnets and networks based on route tables |
| Firewall | Layers 3–4 (stateful), some also Layer 7 | Filters by IP/port with connection-state tracking; next-gen firewalls add application-aware (L7) inspection |
| Load balancer | Layer 4 or Layer 7, depending on mode | L4 balances by IP/port; L7 balances by inspecting HTTP headers, paths, or cookies |
| Access point | Layers 1–2 | Bridges wireless clients onto a wired L2 segment |
OSI Model vs TCP/IP Model: Practical Comparison
The internet doesn't run on OSI's seven layers — it runs on the four-layer Internet model formalized in IETF RFC 1122, which groups OSI's top three layers into one "Application" layer because, in practice, session and presentation concerns are handled inside applications rather than as separate protocols.
| OSI layers | TCP/IP (RFC 1122) layer | Typical protocols |
|---|---|---|
| 1–2 (Physical, Data Link) | Link | Ethernet, 802.11, switching, VLANs |
| 3 (Network) | Internet | IPv4/IPv6, ICMP, OSPF/BGP |
| 4 (Transport) | Transport | TCP, UDP |
| 5–7 (Session, Presentation, Application) | Application | HTTP(S), DNS, SMTP, TLS |
Practically, this mapping tells you which tool to reach for: Wireshark for L1–4 packet detail, ss/netstat for L4 socket state, and application logs for everything TCP/IP folds into "Application."
Common Misconceptions About the OSI Model
- "Every protocol lives at exactly one layer." Many don't. ARP straddles L2/L3. TLS is described as L6 conceptually but is implemented as its own protocol running over L4. MPLS is often called "Layer 2.5." Treat the layer numbers as a mental model for isolating faults, not a strict classification system.
- "OSI is what the internet actually runs on." It isn't — TCP/IP is, and it only has four layers (RFC 1122). OSI is a teaching and troubleshooting reference, not the internet's implementation architecture.
- "Session and Presentation are obsolete, so skip them." They're not obsolete, they're just absorbed into applications (TLS libraries, session tokens, serialization formats) instead of existing as separate wire protocols — understanding what those two layers conceptually cover still helps you place a bug correctly.
- "Higher layer numbers are 'more important.'" A Layer 1 cable fault takes down every layer above it; a Layer 7 bug affects one application. Lower layers are foundational, not less significant.
OSI Model Cheat Sheet
| Layer | Main responsibility | Example protocols/devices | PDU | Quick troubleshooting move |
|---|---|---|---|---|
| 7 Application | App services & user interfaces | HTTP, DNS, SMTP, SSH | Data | curl -v/dig; check app logs |
| 6 Presentation | Encryption, compression, encoding | TLS, gzip, UTF-8 | Data | Check cert validity and cipher suites |
| 5 Session | Session establishment & state | SMB sessions, RPC, cookies/tokens | Data | Check timeouts and session tables |
| 4 Transport | Ports, reliability, segmentation | TCP, UDP | Segments/Datagrams | Test ports (nc -zv); check for retransmits |
| 3 Network | Routing & logical addressing | IPv4/IPv6, ICMP | Packets | traceroute; check the route table |
| 2 Data Link | Framing, MACs, VLANs, switching | Ethernet, 802.1Q, STP | Frames | Check VLAN/trunk config, MAC table |
| 1 Physical | Media, signaling, connectors | Copper, fiber, Wi-Fi | Bits | Check link lights, error counters, SNR |
Real-World Troubleshooting Scenarios, Layer by Layer
Scenario 1 — "The website won't load."
- Layer 1: confirm the server's physical link and the switch/router port status.
- Layer 2: verify VLAN and trunk settings; confirm MAC learning on the relevant switch ports.
- Layer 3: confirm the server's IP, default gateway, and that routing to its subnet actually works from where the client sits.
- Layer 4: test HTTP(S) ports 80/443 directly from a client, then from a host closer to the server, to bisect where connectivity stops.
- Layers 6–7: check TLS certificate validity, then application logs for errors once the network layers are confirmed clean.
Scenario 2 — "The device has an IP but can't reach anything past the local segment." This is almost always Layer 2: check switchport VLAN membership, trunk tagging on the uplink, STP port state, and the MAC table entries for both the client and its gateway.
Scenario 3 — "DNS resolution fails but the server is reachable by IP." Confirm resolver configuration on the client, test manually with dig/nslookup, check whether UDP/TCP port 53 is blocked somewhere on the path, and inspect the DNS server's logs for refusals or recursion problems.
Scenario 4 — "Uploads work, but large downloads randomly stall or corrupt." Suspect an MTU/fragmentation mismatch, often introduced by a VPN or tunnel that reduces the effective MTU without the endpoints agreeing on it — this shows up as connections that establish fine (small packets) but fail once a payload exceeds the path's actual maximum size.
OSI Model in Certifications and Job Interviews
The OSI model shows up on CompTIA Network+, Cisco CCNA, and most entry-level networking or security interviews for a simple reason: it's the fastest way to test whether a candidate can reason about where a problem lives instead of just naming protocols. Two patterns come up repeatedly:
- "Name the layer for protocol X" — straightforward recall, covered by the tables above.
- "Walk me through what happens when a user types a URL and hits enter" — this is the OSI model applied end to end: DNS resolution, TCP handshake, TLS negotiation, HTTP request/response, all mapped to layers 7 through 1 and back. The "Tracing One HTTP Request" section above is effectively a prepared answer to this exact interview question.
How to Remember the 7 OSI Layers (Mnemonics)
Bottom-up (1→7): "Please Do Not Throw Sausage Pizza Away" (Physical, Data Link, Network, Transport, Session, Presentation, Application).
Top-down (7→1): "All People Seem To Need Data Processing."
Practice suggestions that make the mnemonic stick instead of just letting you recite it:
- Map commands you already use to layers:
ping(L3/ICMP),traceroute(L3 path discovery),dig(L7 DNS),curl(L7 HTTP),ss/netstat(L4 sockets). - Capture a real HTTP request with Wireshark and step through the encapsulation for yourself instead of reading it secondhand.
- Build a small lab with virtual routers/switches (or a packet-emulation sandbox) and practice injecting failures at a specific layer, then diagnosing which one broke.
Conclusion: Turn the OSI Model Into a Debugging Habit
The value of the OSI model isn't reciting seven names in order — it's the habit of asking "which layer is this?" before you start changing configuration. A cable fault, a VLAN mismatch, a bad route, a closed port, an expired certificate, and a broken API all present as "it doesn't work," and the model is what lets you tell them apart in minutes instead of hours. Keep the cheat sheet nearby, run the curl -v trace on a real request the next time something breaks, and the layers stop being trivia and start being a checklist.
If your team is debugging network- or infrastructure-level issues on a production system regularly and wants a second set of eyes on the architecture, Netalith offers a free consultation to talk through what's actually going on before you commit to a fix.
FAQ
Frequently asked questions
What is the OSI model in simple terms?
The OSI model is a 7-layer reference framework that breaks networking into distinct jobs — from putting raw signal on a cable (Layer 1) up to the applications people actually use (Layer 7). It's not a real protocol stack; it's a shared vocabulary engineers use to describe and isolate where a problem is happening.
How many layers does the OSI model have, and what are they called?
Seven: Layer 1 Physical, Layer 2 Data Link, Layer 3 Network, Layer 4 Transport, Layer 5 Session, Layer 6 Presentation, and Layer 7 Application. A common mnemonic for remembering them in order is 'Please Do Not Throw Sausage Pizza Away.'
What's the difference between the OSI model and the TCP/IP model?
OSI has seven layers and is a conceptual teaching/troubleshooting model. TCP/IP, defined in RFC 1122, has four layers (Link, Internet, Transport, Application) and is what the actual internet runs on — it folds OSI's Session, Presentation, and Application layers into one Application layer.
Is the OSI model still used in real networks today?
Real traffic runs on TCP/IP, not OSI directly, but the OSI model is still the standard way engineers describe and troubleshoot networks, and it remains core material in certifications like CompTIA Network+ and Cisco CCNA.
What layer does a firewall operate at?
Most firewalls do stateful filtering at Layers 3 and 4 (IP addresses and ports, with connection tracking). Next-generation firewalls add Layer 7 inspection to filter based on application content, not just headers.
What does PDU mean in networking?
PDU stands for Protocol Data Unit — the name for the chunk of data at a given OSI layer. It's called a frame at Layer 2, a packet at Layer 3, a segment (TCP) or datagram (UDP) at Layer 4, and simply data at Layers 5 through 7.