Cheat sheet: OSI and TCP/IP layers

The seven OSI layers next to the four TCP/IP layers, with the protocols, devices and data units at each, and a way to troubleshoot by layer.

# OSI layer Data unit Examples Devices and things
7 Application Data HTTP, DNS, SSH, SMTP Browsers, servers, proxies
6 Presentation Data TLS, character encoding, compression
5 Session Data Sessions, RPC
4 Transport Segment (TCP) or datagram (UDP) TCP, UDP, ports Firewalls (by port)
3 Network Packet IP, ICMP, routing Routers, layer 3 switches
2 Data link Frame Ethernet, Wi-Fi, ARP, VLANs Switches, access points
1 Physical Bits Cables, fibre, radio, voltage Cables, hubs, transceivers

TCP/IP in four layers

TCP/IP layer Matches OSI Examples
Application 5, 6, 7 HTTP, DNS, SSH
Transport 4 TCP, UDP
Internet 3 IP, ICMP
Link 1, 2 Ethernet, Wi-Fi

Remember the order

Top to bottom: All People Seem To Need Data Processing.

Troubleshoot from the bottom up

Layer Question Quick check
1 Physical Is it plugged in and is there a link light? Cable, port LED, ip link
2 Data link Can it talk to its neighbour? Right VLAN? arp -a, switch port and VLAN
3 Network Has it an address, a gateway and a route? ip a, ip r, ping the gateway, then ping 8.8.8.8
4 Transport Is the service listening, and is the port open? ss -tulpn, nc -vz host port
7 Application Does the service itself answer correctly? curl -I, dig, the service’s own logs

Rule of thumb: if you can ping an IP address but not a name, it is DNS (layer 7), not routing.

What each device looks at

  • A switch reads the destination MAC address (layer 2).
  • A router reads the destination IP address (layer 3).
  • A firewall also reads ports (layer 4) and sometimes the content (layer 7).