← all topics

6 · Protocol layers

Slides 1-62 → 1-67 · Sample midterm 1b

Why layering?

The 5-layer Internet stack (memorize this table)

#LayerJobExamplesData unit
5ApplicationSupports network appsHTTP, SMTP, IMAP, DNSmessage
4TransportProcess-to-process data transferTCP, UDPsegment
3NetworkRouting datagrams from source host to destination hostIP, routing protocolsdatagram
2LinkData transfer between neighboring network elements (one hop)Ethernet, 802.11 (WiFi), PPPframe
1PhysicalBits "on the wire"Copper, fiber, radiobits
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.

The 7-layer ISO/OSI model

Same as the Internet stack, plus two extra layers between application and transport:

OSIInternet
ApplicationApplication
Presentation: lets apps interpret the meaning of data (encryption, compression, machine-specific conventions)
Session: synchronization, checkpointing, recovery of data exchange
TransportTransport
NetworkNetwork
LinkLink
PhysicalPhysical

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.

LayerWhat it sendsName
ApplicationMmessage
TransportHt | Msegment
NetworkHn | Ht | Mdatagram
LinkHl | Hn | Ht | Mframe

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?

DeviceLayers it implements
Host (end system)All 5
Router3: network, link, physical
Link-layer switch2: 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.

← 5 · Throughput · all topics