What the OSI model is
The OSI (Open Systems Interconnection) model splits network communication into seven layers, from physical signals at layer 1 to application protocols at layer 7. Each layer does one job, relies on the layer below it and serves the layer above it.
ISO published it in 1984 alongside a family of OSI protocols that never caught on. The internet runs on the TCP/IP protocols instead, but the OSI layer numbers stuck as the shared vocabulary engineers use to say where something happens.
When data is sent, each layer wraps what it receives from above in its own header, a process called encapsulation. An HTTP request goes inside a TCP segment, which goes inside an IP packet, which goes inside an Ethernet or Wi-Fi frame. The receiver unwraps them in reverse order.
The seven layers, with examples
From the bottom up (a common mnemonic is "Please Do Not Throw Sausage Pizza Away"):
- Layer 1, physical, sends raw bits as electrical, light or radio signals. Copper Ethernet cables, optical fiber, Wi-Fi radio and connectors belong here.
- Layer 2, data link, moves frames between devices on the same local network using MAC addresses, and detects corrupted frames with a checksum. Ethernet and Wi-Fi framing, switches and VLANs work at this layer.
- Layer 3, network, gives devices logical addresses and routes packets between networks. IPv4, IPv6 and ICMP (used by ping) live here, and so do routers.
- Layer 4, transport, carries data between programs on two hosts, using port numbers to tell them apart. TCP adds reliable, ordered delivery and congestion control; UDP sends independent datagrams without either.
- Layer 5, session, sets up, coordinates and ends conversations between applications. Few internet protocols map to it cleanly, and web applications track sessions themselves, for example with cookies.
- Layer 6, presentation, deals with how data is represented: character encoding, compression and encryption. TLS is often placed here, though it does not fit any single layer neatly.
- Layer 7, application, holds the protocols applications use directly, such as HTTP, DNS, SMTP and SSH. The layer means the protocol, so HTTP is layer 7 while the browser is a program that uses it.
The TCP/IP model most real networks follow
The internet's protocols were designed around a simpler model. RFC 1122 describes four layers: link, internet, transport and application.
The mapping to OSI is rough. Layers 1 and 2 match the link layer, layer 3 is the internet layer (IP) and layer 4 is transport (TCP and UDP). Layers 5 to 7 fold into a single application layer, and many textbooks use a five-layer version that keeps physical and data link apart.
Real protocols do not always fit either model. TLS sits between TCP and HTTP, and QUIC is a transport protocol carried inside UDP, which is itself a transport protocol. ARP links layer 2 addresses to layer 3 ones, and VPNs carry whole IP packets inside other packets.
Treat the models as maps rather than rules. Arguing over which layer a protocol belongs to rarely fixes anything.
Why layer numbers are still useful vocabulary
Engineers use layer numbers as shorthand, and the terms appear in product names and documentation. A layer 4 load balancer forwards connections by IP address and port without reading their contents. A layer 7 load balancer reads the HTTP request, so it can route by hostname, path or header.
Firewalls follow the same split. A network firewall filters by address, protocol and port (layers 3 and 4), while a web application firewall inspects HTTP requests at layer 7. Calling something "a layer 2 problem" tells a colleague to look at the local network before the application.
Troubleshooting a connection from the bottom up
When something cannot connect, check the layers in order. A fault low in the stack breaks everything above it, so start at the bottom and stop at the first layer that fails.
- Layer 1: confirm the device is connected, with a link light on the cable or a Wi-Fi connection with usable signal.
- Layer 2: confirm the device can reach others on the same network. A wrong VLAN or a faulty switch port shows up here.
- Layer 3: confirm the device has a valid IP address and default gateway, then ping the gateway and a remote address. A 169.254.x.x address means DHCP failed, and some hosts block ping, so one failed ping does not prove a path is down.
- Layer 4: confirm the port is reachable. "Connection refused" usually means the host answered but nothing is listening, while a timeout usually means a firewall is dropping packets.
- Layers 5 to 7: check name resolution, the TLS certificate and the HTTP response. "Server not found" points to DNS, a certificate warning to TLS, and a 404 or 500 to the application.