Seven layers that explain how a message travels from your app to another computer.
The OSI model splits network communication into 7 layers. Each layer has one job and talks only to the layer above and below it.
OSI stands for Open Systems Interconnection. It is a reference model: a map that helps us talk about and fix network problems. Real networks use the simpler TCP/IP stack (4 or 5 layers), but OSI is the common language for engineers.
Layering: each layer does one job and hides the details from others.
Encapsulation: going down, each layer wraps the data with its own header (like putting a letter in an envelope, then in a bigger envelope).
De-encapsulation: going up, each layer opens its own envelope.
| Layer | Name | Data unit (PDU) | Address / key idea |
|---|---|---|---|
| 7 Application | Application | Data | URLs, HTTP methods |
| 6 Presentation | Presentation | Data | Encoding, encryption, compression |
| 5 Session | Session | Data | Session set-up and tear-down |
| 4 Transport | Transport | Segment (TCP) or Datagram (UDP) | Port numbers |
| 3 Network | Network | Packet | IP addresses |
| 2 Data Link | Data Link | Frame | MAC addresses |
| 1 Physical | Physical | Bits | Signals |
| # | Layer | Job | Examples |
|---|---|---|---|
| 7 | Application | What the user's program uses to talk on the network | HTTP, HTTPS, FTP, SMTP, DNS |
| 6 | Presentation | Translate, encrypt and compress data | TLS/SSL, JPEG, JSON, ASCII |
| 5 | Session | Start, keep and end a conversation | Sessions, RPC, NetBIOS |
| 4 | Transport | End-to-end delivery, split into segments, ports, reliability | TCP, UDP |
| 3 | Network | Choose the path between networks using IP addresses | IP, ICMP, routers |
| 2 | Data Link | Move frames between devices on the same network using MAC addresses | Ethernet, Wi-Fi, switches |
| 1 | Physical | Send raw bits as electricity, light or radio | Cables, fibre, hubs, radio |
| Layer 4 load balancer | Layer 7 load balancer | |
|---|---|---|
| Looks at | IP address and port | URL, headers, cookies |
| Speed | Very fast, simple | Slower, smarter |
| Can route /images to a special server? | No | Yes |
| Can end TLS? | Not usually | Yes |
ping tests layer 3. traceroute shows hops (layer 3). curl tests layer 7.| Term | Meaning in easy words |
|---|---|
| Layer | One level of the model. It does one job. |
| Protocol | A set of rules for talking at one layer, like HTTP or TCP. |
| Encapsulation | Wrapping data with a header at each layer on the way down. |
| De-encapsulation | Removing those headers on the way up. |
| PDU | Protocol data unit: the name of the data at each layer (data, segment, packet, frame, bits). |
| Header | Extra control information added at the front of the data. |
| MAC address | A hardware address of a network card. Used on the local network (layer 2). |
| IP address | A logical address used to route between networks (layer 3). |
| Port | A number that picks the app on a machine (layer 4). |
| Switch | Layer 2 device that forwards frames by MAC address. |
| Router | Layer 3 device that forwards packets by IP address. |
| TCP/IP | The real protocol suite of the internet. It has 4 layers. |