OSI model
The Open Systems Interconnection (OSI) model is a conceptual framework developed by the International Organization for Standardization (ISO) that describes how data communication between networked systems should be structured. It divides the communication process into seven distinct layers, each with a specific responsibility. The model is used to reason about network protocols, diagnose problems, and design systems — even though real-world networking does not follow it exactly.
The OSI model exists to promote interoperability: by standardising what each layer does and how adjacent layers communicate, different vendors' hardware and software can work together over a shared network.
Encapsulation
As data travels down the stack from Layer 7 to Layer 1 on the sending side, each layer wraps the data with its own header (and sometimes a trailer). This is called encapsulation. On the receiving side, each layer strips its header as data travels back up the stack — a process called decapsulation. This means each layer only needs to understand the headers added by its peer layer on the other machine; it treats everything below as opaque payload.
The seven layers
| Layer | Name | Responsibility | Examples |
|---|---|---|---|
7 |
Application |
Provides network services directly to user applications. Defines the protocols applications use to communicate. |
HTTP, HTTPS, FTP, SMTP, DNS, WebSocket |
6 |
Presentation |
Translates data between application format and network format. Handles encoding, encryption, and compression. |
TLS/SSL, JPEG, ASCII, UTF-8 |
5 |
Session |
Establishes, manages, and terminates communication sessions between applications. Handles synchronisation and session recovery. |
NetBIOS, RPC session management |
4 |
Transport |
Provides end-to-end communication between processes on different hosts. Handles segmentation, flow control, error recovery, and multiplexing via port numbers. |
TCP, UDP |
3 |
Network |
Routes packets across multiple networks from source to destination. Handles logical addressing. |
IP (IPv4, IPv6), ICMP, routers |
2 |
Data link |
Provides reliable node-to-node data transfer between directly connected devices. Handles framing, MAC addressing, and error detection within a single network segment. |
Ethernet (IEEE 802.3), Wi-Fi (IEEE 802.11), switches |
1 |
Physical |
Transmits raw bits over a physical medium. Defines electrical, optical, or radio signals, cable types, and connector specifications. |
Ethernet cable, fiber optic, USB, Bluetooth radio |
Layers 4 (transport) and 7 (application) are the most relevant for software developers. Layer 4 determines whether data is delivered reliably (TCP) or with minimal overhead (UDP), and is the layer at which Layer 4 load balancers operate. Layer 7 is where application protocols live and where Layer 7 load balancers, reverse proxies, and API gateways make routing decisions based on request content.
Layer 6 is where TLS encryption and decryption formally belongs in the model, though in practice TLS is implemented as part of the application stack rather than a standalone layer.
The TCP/IP model
The OSI model is a theoretical reference. The protocol suite that actually underpins the internet is the TCP/IP model (also called the Internet model), which collapses the seven OSI layers into four:
| TCP/IP layer | Corresponds to OSI layers | Examples |
|---|---|---|
Application |
Layers 5, 6, 7 |
HTTP, DNS, TLS, FTP, SMTP |
Transport |
Layer 4 |
TCP, UDP |
Internet |
Layer 3 |
IP, ICMP |
Network access (link) |
Layers 1, 2 |
Ethernet, Wi-Fi |
The OSI model is taught because of its analytical clarity — seven discrete concerns make it easier to isolate problems ("is this a Layer 3 routing issue or a Layer 4 connection issue?"). The TCP/IP model reflects how networking is actually implemented.