Skip to content

BeginnerLesson 3 of 11

Messages in pieces ​

A device never sends a message over a network in one go. It cuts the message into small pieces, called packets, and sends each piece on its own. The device at the other end puts the pieces back together. A short chat message may fit in one packet. A photo becomes a few thousand.

Cutting a message into packets ​

Everything a device sends is Anything a device stores or sends, such as the letters of a message, a photo, or a call.. Each piece of data travels in a A small piece of data with a label that says where it comes from, where it goes, and which piece it is. Everything on a network travels in packets.. On most networks, one packet holds at most about 1,500 letters of plain text. That limit is the MTU from Cables, light, and radio.

Every packet has a label with three things on it:

On the labelWhat it is for
FromThe answer goes back to this device.
ToEvery box on the way reads it to know where to pass the packet on.
Its numberThe receiver puts the pieces back in order, and notices when one is missing.

On a real network, "from" and "to" are addresses, the subject of the next lesson.

Try itSend a message in packets
2. Pick a packet size
3. On the way

The message as 4 packets:

  1. No. 1 of 4Laptop → Friend’s phoneMeet me
  2. No. 2 of 4Laptop → Friend’s phoneat the s
  3. No. 3 of 4Laptop → Friend’s phonetation a
  4. No. 4 of 4Laptop → Friend’s phonet five
LaptopHome routerQuiet wayBusy wayFriend’s routerFriend’s phone

Received, in the order it came:

  1. nothing yet

Put back in order by number:

  1. 1…
  2. 2…
  3. 3…
  4. 4…

Send it, then change the packet size or the loss and send it again. The ways and losses are random, but a run number always gives the same ones.

Different ways, different order ​

There is often more than one way between two devices. Each box in the middle, like your home router, passes every packet on to the next box. When one way is busy, packets wait there in line. Packets that take a quiet way overtake them.

The packets of one message usually follow the same way, but they do not have to. If a link breaks or gets crowded, later packets may go another way and arrive before earlier ones.

The receiver does not mind the order. It puts each packet in its place by its number. When it has them all, the message is whole again.

CheckA message is cut into four packets. They arrive at the phone in the order 2, 1, 4, 3. What does the phone show?

Lost packets are sent again ​

Sometimes a packet never arrives. A box in the middle that is too busy may have no room for one more packet, so it throws the packet away. Radio waves, which Wi-Fi uses, can be disturbed, and a damaged packet is thrown away too. Either way, the packet is lost.

The receiver notices from the numbers. If it has packets 1, 2, 4, and 5, then 3 is missing. It tells the sender which packet is missing, and the sender sends that one packet again. When the gap is filled, the receiver puts the message together.

This happens all the time when you open web pages, send messages, or download files, and you never notice it. Video calls and games work another way. They skip a lost piece, because waiting for it would be worse. Ports and protocols shows how.

A packet sent again can be lost again

The receiver then asks again until the packet arrives, or the sender gives up.

CheckA message is six packets long. The phone has received packets 1, 2, 3, 5, and 6. What happens next?

Why cut messages up at all? ​

Each packet needs a label, and the receiver must put the packets back together. Networks use them anyway, for two reasons.

Try itShare one cable
Laptop: videoPhone: chatHome routerThe internetOne cable: one thing at a time

What crossed the cable, moment by moment

V the laptop’s video C the phone’s chat message ✕ damaged by noise V sent again

Send both with packets off, then on. Then turn on the noise and try both again. Watch when the chat message gets through.

Packets let devices share a link fairly. A cable carries one thing at a time. With packets, devices take turns, so a short message does not wait behind a long one. So a message from your phone still arrives quickly while someone else at home watches a film.

Packets turn a big loss into a small one. When noise damages one packet, only that packet is sent again, not the whole message.

Smaller packets mean more labels for the same message. Real networks use packets of up to about 1,500 letters. That is small enough to share a link, and large enough to keep the labels a small part of each packet.

CheckWhy is a big file sent as many small packets instead of one big piece?

Discussion

Stuck, or found a mistake? Ask here. You sign in with GitHub.

Released under the Business Source License 1.1.