The OSI Model: All 7 Layers Explained Simply

Sending data across a network is like mailing a letter through the postal system -- each layer wraps your message in another envelope. The OSI model names those seven envelopes.

Explore the layers interactively

Free interactive lab. No signup. Runs in your browser.

Quick Summary

The Postal System Analogy

Imagine you want to mail a birthday card to a friend in another city. You write the card (the actual message), slip it into an envelope, address it, drop it in a mailbox, and trust the postal system to do the rest. Behind the scenes, that card passes through many hands: a local post office sorts it, a truck carries it to a regional hub, a plane flies it across the country, another truck delivers it, and finally a mail carrier walks it to the door. Each stage only cares about its own job -- the plane does not read your message, and you do not need to know which truck was used.

The OSI model works exactly like this. When your computer sends data, the message starts at the top (the "card you wrote") and travels down through seven layers. Each layer adds its own "envelope" -- a small header with the information that layer needs -- and hands the bundle to the layer below. By the time it reaches the bottom, your message is wrapped in several nested envelopes and converted into raw electrical, optical, or radio signals on the wire.

On the receiving computer, the process runs in reverse and up the stack. Each layer opens its own envelope, reads only the part addressed to it, and passes the rest upward. Finally the top layer hands the original message -- your birthday card -- to the application. This "wrap on the way down, unwrap on the way up" idea is the single most important concept in the entire model, and we will watch it happen step by step below.

The 7 Layers at a Glance

Here are all seven layers, top to bottom, with the unit of data (the PDU) each one works with and a device that operates there:

OSI Reference Model — 7 Layers (top to bottom) 7 Application HTTP, DNS, SMTP — PDU: Data apps 6 Presentation TLS encryption, compression, encoding — PDU: Data — 5 Session Sessions, dialog control — PDU: Data — 4 Transport TCP / UDP, ports — PDU: Segment / Datagram firewall/LB 3 Network IP addressing, routing — PDU: Packet router 2 Data Link MAC addressing, Ethernet, FCS — PDU: Frame switch 1 Physical Cables, fiber, radio, voltage — PDU: Bits hub / cable SEND down RECEIVE up Mnemonic (top→down): "All People Seem To Need Data Processing"

7-Layer Explorer + Encapsulation Animator

Click any layer to see its PDU, example protocols, and the device that operates there. Then press Send data ↓ to watch your message get wrapped into a frame, and Receive ↑ to unwrap it.

Press “Send data ↓” to begin encapsulation.

Notice the pattern in the animation: nothing is ever thrown away on the way down. Each layer simply wraps what it received from the layer above. That is why the original Data ends up buried in the middle of the frame, surrounded by the Transport, Network, and Data Link headers (plus the Data Link trailer). On the receiving side, every layer peels off exactly its own header and hands the rest up, until the application gets back the clean message it was sent.

Walking the Stack, Step by Step

1

Layers 7-5: Application, Presentation, Session

The top three layers are closest to you. Layer 7 (Application) is the user-facing layer where protocols like HTTP, DNS, and SMTP live -- it is your web browser asking for a page. Layer 6 (Presentation) handles how data is formatted: encryption with TLS, compression, and character encoding such as ASCII, UTF-8, or JPEG. Layer 5 (Session) sets up, manages, and tears down the conversation (the "session") between two applications. At all three of these layers the unit of data is simply called Data.

2

Layer 4: Transport (TCP & UDP)

The Transport layer is responsible for end-to-end delivery between the two communicating hosts. It introduces ports so a single device can run many services at once, and it is where TCP (reliable, ordered, connection-oriented) and UDP (fast, connectionless) operate. When TCP is used, the PDU is called a Segment; with UDP it is a Datagram. This is the layer that decides whether every byte must arrive correctly or whether speed matters more than perfection.

3

Layer 3: Network (IP & Routing)

The Network layer is the home of IP addressing and routing. It adds the source and destination IP addresses and decides how to get a Packet (its PDU) across multiple networks to a host that may be on the other side of the world. Routers are Layer 3 devices: they read the destination IP, consult their routing table, and forward the packet toward its destination, hop by hop. This is the layer that makes the global internet possible.

4

Layers 2-1: Data Link & Physical

The Data Link layer moves data across a single physical link using MAC addresses and packages everything into a Frame, adding both a header and a trailer (the FCS, used for error detection). Switches are Layer 2 devices. Finally, the Physical layer converts the frame into raw Bits -- electrical voltages on copper, pulses of light on fiber, or radio waves over the air. Cables, connectors, and hubs live here. A simple bottom-up mnemonic is "Please Do Not Throw Sausage Pizza Away."

The OSI Model in the Real World

Engineers talk in OSI layer numbers every day. Here are three places that vocabulary shows up:

🌐

Loading a Web Page

Your browser (L7 HTTP) asks for a page, TLS encrypts it (L6), the conversation is a session (L5), TCP (L4) breaks it into segments with port 443, IP (L3) routes the packets to the server, switches (L2) forward frames across each LAN, and the bits (L1) cross fiber and copper. All seven layers, one click.

🔐

A "Layer 3 vs Layer 7" Firewall

When a vendor says a firewall is "Layer 3," it filters on IP addresses and ports. A "Layer 7" or "next-generation" firewall can also inspect the actual application data -- which website or which HTTP request -- because it understands the top of the stack. The OSI numbers tell you exactly how deep it sees.

🔧

Troubleshooting Bottom-Up

A classic technique is to debug from Layer 1 up: is the cable plugged in (L1)? Is the link up and the MAC learned (L2)? Can you ping the IP (L3)? Is the TCP port open (L4)? Does the app respond (L7)? Naming the layer pinpoints the problem fast.

Common OSI Model Mistakes

The OSI model is simple once it clicks, but a few misunderstandings trip up almost every beginner:

⚠

Thinking the Internet Runs on OSI

The OSI model is a conceptual reference, not the protocol stack the internet actually uses. Real traffic runs on the TCP/IP model, which has 4-5 layers and merges OSI's top three into one Application layer. OSI is invaluable for learning and for shared vocabulary, but no packet on the wire has seven distinct OSI headers labeled 7 through 1.

⚠

Mixing Up the Layer Order

It is easy to flip the order or forget a layer. Anchor yourself with a mnemonic: top-to-bottom "All People Seem To Need Data Processing" (Application, Presentation, Session, Transport, Network, Data Link, Physical), or bottom-to-top "Please Do Not Throw Sausage Pizza Away."

⚠

Confusing Packets, Frames, and Segments

These words are not interchangeable -- each names the PDU at a specific layer. A Segment (or Datagram) is Layer 4, a Packet is Layer 3, and a Frame is Layer 2. Saying "a packet arrives at the switch" is technically off, because a switch handles frames. Using the right term signals you understand where in the stack you are.

OSI vs. the TCP/IP Model

Since the internet actually runs on the TCP/IP model, it is worth seeing how the two line up. TCP/IP collapses OSI's Application, Presentation, and Session layers into a single Application layer, keeps Transport and Internet (OSI's Network) layers as they are, and combines OSI's Data Link and Physical into one Link layer (sometimes split into Link and Physical, giving five layers). The protocols you use every day -- HTTP, TCP, IP, Ethernet -- map cleanly onto this simpler stack. Despite that, engineers still reach for OSI's numbering because saying "a Layer 3 problem" or "a Layer 7 load balancer" is precise and universally understood.

Why the Layered Design Matters

The real power of layering is independence. Because each layer only talks to its immediate neighbors through a well-defined interface, you can swap out one layer without touching the others. You can switch from copper to fiber (Layer 1) without changing how IP routing works (Layer 3). You can add TLS encryption (Layer 6) without rewriting your web server (Layer 7). This separation of concerns is exactly why the internet has been able to evolve for decades while still carrying traffic from the very first protocols.

The bottom line: the OSI model is your map of how networks work. Once you can picture data being wrapped on the way down and unwrapped on the way up -- and you know which layer owns IP, which owns MAC, and which owns ports -- nearly every other networking topic has a place to live.

Frequently asked questions about the OSI model

What is the OSI model?

The OSI (Open Systems Interconnection) model is a conceptual reference model that describes how data travels across a network by splitting communication into seven layers, from the user-facing Application layer down to the Physical layer that moves raw bits. Each layer has a defined job and talks only to the layers directly above and below it, which makes complex networking easier to design, teach, and troubleshoot.

What are the 7 layers of the OSI model?

From top to bottom they are: Layer 7 Application (HTTP, DNS, SMTP), Layer 6 Presentation (encryption/TLS, compression, encoding), Layer 5 Session (sessions and dialog control), Layer 4 Transport (TCP/UDP, ports, segments and datagrams), Layer 3 Network (IP addressing and routing, packets), Layer 2 Data Link (MAC addressing, switches, frames), and Layer 1 Physical (cables, fiber, radio, raw bits). A common mnemonic top-to-bottom is "All People Seem To Need Data Processing."

What is the difference between the OSI model and the TCP/IP model?

The OSI model is a seven-layer conceptual reference used for teaching and discussion, while the TCP/IP model is the four-to-five-layer model the real internet actually runs on. TCP/IP collapses OSI's Application, Presentation, and Session layers into a single Application layer and merges Physical and Data Link into a Link layer. Even though the internet uses TCP/IP, OSI vocabulary like Layer 2, Layer 3, and Layer 7 is used universally.

What is encapsulation in the OSI model?

Encapsulation is the process of wrapping data in headers (and at Layer 2, a trailer) as it moves down the sender's stack. The Transport layer adds a header to make a segment, the Network layer adds an IP header to make a packet, and the Data Link layer adds a header and trailer to make a frame, which the Physical layer sends as bits. On the receiving device the process reverses, de-encapsulating the data layer by layer back up the stack.

Which OSI layer does a router or a switch operate at?

A switch operates at Layer 2, the Data Link layer, forwarding frames using MAC addresses, while a router operates at Layer 3, the Network layer, forwarding packets using IP addresses. A plain hub is a Layer 1 device that just repeats bits. Firewalls and load balancers often work across several layers, anywhere from Layer 3 up to Layer 7.

See the layers come alive

You just learned how data is wrapped and routed through seven layers. Now build a topology, trace traffic between hosts, and see switches carry frames by MAC address while routers make the Layer 3 decisions, with the headers of every hop in the Packet Inspector.

Launch the network lab →