SkillGridLearn computer science by doing

The network stack: why layers exist

How a message becomes a frame and back again, and how layers turn "the internet is broken" into a solvable problem.

12 min · 40 XP

Sending "hello" to another machine is really dozens of decisions: which program gets it, how to find the machine, what to do when a cable drops a signal. If every app had to solve all of them, the internet would be impossible. Layers split those decisions: each one solves a single problem and trusts the layer below.

Four layers carry you from a click to a wire. Application: what you actually mean (HTTP, DNS, SMTP). Transport: which program on the machine and whether delivery is guaranteed (TCP, UDP, ports). Internet: how to find the machine anywhere on the planet (IP addresses, routing). Link: how to move bytes across one physical hop (Ethernet, Wi-Fi, MAC addresses).

Приложение   "привет"                                  <- данные
Транспорт    [TCP | порт 443 | привет]                   <- сегмент
Сеть         [IP | 93.184.216.34 | TCP | порт 443 | ...]  <- пакет
Канальный    [Ethernet | MAC роутера | IP | TCP | ...]    <- кадр

На каждом слое добавляется свой заголовок.
Получив кадр, приёмник снимает заголовки в обратном порядке.
БраузерСерверСтек на машинеapplication: запросtransport: порт и надёжностьinternet: IP-адресlink: кадр в сеть0101010101снимает заголовки по очередиapplication: ответ

Practice

  1. Order the layers as a message travels down from your application to the wire.

    Hints
    • Start with what a human creates: text, a click, a request.
    • A port is transport, an IP address is internet, a MAC address is link.

    12 XP

  2. Match each layer with what it is actually responsible for.

    Hints
    • An IP address does not guarantee delivery — it only says where to go.
    • DNS and HTTP are things the application itself does, not the network.

    12 XP

  3. A packet leaves your laptop for a server in another country. Which device decides which neighbour the packet goes to next?

    Hints
    • Think about who chooses the next hop for the packet.
    • A switch only works inside one local network segment.

    16 XP