Spotting a missing packet from the packet numbers

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

Spotting a missing packet from the packet numbers

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Packets numbered 1, 2, 4, 5 arrive. What does the gap tell the receiver?
A Packet 3 is missing
B Packet 3 arrived twice
2. A message was sent as 5 packets. Only packets 1, 2, 4 and 5 arrive. Is the message complete?
A No, it is incomplete
B Yes, 4 packets is enough
3. How does the receiver know a packet is missing?
A The packets arrive very quickly
B There is a gap in the packet numbers
4. Which set of received packet numbers shows a missing packet?
A 1, 2, 3, 4
B 1, 2, 4, 5
5. A header says 'packet 2 of 5'. How does this help the receiver spot a missing packet?
A It gives the total count to check against
B It tells the packet which route to take

Match the Pairs

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

Left columnRight column
1Received: 1, 2, 4, 5 AOnly four of the five packets arrived. The numbers skip 3, so packet 3 is missing and the message is incomplete.
2Packet 2 of 5 BThe total is 5, so packet 5 is missing. The receiver must check the numbers against the total, not just look for gaps in the middle.
3A gap in the packet numbers shows a packet is missing and the message is incomplete CThe total packet count is 5, so the receiver expects numbers 1 to 5
4After spotting a missing packet, the receiver asks the sender for a resend Dif 3 not in received: missing = 3
5Received 1, 2, 4, 5 of 5: all packets arrived Esend('Please resend packet 3')
6Received 1, 2, 3, 4 of 5: complete FPacket 3 is missing, because there is a gap in the numbers

Definitions

missing packet

Fill in the Blanks

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

1.
received ← [1, 2, 4, 5] DISPLAY "Packet " + _ + " is missing"
2.
IF LENGTH(received) _ total THEN DISPLAY "Please resend packet 3" END IF
3.
IF 3 ______ received THEN DISPLAY "Packet 3 is missing" END IF
4.
FOR n = 1 TO _____ IF n NOT IN received THEN DISPLAY n NEXT n
5.
IF LENGTH(received) = total THEN DISPLAY "Message complete" ____ DISPLAY "Resend missing packet"

Spot the Error

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

Question 1
A total ← 5
B received ← [1, 2, 4, 5, 6]
C IF LENGTH(received) < total THEN
D OUTPUT "Packet missing"
Question 2
A total ← 4
B received ← [1, 2, 4, 5]
C IF LENGTH(received) < total THEN
D OUTPUT "Packet 3 is missing"
Question 3
A prev ← 2
B next ← 4
C IF next - prev < 1 THEN
D OUTPUT "Packet missing"
Question 4
A total ← 5
B count ← 4
C missing ← count - total
D OUTPUT missing, " packet missing"
Question 5
A received ← [1, 2, 4, 5]
B total ← 5
C IF LENGTH(received) = total THEN
D OUTPUT "Packet missing"
E ELSE
F OUTPUT "Packet missing"

Answer Key

Spotting a missing packet from the packet numbers
Section A: Quick Questions
Q1
A — Packet 3 is missing
Q2
A — No, it is incomplete
Q3
B — There is a gap in the packet numbers
Q4
B — 1, 2, 4, 5
Q5
A — It gives the total count to check against
Section B: Match the Pairs
Q1
Received: 1, 2, 4, 5 → Packet 3 is missing, because there is a gap in the numbers
Q2
Packet 2 of 5 → The total packet count is 5, so the receiver expects numbers 1 to 5
Q3
A gap in the packet numbers shows a packet is missing and the message is incomplete → if 3 not in received: missing = 3
Q4
After spotting a missing packet, the receiver asks the sender for a resend → send('Please resend packet 3')
Q5
Received 1, 2, 4, 5 of 5: all packets arrived → Only four of the five packets arrived. The numbers skip 3, so packet 3 is missing and the message is incomplete.
Q6
Received 1, 2, 3, 4 of 5: complete → The total is 5, so packet 5 is missing. The receiver must check the numbers against the total, not just look for gaps in the middle.
Section C: Definitions
Q1
missing packet — A gap in the packet numbers received, like 1, 2, 4, 5, shows a packet is missing. The receiver knows the message is incomplete and can ask for a resend.
Section D: Fill in the Blanks
Q1
received ← [1, 2, 4, 5] DISPLAY "Packet " + 3 + " is missing"
Q2
IF LENGTH(received) < total THEN DISPLAY "Please resend packet 3" END IF
Q3
IF 3 NOT IN received THEN DISPLAY "Packet 3 is missing" END IF
Q4
FOR n = 1 TO total IF n NOT IN received THEN DISPLAY n NEXT n
Q5
IF LENGTH(received) = total THEN DISPLAY "Message complete" ELSE DISPLAY "Resend missing packet"
Section E: Spot the Error
Q1
B — The message only has packets 1 to 5, so packet 6 does not exist. The list should be [1, 2, 4, 5]. With 5 numbers the count would equal the total and packet 3 would not be noticed.
Q2
A — The message has 5 packets in total, so total should be 5. If total is 4, it matches the 4 packets received and the missing packet 3 is never spotted.
Q3
C — Numbers 2 then 4 have a gap of 2. A gap means the difference is greater than 1, so the test should be next - prev > 1. Using < 1 would never be true.
Q4
C — The number of missing packets is the total minus the count received, so it should be total - count. Swapping them gives -1, which makes no sense.
Q5
D — This line is in the branch where the count equals the total, so every packet has arrived. It should say "Message complete". The message "Packet missing" belongs in the ELSE branch.