Seven layers. Every packet that has ever crossed the internet. One mental model that makes all of networking finally click.
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.
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.
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.
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 |
|---|---|---|---|
| 7 | Application | Away | All |
| 6 | Presentation | Pizza | People |
| 5 | Session | Sausage | Seem |
| 4 | Transport | Throw | To |
| 3 | Network | Not | Need |
| 2 | Data Link | Do | Data |
| 1 | Physical | Please | Processing |
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.
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.
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.
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–5 | Data / Message | Application | Application-specific |
| 4 | Segment (TCP) / Datagram (UDP) | Transport layer | Source port, destination port, seq #, checksum |
| 3 | Packet | Network layer | Source IP, destination IP, TTL, protocol |
| 2 | Frame | Data Link layer | Source MAC, destination MAC, EtherType, FCS trailer |
| 1 | Bits | Physical layer | Voltage signals, encoding scheme |
Let's make this concrete. You type https://thedaddyproject.org and hit Enter. Here's what happens, layer by layer:
thedaddyproject.org to an IP.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.
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. |
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.
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.
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 |
|---|---|---|---|---|
| HTTP | L7 | TCP | 80 | Unencrypted web traffic. Never send passwords here. |
| HTTPS | L7 | TCP | 443 | HTTP over TLS. The padlock. Encrypted. |
| DNS | L7 | UDP (53) / TCP (53) | 53 | Resolves hostnames to IPs. The phonebook of the internet. |
| SMTP | L7 | TCP | 25/587 | Sends email. Port 587 is modern submission (with auth). |
| IMAP | L7 | TCP | 143/993 | Reads email from server (keeps it on server). 993 = TLS. |
| SSH | L7 | TCP | 22 | Encrypted remote shell. Replace Telnet with this, always. |
| FTP | L7 | TCP | 20/21 | File transfer. Unencrypted — use SFTP (port 22) instead. |
| DHCP | L7 | UDP | 67/68 | Auto-assigns IP addresses to devices joining a network. |
| SNMP | L7 | UDP | 161 | Network device monitoring and management. |
| TCP | L4 | — | — | Reliable, ordered, connection-oriented. The workhorse. |
| UDP | L4 | — | — | Fast, connectionless. Used for DNS, video, VoIP, gaming. |
| IP (v4/v6) | L3 | — | — | Logical addressing and routing. The core of the internet. |
| ICMP | L3 | — | — | Diagnostics: ping, traceroute, "destination unreachable" errors. |
| ARP | L2/3 | — | — | Resolves IP addresses to MAC addresses on local networks. |
TCP is reliable because it establishes a connection before sending data. That process is three steps and it's worth knowing cold:
Closing a TCP connection requires a four-way FIN process (FIN → ACK → FIN → ACK), because each direction of the connection closes independently.
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
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.
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/8 | A | Yes | Large corporate LANs, cloud VPCs |
| 172.16.0.0/12 | B | Yes | Mid-size private networks |
| 192.168.0.0/16 | C | Yes | Home routers, small offices |
| 127.0.0.0/8 | — | Loopback | 127.0.0.1 = "this machine." ping it to test your TCP/IP stack. |
| 0.0.0.0/0 | — | Default 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.
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 |
|---|---|---|---|
| /8 | 255.0.0.0 | 16,777,214 | Large enterprise WAN |
| /16 | 255.255.0.0 | 65,534 | Campus or datacenter |
| /24 | 255.255.255.0 | 254 | Home network, small office |
| /30 | 255.255.255.252 | 2 | Router-to-router point-to-point links |
| /32 | 255.255.255.255 | 1 | Specific host route, loopback |
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.)
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.
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) |
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:
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.