# GATE2019-28

3.3k views

Consider three machines M, N, and P with IP addresses $100.10.5.2, \: 100.10.5.5$, and $100.10.5.6$ respectively. The subnet mask is set to $255.255.255.252$ for all the three machines. Which one of the following is true?

1. M, N, and P all belong to the same subnet
2. Only M and N belong to the same subnet
3. Only N and P belong to the same subnet
4. M, N, and P belong to three different subnets

edited

First derive the network address of those machines, then we can decide !

Finding network address for a M/C :- Perform Bitwise AND between m/c address and given subnet mask.

Subnet Mask: keep $1$'s in Network part $+$ subnet part and keep $0$'s in Host part.

$255.255.255.252 = 11111111.11111111.11111111.11111100$
$\implies 24( \text{from first 3 octets} ) + 6 ( \text{ in last octet })$
$\quad = 30 \text{bits in Network+ subnet portion and last 2 bits represent the Host part}.$

Subnet Mask $= 255.255.255.252$ and $M = 100.10.5.2$ but keep all zero's in HOST part !

$\begin{array}{|l|l|l|l|} \hline 100 = 01100100 & 10 = 00001010 & 5 = 00000101 & 2 = 000000 \color{red}{00} \\ \hline 255 = 11111111 & 255 = 11111111 & 255 = 11111111 & 252 = 11111100 \\ \hline 100 & 10 & 5 & 0 \\ \hline \end{array}$

Subnet Mask $= 255.255.255.252$ and $N = 100.10.5.5$ but keep all zero's in HOST part !

$\begin{array}{|l|l|l|l|} \hline 100 = 01100100 & 10 = 00001010 & 5 = 00000101 & 5 = 000001 \color{red}{00} \\ \hline 255 = 11111111 & 255 = 11111111 & 255 = 11111111 & 252 = 11111100 \\ \hline 100 & 10 & 5 & 4 \\ \hline \end{array}$

Subnet Mask $= 255.255.255.252$ and $P = 100.10.5.6$ but keep all zero's in HOST part !

$\begin{array}{|l|l|l|l|} \hline 100 = 01100100 & 10 = 00001010 & 5 = 00000101 & 6 = 000001\color{red}{00} \\ \hline 255 = 11111111 & 255 = 11111111 & 255 = 11111111 & 252 = 11111100 \\ \hline 100 & 10 & 5 & 4 \\ \hline \end{array}$

$\therefore$ only $N$ and $P$ are belong to same network $(100.10.5.4/30)$

edited
1

why to keep zeroes in the host ID  part?

1
@Shaik Masthan
00000100 = 4 not 1
0

that's how subnet mask is defined. 1's in network ID part and 0's in host ID part.

M: 100.10.5.2 , N: 100.10.5.5 , p: 100.10.5.6

SM =  255.255.255.252 = 255.255.255.11111100 (only express Last byte into binary form bcz first 3 byte already all 1)

Now Bitwise end of each IP addresses (M,N,P) with SM . It will give us Subnet id (SID) of each Machine.

for M it SID gives : 100.10.5.0

for N it SID gives : 100.10.5.4

for P it SID gives : 100.10.5.4

So, we can say that SID of N is same as SID of P . So  N,P belongs to the same subnet

And subnet is : (100.10.5.4/30)

edited
If two host belong to same network then their subnet id should be same . Subnet id can be obtained using subnet mask .Take a IP address of a host and perform Bitwise AND operation with subnet mask results subnet id.
Ip address of M IPm: 194.56.10.2
Ip address of N IPn : 194.56.10.5
Ip address of P IPp: 194.56.10.6
Subnet id of M sidm = SM        11111111.11111111.11111111.11111100                                                                                        Bitwise AND                                                                                                                                                                                        IPm                                           11000010.00111000.00001010.00000010                                                                        ____________________________________________________________________
=      11000010.00111000.00001010.00000000
=     194.56.10.0

Subnet id of N= SM             11111111.11111111.11111111.11111100                                                                                             Bitwise AND                                                                                                                                                                                                          IPn                   11000010.00111000.00001010.00000101                     ___________________________________________________________________                                                                                                              = 11000010.00111000.00001010.0000.100                                                                                                                                       =194.56.10.4

Subnet id of P= SM             11111111.11111111.11111111.11111100                                                                                              Bitwise AND                                                                                                                                                                                                     IPp                          11000010.00111000.00001010.00000110               __________________________________________________________________________ .                                                                                             = 11000010.00111000.00001010.00000100
= 194.56.10.4
Sid of N = Sid of P
Hence N and P are host of same network

This is what I think:

Firstly, the technique is, do bitwise AND with subnet- the network ids given, those who return the same values are in the same subnet.

The parts of the subnet which are 255 will spit out what we give them, they are all 1's so we already know first three octets after multiplication for all three network IDs. They will be the same.

The last octet of the subnet, 252 only matters. Break it to get the binary - 128+64+32+16+8+4 = 11111100. Doing bitwise AND with this binary number will spit out same nos till 6th-bit rest will be eaten by 0's.

The last octets of net ids are -  2-> 000000'10,     5-> 000001'01,      6-> 000001'10  (The ' symbol shows how far the bits survive)

So for 5 and 6 same bit pattern survives, basically, ANDing 252 with 2 gives 0, with 5 gives 4, with 6 gives 4.

As 5 and 6 return same values, they are in the same subnet.

## Related questions

1
4k views
Which of the following protocol pairs can be used to send and retrieve e-mails (in that order)? IMAP POP3 SMTP, POP3 SMTP MIME IMAP, SMTP
Consider that $15$ machines need to be connected in a LAN using $8$-port Ethernet switches. Assume that these switches do not have any separate uplink ports. The minimum number of switches needed is ______
In an RSA cryptosystem, the value of the public modulus parameter $n$ is $3007$. If it is also known as that $\phi(n)=2880$ where $\phi()$ denotes Euler’s Totient Function, then the prime factor of $n$ which is greater than $50$ is _________