Skip to content
World 1 · Packets: Breaking a Message Apart · 12 min

Putting it back together

Reassembly and checks

Teaching this? Open projector mode

The packets of one message leave the sender in order, but they do not necessarily arrive in order. Different paths, a busy link or a lost-and-resent packet can all shuffle them. So the receiver needs a way to rebuild the message.

It uses the sequence number in each header. The receiver puts the packets in order of that number, like numbered pages of a book, and then joins the payloads.

Example: the message "NETWORKS ARE FUN" is sent as four packets, 1 to 4. They arrive as 3, 1, 4, 2. The receiver sorts them back into 1, 2, 3, 4 and reads the full message. If packet 3 never arrives, the receiver can see the gap: it has 1, 2 and 4 but nothing numbered 3.

Spotting damage: the checksum. Wires and radio links are not perfect, and a bit can occasionally flip from 0 to 1. To catch that, the sender computes a small number from the data and puts it in the header. The receiver computes the same number from what it got and compares.

A toy version: add up all the payload bytes and keep the remainder after dividing by 256. For the five bytes 72, 101, 108, 108, 111 (the letters of "Hello") the sum is 500, and 500 − 256 = 244. If one byte changed on the way, the receiver's sum would not be 244, and it would know the packet was damaged and throw it away. The real Internet checksum is a bit cleverer, but the idea is the same: a small number that changes when the data changes.

A checksum can detect errors. It cannot repair them. The fix is to ask for the packet again.

Who notices a missing packet, and what happens next? On the Internet, a protocol called TCP (World 5) does this job. The receiver sends back short messages called acknowledgements that say what has arrived. If a packet is missing, the sender hears nothing for it and sends it again. The application, such as your browser, never sees the gaps or the shuffling. It just receives the finished file.

Everything you download is split up this way, not only files and photos. Even a single web page, a song or the answer to a search is cut into packets, because it is bigger than one packet can hold.

Loading 3D lab…
Check yourself

Packets arrive in the order 3, 1, 4, 2. How does the receiver rebuild the message?

Check yourself

What is a checksum for?

Check yourself

Who notices that a packet is missing, on the Internet?

Check yourself

The toy checksum is the sum of the payload bytes modulo 256. The bytes are 10, 20 and 30. What is the checksum?

0 of 5 required activities complete. Finish each task and quiz.Next lesson →
My notes
Only saved in this browserAll my notes →

Report a mistake

What is wrong?
0 / 2000 · at least 10 characters
Sent along with your report
  • Page
  • About Putting it back together — How the Internet Works · internet/putting-it-back-together
Plus your browser type. Reports go to our support system; see the privacy notice.