Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1reordering packets | Amessage = payload1 + payload2 + payload3 | |
| 2packet number (in header) | Bif all_packets_arrived: reorder(packets) | |
| 3The receiving device waits until the last packet has arrived before it puts the packets in order | CReordering happens once the last packet has arrived, not while packets are still arriving, because the device cannot sort the full set until it has all of them. | |
| 4Once the packets are in order, the payloads are joined together to rebuild the original message | DThe value the receiving device reads to decide where each packet belongs in the sequence | |
| 5Packets arrive as 3, 1, 2 so the message is rebuilt as 3, 1, 2 | EAfter the last packet arrives, the receiving device puts the packets back into the correct order and rebuilds the message | |
| 6Reorder each packet the moment it arrives, before the last packet | FThe packets were joined in the order they arrived, but they should be reordered by packet number first (1, 2, 3). |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
reordering packets — After the last packet arrives, the receiving device uses the packet numbers in the headers to put the packets in the right order and joins the payloads to rebuild the message.IF lastPacketArrived = TRUE THEN
SORT packets BY packetNumber
ENDIFIF lastPacketArrived = TRUE THEN
SORT packets BY packetNumber
ENDIFWHILE lastPacketArrived = FALSE
RECEIVE packet
ENDWHILEFOR EACH packet IN sortedPackets
message ← message + packet.payload
NEXT packetIF packet1.number > packet2.number THEN
SWAP packet1, packet2
ENDIF