# GATE2015-2-41

6.3k views

Consider the following routing table at an IP router:
$$\begin{array}{|l|l|l|} \hline \textbf {Network No} & \textbf {Net Mask} & \textbf{Next Hop} \\\hline \text {128.96.170.0} & \text{255.255.254.0} & \text{Interface 0} \\\hline\text {128.96.168.0} & \text{255.255.254.0} & \text{Interface 1} \\\hline\text {128.96.166.0} & \text{255.255.254.0} & \text{R2}\\\hline \text {128.96.164.0} & \text{255.255.252.0} & \text{R3}\\\hline \text {0.0.0.0} & \text{Default} & \text{R4}\\\hline \end{array}$$
For each IP address in Group I Identify the correct choice of the next hop from Group II using the entries from the routing table above.
$$\begin{array}{l|ll} \hline \textbf {Group I} & \textbf {Group II} \\\hline \text {i) 128.96.171.92} & \text{a) Interface 0} \\ \hline \text {ii) 128.96.167.151} & \text{b) Interface 1} \\\hline \text {iii) 128.96.163.151} & \text{c) R2}\\ \hline \text {iv) 128.96.164.121} & \text{d) R3}\\ \hline \text {} & \text{e) R4}\\\hline \end{array}$$

1. i-a, ii-c, iii-e, iv-d
2. i-a, ii-d, iii-b, iv-e
3. i-b, ii-c, iii-d, iv-e
4. i-b, ii-c, iii-e, iv-d

edited
0
iii matches with none. so it goes to default router.
0

Taking the 1st IP Address: 128.96.171.92

Bitwise AND between 128.96.171.92 and 255.255.254.0 we get the subnet ID as follows:$$\begin{array} {rrrr}255&255&11111110&0 \\ 128&96&10101011&92 \\ \hline \textbf{128}&\textbf{96}&\textbf{10101010}&\textbf{0}\end{array}$$

∴ Subnet ID = 128.96.170.0
∴ 128.96.171.92 will forward to interface 0

Taking the 2nd IP Address: 128.96.167.151

Bitwise AND between 128.96.167.151 and 255.255.254.0 we get, $$\begin{array} {rrrr}255&255&11111110&0 \\ 128&96&10100111&151 \\ \hline \textbf{128}&\textbf{96}&\textbf{10100110}&\textbf{0}\end{array}$$

∴ Subnet ID = 128.96.166.0
∴ 128.96.167.151 will forward to interface R2

Taking the 3rd IP Address: 128.96.163.151

Bitwise AND between 128.96.167.151 and 255.255.254.0 we get, $$\begin{array} {rrrr}255&255&11111110&0 \\ 128&96&10100011&151 \\ \hline \textbf{128}&\textbf{96}&\textbf{10100010}&\textbf{0}\end{array}$$

∴ Subnet ID = 128.96.162.0 (Doesn’t match with any given interface)

Now, Bitwise AND between 128.96.167.151 and 255.255.252.0 we get, $$\begin{array} {rrrr}255&255&11111100&0 \\ 128&96&10100011&151 \\ \hline \textbf{128}&\textbf{96}&\textbf{10100000}&\textbf{0}\end{array}$$

∴ Subnet ID = 128.96.160.0 (Doesn’t match with any given interface)
∴ 128.96.163.151 will forward to default interface R4

Taking the last IP Address: 128.96.164.121

Bitwise AND between 128.96.164.121 and 255.255.254.0 we get, $$\begin{array} {rrrr}255&255&11111110&0 \\ 128&96&10100100&121 \\ \hline \textbf{128}&\textbf{96}&\textbf{10100100}&\textbf{0}\end{array}$$

∴ Subnet ID = 128.96.164.0
∴ 128.96.167.151 will forward to interface R3

∴ Option (a) is the correct answer

selected by
Option $A$ is correct . Do the $AND$ operation of group $1$ with net mask you will get the answer.

edited
0
Can u explain this what to check with result of  AND operation to get next hop ???
2

The next hop is decided according to the longest prefix matching obtained by AND operation, hope this helps

So now we can eliminate the options easily.

i -> a

ii -> c

Option - A

i) 128.96.171.92  --- > First addr 128.96.170.0         a) Interface 0

ii) 128.96.167.151 ---> First  addr 128.96.166.0        c) R2

iii) 128.96.163.151--> first addr matches none e) R4

iv) 128.96.164.121---> first addr  128.96.164.0       d) R3

Consider the following routing table at an IP router:

Network No                      Net Mask            Next Hop

128.96.170.0/23 255.255.254.0     Interface 0

128.96.168.0/23 255.255.254.0     Interface 1

128.96.166.0/23 255.255.254.0     R2

128.96.164.0/22 255.255.252.0     R3

0.0.0.0   Default R4

128.96.171.92

To get First Net addr make the last 32-N bits of the addr to zero.[N is prefix]

First prefix to check is 23 --> 32-23=9

Make the last 9 bits of the addr to zero. The last 9 bits of address are in the last two octets.

171.92 -  - - - - -> 170.0   hence first netaddress is 128.96.170.0 matches first entry.
1 vote

This simple concept of Bitwise ending Network Mask and IP address gives us network ID is being asked in GATE numerous times.

In question we are given with the network id and subnet mask. we are asked that which of the following IP addres belongs to which network?

As it is Classless

just look at third octet as the starting two octets are same in all options.

Approach:

Write the binary for

163 - 10100011 matches with nothing so it will go through default 0.0.0.0

165 - 10100101   matches with    164 - 10100100              255.255.252.0

167 - 10100111   matches with    166 - 10100110              255.255.254.0

171 - 10101011   matches with    170 - 10101010              255.255.254.0

So option A is correct

## Related questions

1
4.8k views
Identify the correct order in which a server process must invoke the function calls accept, bind, listen, and recv according to UNIX socket API. listen, accept, bind, recv bind, listen, accept, recv bind, accept, listen, recv accept, listen, bind, recv
In a connected graph, a bridge is an edge whose removal disconnects the graph. Which one of the following statements is true? A tree has no bridges A bridge cannot be part of a simple cycle Every edge of a clique with size $\geq 3$ is a bridge (A clique is any complete subgraph of a graph) A graph with bridges cannot have cycle
Consider a processor with byte-addressable memory. Assume that all registers, including program counter (PC) and Program Status Word (PSW), are size of two bytes. A stack in the main memory is implemented from memory location $(0100)_{16}$ and it grows upward. The stack pointer (SP) points to ... , the value of the stack pointer is: $(016A)_{16}$ $(016C)_{16}$ $(0170)_{16}$ $(0172)_{16}$