Networking / Guide

The OSI and TCP/IP models explained simply

The 7 layers of the OSI model and the 4 layers of TCP/IP, what each one does, how data is wrapped and unwrapped from one machine to another, TCP versus UDP, the equipment at each layer and how to troubleshoot a fault layer by layer.

Networking Guide Beginner Published October 20, 2026 Translated November 20, 2026 18 min read Version française
A bundle of optical fibres glowing blue in the dark
Photo: Denny Müller on Unsplash

In plain words

Sending data over a network is like posting a parcel. You write the letter (the application), put it in an envelope with the name of the receiving department (the port), then in a box with the postal address (the IP address), you stick on the courier's label for the next leg (the MAC address), and the van drives off (the cable or the radio waves). On arrival, everything is opened in reverse order. Each layer of the model is one of these wrappings, and each one only looks after its own.

1. Why a layered model?

A Dell computer running Windows, an ISP router, a Cisco switch and a Linux server at a hosting provider manage to talk to each other. That works because they all follow the same rules, organised in layers. Each layer:

  • provides a single service to the layer above (for example: "deliver this packet to this IP address");
  • ignores how the layers below do their job. A web page displays the same way over Wi-Fi, fibre or 4G, because the application can't tell the difference.

The model is also a troubleshooting tool: when "the internet doesn't work", you check the layers one by one, starting from the bottom (section 8).

Two models exist side by side:

  • OSI (7 layers), published by ISO in 1984: the reference model, the one behind the vocabulary ("a layer 2 switch", "a layer 1 problem");
  • TCP/IP (4 layers): the model the internet actually uses.

2. The 7 layers of the OSI model

They are numbered from the bottom up: layer 1 touches the cable, layer 7 touches the user.

No. Layer Its role, in one sentence What travels Address used Examples
7 Application Provide the network service to the software Data Name (example.com) HTTP, DNS, SMTP, SSH, FTP, DHCP
6 Presentation Put the data in a common format: encoding, compression, encryption Data — UTF-8, JPEG, TLS (often placed here)
5 Session Open, maintain and close the dialogue between two applications Data — RPC, NetBIOS
4 Transport Carry data from one program to another, reliably or quickly Segment (TCP), datagram (UDP) Port (443, 22…) TCP, UDP
3 Network Find the route from one machine to another, across several networks Packet IP address IP, ICMP (ping), routing
2 Data link Pass data from one device to the next, on the same local network Frame MAC address Ethernet, Wi-Fi (802.11), VLAN (802.1Q), ARP
1 Physical Turn bits into a signal (electrical, light, radio) Bits — RJ45 cable, fibre, Wi-Fi radio waves, connectors

To remember them, from layer 1 to layer 7

Please Do Not Throw Sausage Pizza Away: Physical, Data link, Network, Transport, Session, Presentation, Application.

The difference between layers 2, 3 and 4, simply

These are the three layers you deal with every day. Back to the parcel:

Layer The question it answers Analogy
2, Data link (MAC) Which device right next to me do I hand the parcel to? The courier's label, replaced at every depot
3, Network (IP) Which final machine is the parcel for? The postal address, unchanged from start to finish
4, Transport (port) Which program on that machine? The department name on the envelope: "Accounts department"

The MAC address changes at every router hop; the IP address stays the same end to end (unless a NAT translates it, see Public IP, private IP and NAT); the port names the software that should receive the data.

3. The TCP/IP model, the one the internet uses

TCP/IP groups the OSI layers into four:

TCP/IP layer Matching OSI layers Protocols
Application 7, 6 and 5 HTTP, DNS, SSH, SMTP, TLS…
Transport 4 TCP, UDP
Internet 3 IP, ICMP
Network access (or Link) 2 and 1 Ethernet, Wi-Fi

In practice, OSI layers 5 and 6 don't exist separately: the application handles its own format, sessions and encryption. Some books present TCP/IP with 5 layers, splitting the physical layer from the link layer; the principle is the same.

4. Encapsulation: the journey of a web page

You open https://example.com from a computer at 192.168.1.42.

When sending, each layer adds its header (its wrapping) in front of what the layer above gives it:

7 Application                                   [ HTTPS request ]
4 Transport                    [ TCP 51000→443 ][ HTTPS request ]
3 Network   [ IP 192.168.1.42→server ][ TCP ][ HTTPS request ]
2 Data link [ Ethernet MAC PC→router ][ IP ][ TCP ][ Request ][ FCS ]
1 Physical  010010110101010011010010…  (electrical signal, light, radio waves)

At each router along the way, the device opens the data up to layer 3, reads the destination IP address, chooses the route, then builds a new layer 2 wrapping with the MAC addresses of the next leg.

On arrival, the server does the reverse, decapsulation: it removes the Ethernet header, then the IP header, then the TCP header, and hands the request to the software listening on port 443.

Actual sizes

Element Size
Ethernet header 14 bytes, plus 4 bytes of checksum (FCS) at the end of the frame
IPv4 header 20 bytes minimum
TCP header 20 bytes minimum
UDP header 8 bytes
Ethernet MTU: maximum size of the IP packet in a frame 1,500 bytes
TCP MSS: payload per segment with a 1,500 MTU 1,460 bytes (1,500 − 20 − 20)

When a tunnel or a VPN adds its own headers, the space available shrinks: this is the cause of many "MTU" problems (websites that only half load behind a VPN, for example).

5. TCP or UDP: two ways to transport data

TCP UDP
Principle A conversation: the connection is set up and every delivery is acknowledged A simple send: data goes out without warning or waiting for a reply
Opening Three-way handshake: SYN, SYN-ACK, ACK None
Reliability Resends what is lost, puts data back in order What is lost stays lost
Speed Slower to start, heavier (header of 20 bytes or more) Faster and lighter (8-byte header)
Used for Web, email, SSH, file transfer DNS, DHCP, voice over IP, video calls, online games, live streaming

Analogy: TCP is a recorded-delivery letter with proof of receipt, UDP a postcard.

Good to know

The line keeps moving: HTTP/3, used by many websites, runs on top of QUIC, a protocol built on UDP that recreates TCP's reliability itself. And DNS, usually over UDP, switches to TCP for large responses.

The most common ports

Port Protocol Use
22 TCP SSH, remote administration
53 UDP and TCP DNS
67 and 68 UDP DHCP
80 TCP HTTP (unencrypted web)
123 UDP NTP (time)
443 TCP and UDP HTTPS (UDP for HTTP/3)
3389 TCP Windows Remote Desktop (RDP)

6. Equipment, layer by layer

Device Layer What it understands What it does
Cable, repeater, hub 1 Signals Repeats the signal on all its ports, without understanding anything
Switch, Wi-Fi access point 2 MAC addresses Sends each frame only to the port where the recipient is
Router, ISP router 3 IP addresses Moves packets from one network to another
Layer 3 switch 2 and 3 MAC and IP A switch that can also route between VLANs
Firewall 3 and 4, up to 7 IP, ports, sometimes applications Allows or blocks traffic according to rules
Load balancer, reverse proxy 4 or 7 Ports or HTTP content Spreads connections across several servers

This explains terms like "layer 2 switch" or "application firewall" (layer 7). To go further on layer 2: understanding VLANs.

7. The layers in real life

Situation Layer involved
Unplugged cable, socket light off 1
Two devices on the same switch can't see each other because of a wrong VLAN 2
Wrong subnet mask or wrong gateway 3
Firewall blocking port 443 4
Expired certificate, HTTPS error in the browser 6 and 7
Website name that doesn't resolve (DNS) 7

8. Troubleshooting a fault layer by layer

Always start from the bottom: there's no point looking for a DNS problem if the cable is unplugged.

Layer Question Windows Linux macOS
1 Is the network card connected? Get-NetAdapter ip link ifconfig en0
2 Do the neighbours on the network answer? arp -a ip neigh arp -a
3 Does the gateway answer? The internet by IP? ping 192.168.1.1 then ping 1.1.1.1 ping -c 4 192.168.1.1 ping -c 4 192.168.1.1
4 Can the service's port be reached? Test-NetConnection example.com -Port 443 nc -zv example.com 443 nc -zv example.com 443
7 Does the name resolve? Does the service answer? nslookup example.com curl -I https://example.com curl -I https://example.com

As soon as one layer fails, the fault is at that level or below it. The complete method is in network troubleshooting: the essential commands.

9. Nuances worth knowing

  • The OSI model is a reference, not an implementation: no common network applies its 7 layers to the letter.
  • Some protocols straddle layers: ARP links layer 3 (IP) to layer 2 (MAC); depending on the source, TLS is placed at layer 5, 6 or 7.
  • The vocabulary varies: people often say "packet" for everything, but strictly speaking it's a frame at layer 2, a packet at layer 3 and a segment at layer 4.
  • IT people sometimes talk about a "layer 8 error": the layer above the application, in other words the user.

Key points

  • OSI: 7 layers, the reference model and the source of the vocabulary. TCP/IP: 4 layers, the model actually in use.
  • Layer 2 = MAC, from one device to the next; layer 3 = IP, from machine to machine; layer 4 = port, from program to program.
  • When sending, each layer adds its header; on arrival, each layer removes its own.
  • TCP: reliable and ordered; UDP: fast and light.
  • Switch = layer 2, router = layer 3, firewall = layers 3 to 7.
  • To troubleshoot, work up the layers from 1 to 7.

Read next