LightMySky

Layering and Encapsulation in the Protocol Stack

Each layer wraps the layer above in a header and hands it down, so a message crossing the network is a set of nested envelopes. The arrangement means a change in how a link carries bits does not reach the application, and it also means a failure at one layer is reported in that layer's terms.

No account needed. Progress saves in this browser.

What a learner can do afterwards

  • Follow one message down the stack, naming the header each layer adds
  • Say which layer a stated failure belongs to and how it would be reported
  • Explain what a layer boundary buys and what it hides

1 · Read

Picture sending a gift in the mail. You do not hand over the bare gift. You set it in a box, tape that box shut, and slide it into a bigger shipping box with a label. A message crosses the network the same way. Each layer wraps what it received from above in its own header and hands it down. From the bottom up the layers are: physical, which moves raw bits over wire, wifi or fiber; link, which carries data between two devices on the same local network, such as your laptop and your home router; Internet, where IP moves packets across many networks; transport, where TCP keeps the trip reliable and in order; and application, where programs such as your browser ask for pages with HTTP. Each layer speaks only with the neighbor above it and the neighbor below it.

Try it together

Follow one web request down the stack. Your browser builds an HTTP request that opens with plain text like GET /index.html. TCP chops the request into pieces called segments and adds a header of numbers to each one, so the pieces can be put back in order and resent if one goes missing. IP adds a header with the source and destination addresses, turning each segment into a packet that routers can forward. The link layer adds one more header for the hop to your router, and then it all becomes bits on a wire. At the far end the headers peel off in reverse, and each layer removes only the header it understands.

HTTP requestTCP segmentIP packetlink framebits on wire

Paths break, and the design expects it. A storm can drop a cable or a router can fail, yet packets still arrive because routers usually know more than one route to the same place and pick the next best one. If a piece still goes missing, TCP spots the gap in its numbers and asks the sender for that piece again. Notice what your app sees of all this: nothing about cables or routers. It receives one complete message, perhaps a little late. Each failure is handled and described in the terms of the layer that understands it, which keeps every layer above blissfully simple.

Good to know

Two habits answer most questions on this topic. To name the layer, ask what the header does. Addresses for travel between networks point to the Internet layer and IP. Numbers for order and resends point to the transport layer and TCP. The short hop to the next box on your own network points to the link layer. Raw ones and zeros point to the physical layer, and the page or mail request itself points to the application layer. To say what a boundary buys, run the swap test: a faster cable changes only the bottom while every app above keeps working, and a brand new app runs fine on the same TCP and IP. Each side improves alone because each trusts its neighbor to do its job.

Each layer adds one header going down, removes it coming up, and hides its own troubles from everyone above.

2 · Watch

Take it off screen

Print a worksheetA4 with an answer key page for grown-ups. No screen, no internet.

Where it sits

Then practise

8 questions wait behind this lesson, each with its answer explained. Every answer feeds the sky: stars light as they are learned, and dim when it is time to come back.

Spotted a problem on this page? Tell us
Layering and Encapsulation in the Protocol Stack · Computing, ages 18 to 19 · LightMySky