The Internet is organised as five layers, and each one wraps the layer above in its own header before passing it down.
Words you will meet
- Layer — one level of the design, offering a service to the level above it.
- Service model — what a layer promises to the layer above.
- Protocol stack — the five layers taken together.
- Message — the application layer’s packet.
- Segment — the transport layer’s packet.
- Datagram — the network layer’s packet.
- Frame — the link layer’s packet.
- Header — the bytes a layer puts in front of what it was given.
- Payload — what a layer was given, treated as opaque.
- Encapsulation — the act of wrapping the payload in a header.
Why this matters
This is the most important page in the chapter. The five layers are the book’s skeleton: chapter 2 is the application layer, chapter 3 the transport layer, chapters 4 and 5 the network layer, chapter 6 the link layer. Everything after this page lives inside one of these boxes.
The four words — message, segment, datagram, frame — are also the vocabulary the rest of the book is written in. Learn them here and the later chapters read smoothly. Skip them and every chapter will be slightly confusing.
Why layer anything?
The Internet has numerous applications and protocols, various kinds of host, packet switches and link media. Given that complexity, can a network architecture be organised at all?
Yes — and the book reaches for an analogy first.
Everyday picture — the book’s airline
Describe the airline system. It has ticketing agents, baggage checkers, gate staff, pilots, aeroplanes and a worldwide system for routing aircraft. One way to describe it is as the series of actions you take: buy a ticket, check your bags, go to the gate, board. The plane takes off and is routed to its destination. After it lands you leave at the gate and claim your bags. If the trip was bad, you complain to a ticket agent.
Now look at that list horizontally instead. There is a ticketing function at each end. There is a baggage function, but only for people who are already ticketed. There is a gate function, but only for people who are already ticketed and baggage-checked. Above the runway there is a routing function.
So the airline has layers.
Where the picture breaks: you experience all the airline’s layers yourself, in order. A packet does not experience anything, and the intermediate machines it passes implement only the lower layers — an aeroplane does not check your ticket again in mid-air.
Each layer, combined with the layers below it, implements some service. At the ticketing layer and below, a person is transferred counter to counter. At the baggage layer and below, a person and their bags are transferred check to claim — but only for someone already ticketed. At the gate layer, gate to gate. At the takeoff/landing layer, runway to runway.
Each layer provides its service in two ways: by doing certain things itself, and by using the services of the layer directly below it. Organising protocols this way is called protocol layering protocol layering Simple Organising protocols into levels, where each level uses the level below it. Precise The organisation of protocols — and the hardware and software that implement them — into layers. Each layer provides its service by performing certain actions within that layer and by using the services of the layer directly below it. introduced in ch. 1 — open in glossary , and what a layer promises upward is its service model service model Simple What a layer promises to do for the layer above it. Precise The set of services that a layer offers to the layer above. As long as a layer offers the same service model and uses the same services from below, its implementation can change without affecting the rest of the system. introduced in ch. 1 — open in glossary .
What layering buys
A layered architecture lets you discuss one well-defined part of a large system. That simplification gives modularity: it becomes far easier to change how a service is implemented.
A layer may change how it works freely. The rest of the system is unaffected, so long as it still offers the same service upward and uses the same services from below.
In plain words
Changing how a service is implemented is very different from changing what the service is.
If the airline decided to board passengers by height, nothing else in the system would need to change. The gate layer still loads and unloads people; it just does it differently. That is the whole value of a service model.
What layering costs
Layering is not universally admired. Some researchers and engineers are vehemently opposed to it, and the book names two real drawbacks.
- One layer may duplicate what a lower layer already does. Many protocol stacks provide error recovery both per-link and again end to end.
- A layer may need information that exists only in another layer — a timestamp, for example. Reaching for it violates the separation the layers were supposed to give.
The five layers
The protocols of the various layers, taken together, are the protocol stack protocol stack Simple The five layers of protocols stacked on each other, from application down to physical. Precise The protocols of the various layers taken together. The Internet protocol stack has five layers: application, transport, network, link and physical. Hosts implement all five, routers implement layers 1–3, and link-layer switches implement layers 1–2. introduced in ch. 1 — open in glossary . The Internet’s has five layers.
| Applicationlayer 5 | Transportlayer 4 | Networklayer 3 | Linklayer 2 | Physicallayer 1 | |
|---|---|---|---|---|---|
| Its job | |||||
| Packet is called | |||||
| Example protocols | |||||
| Usually implemented in | |||||
| Which devices run it | |||||
| How far its header travels |
Cells marked ⓘ have a reason behind them — click to read it.
Read the “Packet is called” row. Those four words are the vocabulary this whole book depends on.
Notice that a protocol layer may be implemented in software, in hardware, or in both. Application- and transport-layer protocols are almost always software in the hosts. Because the physical and link layers handle communication over one specific link, they typically live in the network interface card for that link. The network layer is often a mixture.
The airline’s functions were spread across airports and control centres. In the same way, a layer-n protocol is distributed among the hosts, packet switches and other components that make up the network.
The four words
The book uses a different word at each layer, and it is never careless about which. Neither is this site.
| Layer | Call it a… | Looks like | Its header says |
|---|---|---|---|
| application | message | What the application actually wants to send. | |
| transport | segment | Which program on the far host, plus error-detection bits. | |
| network | datagram | The addresses of the two hosts. | |
| link | frame | How to cross this one link — and it changes at every hop. |
M is the application's message. Ht, Hn and Hl are the transport, network and link headers. Each layer treats everything handed down to it as one opaque payload and puts its own header in front.
Do not treat these as synonyms
The book uses a different word at each layer and is never careless about which. Neither is this site. Saying “packet” when you mean “frame” will cost you in chapter 6, where the two are genuinely different objects handled by different devices.
Use packet only when the layer is deliberately unspecified.
Encapsulation
Now watch the four names appear and disappear.
At the sending host, an application-layer message message Simple The packet at the application layer: what your application actually sends. Precise The application-layer packet of information, exchanged between the application-layer protocol entities running in different hosts. Written M in the encapsulation figure. introduced in ch. 1 — open in glossary is passed down to the transport layer. The transport layer appends its own header — — which the receiving host’s transport layer will read. Message plus is a segment segment Simple The transport-layer packet: the application's message plus a transport header. Precise The transport-layer packet. It encapsulates an application-layer message and adds transport-layer header information (Ht), which may include information for delivering the message to the right application and error-detection bits. introduced in ch. 1 — open in glossary .
We say that the segment encapsulates encapsulation Simple Each layer wraps the data from the layer above inside its own header. Precise The process by which a layer takes the packet from the layer above as its payload and adds its own header, producing that layer's packet: message → segment → datagram → frame. introduced in ch. 1 — open in glossary the message.
The added information might tell the receiving transport layer which application the message belongs to, and might include error-detection bits.
The segment goes down to the network layer, which adds — carrying the source and destination host addresses — creating a datagram datagram Simple The network-layer packet: a segment plus a header carrying the two host addresses. Precise The network-layer packet. It encapsulates a transport-layer segment and adds network-layer header information (Hn), such as the source and destination host addresses. introduced in ch. 1 — open in glossary . The datagram goes down to the link layer, which adds , creating a frame frame Simple The link-layer packet, sent over one single link from one device to the next. Precise The link-layer packet. It encapsulates a network-layer datagram and adds link-layer header information (Hl). A datagram may be carried by a different link-layer protocol, and therefore a different frame format, on each link along its route. introduced in ch. 1 — open in glossary .
In plain words
At every layer a packet has just two kinds of field: a header header Simple The extra bytes at the front of a packet, carrying addresses and control information. Precise The fields a layer adds in front of its payload, to be read by the peer layer at the receiver. At each layer a packet has two kinds of fields: header fields and a payload field. introduced in ch. 1 — open in glossary and a payload payload Simple The part of a packet that carries the data, not the header. Precise The field of a packet that carries the data being delivered; it is typically the entire packet from the layer above. introduced in ch. 1 — open in glossary . The payload is normally the entire packet from the layer above.
Each layer refuses to look inside its payload. That refusal is what makes the layers independent.
Lin’s laptop · Application — The application has a message to send. At this point it is just data — nothing has been added to it yet.
Scrub through it. Watch two things: the greyed-out layers at the switch and the router, and what happens to the link header each time a hop ends.
Read all 19 steps as text
- Lin’s laptop · Application [GET /index.html] — The application has a message to send. At this point it is just data — nothing has been added to it yet.
- Lin’s laptop · Transport [Ht | GET /index.html] — The transport layer puts its header Ht in front. Everything below now treats the message as an opaque payload. This is a segment.
- Lin’s laptop · Network [Hn | Ht | GET /index.html] — The network layer adds Hn, carrying the addresses of the two hosts. This is a datagram.
- Lin’s laptop · Link [Hl | Hn | Ht | GET /index.html] — The link layer adds Hl, which describes how to cross this one link. This is a frame.
- Lin’s laptop · Physical [Hl | Hn | Ht | GET /index.html] — The physical layer puts the individual bits of the frame onto the medium.
- link-layer switch · Physical [Hl | Hn | Ht | GET /index.html] — The bits arrive and are reassembled into a frame.
- link-layer switch · Link [Hn | Ht | GET /index.html] — The switch reads the link header and decides which port to use. It stops here: it does not implement the network layer, so it cannot see the IP addresses inside at all.
- link-layer switch · Link [Hl | Hn | Ht | GET /index.html] — A brand-new link header is added for the next link. It may be a completely different link technology — Ethernet here, WiFi next — and the header changes to match.
- link-layer switch · Physical [Hl | Hn | Ht | GET /index.html] — The frame goes out onto the next link as bits.
- router · Physical [Hl | Hn | Ht | GET /index.html] — The bits arrive and are reassembled into a frame.
- router · Link [Hn | Ht | GET /index.html] — The old link header is removed and discarded. It described the link the frame just crossed, and that link is behind us now.
- router · Network [Ht | GET /index.html] — The router reads the destination address in Hn and chooses the outgoing link. It stops here: it does not implement the transport layer, so Ht means nothing to it.
- router · Link [Hl | Ht | GET /index.html] — A brand-new link header is added for the next link. It may be a completely different link technology — Ethernet here, WiFi next — and the header changes to match.
- router · Physical [Hl | Ht | GET /index.html] — The frame goes out onto the next link as bits.
- web server · Physical [Hl | Hn | Ht | GET /index.html] — The bits arrive and are reassembled into a frame.
- web server · Link [Hn | Ht | GET /index.html] — The old link header is removed and discarded. It described the link the frame just crossed, and that link is behind us now.
- web server · Network [Ht | GET /index.html] — The network layer removes Hn and passes the segment up.
- web server · Transport [GET /index.html] — The transport layer removes Ht, checks it, and works out which application the message belongs to.
- web server · Application [GET /index.html] — The message arrives at the application, byte for byte what was sent.
Not every device has every layer
Routers and link-layer switches are both packet switches, and both organise their software and hardware into layers. But they do not implement all of them — only the bottom ones.
- A link-layer switch implements layers 1 and 2.
- A router implements layers 1 to 3.
- A host implements all five.
So a router can run IP (Internet Protocol) Internet Protocol The network-layer protocol that defines the datagram format and addressing every Internet device must use. introduced in ch. 1 , a layer-3 protocol, and a link-layer switch cannot. A switch does not recognise IP addresses at all; it recognises layer-2 addresses such as Ethernet addresses.
Why hosts do the most work
Hosts implement all five layers. Routers implement three, switches two.
This is consistent with a deliberate design choice: the Internet architecture puts much of its complexity at the edges. Keep it in mind. It explains why TCP (Transmission Control Protocol) Transmission Control Protocol The Internet transport protocol that delivers data reliably and in order, with flow control and congestion control. introduced in ch. 1 can be improved without touching a single router, and it is a theme the book returns to repeatedly.
Everyday picture — the book’s interoffice memo
Alice, in one branch office, sends a memo to Bob in another, through the public postal service.
The memo is the application-layer message. Alice puts it in an interoffice envelope with Bob’s name and department on the front. That interoffice envelope is the segment: it has header information — Bob’s name and department — and it encapsulates the memo.
The sending mailroom puts that envelope inside a second envelope suitable for the postal service, and writes the postal addresses of the two branch offices on it. That outer envelope is the datagram.
The postal service delivers it. The receiving mailroom begins de-encapsulation: it extracts the interoffice envelope and forwards it to Bob. Bob opens it and removes the memo.
Where the picture breaks: the postal service handles one envelope from end to end. A datagram’s outer link-layer envelope is thrown away and rebuilt at every single hop, as the animation above shows. Nothing in the postal system works that way.
Encapsulation can be more complex than this. A large message may be divided into several segments, and each of those might be divided into several datagrams. At the receiving end, a segment must then be reconstructed from its constituent datagrams.
Check yourself
Check yourself — §1.5
0 of 7 answered1.What is a layer's service model?
2.Name the five layers of the Internet protocol stack, from top to bottom.
3.predictStep the animation to the link-layer switch. Why can it not read the destination IP address?
Look at which layers are drawn as "not implemented" in that column.
4.predictStep the animation through the router. What happens to the link header Hl?
Compare the packet drawn at the router's link layer on the way in and on the way out.
5.Which layers do hosts, routers and link-layer switches implement?
6.A transport-layer packet is called a segment. What does it contain?
7.The book gives two drawbacks of layering. Which is one of them?
What to remember
- The Internet stack has five layers — application, transport, network, link, physical — and their packets are called message, segment, datagram, frame, never used loosely.
- Encapsulation: every layer treats what it is handed as an opaque payload and puts its own header in front.
- Hosts implement all five layers, routers three, switches two. The complexity lives at the edges, and the link header is rebuilt at every hop while the transport header is written once and read once.