Lesson 62: Packets
此页面需较新浏览器(支持 SharedArrayBuffer)。请升级 Chrome、Edge、Firefox 或 Safari 至最新版本。
English
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 |
English
HELLO WORLD in packets of 4
| Header | Payload |
|---|---|
| 1/3 | HELL |
| 2/3 | O WO |
| 3/3 | RLD |
English
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.
难度 3/5 · 今日首次完成可获 200 金币及少量额外奖励
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.
点击“运行”查看此处输出。
难度 4/5 · 今日首次完成可获 280 金币及少量额外奖励
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.
点击“运行”查看此处输出。