The seven OSI layers at a glance
The OSI model describes network communication as seven layers. Layer 1 is the lowest and closest to the hardware. Layer 7 is the highest and closest to the programs you use.
| Layer | Name | Main job | Example |
|---|---|---|---|
| 7 | Application | Network services for programs | HTTP, DNS, SMTP |
| 6 | Presentation | Data format, such as character encoding, compression and encryption | ASCII, JPEG |
| 5 | Session | Opening, managing and closing a session between two programs | NetBIOS session service, RPC |
| 4 | Transport | End-to-end delivery between programs, using port numbers | TCP, UDP |
| 3 | Network | Logical addressing and routing between networks | IP, ICMP |
| 2 | Data link | Frames and MAC addresses on one local link, with error detection | Ethernet, Wi-Fi |
| 1 | Physical | Bits sent as electrical, optical or radio signals | Copper cable, fiber, radio |
A memory aid
A common way to remember the order from layer 7 down to layer 1 is the phrase “All People Seem To Need Data Processing.” Each word starts with the first letter of a layer name, going from Application to Physical.
The upper layers
Application (7) is where network-aware programs ask for services such as web pages, name lookups and email. The protocols at this layer define the requests and responses.
Presentation (6) makes sure data is in a form the receiving side can read. Typical functions in the textbook model are character encoding, compression and encryption. Where encryption such as TLS belongs is debated, because real protocols do not fit neatly into one OSI layer.
Session (5) opens, maintains and closes a session between two applications. In the TCP/IP model, these tasks are usually handled by the application or by protocols within it, rather than by a separate layer.
The lower layers
Transport (4) delivers data between programs. TCP and UDP are the two common transport protocols. Port numbers identify which program should receive the data. TCP provides ordered, reliable delivery, and UDP is connectionless and does not guarantee delivery. The fields that make this possible are described in what is the format of the TCP header.
Network (3) moves packets between networks using IP addresses. Routers make forwarding decisions at this layer. ICMP, the protocol that ping uses, also works here.
Data link (2) moves frames across one local link. It uses MAC addresses, and switches forward frames based on them. Ethernet frames include a check value so that damaged frames can be detected.
Physical (1) carries the bits themselves, as electrical signals on copper, light on fiber, or radio waves in Wi-Fi. For the cables themselves, see the overview of the four types of network cable.
Seeing the layers on your own machine
On Linux, these commands each show one layer’s view of the machine:
ip addrshows IP addresses on each interface (layer 3).ip linkshows interface state and MAC addresses (layer 2).ss -tnlists established TCP connections (layer 4).dig example.comperforms a name lookup, an application-layer service (layer 7).
On Windows, PowerShell offers the same views:
Get-NetAdaptershows the state of network adapters (layers 1 and 2).Get-NetIPAddressshows IP addresses (layer 3).Get-NetTCPConnectionshows TCP connections (layer 4).Resolve-DnsName example.comperforms a name lookup (layer 7).
The TCP/IP model in four layers
The TCP/IP model used on the internet has four layers: link, internet, transport and application. The link layer covers OSI layers 1 and 2, the internet layer matches OSI layer 3, and the application layer covers OSI layers 5 through 7. Many engineers use TCP/IP for everyday work and OSI for teaching and shared vocabulary.
Why the layer model helps troubleshooting
When a connection fails, the layer model tells you where to look. A failed name lookup points to the application layer. A failed port check points to transport or to a firewall. A failed ping points to the network layer or a firewall that blocks ICMP. A working ping does not prove that a web service works, because ping tests only basic reachability at layer 3.