Training · Networking basics

The OSI model: the 7 layers of a network

How does a message leave your phone and reach a server far away? The OSI model explains that journey in 7 layers. Here you will see it step by step, with animations.

What is OSI?

OSI (Open Systems Interconnection) is a reference model published by ISO in 1984, so that devices from different makers could talk to each other. Today it is the standard ISO/IEC 7498-1, which is why people also call it “the ISO layers”.

The model splits network communication into 7 layers. Each layer has one job and talks only to the layer right below and right above it. That is why moving from Wi-Fi to fibre does not mean changing your browser: only the lower layer changes, the ones above stay the same.

The internet itself runs on TCP/IP, but network people still speak OSI's language. Phrases like “a layer 2 problem” or “a layer 7 firewall” come from this map. Going layer by layer is also the fastest way to find a fault.

To remember them

From 1 to 7: “Please Do Not Throw Sausage Pizza Away” → Physical, Data link, Network, Transport, Session, Presentation, Application.

From 7 to 1: “All People Seem To Need Data Processing” → Application, Presentation, Session, Transport, Network, Data link, Physical.

The 7 layers

Tap a layer to see its job, the name of its data, and the protocols and devices that live in it.

  1. Where the program you use talks to the network: the web, e-mail, name lookups.

    Its data is called
    Data
    What lives in it
    HTTP and HTTPS, DNS, SMTP and IMAP (e-mail), SSH, FTP and SFTP, DHCP
    Devices
    Server software, web application firewall (WAF), proxy

A message's journey

You type “Hello” to a web site on your phone. On the sending side the message goes down from 7 to 1, and each layer adds its own label (header). On the other side it goes up from 1 to 7, and each layer reads its label and takes it off. This is called encapsulation.

Your phone

  1. 7Application
  2. 6Presentation
  3. 5Session
  4. 4Transport
  5. 3Network
  6. 2Data link
  7. 1Physical
HTTPGET /chatHello

Server

  1. 7Application
  2. 6Presentation
  3. 5Session
  4. 4Transport
  5. 3Network
  6. 2Data link
  7. 1Physical

Step 1 of 15What it is called now: Data

7. Application: your browser puts “Hello” inside an HTTP request.

Read all the steps as text
  1. 7. Application: your browser puts “Hello” inside an HTTP request.
  2. 6. Presentation: TLS encrypts the message. Anyone listening on the way now sees only meaningless bytes. With HTTPS the HTTP header is encrypted too.
  3. 5. Session: the message belongs to the conversation (session) that is open with the server. On today's internet this layer has no label of its own; TLS and the application do this job together.
  4. 4. Transport: a TCP header is added: source port 51514, destination port 443 (HTTPS) and a sequence number. It is now called a segment.
  5. 3. Network: an IP header is added: source address 192.168.1.20, destination address 203.0.113.10. It is now called a packet.
  6. 2. Data link: an Ethernet or Wi-Fi header goes in front and an error check (FCS) at the end. The destination MAC address is not the server's but your home router's: that is the first stop. It is now called a frame.
  7. 1. Physical: the frame becomes 0s and 1s, then electricity on copper, light in fibre, or radio waves on Wi-Fi.
  8. On the way: every router takes off the layer 2 header, looks at the IP address and sends the packet to the next stop with a new layer 2 header. The destination IP address stays the same all the way. (Your home router changes the source address to its own public one with NAT.)
  9. 1. Physical: the server's network card turns the signal back into 0s and 1s.
  10. 2. Data link: the FCS is checked; a frame damaged on the way is dropped. If it is intact, the Ethernet header and the FCS are taken off.
  11. 3. Network: is the destination IP this server's? Yes. The IP header is taken off.
  12. 4. Transport: destination port 443 tells which program gets the data: the web server. If a piece is missing, TCP asks for it again and puts the pieces in order.
  13. 5. Session: the data joins the right connection and the right conversation.
  14. 6. Presentation: TLS decrypts it. The HTTP request and “Hello” can be read again.
  15. 7. Application: the web server reads the HTTP request and gets “Hello”. Its answer travels back to your phone the same way, in reverse.

OSI and TCP/IP

The model the internet really uses is TCP/IP, with 4 layers (RFC 1122). OSI's top three layers fold into one “Application” layer there, and its bottom two into the “Link” layer.

OSI is a map for teaching and talking: when someone says “a layer 3 problem”, everyone knows where to look. Some books use a 5-layer model in between, which splits Link back into Data link and Physical.

OSI (7 layers)

TCP/IP (4 layers)

7 Application

6 Presentation

5 Session

4 Transport

3 Network

2 Data link

1 Physical

Application

Transport

Internet

The parcel comparison

Think of sending a letter to another city by courier. Each layer takes one part of the job.

  1. 7 Application

    Writing the letter: deciding what to say.

  2. 6 Presentation

    Translating the letter into the reader's language and sealing the envelope.

  3. 5 Session

    Giving the correspondence a file number, so it can go on where it stopped.

  4. 4 Transport

    Packing the shipment into numbered boxes, and sending a lost box again.

  5. 3 Network

    Writing the full address, and the depots choosing the route.

  6. 2 Data link

    Handing over from one depot to the next: a new delivery note at every stop.

  7. 1 Physical

    The road and the truck: what physically carries the shipment.

Troubleshooting: from the bottom up

If the internet does not work, start at layer 1 and go up. Most faults are in the lower layers: an unplugged cable or the wrong Wi-Fi.

  1. 1Physical: Is the cable plugged in and undamaged? Is the Wi-Fi signal strong enough?
  2. 2Data link: Is it on Wi-Fi, the right network? Is the switch port's light on?
  3. 3Network: Did the device get an IP address? Does a ping to the router work?
  4. 4Transport: Is the port you need open (for example 443)? Is a firewall blocking it?
  5. 5Session: Does the connection drop now and then? Does the site keep asking you to sign in?
  6. 6Presentation: Do letters show up garbled? Does the browser warn about the certificate?
  7. 7Application: Does the site open? Which error do you see (404, 500)? Do other sites open?

What comes next?

Each layer is getting its own page: its protocols and devices, its own animation, common faults, attacks and defences. A short quiz comes at the end.

← Back to the blog