Question

Consider the following routing table at an IP router:

Network No.Net MaskNext Hop
128.96.170.0255.255.254.0Interface 0
128.96.168.0255.255.254.0Interface 1
128.96.166.0255.255.254.0R2
128.96.164.0255.255.252.0R3
0.0.0.0DefaultR4

For each IP address in Group I identify the correct choice of the next hop from Group II using the entries from the routing table above.

Group I
i) 128.96.171.92
ii) 128.96.167.151
iii) 128.96.163.151
iv) 128.96.165.121

Group II
a) Interface 0
b) Interface 1
c) R2
d) R3
e) R4

Choose one option
Official answer and solution
Official answer
A
From
Official GATE 2015 answer key

Solution

Perform longest prefix matching by bitwise-ANDing destination IP addresses with routing table masks.

We evaluate each IP address against the routing table prefixes:

  1. IP (i) 128.96.171.92:
  • Mask 255.255.254.0 (/23): The third octet has mask 254=111111102254 = 11111110_2.
    171=101010112  ⟹  171 AND 254=101010102=170.171 = 10101011_2 \implies 171 \text{ AND } 254 = 10101010_2 = 170.
    Result: 128.96.170.0. Matches row 1   ⟹  \implies Interface 0 (a).
  1. IP (ii) 128.96.167.151:
  • Mask 255.255.254.0:
    167=101001112  ⟹  167 AND 254=101001102=166.167 = 10100111_2 \implies 167 \text{ AND } 254 = 10100110_2 = 166.
    Result: 128.96.166.0. Matches row 3   ⟹  \implies R2 (c).
  1. IP (iii) 128.96.163.151:
  • Mask 255.255.254.0: 163 AND 254=162163 \text{ AND } 254 = 162 (no match).
  • Mask 255.255.252.0 (/22): 252=111111002252 = 11111100_2.
    163=101000112  ⟹  163 AND 252=101000002=160≠164.163 = 10100011_2 \implies 163 \text{ AND } 252 = 10100000_2 = 160 \neq 164.
  • No specific network match   ⟹  \implies Default route R4 (e).
  1. IP (iv) 128.96.165.121:
  • Mask 255.255.254.0: 165 AND 254=164165 \text{ AND } 254 = 164 (no match with 170, 168, or 166).
  • Mask 255.255.252.0:
    165=101001012  ⟹  165 AND 252=101001002=164.165 = 10100101_2 \implies 165 \text{ AND } 252 = 10100100_2 = 164.
    Result: 128.96.164.0. Matches row 4   ⟹  \implies R3 (d).

Matching: i-a, ii-c, iii-e, iv-d (option A).

Final answer

A

Common trap

Miscalculating the bitwise AND with mask 254 or 252, confusing 163 AND 252 (= 160) with 164.

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2015 Computer Science and Information Technology (CS) Session 2
Question
51 of 65, printed as CS Q.41
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.