GATE CS 2025 Set 1 | Question 40

MCQ · 2 marks · −0.66

A packet with the destination IP address 145.36.109.70 arrives at a router whose routing table is shown. Which interface will the packet be forwarded to?

Subnet AddressSubnet Mask (in CIDR notation)Interface
145.36.0.0/16E1
145.36.128.0/17E2
145.36.64.0/18E3
145.36.255.0/24E4
Default--E5
  1. Option A: E3 (correct)
  2. Option B: E1
  3. Option C: E2
  4. Option D: E5

Answer

(A)

Explanation

A router uses longest prefix match: among the entries that match the destination, the one with the longest mask wins. The first two octets (145.36) agree with every listed subnet, so only the third octet matters: \(109 = 01101101_2\).

  • /16 (145.36.0.0): matches.
  • /17 (145.36.128.0): needs the third octet to begin with bit 1 (128 to 255); 109 begins with 0, so no match.
  • /18 (145.36.64.0): needs the third octet to begin with 01 (64 to 127); 109 does, so it matches.
  • /24 (145.36.255.0): needs the third octet to be 255, so no match.

Of the matches (/16, /18 and the default route), /18 is the longest, so the packet is sent on E3.

Answer: A