Hops and time to live (TTL)

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

Hops and time to live (TTL)

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. A packet travels from your laptop through 3 routers to reach a server. How many hops did it make?
A 3 hops, one for each router it passed through
B 1 hop, because it is one journey
2. What happens to the TTL value each time a packet reaches a router?
A It goes up by 1
B It drops by 1
3. A packet arrives at a router with a TTL of 1. The router lowers it to 0. What happens next?
A The packet is discarded
B The packet is sent on with a TTL of 0
4. Why do packets carry a TTL value?
A So the packet can be encrypted
B So a packet stuck in a loop is eventually discarded
5. A packet starts with a TTL of 64 and passes through 5 routers. What is its TTL now?
A 59
B 69

Match the Pairs

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

Left columnRight column
1TTL = 64 ATTL = 1 -> 0, discard packet
2TTL: 5 -> 4 BA packet with TTL 0 must be discarded, not forwarded. Passing it on would let packets live forever.
3A packet with TTL 1 is discarded when it reaches the next router, because the TTL hits 0 CThe packet has just passed through one router, so its TTL dropped by 1
4A packet that goes through 3 routers has made 3 hops, so a starting TTL of 10 becomes 7 Dhops = 3, TTL = 10 - 3 = 7
5Router A -> Router B -> Router A -> Router B ... TTL stays 30 EThe TTL must go down at every hop. If it stayed at 30, a packet stuck in a loop would circle forever.
6TTL = 0, so forward the packet to the next router FThe packet can pass through at most 64 routers (hops) before it is discarded

Definitions

TTL

Fill in the Blanks

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

1.
ttl = ttl _ 1
2.
IF ttl = _ THEN discard packet
3.
hops = hops _ 1
4.
_____ ttl > 0 DO forward packet to next router ttl = ttl - 1
5.
ttl = 3 ttl = ___ - 1 PRINT ttl

Spot the Error

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

Question 1
A ttl = 64
B hops = 0
C while ttl > 0:
D ttl = ttl + 1
E hops = hops + 1
Question 2
A ttl = 5
B while ttl < 0:
C ttl = ttl - 1
D print('Packet discarded')
Question 3
A path = ['R1', 'R2', 'R3']
B hops = path
C ttl = 64 - hops
D print(ttl)
Question 4
A ttl = 5
B ttl = ttl - 1
C if ttl = 0:
D print('Discard packet')
Question 5
A hops = 3
B ttl = 64
C ttl = ttl * hops
D print(ttl)

Answer Key

Hops and time to live (TTL)
Section A: Quick Questions
Q1
A — 3 hops, one for each router it passed through
Q2
B — It drops by 1
Q3
A — The packet is discarded
Q4
B — So a packet stuck in a loop is eventually discarded
Q5
A — 59
Section B: Match the Pairs
Q1
TTL = 64 → The packet can pass through at most 64 routers (hops) before it is discarded
Q2
TTL: 5 -> 4 → The packet has just passed through one router, so its TTL dropped by 1
Q3
A packet with TTL 1 is discarded when it reaches the next router, because the TTL hits 0 → TTL = 1 -> 0, discard packet
Q4
A packet that goes through 3 routers has made 3 hops, so a starting TTL of 10 becomes 7 → hops = 3, TTL = 10 - 3 = 7
Q5
Router A -> Router B -> Router A -> Router B ... TTL stays 30 → The TTL must go down at every hop. If it stayed at 30, a packet stuck in a loop would circle forever.
Q6
TTL = 0, so forward the packet to the next router → A packet with TTL 0 must be discarded, not forwarded. Passing it on would let packets live forever.
Section C: Definitions
Q1
TTL — Time to live: a number in a packet that drops by 1 at each router hop. When it reaches 0 the packet is discarded, so a packet stuck in a loop cannot circle forever.
Section D: Fill in the Blanks
Q1
ttl = ttl - 1
Q2
IF ttl = 0 THEN discard packet
Q3
hops = hops + 1
Q4
WHILE ttl > 0 DO forward packet to next router ttl = ttl - 1
Q5
ttl = 3 ttl = ttl - 1 PRINT ttl
Section E: Spot the Error
Q1
D — TTL must go DOWN by 1 at every hop. Adding 1 means it would never reach 0. It should be ttl = ttl - 1.
Q2
B — The packet should keep hopping while TTL is greater than 0. ttl < 0 is false at the start, so the loop never runs. It should be while ttl > 0:.
Q3
B — The number of hops is the number of routers on the path, so you need len(path). Setting hops = path stores the whole list, not a count.
Q4
C — A single = assigns a value. To check whether TTL has reached 0 you compare with ==. It should be if ttl == 0:.
Q5
C — TTL drops by 1 at each hop, so after 3 hops you subtract 3. Multiplying would make TTL bigger. It should be ttl = ttl - hops.