Loading
0x00Lesson 1 of 15

Understand network layers

See how protocols divide a message into manageable jobs.

20 min 7-question quiz
By the end of this lesson you can
  • 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.

Your home networkA data centerThe InternetHome routerProviderCoreEdge routerServerFrames on each local linkPackets between networksFrames on each local linkTCP and HTTP run end to end, between your laptop and the server
Your laptop and a server are on different local networks. Routers carry packets between networks, and frames carry them across each local link.

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.

ApplicationWhat the program wants to sayHTTP, DNS, TLSmessages7 Application6 Presentation5 SessionTransportWhich program, and how reliablyTCP, UDPsegments, datagrams4 TransportInternetWhich network and host, across routersIP, ICMPpackets3 NetworkLinkAcross one local connectionEthernet, Wi-Fiframes2 Data link1 Physical
Left: the four layers the Internet is built on. Right: the seven-layer OSI names you'll still hear, such as “a layer 7 load balancer”.

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 XP

Wrap 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
GET /lessons HTTP/1.1
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.

terminal
$ 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 0

Underneath, 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 XP

Find 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.

Field 1 of 10First try 0/0
LinkFind: Destination MAC

A switch has to decide quickly, so the destination comes first of all. Look at the very start of the frame.

0
16
32
48

Try it

Up to 15 XP

Which 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?

0 of 7 sortedScore 0/0
  • “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…