Question

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
Choose one option
Official answer and solution
Official answer
A
From
Official GATE 2025 answer key

Solution

Convert the third octet of 145.36.109.70 (109=011011012109 = 01101101_2) to binary and apply longest-prefix matching.

The destination IP address 145.36.109.70 has first two octets 145.36 and third octet 109=011011012109 = 01101101_2. Checking each routing table entry:

  • 145.36.0.0/16 (E1): First 16 bits are 145.36   ⟹  \implies Matches (prefix length 16).
  • 145.36.128.0/17 (E2): Third octet of subnet is 128=100000002128 = \mathbf{1}0000000_2; 17th bit is 1, whereas for 109=011011012109 = \mathbf{0}1101101_2 the 17th bit is 0   ⟹  \implies Does not match.
  • 145.36.64.0/18 (E3): Third octet of subnet is 64=01000000264 = \mathbf{01}000000_2; bits 17-18 are 01, which matches bits 17-18 of 109=011011012109 = \mathbf{01}101101_2   ⟹  \implies Matches (prefix length 18).
  • 145.36.255.0/24 (E4): Third octet 255≠109255 \ne 109   ⟹  \implies Does not match.
  • Default (E5): Matches with prefix length 0.

By the longest-prefix match rule, the /18 entry wins, forwarding the packet to interface E3.

Final answer

Option (A)

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

Source

Paper
GATE 2025 Computer Science and Information Technology - Session 1 (CS1)
Question
40 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.