A long letter in many envelopes
You must post a long essay, but each envelope holds only one page. So you number the pages and put each in its own envelope, with the address.
The envelopes go by different routes. Some arrive late. The other person puts the pages back in order using the numbers. A network is a group of computers joined together. Networks send data in the same way. A packet is a small piece of data with an address on it. Each envelope is a packet.
Key words
| Word | What it means | Example |
|---|---|---|
| Packet | A small piece of data sent over a network, with an address on it. | One envelope |
| Header | The front part of a packet. It holds addresses and numbers for delivery. | The address on the envelope |
| Payload | The part of the packet that carries the real data. | The page inside |
| Trailer | The end part of a packet. It holds a check value. | A check number written on the back of the envelope |
| Packet switching | Sending data as packets that may each take a different route. | Envelopes on different roads |
| Sequence number | A number that puts packets back in the right order. | Page 3 of 5 |
| Hop | One step of a packet from one router to the next. | 3 hops to the server |
| TTL | Time to live. A count that goes down at each router. At zero the packet is thrown away. | TTL 64 |
| Protocol | A set of rules that computers follow to talk to each other. | HTTP |
| Redundancy | Something extra, added on purpose. In a packet, it is extra data that helps find mistakes. | A check value |
| CRC | Cyclic redundancy check. A check value that shows if data was damaged on the way. | A number in the trailer |
| IP address | A number that names a device on a network. | 10.0.12.1 |
| Router | A device that joins networks and sends packets on the right way. | A home router |
| Network | Computers joined together to share data. | The college network |
The cells students fill in are left blank in this preview.
What is in a packet?
| Part | What it holds | Role |
|---|---|---|
| Header | Source address, destination address, sequence number | Gets the packet to the right place, in the right order |
| Payload | A piece of the data | The reason the packet exists |
| Trailer | An error check value such as a CRC | Lets the receiver spot damaged data |
The cells students fill in are left blank in this preview.
Packet switching
Data is cut into packets. Each router reads the destination address and sends the packet on to the next router. Two packets of the same message can take different routes.
At the end, the receiver uses the sequence numbers to put the packets back in order. This is good: if one road is busy or broken, packets use another. Many people can share the same cables.
Try it: put the packets in order
# Five packets arrive in the wrong order. Each has a sequence number.
arrived = {3: "my", 1: "I", 5: "phone", 2: "lost", 4: "new"}
for number in range(1, 6):
if number in arrived:
print(number, arrived[number])
else:
print(number, "is missing")
# Now delete one packet from the dictionary and run it again.
# The message has a gap: that is packet loss.
Extra: More in a real header
| Part | What it does |
|---|---|
| TTL (time to live) | Goes down by one at each hop. At zero the packet is thrown away, so a lost packet cannot travel for ever. |
| Protocol | Says which set of rules the payload follows, such as TCP. |
| Where the parts really are | The IP header holds the addresses and the TTL. The sequence number is in the TCP header. The CRC is in the trailer of the frame. |
| Two more causes of loss | The TTL reaches zero, for example when packets go round in a circle. Or a router has no route to the network. |
The cells students fill in are left blank in this preview.
Extra: Send four packets and read them
sudo ip netns exec h1 ping -c 4 -W 1 10.0.12.1A command for the lesson’s lab terminal. It is shown here and not run.
Extra: Send two packets that are lost
sudo ip netns exec h1 ping -c 2 -W 1 10.0.3.2A command for the lesson’s lab terminal. It is shown here and not run.
Extra: What ping showed
data-callouts.note.label
In the first output each line has icmp_seq. This is the sequence number of the packet. Each line also has ttl, the time to live. The second output says every packet was lost, because the router has no route to that network.
Why packets are lost
There are two main causes of packet loss.
The first is congestion. Too many packets arrive and a router has no room, so it throws some away.
The second is errors. A cable or a device is faulty. Wi-Fi has interference (other signals that make yours worse). A damaged packet fails its check and is thrown away.
A lost packet is not always a big problem. The sender can send it again.