• edited by
30,341 views
79 79 votes

The routing table of a router  is shown below:
$$\begin{array}{|l|l|l|} \hline \textbf {Destination} & \textbf {Subnet Mask} & \textbf{Interface}  \\\hline \text {128.75.43.0} &  \text{255.255.255.0} & \text{Eth$0$} \\\hline\text {128.75.43.0} &  \text{255.255.255.128} & \text{Eth$1$} \\\hline\text {192.12.17.5} &  \text{255.255.255.255} & \text{Eth$3$}\\\hline \text {Default} &  \text{} & \text{Eth$2$}\\\hline\end{array}$$
On which interface will the router forward packets addressed to destinations $128.75.43.16$ and $192.12.17.10$ respectively?

  1. Eth$1$ and Eth$2$
  2. Eth$0$ and Eth$2$
  3. Eth$0$ and Eth$3$
  4. Eth$1$ and Eth$3$

9 Answers

Best answer
95 95 votes

The answer must be A.

(Using $\wedge$ to denote bitwise AND)

For 1$^{st}$packet,

$(128.75.43.16) \wedge (255.255.255.0) = (128.75.43.0)$ since $\{16 \wedge 0 = 0\}$, as well as 

$(128.75.43.16) \wedge (255.255.255.128) = (128.75.43.0)$ since $\{16 \wedge 128 = 0\}$.

Now, since both these 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. Hence packet $1$ will be forwarded to Eth$1$.

For $2^{nd}$ packet,

$(192.12.17.10)$ when ANDed with each of the subnet masks does not match with any of the network ID, since:

$(192.12.17.10) \wedge (255.255.255.0) = (192.12.17.0)$ {Does not match with any of the network addresses}

$(192.12.17.10) \wedge (255.255.255.128) = (192.12.17.0)$ {Does not match with any of the network addresses}

$(192.12.17.10) \wedge (255.255.255.255) = (192.12.17.10)$ {Does not match with any of the network addresses}

Hence, default interface must be selected for packet $2$, i.e., Interface Eth$2.$

• edited by
15 15 votes

How router makes decisions ?

Router check the destination address by decapsulating packet and perform bitwise AND with subnet mask of all interfaces and if the resulting n/w address matches with corresponding interface n/w address then router send packet to this interface , in case of tie , router uses Longest prefix match

interface eth0 :- 128.75.43.0/24 (128.75.43.0 to 128.75.43.255)

interface eth1 :- 128.75.43.0/25 (128.75.43.0 to 128.75.43.127)

for 128.75.43.16 we can see there is a tie as it falls within the n/w addresses for eth0 and eth1...which route would the router choose? It depends on the prefix length, or the number of bits set in the subnet mask. Longer prefixes are always preferred over shorter ones when forwarding a packet.

https://en.wikipedia.org/wiki/Longest_prefix_match

https://stackoverflow.com/questions/9335504/network-longest-prefix-matching

1 1 vote
Start with the maximum mask:

128.75.43.16 while doing masking(bit wise AND operation) with

255.255.255.128 will give 128.75.43.0 .

we always takes the maximum mask so ans would be eth1
0 0 votes
It'll be through eth1. If bit wise OR of packet address and subnet mask matches with more than one destination address then we go with the one with longer run of 1s.
0 0 votes
Gabbar is right. But why do we take maximum mask?

Because the mask 255:255:255:128 is included in mask 255:255:255:0

i.e. 2nd destination is part of the 1st destination. So, if we forward directly to 2nd destiantion, the packet may reach the main destination faster.
0 0 votes

1) Destination : 128.75.43.0

Subnet Mask : 255.255.255.0  i.e  111...1 . 111...1 . 111...1 . 000..0

So range will be from 125.75.43.0 to 125.75.43.255 as first three bytes (24 bits) are fixed and last byte (8 bits) can vary from 000..0 to 111..1 i.e 0 to 255 in decimal.

2) Destination : 128.75.43.0

Subnet Mask : 255.255.255.128  i.e  111...1 . 111...1 . 111...1 . 10000000

So range will be from 125.75.43.0 to 125.75.43.127 as first two bytes and first bit (25 bits) are fixed and last byte (7 bits) can vary from 0000000 to 1111111 i.e 0 to 127 in decimal.

3) Destination : 192.12.17.5

Subnet Mask : 255.255.255.255  i.e  111...1 . 111...1 . 111...1 . 111..1

So range will be 192.12.17.5 as all four bytes (32 bits) are fixed.

 

Now, for the given destinations : 

(i)  128.75.43.16 : It falls in the range of 1 and 2 (explained above), but the no. of fixed bits are larger in 2 (25 bits) than in 1 (24 bits), so it will be forwarded through Eth1. Here, we use the concept of longest prefix matching.

NOTE : When a given destination address falls in the range of more than one network, we choose the longest prefix address which matches the destination address i.e in which the no. of fixed bits (i.e 1) is greater than others. This concept is longest prefix matching.

(ii) 192.12.17.10 : Since it does not falls in the range of anyone, it wil be forwarded through default i.e Eth2.

 

Hence , Answer is option (A).

• edited by
Answer:
Position:
Show:

Related questions

94 94 votes
13 answers 13 answers
35.4k
35.4k views
go_editor asked Apr 24, 2016
35,390 views
Consider three IP networks $A, B$ and $C$. Host $H_A$ in network $A$ sends messages each containing $180$ $bytes$ of application data to a host $H_C$ in network $C$. The ...
102 102 votes
9 answers 9 answers
38.9k
38.9k views
Kathleen asked Sep 18, 2014
38,886 views
Consider three IP networks $A, B$ and $C$. Host $H_A$ in network $A$ sends messages each containing $180$ bytes of application data to a host $H_C$ in network $C$. The $\...
62 62 votes
6 answers 6 answers
29.8k
29.8k views
Kathleen asked Sep 18, 2014
29,754 views
$A$ and $B$ are the only two stations on an Ethernet. Each has a steady queue of frames to send. Both $A$ and $B$ attempt to transmit a frame, collide, and $A$ wins the f...
30 30 votes
5 answers 5 answers
23.1k
23.1k views
Kathleen asked Sep 18, 2014
23,144 views
How many $8-bi$t characters can be transmitted per second over a $9600$ baud serial communication link using asynchronous mode of transmission with one start bit, eight d...