GATE / CS ARCHIVE

GATE CSE 2023 / QUESTION 65

GATE CSE 2023 Q65

Computer Networks · Routing Algorithms · Full GATE CSE 2023 paper

GATE 2023, Q65 2 marks · NAT
Report issue

Routing Algorithms

Question 65, GATE 2023: Routes are 200.150.0.0/16→1, 200.150.64.0/19→2, 200.150.68.0/24→3, 200.150.68.64/27→4, and default→0. Which interface receives destination 200.150.68.118 under longest-prefix matching?
Tap to enlarge
Answer & solution

Official answer: 3

Step through it (3 steps)

The destination matches 200.150.0.0/16 and 200.150.64.0/19, and it also matches 200.150.68.0/24. The /27 entry 200.150.68.64 covers last-octet values 64 through 95, so it does not match 118. The longest matching prefix is consequently the /24 entry, whose interface ID is 3.

Teaching detail. Check network matches rather than selecting the most specific row unconditionally. The /19 mask fixes the top three bits of the third octet and covers third-octet values 64 through 95, including 68. The /24 fixes the entire third octet to 68. The /27 additionally divides the last octet into groups of 32; its network 64 covers 64..95, whereas 118 lies in 96..127. The /27 is more specific but fails to match, leaving /24 as the longest matching row. The default is used only when no more specific route matches.

Original paper, page 69 · Answer key