Find a course

Module 1: How Networks WorkLesson 2 of 1311 min

The OSI and TCP/IP Models

Understand why networking is split into layers, what each OSI and TCP/IP layer does, and how encapsulation wraps data in headers as it travels.

Step 1 of 11Learn

Why layers?

Sending a message across the internet involves wildly different problems: turning bits into electrical pulses or radio waves, getting a frame to the next device on the same link, finding a route across continents, making sure nothing is lost, and formatting a web page. No single protocol could handle all of that well.

So networking is split into layers. Each layer solves one problem, uses the services of the layer below and offers services to the layer above. The big benefit is independence: your browser doesn't care whether you are on Wi-Fi, fiber or a phone network, and Wi-Fi doesn't care whether it is carrying a web page or a video call. Engineers can improve one layer, say a faster Wi-Fi standard, without rewriting the others.

Two models describe these layers:

  • The OSI model has seven layers. It was designed as a teaching and reference model, and its layer numbers became the vocabulary of the industry. You will hear people say "that's a Layer 2 problem" or "a Layer 7 load balancer".
  • The TCP/IP model has four layers and matches how the internet's protocols are actually built.

You don't need to memorize every detail. You need to know what each layer is responsible for, so you can describe where a problem lives and understand which device or protocol is involved.

Step 2 of 11Learn

The seven OSI layers

From the bottom up:

#LayerJobExamples
7ApplicationNetwork services that programs useHTTP, DNS, SMTP
6PresentationData formats, encryption, compressionTLS encryption, character encoding
5SessionOpening, managing and closing conversationssession setup in some protocols
4TransportEnd-to-end delivery between programs, using portsTCP, UDP
3NetworkLogical addressing and routing between networksIP, routers
2Data linkDelivery to the next device on the same link, using MAC addressesEthernet, Wi-Fi, switches
1PhysicalBits as signals on a mediumcables, fiber, radio, connectors

A popular memory aid from Layer 1 upward is "Please Do Not Throw Sausage Pizza Away": Physical, Data link, Network, Transport, Session, Presentation, Application.

In practice, layers 5 and 6 are thin and usually handled inside applications, which is why the TCP/IP model folds them into one Application layer. The layers that come up most in troubleshooting are 1 (is it plugged in?), 2 (is it on the right local network?), 3 (does it have a correct IP address and route?), 4 (is the port open?) and 7 (is the service itself working?).

Step 3 of 11Practice · Put in order

Put the OSI layers in order from Layer 1 (bottom) to Layer 7 (top).

Drag the items, or use the arrow buttons, to put them in order.

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

Step 4 of 11Practice · Match the pairs

Match each item to its OSI layer.

Tap an answer, then tap the place where it belongs (or drag it there).

  1. Fiber optic cable
  2. Ethernet switch forwarding by MAC address
  3. Router choosing a path by IP address
  4. TCP port 443
  5. A web browser's HTTP request

Step 5 of 11Diagram

The OSI stack, top to bottom

Tap a layer to see a real example of something that lives there.

The OSI stack, top to bottomLayer diagram: 7 Application, 6 Presentation, 5 Session, 4 Transport, 3 Network, 2 Data link, 1 Physical.7 Application6 Presentation5 Session4 Transport3 Network2 Data link1 Physical

Tap a shape with to see more.

7 Application

HTTP, DNS, SMTP: what programs speak.

6 Presentation

Formats and encryption, such as TLS and character encodings.

5 Session

Starting, keeping and ending conversations.

4 Transport

TCP and UDP, with port numbers.

3 Network

IP addresses and routers.

2 Data link

MAC addresses, switches, Wi-Fi association.

1 Physical

Cables, connectors, radio signals, light pulses.

Step 6 of 11Learn

Encapsulation: envelopes inside envelopes

As data moves down the layers on the sending computer, each layer adds its own header with the information it needs. This is encapsulation.

  1. The browser creates an HTTP request (application data).
  2. TCP adds a header with source and destination ports and a sequence number. The result is a segment.
  3. IP adds a header with source and destination IP addresses. Now it is a packet.
  4. Ethernet or Wi-Fi adds a header with MAC addresses and a trailer with an error check. Now it is a frame.
  5. The physical layer sends the frame as bits: voltages, light pulses or radio waves.

At each router along the way, the frame is unwrapped to read the IP header, then rewrapped in a new frame for the next link, because MAC addresses only matter on one link while IP addresses stay the same end to end (except where NAT rewrites them, which you'll see later). At the destination, each layer strips its header and passes the rest up, until the web server receives the original HTTP request.

The names of the wrapped units are worth knowing because they hint at the layer being discussed: frame (Layer 2), packet (Layer 3), segment (Layer 4 TCP; a UDP unit is called a datagram).

Encapsulation: data wrapped in TCP, IP and Ethernet headersHTTP dataTCPdataIPsegmentEthernetpacketL7L4L3

Step 7 of 11Practice · Fill in the blanks

Fill in the blanks

At Layer 2 the unit of data is called a , at Layer 3 it is called a , and a TCP unit at Layer 4 is called a .

Step 8 of 11Compare

OSI vs. TCP/IP

AspectOSI modelTCP/IP model
Number of layers74 (some books use 5, splitting the bottom layer in two)
TopApplication, Presentation, SessionApplication (covers all three)
MiddleTransport; NetworkTransport; Internet
BottomData link; PhysicalLink (network access)
Main use todayShared vocabulary and troubleshooting languageDescribes how real internet protocols are built

Step 9 of 11Note

Step 10 of 11Practice · Choose one

A user reports "the network is broken". You find the cable unplugged from the wall jack. Which OSI layer did the problem live at?

Step 11 of 11Practice · What would you do?

What would you do?

A coworker says, "My laptop shows it's connected to Wi-Fi with a strong signal, it has a valid IP address and can ping the router, but one particular website shows an error page from the site itself." Where is the problem most likely?