The Gateway to Computer Science Excellence
+22 votes

A router uses the following routing table:

\begin{array}{|l|l|l|} \hline \textbf {Destination} & \textbf { Mask} & \textbf{Interface}  \\\hline \text {} &  \text{} & \text{eth$0$} \\\hline\text {} &  \text{} & \text{eth$1$} \\\hline\text {} &  \text{} & \text{eth$2$}\\\hline \text {} &  \text{} & \text{eth$3$}\\\hline\end{array}

 Packet bearing a destination address $$ arrives at the router. On which interface will it be forwarded?

  1. eth$0$
  2. eth$1$
  3. eth$2$
  4. eth$3$
in Computer Networks by Boss (16.3k points)
edited by | 4.6k views
Is the answer C
yes Kapil

5 Answers

+46 votes
Best answer

Firstly start with Longest mask

 $\text{144. 16 . 68 .117   =  144.  16.  68. 01110101}$  AND

 $\text{   =  255.255.255. 11100000}$

 $\qquad \qquad \qquad =\text{}$ (Not matching with Destination)

 Now, take $\text{255. 255. 255. 0}$

$\text{144.16. 68.117}$ AND $\text{ =}$ (matched)

So, interface chosen is eth2 OPTION (C).

by Boss (15.9k points)
edited by
entries are stored in routing table in Descending order of subnet mask  ???
+28 votes

To get network id we perform $\text{Bitwise AND}$  operation of ip address with every
subnet mask...after if the obtain value matches with the network id ..then we send
the data through that..if more than one network id matches then we check for
the longest mask.

ip address $=$ and with all mask one by one

first mask  $= \Rightarrow 11111111.11111111.00000000.00000000$

                   $\Rightarrow 10010000.00010000.01000100.01110101$

bit wise and operation

we get ,           $\Rightarrow  10010000.00010000.00000000.00000000$          

which is matching with network id $$ given opposite to mask $$

but we cannot stop here  may some more network id check for every mask





which is matching with network id  $$ given opposite to mask $$

Now next ,




Which is matching with network id  $$ given opposite
to mask $$

Now last,                         




Which is  $\text{NOT}$ matching with network id  $$ given opposite
to mask $$

Now $3$ of the networks are we check for longest mask..

i.e        $$


So, last one is the largest therefore $\text{eth2}$ will be chosen to send packet.

by Boss (10.1k points)
edited by
Nice @Tauhin
thank you master
Why we choose longest subnets mask ? I did not understand behind choose longest subnets mask.
+3 votes
Option (3). eh2
by Active (5k points)
plzz  explain..?
It shud be D due to longest mask matching
D is not matching :)
–2 votes

Answer ( C )

by Junior (767 points)
–5 votes
Answer: D

Select the longest mask as the packet is eligible to be forwarded to all interfaces.
by Boss (33.9k points)

"" AND "" gives But the mask is of subnetwork So this IP doesn't belongs to this subnetwork and moreover it is not a default. So how come you forwarded a IP packet which is belong to subnetwork according to this subnet mask to subnetwork

So according to you any packet which comes to this router for routing, the router will forward all the packet to the interface because this interface has longest mask and packets are elligible to be forwared in all the interface. isn't it? So there is no routing decision left we can optimize it. 

0 AND = AND =


224 : 1110 0000

117:  0111 0101


        0110 0000 : 96

but the mask belong to the sub network: but the IP is of the sub network according to this mask. So it won't be forwarded in this interface, rt?
yes, you are right :)

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,737 questions
57,324 answers
105,169 users