Course outline · 0% complete

0/25 lessons0%

Course overview →

Packets: data travels in pieces

lesson 3-1 · ~10 min · 6/25

Quiz

Warm-up from unit 2: DNS gave your browser the answer 93.184.215.14 for example.com. What is that value?

Nothing is sent whole

Networks never send a file, a page, or even a long message in one piece. Everything is chopped into packets: small chunks of data, typically around 1,500 bytes each, that travel independently. A 1 MB photo becomes roughly 700 packets.

Each packet carries a header, a small block of bookkeeping in front of the data:

  • the source IP address (who sent it)
  • the destination IP address (where it is going)
  • a sequence number (which piece of the whole this is)

Routers between you and the server read only the destination and pass the packet along, hop by hop. Different packets from the same message can take different routes, arrive out of order, or get lost entirely. That sounds like chaos, and at this layer it is. The next lesson shows how TCP builds reliability on top of it.

Packet thinking pays off in real diagnostics: a "slow" connection is very often a lossy one, where a few percent of packets vanish and everything stalls while they are resent. Tools you will meet later, like ping with its "0.0% packet loss" line, are measuring exactly this.

from192.168.1.7to93.184.215.14seq3 of 700data~1,460 bytesheader (bookkeeping)payload
One packet: a header with source, destination, and sequence number, followed by the actual chunk of data.

Code exercise · bash

Run this. It plays the sender's role: chopping a message into fixed-size packets. fold -w 12 splits text into 12-character lines, and the loop numbers each chunk like a sequence number would.

Code exercise · bash

Your turn, now play the receiver. The packets below arrived out of order, each tagged seq:word. Sort them by sequence number and print the reassembled message on one line. sort -n sorts numerically and cut -d: -f2 keeps the part after the colon.