← Back to Deep Dives Tech

The OSI Model, Actually Explained

Seven layers. Every packet that has ever crossed the internet. One mental model that makes all of networking finally click.

🕮 ~18 min read · Written by Ian · Updated March 2026

Every time you open a browser tab, stream a video, send a message, or ping a server, data travels through seven conceptual layers. The OSI model is the map. Most people have heard of it. Most people couldn't tell you what Layer 4 is without Googling it. By the time you finish this, you'll own it.

We're not going surface level here. I want you to understand this model well enough to use it — to debug a network problem, to explain it in a job interview, to know why your VPN slows you down or why a firewall lives where it does. Let's go.

Why a Layered Model at All?

In the 1970s, every networking vendor had their own proprietary stack. IBM had SNA. DEC had DECnet. You couldn't easily connect an IBM machine to a DEC machine. The International Organization for Standardization (ISO) decided that was a problem worth solving. In 1984 they published the Open Systems Interconnection model — OSI.

The big idea: break the complex problem of "how do two computers talk to each other?" into discrete, independent concerns. Each layer handles one job. Each layer only talks to the layer directly above it and directly below it. You can swap out implementations at one layer without touching the others.

Why You Actually Care

In practice, TCP/IP (not OSI) is what runs the internet. The OSI model is a reference model — a conceptual framework, not a literal implementation. But it's universally used for troubleshooting, documentation, certification exams, and job interviews. Every network engineer thinks in OSI layers whether they admit it or not.

The Mnemonic

There are two directions you can read the model, and two mnemonics to match. Pick the one that sticks:

Layer # Name Bottom-Up Mnemonic Top-Down Mnemonic
7ApplicationAwayAll
6PresentationPizzaPeople
5SessionSausageSeem
4TransportThrowTo
3NetworkNotNeed
2Data LinkDoData
1PhysicalPleaseProcessing

Bottom-up: Please Do Not Throw Sausage Pizza Away. Top-down: All People Seem To Need Data Processing. Doesn't matter which. Pick one and burn it in.

The Seven Layers

We'll go bottom-up, because that's the direction data travels as it's built up for transmission. Think of it as wrapping a gift: each layer adds its own packaging before handing it down.

1
Physical
Bits • Cables, Radio, Light
Raw bits on a medium. Voltages on copper wire, light pulses in fiber optic cable, radio waves in Wi-Fi. This layer defines connectors, pin layouts, voltage levels, frequencies, and transmission rates. It has zero concept of what the bits mean — it just moves them.
Examples: Ethernet cable (Cat5e/Cat6), fiber optic, Wi-Fi radio (802.11), Bluetooth, USB, RS-232
2
Data Link
Frames • Node-to-Node Delivery
Takes raw bits and organizes them into frames. Handles node-to-node delivery on a single network segment, error detection (not correction), and flow control. This is where MAC addresses live — hardware addresses burned into network interface cards at the factory. Layer 2 knows nothing about routing between networks; it only knows about the local segment.
Examples: Ethernet (IEEE 802.3), Wi-Fi (IEEE 802.11), Switches, Bridges, ARP, PPP, VLAN tagging (802.1Q)
3
Network
Packets • End-to-End Routing
The routing layer. Takes frames from Layer 2 and wraps them in packets with source and destination IP addresses. Routers operate here — they read the destination IP, consult their routing tables, and forward the packet toward its destination, one hop at a time. Layer 3 provides logical addressing and path determination. It does not guarantee delivery or order. Because IP address blocks are allocated regionally and hierarchically, a router in Europe doesn't need to know about every IP on the internet — it just needs to know "anything starting with 24.x goes west." Steve Gibson's analogy: a router with four interfaces (north/south/east/west) only needs a short table mapping IP prefixes to exit directions. The packet moves hop by hop, each router only knowing the next step. — Security Now! #25
Examples: IP (IPv4/IPv6), ICMP (ping!), OSPF, BGP, RIP, Routers, Layer 3 switches, NAT
4
Transport
Segments • End-to-End Reliability
Where TCP and UDP live. Layer 4 provides end-to-end communication between applications. TCP adds reliability: connection establishment (three-way handshake), guaranteed delivery, in-order reassembly, and flow control. UDP skips all that for raw speed. Ports live here — that's how the OS knows which application gets which data. Port 443 goes to your HTTPS app, port 22 goes to SSH, and so on.
Examples: TCP (reliable, ordered), UDP (fast, unordered), port numbers, three-way handshake, TLS operates here and at L5/L6
5
Session
Sessions • Dialog Management
Manages the sessions between applications — the start, maintenance, and teardown of a conversation. Handles authentication at the session level, synchronization checkpoints (so a long transfer can resume rather than restart), and half-duplex vs full-duplex dialog control. Honestly the most abstract layer; in practice TCP/IP collapses much of this into layers 4 and 7. But the concept matters.
Examples: NetBIOS, RPC, SQL sessions, NFS, SMB session layer, TLS session resumption
6
Presentation
Data • Translation, Encryption, Compression
The translator. Layer 6 converts data between the formats that applications use and the formats that the network uses. This includes character encoding (ASCII to UTF-8), serialization formats (JSON, XML, ASN.1), encryption and decryption (TLS lives conceptually here and at Layer 4/5), and compression. When your browser and server negotiate TLS, the Presentation layer is doing the work of making sure both sides can actually read each other's bytes.
Examples: TLS/SSL encryption, JPEG/MPEG/GIF compression, ASCII/Unicode, MIME types, XDR serialization
7
Application
Data • User-Facing Protocols
The layer you actually see. HTTP, HTTPS, DNS, FTP, SMTP, SSH — these are all Layer 7 protocols. This is where user applications interact with the network stack. A common misconception: the application itself (Chrome, Outlook, your terminal) is not "Layer 7." Layer 7 is the protocol that application uses to communicate — the rules governing format, requests, and responses.
Examples: HTTP/HTTPS, DNS, SMTP/IMAP/POP3, FTP/SFTP, SSH, SNMP, DHCP, Telnet, WebSocket

Encapsulation: How a Packet Is Actually Built

This is the concept that makes the model click from theory into something real. When you send data, it travels down the stack on the sender's machine — each layer wraps the data from the layer above in its own header (and sometimes a trailer). This is called encapsulation.

On the receiving end, it travels up the stack, with each layer stripping off its own header and passing the payload up to the next layer. This is de-encapsulation.

The Gift-Wrapping Analogy

Imagine you're shipping a fragile item to your kid at college. You put the item in a box (L7 data), wrap it in padding (L6 encoding), seal the box (L5 session), address it with their dorm room number (L4 port), put the full mailing address on the outside (L3 IP), hand it to the postal truck driver who knows the local routes (L2 MAC), and the truck's wheels physically move it (L1 physical). The recipient reverses every step to get the original item.

Each layer adds its own header. The data unit name changes at each layer:

Layer Data Unit Name Header Added By Key Fields
7–5Data / MessageApplicationApplication-specific
4Segment (TCP) / Datagram (UDP)Transport layerSource port, destination port, seq #, checksum
3PacketNetwork layerSource IP, destination IP, TTL, protocol
2FrameData Link layerSource MAC, destination MAC, EtherType, FCS trailer
1BitsPhysical layerVoltage signals, encoding scheme

A Real-World Trace: You Type a URL

Let's make this concrete. You type https://thedaddyproject.org and hit Enter. Here's what happens, layer by layer:

  1. Layer 7 — Application: Your browser constructs an HTTP GET request. Before that can go anywhere, it needs an IP address for the hostname. A DNS query is fired — also Layer 7, also UDP — to resolve thedaddyproject.org to an IP.
  2. Layer 6 — Presentation: TLS negotiation kicks off. Your browser and the server exchange certificates, agree on a cipher suite, and establish an encrypted channel. From this point forward, the HTTP data is encrypted.
  3. Layer 5 — Session: A session is established and maintained. TLS session tickets may allow resumption if you visit again soon.
  4. Layer 4 — Transport: TCP wraps the data. A three-way handshake (SYN → SYN-ACK → ACK) establishes the connection. The HTTP GET is segmented, each segment gets a source port (some ephemeral high port on your machine) and destination port 443. TCP will guarantee these arrive and reassemble correctly.
  5. Layer 3 — Network: The TCP segment becomes the payload of an IP packet. Source IP: your machine. Destination IP: the server. Your OS hands this to your router, which looks up the best path toward the destination and forwards it. Every router along the way reads the Layer 3 header only.
  6. Layer 2 — Data Link: On your local network, the packet gets wrapped in an Ethernet frame addressed to your router's MAC address (found via ARP). At each hop, frames are stripped and rebuilt — the MAC addresses change at every router, but the IP addresses stay the same.
  7. Layer 1 — Physical: Electrical signals on your Ethernet cable or radio waves on your Wi-Fi carry the bits out of your house. Fiber carries them across the backbone at the speed of light.

The server receives the bits, de-encapsulates up through all seven layers, processes the HTTP GET, and sends a response down its own stack. Your browser gets the HTML, renders the page, and you see what you came for.

I spent years in the Army working with communications equipment and field networks without a formal CS degree. When I finally sat down and actually mapped this model against what I'd been doing hands-on — configuring radios, running network cable in FOBs, troubleshooting connectivity in the field — it was a genuine "oh, THAT'S what I was doing" moment. The model was always true. I just hadn't had the vocabulary for it.

Devices and Where They Live

One of the most useful applications of the OSI model is understanding which network device operates at which layer. This tells you exactly what each device can and can't see, and what kind of decisions it can make.

Device Layer What It Reads What It Does
Hub L1 Nothing — just repeats bits Broadcasts every signal to every port. Dumb. Mostly gone.
Switch L2 MAC addresses Learns which MAC is on which port, forwards frames only to the correct destination. Doesn't read IPs.
Router L3 IP addresses Makes routing decisions between networks. Decrements TTL. Can connect different network types.
Firewall (traditional) L3–L4 IP addresses + ports Allows/blocks traffic based on IP + port rules. "Block all inbound TCP port 23" = firewall job.
Next-Gen Firewall / WAF L7 Full application data Deep packet inspection. Can block specific URLs, detect SQL injection, inspect HTTPS content (with cert).
Load Balancer L4 or L7 Ports or full HTTP headers Distributes connections across servers. L7 LBs can route based on URL paths, cookies, and hostnames.
NIC (network card) L1–L2 Bits + MAC frames Converts between the physical medium and the logical frame. Has a burned-in MAC address.
The "Layer X Problem" Troubleshooting Trick

When something doesn't work, start at Layer 1 and move up. Is the cable plugged in? (L1) Can you ping the default gateway by IP? (L3) Can you reach the port? (L4) Can you get an HTTP 200? (L7) This systematic approach cuts troubleshooting time dramatically. Most problems are at Layer 8 — that's the person.

TCP/IP vs OSI: What Actually Runs the Internet

Here's the honest truth: TCP/IP predates OSI and doesn't map perfectly to it. The internet runs on the TCP/IP model (also called the Internet model or DoD model), which has four layers. Knowing how they map helps you translate between the two:

TCP/IP Layer OSI Equivalent Protocols
Application L5 + L6 + L7 HTTP, HTTPS, DNS, SMTP, SSH, FTP, SNMP
Transport L4 TCP, UDP
Internet L3 IP, ICMP, OSPF, BGP
Network Access / Link L1 + L2 Ethernet, Wi-Fi, ARP, PPP

The OSI model collapses when you try to map TLS to it precisely — TLS overlaps L4, L5, and L6 depending on which functionality you're looking at. That's fine. The model is a thinking tool, not a law of physics.

The Protocols You Actually Need to Know

This is the reference table I wish I'd had. Sorted by layer, with the stuff that actually matters in real life.

Protocol Layer Transport Default Port What It Does
HTTPL7TCP80Unencrypted web traffic. Never send passwords here.
HTTPSL7TCP443HTTP over TLS. The padlock. Encrypted.
DNSL7UDP (53) / TCP (53)53Resolves hostnames to IPs. The phonebook of the internet.
SMTPL7TCP25/587Sends email. Port 587 is modern submission (with auth).
IMAPL7TCP143/993Reads email from server (keeps it on server). 993 = TLS.
SSHL7TCP22Encrypted remote shell. Replace Telnet with this, always.
FTPL7TCP20/21File transfer. Unencrypted — use SFTP (port 22) instead.
DHCPL7UDP67/68Auto-assigns IP addresses to devices joining a network.
SNMPL7UDP161Network device monitoring and management.
TCPL4Reliable, ordered, connection-oriented. The workhorse.
UDPL4Fast, connectionless. Used for DNS, video, VoIP, gaming.
IP (v4/v6)L3Logical addressing and routing. The core of the internet.
ICMPL3Diagnostics: ping, traceroute, "destination unreachable" errors.
ARPL2/3Resolves IP addresses to MAC addresses on local networks.

The Three-Way Handshake (TCP Connection Establishment)

TCP is reliable because it establishes a connection before sending data. That process is three steps and it's worth knowing cold:

  1. SYN — Client sends a synchronize packet to the server: "I want to talk. Here's my starting sequence number: X."
  2. SYN-ACK — Server responds: "Got it. Acknowledged (X+1). Here's my starting sequence number: Y."
  3. ACK — Client acknowledges: "Got your Y. We're connected." Data can now flow.

Closing a TCP connection requires a four-way FIN process (FIN → ACK → FIN → ACK), because each direction of the connection closes independently.

Steve Gibson on Security Now! — TTL, Router Loops, and Traceroute

Every IP packet carries a Time To Live (TTL) counter — not measured in seconds, but in router hops. Each router that forwards a packet decrements TTL by one. When TTL hits zero, the router discards the packet and sends an ICMP "Time Exceeded" message back to the sender. This prevents misconfigured routers from creating infinite loops, passing the same packet endlessly in a circle — what Gibson calls the Hot Potato problem.

The clever part: traceroute exploits this deliberately. It sends the first packet with TTL=1, so it dies at the first router, which reports back its own IP. Then TTL=2 — dies at router 2, which reports back. And so on until the destination is reached. "By repeating that process," Gibson explains, "we end up with a very elegant little listing of every router between us and our destination." — Security Now! #25

SYN Flood Attacks

A classic DDoS attack exploits the three-way handshake: an attacker sends millions of SYN packets with fake source IPs. The server allocates resources for each half-open connection waiting for the final ACK that never comes. The server's connection table fills up and it can't accept legitimate connections. Defense: SYN cookies, rate limiting, firewalls.

IP Addresses: A Quick But Necessary Detour

The OSI model relies on logical addressing at Layer 3. You need to understand the basics of IPv4 to use this model in practice.

An IPv4 address is 32 bits written as four decimal octets: 192.168.1.100. Each octet is 0–255. The address has two parts: the network portion and the host portion, determined by the subnet mask.

Range Class Private? Common Use
10.0.0.0/8AYesLarge corporate LANs, cloud VPCs
172.16.0.0/12BYesMid-size private networks
192.168.0.0/16CYesHome routers, small offices
127.0.0.0/8Loopback127.0.0.1 = "this machine." ping it to test your TCP/IP stack.
0.0.0.0/0Default Route"Send anything I don't have a better route for here." Points to your ISP.

IPv4 is running out — the last large blocks were allocated around 2011. IPv6 uses 128-bit addresses written in hexadecimal (2001:0db8:85a3::8a2e:0370:7334), providing an essentially inexhaustible address space. The internet is slowly migrating.

Subnetting in Plain English

A subnet mask tells you which part of an IP address identifies the network and which part identifies the host. /24 means the first 24 bits are the network — leaving 8 bits for hosts, which gives you 254 usable addresses (256 - 2, subtracting the network address and broadcast address).

CIDR Notation Subnet Mask Usable Hosts Common Use
/8255.0.0.016,777,214Large enterprise WAN
/16255.255.0.065,534Campus or datacenter
/24255.255.255.0254Home network, small office
/30255.255.255.2522Router-to-router point-to-point links
/32255.255.255.2551Specific host route, loopback

How Encryption Fits the Model

People get confused about where TLS/HTTPS "lives." The honest answer is: it spans multiple layers, which is part of why OSI-to-TCP/IP mapping gets messy. Here's how to think about it:

The key takeaway: HTTPS means the HTTP data (URL, headers, body) is encrypted. The IP addresses of source and destination are not encrypted — they're in the L3 header which must be readable by routers. A network observer can see that you're talking to a server, but not what you said. (SNI leaks the hostname too, unless you use Encrypted Client Hello — but that's another deep dive.)

VPNs and the Layer Stack

A VPN wraps your entire IP packet (L3 and everything above) inside a new IP packet destined for the VPN server. Your ISP only sees encrypted traffic going to the VPN endpoint — they can't read the inner packet. The VPN server decrypts, reads the original L3 destination, and forwards it. This is why VPNs add latency: your packets travel to the VPN server first, then onward. There's no magic — just another layer of encapsulation.

Quick Reference: Troubleshooting by Layer

Bookmark this. When something breaks on the network, here's the systematic approach:

Layer Question to Ask Tools / Commands
L1 Is the cable plugged in? Is the link light on? Is Wi-Fi signal present? Physical inspection, ip link, ifconfig
L2 Is the NIC getting a MAC address? Is ARP resolving correctly? arp -a, ip neighbor
L3 Do you have an IP? Can you ping the gateway? Can you ping the destination? ping, ip route, traceroute / tracert
L4 Is the port open? Is the firewall blocking? Is the service listening? telnet host port, nc -zv, netstat -an, ss -tulnp
L5–6 Is TLS handshaking? Is the cert valid and trusted? Is the cipher supported? openssl s_client -connect host:443, browser cert viewer
L7 Is the application responding? Is the HTTP response code correct? curl -v https://host, browser DevTools (Network tab)

The Stuff Worth Memorizing Cold

If you're studying for CompTIA Network+, a job interview, or just want the model to live in your head instead of on a flash card, here's the minimum:

"All models are wrong, but some are useful." — George Box, statistician. Also true of the OSI model.

The OSI model is a simplification of reality. TCP/IP doesn't follow it perfectly. TLS doesn't map cleanly to a single layer. Real network stacks are messier than seven clean boxes. But the model gives you a shared vocabulary and a thinking framework that has stood for over 40 years. That's not nothing — that's everything when you're trying to debug why your VPN is routing weird at 2am.

You own this now. Go break something on purpose and trace it down from Layer 7 to Layer 1. That's how it becomes reflexive.

👤
Ian
Army vet, combat journalist, father of many. Learned networking the hard way — running cable in FOBs, configuring comms gear in the field, and eventually getting the CS vocabulary to match the hands-on reality. Writes about tech, faith, cars, and whatever else won't leave him alone.