Understand network layers
See how protocols divide a message into manageable jobs.
- Name the four layers of the Internet model and the job of each one.
- Explain how data is wrapped as it moves through network layers.
- Predict which headers change at a router and which survive end to end.
When you open a web page, your request crosses Wi-Fi, copper and fiber, passing through equipment owned by companies that have never heard of each other. Nobody designed that exact path, and it still works in a fraction of a second.
It works because the problem is split into separate jobs, and each job only has to agree with its counterpart on the other side.
Four jobs, four layers
Each layer answers one question and relies on the layer below it for everything else:
- Application: what does the program want to say? (HTTP, DNS)
- Transport: which program on the machine should get this, and how reliably? (TCP, UDP)
- Internet: how does this reach the right machine across many networks? (IP)
- Link: how does this cross the single connection in front of me? (Ethernet, Wi-Fi)
Those four colors stay the same in every diagram and lab in this track, so purple always means the application and blue always means IP.
Encapsulation: wrapping as you go down
Going down the stack, each layer treats everything it received as opaque data and adds its own header in front. This wrapping is called encapsulation. On the receiving side, each layer reads its own header, removes it and passes the rest up.
Think of a letter in an envelope, inside a shipping box. The courier reads the box label and never opens the envelope.
Try it
Up to 15 XPWrap a request and send it across the Internet
Add each header, then carry the packet across the links. Before the packet reaches the first router, you'll be asked to predict what changes. Watch the highlighted fields at each hop: which addresses change, and which ones survive the whole trip?
- Application data
- 21 bytes
- Headers added
- 0 bytes
- Where it is now
- On your laptop
See a real packet
This is what a capture tool prints for the packet you just wrapped. Read it from left to right: the MAC addresses come from the Ethernet header, the IP addresses from the IP header, and the port numbers and flags from the TCP header.
$ sudo tcpdump -e -n -c 1 port 443
aa:aa:aa:00:00:10 > bb:bb:bb:00:00:01, ethertype IPv4, length 54:
192.168.1.10.51514 > 203.0.113.8.443: Flags [S], seq 1000, win 64240, length 0Underneath, that packet is just 54 bytes. Each header sits at a fixed position, so every device knows exactly where to look.
Try it
Up to 15 XPFind the headers in the raw bytes
This is the same packet as a hex dump, with one byte per box. Find each field by clicking any of its bytes. The Ethernet header takes bytes 0 to 13, the IP header bytes 14 to 33 and the TCP header bytes 34 to 53.
Notice the order: the outermost header comes first, exactly like the boxes you just nested.
A switch has to decide quickly, so the destination comes first of all. Look at the very start of the frame.
Try it
Up to 15 XPWhich layer owns it?
Sort each item into the layer that uses it. If you're unsure, ask what question the item answers: which program, which machine, or which link?
“The path /lessons in a URL”
“Port 443”
“The address 203.0.113.8”
“The address aa:bb:cc:dd:ee:ff”
“Retransmitting a lost segment”
“Choosing a Wi-Fi channel”
“Deciding the next router”
Key takeaways
Each layer answers one question and hides its details from the others.
Going down the stack adds headers, and going up removes them.
IP addresses describe the whole trip, while MAC addresses describe one link.
Lesson quiz
7 questions · pass with 5 correct · up to 50 XP
Passing this quiz completes the lesson and keeps your streak going. Questions you miss come back in review sessions later.
Questions about this lesson
Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.
Loading posts…