The OSI Model

Learn the seven layers of the OSI model, what each one does, how data is wrapped as it travels, and how to use the layers to find network problems.

~21 min Beginner

Why networks use layers

Sending a photo to a friend looks like one action, but a lot happens underneath. The photo is cut into pieces, each piece gets an address, the pieces travel over cables or radio, and at the other end they are put back together.

If one program did all of that, fixing a bug in it would be very hard. So network designers split the work into layers. Each layer has one narrow job and only deals with the layer directly above it and the layer directly below it.

The best-known layered design is the OSI model (Open Systems Interconnection). It has seven layers and gives everyone the same vocabulary for talking about networks.

The seven layers

From the top (closest to you) to the bottom (closest to the wire):

  • 7. Application: the services programs use, such as HTTP for the web, DNS for names and SSH for remote logins.
  • 6. Presentation: how data is represented: character encoding, compression and encryption.
  • 5. Session: starting, maintaining and ending a conversation between two programs.
  • 4. Transport: splitting data into pieces and delivering them between programs. TCP, UDP and port numbers belong here.
  • 3. Network: addressing and routing between different networks. IP addresses and routers belong here.
  • 2. Data Link: delivery between two devices on the same local network. MAC addresses and switches belong here.
  • 1. Physical: the actual signal. Cables, radio waves, voltages and light pulses.

A way to remember them

A common memory aid takes the first letter of each layer, from layer 7 down to layer 1:

All People Seem To Need Data Processing

Application, Presentation, Session, Transport, Network, Data Link, Physical. You do not need to memorise it for life. Use it until the order feels natural.

Following one web request

Here is what happens, layer by layer, when your browser opens https://example.com:

  1. Application (7): the browser builds an HTTP request that asks for the home page.
  2. Presentation (6): the request is encoded and encrypted so people on the path cannot read it.
  3. Session (5): the conversation with the server is opened and tracked.
  4. Transport (4): TCP splits the data into segments and adds port 443, so the data reaches the web server program.
  5. Network (3): IP adds your address and the server's address.
  6. Data Link (2): Ethernet or WiFi adds the MAC address of the next device, usually your router.
  7. Physical (1): everything becomes electrical pulses, light or radio waves.

Your router reads the IP address and passes the packet on. This repeats until the packet reaches the server, which unwraps the layers in reverse order.

In practice, encryption (TLS) does not fit neatly into one OSI layer. Textbooks usually place it at layers 5 and 6, and that is how this lesson shows it.

Encapsulation: how data gets wrapped

Data starts at the top layer and is wrapped on its way down. Each layer puts its own header (and sometimes a trailer) around what it received from the layer above.

  • Transport adds the port numbers.
  • Network adds the IP addresses.
  • Data Link adds the MAC addresses.
  • Physical turns the result into signals on a wire or in the air.

The receiving device does the reverse. It strips one header at a time, from layer 1 up to layer 7, until the application gets the original data. Wrapping is called encapsulation and unwrapping is de-encapsulation.

Names for data at each layer

The unit of data has a different name depending on the layer you are talking about:

  • Data at the top layers (what the application wants to send).
  • Segment at the Transport layer for TCP, or datagram for UDP.
  • Packet at the Network layer. It carries IP addresses.
  • Frame at the Data Link layer. It carries MAC addresses.
  • Bits at the Physical layer.

These names tell you where to look. "A frame was dropped" points at layer 2. "The packet was routed" points at layer 3.

Using the layers to find problems

You will rarely be asked to recite the layers at work. You will use them to troubleshoot. When a website will not load, work through the layers from the bottom:

  1. Layer 1: Is the cable plugged in? Is WiFi turned on?
  2. Layers 2 and 3: Does the device have a valid IP address?
  3. Layer 4: Can you reach the right port on the server?
  4. Layer 7: Is the website itself working?

Starting at the bottom stops you from blaming DNS when the real problem is an unplugged cable.

Network engineers use these phrases every day. A "layer 1 problem" is physical, a "layer 3 problem" is about addressing or routing, and a "layer 7 problem" is in the application.

OSI and TCP/IP

The internet is actually built on a simpler four-layer model called TCP/IP: Link, Internet, Transport and Application. It merges several OSI layers into one.

OSI is still taught everywhere because it gives people a shared vocabulary, even though real networks follow TCP/IP. When someone says "layer 3", they mean the OSI layer number.

Sign up to track your progress Mark lessons as read and pick up where you left off Sign up free to unlock this practice Your first practice lesson is free to try. Create an account to unlock the rest and save your progress