Question

The forwarding table of a router is shown below.

Router Forwarding Table
Subnet NumberSubnet MaskInterface ID
200.150.0.0255.255.0.01
200.150.64.0255.255.224.02
200.150.68.0255.255.255.03
200.150.68.64255.255.255.2244
Default0

A packet addressed to a destination address 200.150.68.118 arrives at the router. It will be forwarded to the interface with ID _______.

Official answer and solution
Official answer
3
From
Official GATE 2023 answer key

Solution

Perform longest prefix matching for destination IP 200.150.68.118 against routing table entries.

Destination address: 200.150.68.118200.150.68.118.
In binary, fourth octet 118=011101102118 = 01110110_2.

  1. Subnet 4: 200.150.68.64, mask 255.255.255.224 (/27)

    • Mask fourth octet: 224=111000002224 = 11100000_2
    • 118 AND 224=011101102 AND 111000002=011000002=96118 \text{ AND } 224 = 01110110_2 \text{ AND } 11100000_2 = 01100000_2 = 96
    • Target subnet octet is 6464. Since 96≠6496 \neq 64, this does NOT match.
  2. Subnet 3: 200.150.68.0, mask 255.255.255.0 (/24)

    • 200.150.68.118 AND 255.255.255.0=200.150.68.0200.150.68.118 \text{ AND } 255.255.255.0 = 200.150.68.0
    • Matches! Prefix length = 24 bits.
  3. Subnet 2: 200.150.64.0, mask 255.255.224.0 (/19)

    • Matches, with prefix length = 19 bits.
  4. Subnet 1: 200.150.0.0, mask 255.255.0.0 (/16)

    • Matches, with prefix length = 16 bits.

Under Longest Prefix Matching (LPM), the router selects the entry with the longest matching subnet mask. Subnet 3 has the longest mask (/24). Therefore, the packet is forwarded to Interface 3.

Final answer

3

Common trap

Assuming Subnet 4 matches because 118>64118 > 64, failing to perform the bitwise AND with mask 224.

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

Source

Paper
GATE 2023 Computer Science and Information Technology (CS)
Question
65 of 65
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.