The layered model and IP addressing
The layered model
When you send a message over the Internet - a web page, an e-mail, a video call - the data never travels alone. It goes through several software layers, each with a specific role. This is the layered model (the most used in practice is the TCP/IP model, a simplified version of the 7-layer OSI model).
Four layers, from top to bottom:
- Application layer: HTTP for the web, DNS for names, SMTP for mail.
- Transport layer: splits the data, handles reliability (TCP) or speed (UDP), using ports.
- Internet (or network) layer: routes the packets using IP addresses, without guaranteeing order or arrival.
- Network access layer: physically carries the bits (cables, Wifi, fibre), using MAC addresses.
Layers (Sender) Layers (Receiver)
4 Application (HTTP, DNS, SMTP...) <-----> 4 Application
3 Transport (TCP, UDP - ports) <-----> 3 Transport
2 Internet (IP - IP addresses) <-----> 2 Internet
1 Network access(Ethernet, Wifi - MAC) <-----> 1 Network access
Encapsulation going down (sender):
[ DATA ] (layer 4: raw data)
[ TCP | DATA ] (layer 3: add source/destination port)
[ IP | TCP | DATA ] (layer 2: add source/destination IP address)
[ ETH | IP | TCP | DATA ] (layer 1: add source/destination MAC address)
Decapsulation going up (receiver): remove ETH, then IP, then TCP - DATA remains.
The key principle is encapsulation. Each layer adds its own header (like an envelope inside an envelope) without ever looking at the content of the upper layers. The recipient does the reverse: it removes the envelopes one by one, from layer 1 up to layer 4 - this is decapsulation.
Common pitfall: believing that a layer "knows" the others. In reality, each layer ignores what is above it: the IP layer does not know whether it is carrying TCP or UDP, it just looks at a "protocol" field in its header. This separation allows one layer to be changed (switching from Wifi to fibre) without touching the others.
Another pitfall: thinking this model slows everything down because of the stacked headers. In practice, they weigh a few dozen bytes against data that can weigh megabytes - the cost is negligible compared to the modularity benefit.

