Opening a website involves several separate jobs: requesting the page, protecting the connection, delivering the data, choosing a route and transmitting signals. Layers organise those jobs, and each layer uses the service of the layer below it. By the end of this lesson, you should be able to answer four questions:
- What does each of the seven layers do, and what is its unit of data (PDU)?
- Which protocols and devices work at each layer?
- Where do MAC addresses, IP addresses and ports fit?
- What happens, layer by layer, when a laptop opens a website?
💡 In simple terms: sending data is like sending a parcel. The contents, the packaging, the delivery address and the van each do a different job, and none of them needs to know how the others work.
Why a layered model?
In the 1970s, every computer maker had its own networking system, and systems from different makers could not talk to each other. The OSI (Open Systems Interconnection) model was published by the ISO in 1984 as a common, vendor-neutral way to describe networking. Splitting the work into layers solves several problems:
OSI is a reference model: a way to describe and discuss networking. The protocols that actually run the internet come from the TCP/IP suite.
Learn more: The TCP/IP Model
The seven layers at a glance
OSI is numbered from Physical (1) at the bottom to Application (7) at the top. Data goes down the layers on the sender and up the layers on the receiver.
- 7ApplicationData
Gives programs a way onto the network: the requests and replies they send.
e.g. HTTP, HTTPS, DNS, DHCP, SSH, SMTP
- 6PresentationData
Agrees how data is written: character sets, compression and encryption.
e.g. UTF-8, JPEG, MP4, TLS encryption
- 5SessionData
Opens, keeps track of and closes conversations between programs.
e.g. RPC, NetBIOS, SOCKS
- 4TransportSegment (TCP) / Datagram (UDP)
Gets data to the right program (port) on the other device; TCP adds reliability.
e.g. TCP, UDP
- 3NetworkPacket
Logical (IP) addresses, and choosing a path from one network to another.
e.g. IPv4, IPv6, ICMP, OSPF
- 2Data LinkFrame
Moves frames across one local link using MAC addresses, and checks for errors.
e.g. Ethernet (802.3), Wi-Fi (802.11), PPP
- 1PhysicalBits
Turns bits into signals and back: voltage on copper, light in fibre, radio waves.
e.g. Copper (1000BASE-T), fibre, Wi-Fi radio, connectors
A PDU (protocol data unit) is the name for a unit of data at a given layer. Using the right name tells people which layer you mean: a frame is layer 2, a packet is layer 3.
💡 Memory trick from layer 7 down: "All People Seem To Need Data Processing". From layer 1 up: "Please Do Not Throw Sausage Pizza Away".
The layers are functional categories. Real protocols don't always fit neatly into one layer, especially at layers 5 to 7.
Each layer in detail
Each card shows the layer's job, its PDU, example protocols, the devices that work at that layer, and what it does when you open a web page.
7Layer 7: Application
Gives applications access to network services: asking for a web page, looking up a name, sending an email.
- PDU
- Data
- Protocols
- HTTP, HTTPS, DNS, DHCP, SMTP, IMAP, FTP, SSH
- Devices
- Hosts (PCs, servers); firewalls and proxies that inspect applications
- Real example
- Your browser sends the HTTP request “GET /index.html” to the web server.
6Layer 6: Presentation
Makes sure both sides understand the data: character encoding, data formats, compression and encryption.
- PDU
- Data
- Protocols
- Formats such as UTF-8, JPEG, MPEG; TLS encryption is often placed here
- Devices
- Hosts
- Real example
- The page is encoded as UTF-8 text and encrypted with TLS before it leaves the server.
5Layer 5: Session
Opens, manages and closes conversations (sessions) between applications, and can resume them after a break.
- PDU
- Data
- Protocols
- Session functions of RPC, NetBIOS, SMB, TLS session resumption
- Devices
- Hosts
- Real example
- Your login to a web app stays open while you click between pages, and is ended when you log out.
4Layer 4: Transport
Delivers data between the right applications on two hosts, using port numbers. TCP adds reliability and ordering.
- PDU
- Segment (TCP) or datagram (UDP)
- Protocols
- TCP, UDP (and QUIC, built on UDP)
- Devices
- Hosts; firewalls and NAT routers read ports
- Real example
- Your PC sends from port 51524 to the server’s port 443, and resends any segment that gets lost.
3Layer 3: Network
Moves packets between different networks using logical (IP) addresses, choosing a route hop by hop.
- PDU
- Packet
- Protocols
- IPv4, IPv6, ICMP; routing protocols such as OSPF and BGP
- Devices
- Routers, Layer 3 switches, firewalls
- Real example
- Your packet carries source 192.168.1.20 and destination 203.0.113.20, and each router picks the next hop.
2Layer 2: Data Link
Delivers frames across one local link using MAC addresses, and detects damaged frames.
- PDU
- Frame
- Protocols
- Ethernet (802.3), Wi-Fi (802.11), PPP; ARP (finds the MAC address for an IP address)
- Devices
- Switches, wireless access points, network interface cards (NICs)
- Real example
- Your laptop puts the packet in a frame addressed to the home router’s MAC address 02:00:00:00:00:01.
1Layer 1: Physical
Turns bits into signals and back: voltages on copper, light in fibre, radio waves in the air. Defines cables, connectors and speeds.
- PDU
- Bits
- Protocols
- Ethernet physical standards (1000BASE-T, 10GBASE-SR), Wi-Fi radio, DSL, fibre
- Devices
- Cables, connectors, hubs, repeaters, transceivers, modems
- Real example
- The frame leaves your laptop as bits carried on Wi-Fi radio waves and reaches the router’s antenna.
Layer 7: what “Application” really means
Application-layer protocols define the service being requested: HTTP requests a page, DNS asks for an address, DHCP requests IP settings and SSH provides secure remote access. The browser itself is an application that uses these protocols; it is not “in” layer 7.
Learn more: HTTP: How the Web TalksDNSDHCP
Layers 6 and 5: real but blurry
The Presentation and Session layers deal with how information is represented or protected, and how a conversation is managed. In TCP/IP, applications and supporting protocols do these jobs, so don't expect a separate layer 5 or layer 6 header in every packet. TLS, for example, protects many connections, but calling it “only layer 6” oversimplifies its role.
Learn more: HTTPS and TLS
Layer 4: TCP and UDP
The transport layer delivers data between applications on two hosts:
| TCP | UDP | |
|---|---|---|
| Style | Connection-oriented byte stream | Connectionless datagrams |
| Delivery & order | Reliable and in order | Not guaranteed by UDP itself |
| Lost data | Retransmitted | No built-in retransmission |
| Ports | Yes | Yes |
Applications can add their own reliability on top of UDP, so “uses UDP” doesn't always mean “unreliable”.
Learn more: What the Transport Layer Does
Layers 3, 2 and 1: getting there
Layer 3, Network: IP addresses identify interfaces across networks, and routers use the destination IP and their routing table to choose where a packet goes next. Layer 2, Data Link: on an Ethernet LAN, frames carry source and destination MAC addresses, and switches use their MAC address table to forward them. Layer 1, Physical: the frame is sent as signals over copper, fibre or radio. A damaged cable or the wrong optical transceiver stops everything before the higher layers get a chance to work.
Which devices work at which layer?
A device is usually described by the highest layer it reads to make its forwarding decision. Watch how far “up” each device looks:
- 1. Switch: layer 2. It reads only the destination MAC address in the frame and forwards the frame out of the right port.
- 2. Router: layer 3. It removes the frame, reads the destination IP address, chooses the next hop and builds a new frame.
- 3. Firewall: layers 3 to 7. It checks the IP addresses and the TCP port. A modern firewall may also inspect the application data.
- 4. Hosts: all seven. The web server unwraps every layer to reach the HTTP request itself.
| Layer | Devices |
|---|---|
| 1 Physical | Cables, connectors, hubs, repeaters, media converters, modems |
| 2 Data Link | Switches, access points, NICs |
| 3 Network | Routers, Layer 3 switches |
| 4 to 7 | Firewalls, load balancers, proxies, and every host |
Real devices often work at several layers at once. A home router, for example, is a switch (L2), a router (L3) and a firewall with NAT (L3/L4) in one box.
Learn more: Comparing Network Devices
MAC address, IP address and port: different jobs
| Identifier | Layer | What it identifies |
|---|---|---|
| MAC address | 2 | The sender or next recipient on one local link |
| IP address | 3 | A network interface across an IP network |
| TCP/UDP port | 4 | An application endpoint or service |
An HTTPS connection might look like this:
| Field | Example |
|---|---|
| Client IP | 192.168.1.20 |
| Server IP | 203.0.113.20 |
| Client source port | 51524 (temporary) |
| Server destination port | 443 |
| Transport | TCP |
The reply reverses the ports: source port 443, destination port 51524. (203.0.113.20 is a documentation address, not a live server.)
Common protocols and ports
Port numbers belong to the transport protocols (TCP and UDP), not to the OSI layers in general.
| Service | Transport | Port |
|---|---|---|
| HTTP | TCP | 80 |
| HTTPS (HTTP/1.1, HTTP/2) | TCP | 443 |
| HTTPS (HTTP/3) | QUIC over UDP | 443 |
| DNS | UDP and TCP | 53 |
| SSH | TCP | 22 |
| DHCPv4 server / client | UDP | 67 / 68 |
These are common defaults, not proof of which application sent a packet, because services can run on other ports. ICMP (used by ping) has no ports at all: it is carried directly inside IP.
Learn more: Common Ports to Know
Encapsulation: wrapping data for delivery
On the way down the sender's stack, each protocol adds its own control information, usually a header. This is called encapsulation. On the way up, the receiver removes each header again. This is de-encapsulation (also called decapsulation). Each layer reads only its own header, as if it were talking directly to the same layer on the other device.
You type a message. The chat app hands it to the network stack.
The short version, with the name of the data unit at each stage:
Data: The application produces data, such as an HTTPS request.A complete Ethernet frame
- Data · application
- Segment · transport
- Packet · network
- Frame · data link
Data: The application produces data, such as an HTTPS request. Segment: TCP adds a header with the source and destination ports. Packet: IP adds a header with the source and destination IP addresses. Frame: Ethernet adds MAC addresses in front and an error check (FCS) at the end.
| Stage | Unit | What's added |
|---|---|---|
| Application | Data | The request or response content |
| TCP | Segment (UDP: datagram) | Ports, sequence numbers and other TCP fields |
| IP | Packet | Source and destination IP addresses |
| Ethernet | Frame | MAC addresses, EtherType and an error-check trailer |
| Physical | Bits | Link-specific signalling |
Here's what the finished Ethernet frame looks like:
This is simplified: HTTPS also adds TLS protection, and a large message is split across many packets. The encapsulation lesson follows every header as it is added and removed, with real addresses, and shows what changes at a router.
Learn more: Encapsulation and De-encapsulation
OSI compared with TCP/IP
TCP/IP is the protocol suite the internet actually runs on. Its common model has four layers. You can switch the diagram to the five-layer view that many courses use:
| OSI layers | TCP/IP layer | Examples |
|---|---|---|
| 7, 6, 5 | Application | HTTP, DNS, DHCP, SSH, plus security and session functions |
| 4 | Transport | TCP, UDP |
| 3 | Internet | IPv4, IPv6, ICMP |
| 2, 1 | Link / Network Access | Ethernet, Wi-Fi, physical transmission |
Use OSI numbers to talk about problems, and TCP/IP to understand what actually runs.
Learn more: The TCP/IP Model
A laptop opens a website
Assume the laptop already has working IP settings and the site uses HTTPS over TCP. Select any step to see which layers are involved.
1. DNS query · Application · UDP 53
What's the address of example.com?
Tap this step's arrow for the details.
Logical view: DNS traffic to a remote resolver also passes through the gateway. HTTP/3 replaces the TCP and TLS steps with QUIC over UDP, which builds in TLS.
In order, the important steps are:
- Name resolution: get the server's IP address, unless it is already cached.
- Next-hop choice: is the destination local, or does it need the gateway?
- Local delivery: find the next hop's MAC address with ARP if needed.
- Transport setup: open the TCP connection.
- Security and application: negotiate TLS and send the HTTP request.
A later lesson follows the same request packet by packet.
Learn more: What Happens When You Open a Website?
When a layer fails
Each layer depends on the one below it, so a failure at a low layer breaks everything above it. A failure at a high layer leaves the lower layers working:
| Layer | Example symptom | Check |
|---|---|---|
| Physical | No link light | Cable, power, fibre, transceiver, interface status |
| Data link | Link up, but local devices unreachable | Wi-Fi association, switch port, MAC learning, interface errors |
| Network | Other networks unreachable | IP address, mask, gateway, routes |
| Transport | Host reachable, service isn't | Is the service listening? Is the port filtered? |
| Application | Connects, but the request fails | DNS, certificates, authentication, application logs |
Troubleshooting with the layers
Many engineers check from the bottom up: they prove that each layer works before moving to the next one. Useful commands on a Windows PC:
| Layer | Command | What it proves |
|---|---|---|
| 1–2 | ipconfig /all, netsh wlan show interfaces | The adapter is connected and has a MAC address |
| 2–3 | arp -a | The PC has learned the gateway's MAC address |
| 3 | ping 192.168.1.1, tracert 203.0.113.20 | IP packets reach the gateway and beyond |
| 4 | Test-NetConnection host -Port 443 | A TCP connection to the service opens |
| 7 | nslookup example.com, the browser | DNS answers and the application responds |
PowerShell's Test-NetConnection tests DNS (layer 7), IP (layer 3) and TCP (layer 4) in one command:
PS C:\> Test-NetConnection example.com -Port 443 ComputerName : example.com RemoteAddress : 203.0.113.20 RemotePort : 443 InterfaceAlias : Wi-Fi SourceAddress : 192.168.1.20 TcpTestSucceeded : True
False would point to a closed or filtered port. If the website still fails, look at TLS or the application itself.A successful ping tests only layers 1 to 3: it doesn't prove that HTTPS on port 443 works.
Learn more: Bottom-Up, Top-Down, Divide and ConquerA Troubleshooting Method
Common mistakes
- Thinking every packet has seven headers. Real traffic uses TCP/IP, and layers 5 and 6 rarely have a header of their own.
- Calling everything a “packet”. A frame is layer 2, a packet is layer 3 and a segment is layer 4. Using the right word shows which layer you mean.
- Saying a switch works at layer 3. A normal switch forwards frames using MAC addresses (layer 2). Only a Layer 3 (multilayer) switch can also route.
- Placing ports at layer 3. Ports belong to TCP and UDP at layer 4; IP addresses are layer 3.
- Treating the browser as “the application layer”. The browser is an application that uses layer 7 protocols such as HTTP and DNS.
- Forcing every protocol into one layer. ARP sits between layers 2 and 3, and TLS spans layers 5 to 7. The model is a guide, not a strict rule.
- OSI has seven layers: Physical, Data Link, Network, Transport, Session, Presentation and Application.
- PDUs: bits (1), frame (2), packet (3), segment or datagram (4), data (5–7).
- Switches work at layer 2, routers at layer 3, firewalls at layers 3 to 7; hosts use all seven.
- MAC addresses, IP addresses and ports do different jobs at layers 2, 3 and 4.
- The sender wraps data in headers; the receiver removes them in reverse order.
- OSI is the shared vocabulary; TCP/IP (taught with four or five layers) is what actually runs.
- Layer models are a guide; not every protocol fits exactly one layer.
Knowledge check: which layer?
A laptop's Ethernet port shows no link light at all. At which layer should you start looking?
A PC can ping the web server's IP, but the website won't load in the browser.
A router receives data from one network and must forward it to another. What is the layer 3 PDU it works with, and which addresses does it read?
A frame arrives on one port and must be forwarded out of the correct port inside the same LAN, using the destination MAC address. Which device does this?
Users can reach websites by IP address but not by name. Which layer and service is the most likely cause?
Where to go next
Continue with The TCP/IP model to see the four layers that really run the internet, then Encapsulation and de-encapsulation to watch each header being added and removed. For layer 2 details, read Ethernet fundamentals and MAC addresses.