Working in layers: the layers of a network
Imagine mailing a letter. You write on paper, slip the paper into an envelope, put an address on the envelope, and drop it into a mail bin. No one person does it all at once, the steps are split apart. A network works the same way, split into layers.
Why split into layers
As we saw before,
your message is delivered through several stations.
But even that single delivery
has a lot to do.
Hold the content,
make sure nothing is lost or out of order,
attach an address for where to send it,
and turn it into a real signal.
Doing all this as one lump
is so complex it tangles easily.
Tap the single lump on the left. The jobs tangle up. Split into layers like the right and each job becomes clear.
The single lump was scary to touch.
Fix one thing
and something unrelated shakes too.
But once you split into layers,
each layer takes only its own job.
The layer that adds the address need not know the content,
the layer that makes the signal need not know the address.
So even if you fix one layer,
the others stay fine.
That is the first reason to split into layers.
Wrap it layer upon layer
When sending, you wrap the message layer upon layer.
First you write the content on paper.
You slip that paper into an inner envelope.
The inner envelope goes into an outer envelope,
and you write an address on the outer one.
Finally you put it into a mail bin.
The bin is the real signal of 0s and 1s.
The inner content stays as it is
while you add an outer wrap one layer at a time.
Wrapping like this is called encapsulation.
Each press wraps one more layer. Paper, inner envelope, outer envelope, mail bin. This is encapsulation.
Once it is all wrapped,
from the outside you only see the mail bin.
What content sits inside
the outer signal need not know.
It just carries the 0s and 1s.
The other way around, the paper
doesn't care what the address is.
Each wrap minds only its own share.
So next let's peek at what job
each layer takes on.
Each layer does only its own job
The four wraps each have a different job.
The paper handles the content.
What you want to say.
The inner envelope handles correctness.
Whether it all arrived, in order, with nothing missing.
The outer envelope handles the address.
Where to send it.
The mail bin handles the signal.
Putting the 0s and 1s onto real wires and waves.
Tap each layer. Only that layer's job lights up clearly. Content, correctness, address, signal.
The fun part is
a layer need not know the insides of its neighbor.
The address layer need not know
whether the content is a greeting or a photo.
The signal layer doesn't care
what address sits above it.
If each just keeps its own slot well,
the whole thing runs smoothly.
So how does the receiving side
unwrap these layers?
When it arrives, unwrap in reverse
On the side that arrived, you undo it in reverse.
The opposite order of how it was wrapped.
First you take it out of the mail bin.
Gather the 0s and 1s back into the bundle of envelopes.
Then peel off the outer envelope.
The address has done its job, so remove it.
Next peel off the inner envelope,
checking that it all arrived with nothing missing.
Finally you open the paper,
and the sender's message comes out just as it was.
Each press peels one layer from the outside. Mail bin, outer envelope, inner envelope, paper (the message arrives).
With every layer peeled,
the message written at the start is intact.
Quite something, isn't it.
The order the sender wrapped in
the receiver undoes in exact reverse.
So the content inside
is never touched along the whole way.
That's because the same layers follow the same agreement.
Thanks to this agreement,
any machines in the world can understand each other.
Let's wrap up
Gathered on one line, it's this.
A network doesn't do everything at once,
it splits into layers and each layer does only its own job.
When sending, from the paper to the mail bin,
you wrap it layer upon layer. This is encapsulation.
When receiving, the other way around,
you peel from the outside one layer at a time to reach the message.
Since every layer keeps the same agreement,
even a complex job runs simply and sturdily.
Tap the key points in order to review. (split into layers, wrap when sending (encapsulation), each layer does its own job, peel in reverse when receiving)
Now that you know how to split, wrap, and unwrap in layers,
one more thing makes you curious.
That address written on the outer envelope,
what does it actually look like
and how does it point to a single unique place in the world?
Next lesson, let's look together
at what that address really is.