Skip to main content
Back to module
Networking Fundamentals · How Networks Work

The OSI and TCP/IP models

Reading20mLesson 1 of 3 in this module

Map common protocols such as Ethernet, IP, TCP, DNS and HTTP to the layers of the OSI and TCP/IP models.

Why it matters

When a web page will not load, the cause could be a loose cable, a Wi-Fi password, a wrong IP address, a blocked port, a DNS failure, an expired certificate or a bug in the application. Network models give you a map so you can check these one layer at a time instead of guessing. They also give engineers a shared vocabulary: "it's a layer 3 problem" means "look at IP addressing and routing", and everyone on the call knows where to start.

The core idea: layers

Sending data across a network is split into layers. Each layer does one job and relies on the layer below it. When you send something, every layer wraps the data in its own header (this is called encapsulation). The receiver unwraps the headers in reverse order.

The OSI model (7 layers)

The OSI model is a teaching and troubleshooting model. Real networks do not implement it exactly, but its layer numbers are used everywhere.

#LayerJobExamples
7ApplicationServices programs useHTTP, DNS, SMTP, SSH
6PresentationData format, encryptionTLS (often placed here), JPEG, UTF-8
5SessionOpening and closing conversationssession setup in some protocols
4TransportDelivery between programsTCP, UDP (ports)
3NetworkDelivery between networksIP, ICMP, routers
2Data linkDelivery on one local networkEthernet, Wi-Fi (802.11), MAC addresses, switches
1PhysicalBits on a mediumcables, radio signals, fibre

A common memory aid, from layer 1 up: "Please Do Not Throw Sausage Pizza Away".

The TCP/IP model (4 layers)

The TCP/IP model describes how the internet is actually built. It merges some OSI layers:

TCP/IP layerMatches OSI layersExamples
Application5, 6, 7HTTP, DNS, TLS, SSH
Transport4TCP, UDP
Internet3IP, ICMP
Link (network access)1, 2Ethernet, Wi-Fi

You will hear both. People usually use OSI numbers ("layer 2 switch", "layer 7 load balancer") while describing the TCP/IP stack.

Worked example: loading a web page

You type https://example.com and press Enter. Following the data down the stack on your laptop:

  1. Application: the browser builds an HTTP request (GET /). TLS encrypts it.
  2. Transport: TCP adds a header with the source port (a random high number such as 52814) and destination port 443.
  3. Internet: IP adds a header with your IP address and the server's IP address.
  4. Link: Wi-Fi adds a frame header with your laptop's MAC address and your router's MAC address, then sends it as radio signals.

Your router strips the link header, reads the IP header, decides where to send the packet next, and wraps it in a new link header for the next hop. Routers work at layer 3, so the IP addresses stay the same end to end (apart from NAT, covered later), while MAC addresses change at every hop.

Units at each layer

  • Layer 2: a frame
  • Layer 3: a packet
  • Layer 4: a segment (TCP) or datagram (UDP)

Using the model to troubleshoot

Work bottom-up when the problem is "nothing works", and top-down when only one application fails:

  • Layer 1: is the cable plugged in, is Wi-Fi connected?
  • Layer 2: does the device see the local network (link lights, connected SSID)?
  • Layer 3: does it have a valid IP address, can it ping the router?
  • Layer 4: is the port open, is a firewall blocking it?
  • Layer 7: does the name resolve in DNS, does the application return an error?

Common mistakes

  • Treating the models as competing standards. They describe the same thing at different levels of detail.
  • Putting DNS at the transport layer because it uses UDP port 53. DNS is an application-layer protocol that uses the transport layer.
  • Forgetting that a switch and a router work at different layers. A switch forwards frames by MAC address inside one network; a router forwards packets by IP address between networks.
  • Memorising without mapping. The value is in placing a real protocol or fault on a layer, not reciting the list.

Quick recap

  • OSI has 7 layers; TCP/IP has 4 and is what the internet actually runs.
  • Each layer adds a header on the way down and removes it on the way up.
  • Ethernet and Wi-Fi are layer 2, IP is layer 3, TCP and UDP are layer 4, HTTP and DNS are layer 7.
  • Use the layers as a checklist when something breaks.
Also in this lesson: