OSI Reference Model Layers
Suppose you send a photo to a friend on another continent. A lot has to go right. Electrical or light signals must carry the bits. The bits must be grouped and checked for damage. The data must find a path through many networks. The right program on your friend's computer must receive it, and the photo must arrive in an order that makes sense. No single piece of software can handle all of that well. The OSI reference model answers the question of how to split this job into manageable parts. It divides network communication into seven layers, each with one clear responsibility.
Why Networks Are Built in Layers
Think about posting a letter. You write it, fold it, seal it in an envelope, and drop it in a box. A sorting office routes it. A truck carries it to a plane, and the plane flies it to another country. Each step cares only about its own job. The truck driver does not read your letter, and the writer does not care which road the truck takes. If the airline changes its planes, nobody has to rewrite how letters are written.
Network designers use the same idea. A layer is a group of related functions. Each layer handles one kind of problem and hides its details from the layers around it. The rules that two matching layers on different machines follow to communicate are called a protocol. For example, the transport layer on your laptop follows transport rules that the transport layer on the server also follows.
Here is the part people often get wrong. The layers on each machine talk to their matching peers as if they were connected directly. In reality, data never jumps straight across. It moves down the stack on the sending machine, travels over the physical link, and then moves up the stack on the receiving machine. The only layer that physically connects the two computers is the bottom one, the wire or radio signal itself.
The Seven Layers at a Glance
The model numbers its layers from 1 at the bottom to 7 at the top. These numbers are used everywhere, so when someone says a "layer 3 device," they mean a device that works at the network layer. Each layer also has a name for the chunk of data it handles. That name is called a protocol data unit, or PDU for short.
| Layer | Name | Main responsibility | Typical unit of data |
|---|---|---|---|
| 7 | Application | Gives network services directly to programs | Message |
| 6 | Presentation | Agrees on data format, compression, and encryption | Data |
| 5 | Session | Opens, manages, and closes dialogues between programs | Data |
| 4 | Transport | Delivers data between specific programs, with optional reliability | Segment |
| 3 | Network | Moves packets across many networks using logical addresses | Packet |
| 2 | Data Link | Moves frames across one link between directly connected nodes | Frame |
| 1 | Physical | Sends raw bits as signals over a medium | Bit |
A simple memory aid for the order from layer 1 up to layer 7 is "Please Do Not Throw Sausage Pizza Away." The first word of each memory phrase matches the layer names.
Notice how the units shrink and grow as you move down the table. A message from a program becomes segments, then packets, then frames, and finally a stream of bits. Each step wraps the data in new information that the matching layer on the other side will read.
The diagram below shows the seven layers stacked and labeled, so you can keep their order straight.
spec: static diagram of seven stacked horizontal boxes, numbered from 7 at the top to 1 at the bottom. Box 7: "Application - gives network services to programs". Box 6: "Presentation - data format, compression, encryption". Box 5: "Session - opens, manages, closes dialogues". Box 4: "Transport - delivers between programs (ports), optional reliability". Box 3: "Network - logical addressing and routing across networks". Box 2: "Data Link - frames between directly connected nodes". Box 1: "Physical - raw bits as signals on a medium". Along the right edge, label the units of data beside each box: Message, Data, Data, Segment, Packet, Frame, Bit. Arrows on the left side point downward and are labeled "serves the layer above" to show that lower layers provide services upward.
How a Layer Serves the One Above It
Each layer offers a service to the layer directly above it. A service is a set of functions the lower layer performs on request, through a defined interface. The layer above asks for something and gets it. It does not need to know how the lower layer does the work.
Take the transport layer as an example. It needs to send a chunk of data to a program on a distant computer. It asks the network layer to deliver that chunk to a particular machine. The transport layer does not know which cables, routers, or radio links carry the data. The network layer does not know which program will read the data at the end. Each layer depends only on the service of the layer below.
This arrangement lets you swap a layer without rebuilding the rest. A laptop can switch from Wi-Fi to an Ethernet cable, and the layers above keep working, because the data link and physical layers still provide the same service upward. The upper layers never see the change.
The diagram below shows how two stacks communicate. Data moves down one side, across the physical link, and up the other side. The dashed lines show the logical peer relationships.
spec: static diagram of two vertical seven-layer stacks side by side, labeled "Sender" on the left and "Receiver" on the right, with layers 7 (Application) to 1 (Physical) in each. A solid arrow runs down the sender stack from layer 7 to layer 1, then a solid horizontal arrow labeled "bits over physical medium" crosses to the receiver's layer 1, then a solid arrow runs up the receiver stack from layer 1 to layer 7. Dashed horizontal lines connect matching layers across the two stacks, each labeled "peer protocol" at layer 7 and layer 4, to show logical communication between peers. Caption text inside the diagram: "Data goes down, across, and up; peers agree at each level."
The Lower Three Layers: Moving Data Across Links
The physical layer (layer 1) turns bits into signals. A bit is the smallest unit of data, a single 0 or 1. The physical layer decides how a 1 looks on a copper wire, a fiber strand, or a radio wave. It handles voltage levels, timing, and connector pins. It does not know what the bits mean. A stream of ones and zeros is just a stream to it.
The data link layer (layer 2) moves data between two nodes that are directly connected. A node is any device on the network, such as a computer, a switch, or a router. This layer groups bits into frames and marks where each frame starts and ends. It checks each frame for damage. It also uses MAC addresses, hardware addresses burned into network cards, to pick the right device on the local link. In an office, the data link layer is what gets your laptop's frame to the correct port on the switch.
The network layer (layer 3) moves packets across many networks, one hop at a time. A hop is one trip from a router to the next. This layer uses IP addresses, logical addresses that identify a host on the wider internet and can be grouped by network. Routers use the network layer to choose the next hop for each packet.
A common question is why we need both MAC and IP addresses. The answer is that a MAC address only has meaning on a single local link, and it stays tied to the hardware. An IP address can describe the destination no matter how many links lie between you and it. Each address solves a different problem at a different layer.
The Upper Three Layers: Serving the Application
The transport layer (layer 4) delivers data between specific programs on two machines. A computer runs many programs at once, so the transport layer uses port numbers to tell them apart. A port is a number that identifies one program on a host. A web page request and an email transfer can arrive at the same machine, and the port number tells the transport layer which program gets each one. This layer can also add reliability, such as noticing lost data and asking for it again, or it can skip that work to keep delay low.
The session layer (layer 5) manages a dialogue between two programs. It opens the conversation, keeps track of whose turn it is to talk, and closes the conversation cleanly. It can also place checkpoints in a long transfer. If the connection drops during a large file transfer, a checkpoint lets the transfer resume from the last mark instead of starting over.
The presentation layer (layer 6) makes sure the data is readable on both ends. Two computers may store text, numbers, or images in different formats. This layer agrees on a common format, and it handles compression to shrink data and encryption to hide it from eavesdroppers. When you send a file in a compressed and encrypted form, the presentation layer is the one doing that work.
The application layer (layer 7) gives network services to software. Be careful with the name. It does not mean your browser or your chat app. Those programs sit above layer 7 and ask it for services. Protocols such as HTTP for web pages, SMTP for email, and DNS for name lookups all live at this layer. A browser uses HTTP through the application layer, and it never needs to know how the bits leave your machine.
In practice, real protocols often blend the session and presentation functions into other layers. You will rarely meet a clean, standalone session or presentation protocol, but the functions still need to be done somewhere. The seven-layer model keeps them named so you can reason about each job separately.
AI-generated study article from SophistAI. Sign up free to study it with an AI tutor.