Data sent across a network is broken down into packets. This lesson shows the three parts of a packet and what the header holds. Then it shows how packet switching sends each packet by its own route and puts the packets back in order.
about 25 min1 simulation1 practice question
Lesson 1 of 3Show all lessonsHide
Try the code and the simulations beside the lesson.
Why cut data into pieces?
Think of moving house with one giant box. It would block the stairs, and if it fell, everything inside would break. Many small boxes are easier. Each one can go in a different car, and if one is dropped, you only repack that one.
Networks work the same way. A photo, an email or a video is broken down into packets before it is sent. A packet is a small, fixed-size piece of the data with some extra information added to it. Each packet travels on its own. At the other end, the receiving device joins the packets back together.
The structure of a packet
Every packet has three parts.
A long bar split into three boxes from left to right. The first box is the packet header and lists the destination address, the packet number and the originator's address. The middle and widest box is the payload, the data being carried. The last box is the trailer, which marks the end of the packet.
Packet header. It comes first. It holds the information that gets the packet to the right place.
Payload. This is the actual data being carried: a piece of the photo, email or video.
Trailer. It comes last and marks the end of the packet. It often holds an error check, so the receiver can test whether the packet changed on the way. You meet error checks in the next course.
The header holds three things you must know.
The destination address: where the packet is going.
The packet number: its place in the whole message, so the packets can be put back in order.
The originator's address: where the packet came from, so a reply or a request to send again can find its way back.
Here is an example. A message is cut into 5 packets. Packet number 3 carries the third piece of the message. Its header says "to laptop B, packet 3, from phone A".
A common mistake is to say the header holds the data. It does not. The data is the payload.
Packet switching
On a large network there are many paths between two devices. The devices that choose the path are called routers. Packet switching is the way most networks use these paths.
A network of six routers, R1 to R6, joined by lines, between a sending phone on the left and a receiving laptop on the right. Packet 1 and packet 3 travel along the top route through R1, R2 and R3. Packet 2 travels along the bottom route through R4, R5 and R6. At the laptop the packets arrive in the order 1, 3, 2 and are then sorted into the order 1, 2, 3.
The steps of packet switching are these.
The data is broken down into packets.
Each packet could take a different route to the destination.
A router controls the route a packet takes. It reads the destination address in the header and sends the packet on to the next router.
The packets may arrive out of order, because some routes are faster or busier than others.
Once the last packet has arrived, the packets are reordered using their packet numbers.
In the picture, packets 1 and 3 go along the top route and packet 2 goes along the bottom route. Packet 3 arrives before packet 2. The receiver waits for all the packets and then sorts them by packet number.
Why is this a good plan? If one router is busy or broken, packets can go round it. No single line is tied up for the whole message, so many users can share the network. If one packet is lost or damaged, only that packet must be sent again. The cost is that packets can arrive out of order, so they must be reordered at the end.
Practise with new numbers
Try it in Python
The program cuts a short message into packets of 6 characters. Each packet gets a header with a destination, a packet number and an originator. The packets then arrive in a mixed-up order, and the program sorts them by packet number.
Common mistakes
Saying the payload is in the header. The header holds addresses and the packet number. The payload is the data.
Forgetting the packet number. Without it, the receiver could not put the packets back in order.
Saying all packets take the same route. In packet switching, each packet could take a different route.
Saying the packets are reordered as they arrive. They are reordered once the last packet has arrived.
Remember these
A packet has a header, a payload and a trailer.
The header holds the destination address, the packet number and the originator's address.
A router controls the route of each packet.
Packets may arrive out of order and are reordered when the last one has arrived.
Check yourself
Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.
Name the three parts of a packet, in order from start to end.
Which part of a packet holds the piece of the photo being sent?
Why does the header hold a packet number?
A file of 4200 bytes is sent in packets with a payload of at most 1000 bytes. How many packets are needed?
What device reads the destination address of a packet and decides where to send it next?
Enroll free in Packets and Methods of Data Transmission
Every lesson is open to read. Enrolling also lets you:
Mark lessons done and carry on where you stopped.
Take the tests of this lesson and its course.
Count the course towards the certificate for its chapter.