edited by
29,036 views
33 33 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}$ __________.

9 Answers

42 42 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
10 10 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$

6 6 votes

We have 4 interface IDs

If we observe SM & Subnet number

  • INTERFACE 1 :-  200.150.0.0/16
  • INTERFACE 2:- 200.150.64.0/19
  • INTERFACE 3 :- 200.150.68.0/24
  • INTERFACE 4 :- 200.150.68.64/27
  • INTERFACE 0 :-  Default

Now we have longest SM is 27 i.e INTERFACE 4 and its range is 200.150.68.64 to 200.150.68.95 which is not the range for destination address 200.150.68.118

we have 2nd longest SM is 24 i.e INTERFACE 3 and its range is 200.150.68.0 to 200.150.68.255 which is in the range of destn address. So the packet will forwarded to interface 3

LONGEST PREFIX MATCHING:-

 When looking for forwarding table entry for given destination address, use longest address prefix that matches destination address. If subnet masks are producing the same  Network ID, hence The one with greater number of ones will be selected, and the packet will be forwarded there

edited by
2 2 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 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)

0 0 votes
I think the first 2 subnet masks are invalid subnet masks as the subnet id is of class C and mask has less than 24 bits.
Answer:
Position:
Show:

Related questions

36 36 votes
10 10 answers
28.4k
28.4k views
admin asked Feb 15, 2023
28,414 views
Suppose you are asked to design a new reliable byte-stream transport protocol like $\text{TCP}.$ This protocol, named $\textsf{myTCP}$, runs over a $100 \mathrm{~Mbps}$ n...
77 77 votes
5 5 answers
32.6k
32.6k views
admin asked Feb 15, 2023
32,561 views
Suppose in a web browser, you click on the $\textsf{www. gate-2023.in}\; \text{URL}$. The browser cache is empty. The $\text{IP address}$ for this $\text{URL}$ is not cac...
43 43 votes
11 11 answers
29.8k
29.8k views
admin asked Feb 15, 2023
29,779 views
Suppose two hosts are connected by a point-to-point link and they are configured to use $\textsf{Stop-and-Wait}$ protocol for reliable data transfer. Identify in which on...