Packet number in a packet header

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

Packet number in a packet header

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. What does the packet number in a packet header tell the receiving computer?
A The size of the router that sent it
B The packet's position in the whole message
2. Which part of a packet stores the packet number?
A The header
B The payload
3. A header says 'packet 3 of 10'. What does this mean?
A This packet contains 3 bytes of data out of 10
B This is the third packet out of ten in the message
4. Why do packets need a packet number?
A Packets can arrive out of order and must be put back in order
B Packets always arrive in order so the number checks the speed
5. Packets 1, 4, 2 and 3 arrive at the destination. How does the computer put them in the right order?
A It uses the packet numbers in the headers
B It uses the order in which they arrived

Match the Pairs

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

Left columnRight column
1packet_number = 3 AThe packet number and the total number of packets, so the receiver knows this is the third of ten and how many to expect
2packet 3 of 10 BThis packet is the third packet in the message, so it goes after packets 1 and 2 when the message is rebuilt
3Packets can arrive out of order, so the packet number is used to put them back in the correct order CThe message must not be read in arrival order. The packet numbers should be used to reorder the packets as 1, 2, 3, 4 first.
4The packet number is stored in the packet header, not in the payload Dheader = {"packet_number": 3} payload = "data"
5Packets arrive 4, 2, 1, 3, so the message is read in the order they arrived EThe packet number shows the packet's position in the message, not the size of its data. It means this is the third packet.
6Packet number = 3 means the packet contains 3 bytes of data Farrived = [3, 1, 2] sorted(arrived) # [1, 2, 3]

Definitions

packet number

Fill in the Blanks

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

1.
____________ ← 3 totalPackets ← 10
2.
______ packetNumber, "of", totalPackets
3.
packets ← [3, 1, 2] SORT packets BY packetNumber _________
4.
IF packetNumber _ 3 THEN OUTPUT "Packet 3 arrived" ENDIF
5.
totalPackets ← 10 FOR packetNumber ← 1 TO ____________ NEXT packetNumber

Spot the Error

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

Question 1
A HEADER
B packet_number ← 11
C total_packets ← 10
D END HEADER
Question 2
A received ← []
B FOR EACH packet arriving
C APPEND packet TO received
D SORT received BY destination
Question 3
A header ← NEW HEADER
B header.address ← 3
C header.total ← 10
Question 4
A FOR n ← 1 TO 10
B packet.number ← n
C packet.total ← n
D SEND packet
Question 5
A next ← 1
B WHILE next <= 10
C SHOW packet next
D next ← next - 1

Answer Key

Packet number in a packet header
Section A: Quick Questions
Q1
B — The packet's position in the whole message
Q2
A — The header
Q3
B — This is the third packet out of ten in the message
Q4
A — Packets can arrive out of order and must be put back in order
Q5
A — It uses the packet numbers in the headers
Section B: Match the Pairs
Q1
packet_number = 3 → This packet is the third packet in the message, so it goes after packets 1 and 2 when the message is rebuilt
Q2
packet 3 of 10 → The packet number and the total number of packets, so the receiver knows this is the third of ten and how many to expect
Q3
Packets can arrive out of order, so the packet number is used to put them back in the correct order → arrived = [3, 1, 2] sorted(arrived) # [1, 2, 3]
Q4
The packet number is stored in the packet header, not in the payload → header = {"packet_number": 3} payload = "data"
Q5
Packets arrive 4, 2, 1, 3, so the message is read in the order they arrived → The message must not be read in arrival order. The packet numbers should be used to reorder the packets as 1, 2, 3, 4 first.
Q6
Packet number = 3 means the packet contains 3 bytes of data → The packet number shows the packet's position in the message, not the size of its data. It means this is the third packet.
Section C: Definitions
Q1
packet number — A number in the packet header showing the packet's position in the whole message (e.g. packet 3 of 10), so packets that arrive out of order can be put back in the right order.
Section D: Fill in the Blanks
Q1
packetNumber ← 3 totalPackets ← 10
Q2
OUTPUT packetNumber, "of", totalPackets
Q3
packets ← [3, 1, 2] SORT packets BY packetNumber ASCENDING
Q4
IF packetNumber = 3 THEN OUTPUT "Packet 3 arrived" ENDIF
Q5
totalPackets ← 10 FOR packetNumber ← 1 TO totalPackets NEXT packetNumber
Section E: Spot the Error
Q1
B — A packet number shows the packet's position in the message, so it cannot be bigger than the total. In a 10-packet message the numbers run from 1 to 10. Packet 11 cannot exist, so the line should be packet_number ← 3.
Q2
D — Every packet has the same destination address, so sorting by it cannot restore the order. The packets must be sorted by packet_number.
Q3
B — The position of the packet is stored in the packet number field, not an address field. The line should be header.number ← 3.
Q4
C — The total is the same for every packet in the message, so it must stay 10. Only packet.number changes with n. The line should be packet.total ← 10.
Q5
D — To put the packets back in order, the counter must go up by one each time (1, 2, 3 ... 10). Subtracting would go backwards and the loop would never finish. It should be next ← next + 1.