Skip to content
Official PYQ · 2025

GATE CS 2025 Set 1 Q30 — Fragmentation and IP Addressing, IPv4, CIDR

Explain with AI

A packet with the destination IP\text{IP} address 145.36.109.70145.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)Interface145.36.0.0/16E1145.36.128.0/17E2145.36.64.0/18E3145.36.255.0/24E4Default−E5\begin{array}{|l|l|l|} \hline \textbf{Subnet Address} & \textbf{Subnet Mask ( in CIDR notation)} & \textbf{Interface} \\ \hline 145.36.0.0 & /16 & E1 \\ \hline 145.36.128.0 & /17 & E2 \\ \hline 145.36.64.0 & /18 & E3 \\ \hline 145.36.255.0 & /24 & E4 \\ \hline \text{Default} & - & E5 \\ \hline \end{array}

Choose one option
View worked solution

Answer: A

To determine which interface the packet will be forwarded to, we apply the Longest Prefix Match (LPM) algorithm. We compare the destination IP address 145.36.109.70145.36.109.70 with each subnet entry in the routing table:

  1. Subnet 145.36.0.0/16145.36.0.0/16 (Interface E1E1):
    The first 16 bits of the destination IP (145.36145.36) match the subnet prefix.
    Match: Yes (Prefix length = 16).
  2. Subnet 145.36.128.0/17145.36.128.0/17 (Interface E2E2):
    The third octet of the destination is 109=011011012109 = 01101101_2. The third octet of the subnet is 128=100000002128 = 10000000_2.
    For a /17/17 mask, the first bit of the third octet must match. Here, 0≠10 \neq 1.
    Match: No.
  3. Subnet 145.36.64.0/18145.36.64.0/18 (Interface E3E3):
    The third octet of the destination is 109=011011012109 = \mathbf{01}101101_2. The third octet of the subnet is 64=01000000264 = \mathbf{01}000000_2.
    For a /18/18 mask, the first 2 bits of the third octet must match. Since both start with 01\mathbf{01}, they match.
    Match: Yes (Prefix length = 18).
  4. Subnet 145.36.255.0/24145.36.255.0/24 (Interface E4E4):
    The third octet of the destination (109109) does not match the subnet (255255).
    Match: No.

Comparing the matching prefixes, the longest prefix match is /18/18 corresponding to interface E3E3.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Fragmentation and IP Addressing, IPv4, CIDR questions