Loading
0x00Lesson 1 of 7

Understand network layers

See how protocols divide a message into manageable jobs.

15 min 4-question quiz 1 code exercise
By the end of this lesson you can
  • Explain how data is wrapped as it moves through network layers.

A network stack separates responsibilities. An application creates data, a transport protocol such as TCP or UDP carries it between processes, IP moves packets between networks, and a link technology moves frames across one local connection. Each layer adds information its peer needs; this is called encapsulation.

network_demo.py
1message = "Hello"
2transport_segment = {"port": 443, "data": message}
3ip_packet = {"destination": "203.0.113.8", "data": transport_segment}
4print("application → transport → IP")
5print(ip_packet["destination"])
Output
application → transport → IP
203.0.113.8

The model is a teaching aid, not a literal description of every implementation. A router generally forwards IP packets, while a switch forwards link-layer frames on its local network. Protocol layers make it possible for different technologies to work together.

Key takeaways

  • Explain how data is wrapped as it moves through network layers.

  • The code examples simulate protocol behavior; they do not send network traffic.

  • Use the layer model to locate where an address, port, or message belongs.

Lesson quiz

4 questions · pass with 3 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.

Practice: model networking concepts

Use small Python programs to model packet, address, and protocol behavior. These exercises run locally in your browser and do not send network traffic.

Exercise 1

Trace a message through the stack

+25 XP

Print the layer path for a web request, from the application down to the local link.

  • Layer path
main.py
Loading editor…

Python runs in a sandboxed browser worker with a 60 second time limit. Its runtime loads from the Pyodide CDN; your code stays in this browser.

Questions about this lesson

Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.

Loading posts…

Did you like the lesson? 😆👍
Consider a donation to support our work: