edited by
12,176 views
8 votes
8 votes
The forwarding table of a router is shown below.
$$\begin{array}{|l|l|c|}
\hline \textbf{Subnet Number} & \textbf{Subnet Mask} & \textbf{Interface ID} \\
\hline 200.150 .0 .0 & 255.255 .0 .0 & 1 \\
\hline 200.150 .64 .0 & 255.255 .224 .0 & 2 \\
\hline 200.150 .68 .0 & 255.255 .255 .0 & 3 \\
\hline 200.150 .68 .64 & 255.255 .255 .224 & 4 \\
\hline \text{Default} & & 0 \\
\hline
\end{array}$$
A packet addressed to a destination address $200.150 .68 .118$ arrives at the router. It will be forwarded to the interface with $\text{ID}$ __________.
edited by

4 Answers

11 votes
11 votes

As we know that when data packets arrived at the internal router, it will perform the following steps:

  • Find the first address/subnet id between the destination IP address and subnet mask using bitwise and operation.
  • after finding the first address 3 cases can be there:
  1. If FA is matched with one subnet address then data is forwarded to the matched subnet address.
  2. If FA is matched with more than one subnet address then data is forwarded to the  interface corresponding to the largest subnet mask (maximum number of 1’s)
  3. If FA is not matched with anyone then the data packet is forwarded to the default interface.

let’s check one by one:

 (A): $200.150.68.118 \wedge  255.255.0.0$

$\begin{array}{rrrr} 200.150.68.118= 200 & 150& 01000100&01110110  \\\ \wedge 255.255.0.0 =255&255&00000000&00000000 \\  \hline 200.150.0.0=200&150&00000000&00000000 \end{array}$

$\therefore $ subnet id=$200.150.0.0$,matched

 (B): $200.150.68.118 \wedge 255.255.224.0$

$\begin{array}{rrrr} 200.150.68.118= 200 & 150& 01000100&01110110  \\\ \wedge 255.255.224.0=255&255&11100000&00000000 \\  \hline 200.150.64.0=200&150&01000000&00000000 \end{array}$

$\therefore $ subnet id=$200.150.64.0$,matched.

 (C): $200.150.68.118 \wedge 255.255.255.0$

$\begin{array}{rrrr} 200.150.68.118= 200 & 150& 01000100&01110110  \\\ \wedge 255.255.255.0=255&255&11111111&00000000 \\  \hline 200.150.68.0=200&150&01000100&00000000 \end{array}$

$\therefore $ subnet id=$200.150.68.0$,matched.

 (D): $200.150.68.118 \wedge 255.255.255.224$

$\begin{array}{rrrr} 200.150.68.118= 200 & 150& 01000100&01110110  \\\ \wedge 255.255.255.224=255&255&11111111&11100000 \\  \hline 200.150.68.96=200&150&01000100&01100000 \end{array}$

$\therefore $ subnet id=$200.150.68.96$ not matched.

Since more than one subnet address is matched the data packet is forwarded to the interface corresponding to the largest subnet mask (a subnet mask having the maximum number of 1’s). 

Here $255.255.255.0$ has the maximum number of 1’s in binary representation among A, B, and C so the data packet is forwarded to the interface id $3$.

the correct answer is $3$

Ref: A similar type of concept asked in the gate exam :

  1. GATE CSE 2003
  2. GATE CSE 2004
  3. GATE IT 2006
  4. GATE CSE 2014
  5. GATE CSE 2015

 

edited by
6 votes
6 votes

Answer: 3


We will do $\text{IP} \land \text{Subnet mask}$ and see if we are getting same subnet ID or not and we will go for longest prefix match.

So let’s first check subnet $4$ 
$(200.150.68.118) \land (255.255.255.224) = (200.150.68.96)$,  subnet ID do not match

 

Now let’s check for subnet $3$

$(200.150.68.118) \land (255.255.255.0) = (200.150.68.0)$,  subnet ID matches so our packet will be forwarded to subnet $3$

1 votes
1 votes
IP Address: $200.150.68.118$

Net ID  = IP Address (Bitwise AND) Subnet Mask

Interface 4: subnet mask $255.255.255.224$ means Net ID: $200.150.68.96$ So, Doesn’t match

Interface 3: subnet mask $255.255.255.0$ means Net ID: $200.150.68.0$ So, Does match

Interface 2: subnet mask $255.255.224.0$ means Net ID: $200.150.64.0$ So, Does match

Interface 1: subnet mask $255.255.0.0$ means Net ID: $200.150.0.0$ So, Does match

Interface 3,2,1 matches but we have to select Interface with Longest subnet mask (More 1’s). So, Interface 3 is Answer
0 votes
0 votes

Greater the subnet mask, greater the prefix size of the network id. So start comparing from the maximum subnet mask..

Subnet number : 200.150.68.64 : 

255.255.255.224  &   200.150.68.118 = 200.150.68.96 (Does not match)

Subnet number : 200.150.68.0 : 

255.255.255.0  &   200.150.68.118 = 200.150.68.0 

Here is match occurred. It willbe forwarded to interface ID 3

You don’t even have to check the other subnets because their prefix size is smaller than 200.150.68.0

Ans : (3)

Answer:

Related questions