Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Preview

Data packets

This is the first page of the lesson. Read it and have a go at the activities. The rest is in the full lesson.

50 minutes

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

WordWhat it meansExample
PacketA small piece of data sent over a network, with an address on it.One envelope
HeaderThe front part of a packet. It holds addresses and numbers for delivery.The address on the envelope
PayloadThe part of the packet that carries the real data.The page inside
TrailerThe end part of a packet. It holds a check value.A check number written on the back of the envelope
Packet switchingSending data as packets that may each take a different route.Envelopes on different roads
Sequence numberA number that puts packets back in the right order.Page 3 of 5
HopOne step of a packet from one router to the next.3 hops to the server
TTLTime to live. A count that goes down at each router. At zero the packet is thrown away.TTL 64
ProtocolA set of rules that computers follow to talk to each other.HTTP
RedundancySomething extra, added on purpose. In a packet, it is extra data that helps find mistakes.A check value
CRCCyclic redundancy check. A check value that shows if data was damaged on the way.A number in the trailer
IP addressA number that names a device on a network.10.0.12.1
RouterA device that joins networks and sends packets on the right way.A home router
NetworkComputers joined together to share data.The college network

The cells students fill in are left blank in this preview.

What is in a packet?

PartWhat it holdsRole
HeaderSource address, destination address, sequence numberGets the packet to the right place, in the right order
PayloadA piece of the dataThe reason the packet exists
TrailerAn error check value such as a CRCLets 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

Code: python
# 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

PartWhat 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.
ProtocolSays which set of rules the payload follows, such as TCP.
Where the parts really areThe 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 lossThe 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

Command
sudo ip netns exec h1 ping -c 4 -W 1 10.0.12.1

A command for the lesson’s lab terminal. It is shown here and not run.

Extra: Send two packets that are lost

Command
sudo ip netns exec h1 ping -c 2 -W 1 10.0.3.2

A 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.

The lesson goes on

9 more parts of this lesson are in the full curriculum, with the tasks, the final check and the labs. A college account gives your students all of it.