Packets arriving out of order

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Packets arriving out of order

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Packets 1 to 6 are sent in order. Which statement is true about how they arrive?
A They always arrive in the order 1 to 6
B They may arrive in a different order
2. Why can packet 5 arrive before packet 4?
A Packet 5 took a faster route
B Packet 5 was sent before packet 4
3. Is the order of arrival of packets guaranteed?
A No, order is not guaranteed
B Yes, order is always guaranteed
4. What is the main reason packets arrive out of order?
A They take different routes to the destination
B They are all sent at the same time on one wire
5. Packets arrive in the order 1, 2, 3, 5, 4. What has happened?
A Packet 4 was lost and never sent
B Packet 5 arrived before packet 4

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1Sent: 1, 2, 3, 4, 5 | Arrived: 1, 2, 3, 5, 4 AThe packets arrived out of order because packet 5 reached the destination before packet 4
2Packet 4: Route A (busy) | Packet 5: Route B (quiet) BWrong: packet 4 has not necessarily been lost. It may have taken a slower route and still be on its way.
3The order in which packets arrive is not guaranteed, because each packet may take a different route CPacket 5 can overtake packet 4 because it took a faster route
4The destination uses the packet number in each header to put out-of-order packets back into the correct order Dsort(packets, by packet_number)
5Packets always arrive in the order they were sent Earrival_order != sending_order
6Packet 5 arrived before packet 4, so packet 4 must be lost FWrong: packets take different routes, so they may arrive in a different order. The order is not guaranteed.

Definitions

packets arrive out of order

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
Sent 1 2 3 4 5, arrived 1 2 3 _ 4
2.
__ arrivalOrder != sentOrder THEN
3.
SORT packets BY ____________
4.
orderGuaranteed = _____
5.
IF packet5Arrived AND ___ packet4Arrived

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A # Packet 5 arrives before 4
B arrived = [1, 2, 3, 4, 5]
C print(arrived)
Question 2
A packets_sent = [1, 2, 3, 4]
B order_guaranteed = True
C if not order_guaranteed:
D print('Reorder needed')
Question 3
A route_4 = 'short'
B route_5 = 'short'
C # So packet 5 arrives first
Question 4
A arrived = [5, 4, 6]
B sent = [4, 5, 6]
C if arrived == sent:
D print('Out of order')
Question 5
A arrived = [3, 1, 2
B arrived.sort()
C print(arrived)

Answer Key

Packets arriving out of order
Section A: Quick Questions
Q1
B — They may arrive in a different order
Q2
A — Packet 5 took a faster route
Q3
A — No, order is not guaranteed
Q4
A — They take different routes to the destination
Q5
B — Packet 5 arrived before packet 4
Section B: Match the Pairs
Q1
Sent: 1, 2, 3, 4, 5 | Arrived: 1, 2, 3, 5, 4 → The packets arrived out of order because packet 5 reached the destination before packet 4
Q2
Packet 4: Route A (busy) | Packet 5: Route B (quiet) → Packet 5 can overtake packet 4 because it took a faster route
Q3
The order in which packets arrive is not guaranteed, because each packet may take a different route → arrival_order != sending_order
Q4
The destination uses the packet number in each header to put out-of-order packets back into the correct order → sort(packets, by packet_number)
Q5
Packets always arrive in the order they were sent → Wrong: packets take different routes, so they may arrive in a different order. The order is not guaranteed.
Q6
Packet 5 arrived before packet 4, so packet 4 must be lost → Wrong: packet 4 has not necessarily been lost. It may have taken a slower route and still be on its way.
Section C: Definitions
Q1
packets arrive out of order — Packets take different routes, so they may reach the destination in a different order from the one sent, e.g. packet 5 before packet 4. Order is not guaranteed.
Section D: Fill in the Blanks
Q1
Sent 1 2 3 4 5, arrived 1 2 3 5 4
Q2
IF arrivalOrder != sentOrder THEN
Q3
SORT packets BY packetNumber
Q4
orderGuaranteed = FALSE
Q5
IF packet5Arrived AND NOT packet4Arrived
Section E: Spot the Error
Q1
B — The comment says packet 5 arrives before packet 4, but this list has them in order. It should be [1, 2, 3, 5, 4].
Q2
B — Packets take different routes, so the order of arrival is not guaranteed. The variable should be False, which means the reorder step runs.
Q3
A — For packet 5 to arrive before packet 4, packet 4 must take the longer route. Packet 4's route should be 'long', not 'short'.
Q4
C — The packets are out of order when the arrival order is different from the sent order. The test should use != not ==.
Q5
A — The list is missing its closing square bracket. It should be arrived = [3, 1, 2], showing packets that arrived out of order.