Lesson 62: Packets
Small pieces, any route
- Big data is not sent in one piece. It is split into small packets.
- Each packet has a header: who sent it, where it goes, and its packet number.
- Packets can take different routes, so they may arrive out of order. The receiver puts them back in order by number.
Words for this lesson
| Word | Meaning |
|---|---|
| packet | a small piece of the data, with a header |
| header | information about the packet, such as its number |
| payload | the data the packet carries |
| router | a device that chooses the route for each packet |
HELLO WORLD in packets of 4
| Header | Payload |
|---|---|
| 1/3 | HELL |
| 2/3 | O WO |
| 3/3 | RLD |
In the exam
- 0478/11/M/J/23 Q2(c): (i) two things in a packet header. Mark scheme: the destination address, the packet number, the sender's address. (ii) How packet switching works. Mark scheme: the data is split into packets; each packet may take a different route, chosen by a router; packets may arrive out of order; when the last packet arrives they are put back in order; a missing packet is requested again.
Kesulitan 3/5 · 200 koin + bonus kecil pada penyelesaian pertama hari ini
On the internet, data is split into packets. Each packet has a header with its number and the total number of packets. Type a message. The program has worked out total, the number of 4-character packets. Print each packet on its own line as number/total:data, for example 1/3:HELL.
Klik Jalankan untuk melihat output di sini.
Kesulitan 4/5 · 280 koin + bonus kecil pada penyelesaian pertama hari ini
Now be the receiver. Packets can take different routes, so they arrive out of order. The program reads the number n, the total and the data from each packet. Store the data in parts[n] and count the packets. When the last one has arrived, print Message: and the parts in order, from 1 to total.
Klik Jalankan untuk melihat output di sini.