← All lessons
How networks work · Lesson 2 of 7

The layers

Sending a message across the world involves a lot of separate problems: turning bits into electrical or radio signals, getting a packet to the next device, finding a route across many networks, making sure nothing is lost, and understanding what the message means. Networking splits these into layers. Each layer does one job and only talks to the layers just above and below it.

That means you can change one layer without touching the others. Your browser doesn't care whether you're on Wi-Fi or a cable; Wi-Fi doesn't care whether you're loading a web page or a game.

The OSI model has seven layers, numbered from the bottom: 1 Physical (signals on a wire or radio), 2 Data link (getting a frame to the next device on the same network: Ethernet, Wi-Fi), 3 Network (addresses and routes across networks: IP), 4 Transport (between the two programs: TCP, UDP), 5 Session, 6 Presentation and 7 Application (what the program means: HTTP, DNS, email).

The internet itself was built on a simpler model, TCP/IP, with four layers: Link (OSI 1 and 2), Internet (3), Transport (4) and Application (5 to 7). People still use the OSI numbers as shorthand: a "layer 2 switch" works with Ethernet frames, a "layer 7 firewall" looks at web requests.

When you send data, each layer wraps it in its own header on the way down, like an envelope inside an envelope. This is encapsulation. A web request goes inside a TCP segment, which goes inside an IP packet, which goes inside an Ethernet frame. The receiver unwraps them in the reverse order on the way up.

Practice

Put the OSI layers in order, from layer 1 at the bottom to layer 7 at the top.

  1. Tap the items below in order.
More info

Quick reference

Layer 1 PhysicalSignals: cables, radio, light.
Layer 2 Data linkTo the next device: Ethernet, Wi-Fi, MAC addresses.
Layer 3 NetworkAcross networks: IP addresses, routers.
Layer 4 TransportBetween programs: TCP, UDP, ports.
Layer 7 ApplicationWhat it means: HTTP, DNS, SMTP.
EncapsulationEach layer wraps the data in its own header.

The other networking courses