6 · Protocol layers
Slides 1-62 → 1-67 · Sample midterm 1b
Why layering?
- Networks are huge and complex (hosts, routers, links, apps, protocols, hardware, software). Layers give them an explicit structure, so you can name each piece and see how the pieces relate.
- Modularity: each layer gives a service to the layer above it and uses the service of the layer below. You can change how one layer works without affecting the rest (e.g. swap WiFi for Ethernet and HTTP doesn't care).
- − Downsides ("layering considered harmful"): layers can duplicate work (e.g. error checking at more than one layer), and one layer sometimes needs information hidden in another layer.
The 5-layer Internet stack (memorize this table)
| # | Layer | Job | Examples | Data unit |
|---|---|---|---|---|
| 5 | Application | Supports network apps | HTTP, SMTP, IMAP, DNS | message |
| 4 | Transport | Process-to-process data transfer | TCP, UDP | segment |
| 3 | Network | Routing datagrams from source host to destination host | IP, routing protocols | datagram |
| 2 | Link | Data transfer between neighboring network elements (one hop) | Ethernet, 802.11 (WiFi), PPP | frame |
| 1 | Physical | Bits "on the wire" | Copper, fiber, radio | bits |
Mnemonic (top → bottom): All Teachers Need Lots of Patience. Data units: Message, Segment, Datagram, Frame: "My Sister Does Football."
Easy mix-ups
• Transport = process ↔ process (which app on the host, via port numbers). Network = host ↔ host (which machine, via IP address).
• Network = the whole path, end to end. Link = just one hop to the next device.
• Routing is the network layer. That's sample midterm 1b.
• Transport = process ↔ process (which app on the host, via port numbers). Network = host ↔ host (which machine, via IP address).
• Network = the whole path, end to end. Link = just one hop to the next device.
• Routing is the network layer. That's sample midterm 1b.
The 7-layer ISO/OSI model
Same as the Internet stack, plus two extra layers between application and transport:
| OSI | Internet |
|---|---|
| Application | Application |
| Presentation: lets apps interpret the meaning of data (encryption, compression, machine-specific conventions) | |
| Session: synchronization, checkpointing, recovery of data exchange | |
| Transport | Transport |
| Network | Network |
| Link | Link |
| Physical | Physical |
The Internet stack is "missing" presentation and session. If an app needs those services, the app has to implement them itself.
Encapsulation
Going down the stack at the sender, each layer adds its own header in front of what it got from above. Going up at the receiver, each layer strips its header off.
| Layer | What it sends | Name |
|---|---|---|
| Application | M | message |
| Transport | Ht | M | segment |
| Network | Hn | Ht | M | datagram |
| Link | Hl | Hn | Ht | M | frame |
Each header carries what that layer needs. Ht has port numbers (and e.g. sequence numbers), Hn has IP addresses, Hl has link (MAC) addresses.
Which devices use which layers?
| Device | Layers it implements |
|---|---|
| Host (end system) | All 5 |
| Router | 3: network, link, physical |
| Link-layer switch | 2: link, physical |
So a router opens the frame up to the datagram (Hn) to decide where to send it. A switch only looks at the frame (Hl). Neither looks at the transport header or the message.
Ties to other topics: the message segmentation from topic 4 and the header overhead in sample P2 are exactly this. Every packet carries headers, so more packets means more header bits.
Quick check
1. Which layer in the Internet protocol stack does routing? (sample 1b)
The network layer (IP and the routing protocols).2. Name the 5 layers top to bottom, and the data unit at each of the top four.
Application (message), Transport (segment), Network (datagram), Link (frame), Physical.3. Which layer: TCP? Ethernet? HTTP? IP? WiFi? DNS?
TCP = transport. Ethernet = link. HTTP = application. IP = network. WiFi (802.11) = link. DNS = application.4. What's the difference between the transport and network layers?
Transport moves data process to process (between apps, using ports). Network moves datagrams host to host across the whole path (routing, using IP addresses).5. Which two OSI layers does the Internet stack not have, and what do they do?
Presentation: interpreting data (encryption, compression, machine-specific formats). Session: synchronization, checkpointing, recovery. If needed, the application implements them.6. How many layers does a router implement? A switch?
Router: 3 (network, link, physical). Switch: 2 (link, physical).7. Give one advantage and one disadvantage of layering.
Advantage: modular, so you can change one layer's implementation without affecting the rest (and it gives a clear structure to reason about).Disadvantage: duplicated functionality across layers, or a layer needing information hidden in another layer.
That's all of Chapter 1. Next up: Chapter 2, the application layer.