Networks and layering - why the internet was split into layers
How do you divide up an enormous communication problem? The choice of packet switching, and the layered design that makes each layer answer only for its own job.
Introduction
This series follows data from the moment it leaves the cable to the moment it reaches a browser window, climbing one layer at a time. There is a single question: how do you divide up an enormous communication problem?
Part one covers the internet’s two foundational design choices: packet switching and layering.
Circuit switching and packet switching
The traditional telephone network is circuit switched. Once a call connects, the circuit between the two people is held exclusively until the call ends. Quality is guaranteed, but the circuit is wasted during every silent moment.
The internet chose packet switching. Data is broken into small pieces called packets, and each packet finds its way to the destination independently. Because no circuit is monopolised, a single path can be shared by a great many conversations, and traffic can detour around a failure in the middle of a route.
It is not free, of course. Packets can be lost, duplicated, or arrive out of order. Who takes responsibility for that problem is the question that runs through the whole series.
Protocols: the rules of communication
For equipment from different manufacturers and different operating systems to communicate, both sides need agreed-upon rules. Those rules are a protocol. It defines the format of messages, the order in which they are exchanged, and what to do when something goes wrong. Just as an interface defines the contract between objects in object-oriented design, a protocol defines the contract between communicating parties.
Layering: a way to divide the problem
Trying to solve “send a photo from a laptop in Korea to a server in the US” all at once is far too complex. Converting electrical signals, delivering within the same network, choosing a route between networks, recovering from loss, and interpreting the application data all become one lump.
Layering splits this problem by role. Each layer uses the services the layer below provides and provides its own services to the layer above, and it interacts with adjacent layers only through an agreed boundary. As a result, changing one layer’s implementation (from wired Ethernet to Wi-Fi, say) leaves the rest untouched.
The OSI seven layers and the TCP/IP four
Two layer models come up constantly. The OSI seven-layer model is a reference model built for standardisation; the TCP/IP four-layer model is a practical one that grew out of the actual implementation of the internet.
| TCP/IP layer | Corresponding OSI layers | Role | Typical protocols |
|---|---|---|---|
| Application | Application, presentation, session (7, 6, 5) | rules for exchanging data between applications | HTTP, DNS |
| Transport | Transport (4) | process-to-process communication, reliability | TCP, UDP |
| Internet | Network (3) | host addressing and route selection | IP, ICMP |
| Link | Data link, physical (2, 1) | actual transmission within one network | Ethernet, Wi-Fi |
This series works from the TCP/IP four-layer model, starting at the bottom with the link layer and climbing.
Encapsulation: how data passes through the layers
On the way out, data starts at the application layer and descends, with each layer attaching its own header. This is called encapsulation.
Application: [ HTTP message ]
Transport: [ TCP header | HTTP message ] <- segment
Internet: [ IP header | TCP header | HTTP message ] <- packet
Link: [ Eth | IP header | TCP header | HTTP message | FCS ] <- frame
On the receiving side the exact reverse happens: each layer interprets and strips only its own header before passing the rest upward. TCP knows nothing about the contents of the Ethernet header, and Ethernet knows nothing about the contents of the HTTP message. Not knowing each other’s territory is not a weakness of layering; it is the point.
Summary
| Layer | Unit of delivery | Address | Scope of responsibility |
|---|---|---|---|
| Application | message | - | conversation between applications |
| Transport | segment | port | process to process |
| Internet | packet | IP address | host to host |
| Link | frame | MAC address | one hop |
The core point is this.
The internet is built on packet switching, and each layer answers only for its own job, meeting adjacent layers only at an agreed boundary.
Coming up next
The next part starts at the bottom, with the link layer. How do two devices on the same network find each other, and how does a frame reach exactly the right counterpart?