in Computer Networks edited by
28,636 views
55 votes
55 votes

The subnet mask for a particular network is $255.255.31.0.$ Which of the following pairs of $\text{IP}$ addresses could belong to this network?

  1. $172.57.88.62$ and $172.56.87.23$

  2. $10.35.28.2$ and $10.35.29.4$

  3. $191.203.31.87$ and $191.234.31.88$

  4. $128.8.129.43$ and $128.8.161.55$

in Computer Networks edited by
28.6k views

4 Comments

The set bits of a subnet mask indicate the network bits and the unset bits indicate the host bits for an IP address in that network.

Here the subnet mask = $\textbf{1111 1111.1111 1111}.000\textbf{1 1111}.0000 0000$.

The first two octect and the last 5 bits of the 3rd octet give us the network bits of any IP address in that particular network. 
For two IP addresses belonging to the same network these specific bits should match.

So in the options the first 2 octet and the last 5 bits of the 3rd octet of both the IP addresses should match. 

In options $A.$ and $C.$, the addresses clearly have different 2nd octet.

In option $B.$, the first IP address has an even 3rd octet and the second IP address has an odd 3rd octet, so they differ in the last bit of the 3rd octet. Hence they are from different networks.

In option $D.$, the first two octet match.
$129 = (100\textbf{0 0001})_2$ and $161 = (101\textbf{0 0001})_2$, so the last 5 bits of their 3rd octet also match. Hence they belong to the same network.

$\therefore$ $D.$ is the answer

9
9
edited by

Concept: For two IP address to belong to same network they should have same Net ID .

Given: Subnet mask …..

Using Subnet mask and IP address we can find Net Id …..through ANDing.

So by evaluating each ip address in the given options you can calculate which two ip address belong to same network.

(Point to note that you have to evaluate only two options because starting 16 bits must be same so A and C are ruled out)

You will get Correct Option D.

1
1
To find whether hosts belong to same network or not , we have to find their net id, if net-id is same then hosts belong to same network and net id can be find by ANDing subnet mask and IP address.

SM : 255.255.31.0

 IP: 128.8.129.43  and 128.8.161.55

Anding both ip with subnet mask

NID :125.18.2.0 and 125.18.2.0

Note:

instead of checking all option you can filter out option (B) and(D) as first 2 octet of the subnet mask is 255 and only option (B) and(D) have first 2 octets same , now apply and operation on them.
0
0

6 Answers

131 votes
131 votes
Best answer

(A) and (C) are not the answers as the second byte of IP differs and subnet mast has $255$ for second byte.

Consider (B), (& for bitwise AND)

$10.35.28.2  \ \& \ 255.255.31.0 = 10.35.28.0 (28 = 11100_2)$
$10.35.29.4 \  \& \ 255.255.31.0 = 10.35.29.0 (29 = 11101_2)$
So, we get different subnet numbers

Consider (D).

$128.8.129.43 \ \& \ 255.255.31.0 = 128.8.1.0 (129 = 10000001_2)$
$128.8.161.55 \ \& \ 255.255.31.0 = 128.8.1.0 (161 = 10100001_2)$
The subnet number matches. So, (D) is the answer. 

edited by
by

4 Comments

sir, we can only check the bits of third octet to conclude whether the ids belong to the same network or not, right?

0
0

Also, one more thing to note: If I have subnet masks with not contiguous 1’s. It is not possible to divide the subnets into explicit ranges. Such subnet masks are not allowed in CIDR notation as the subnets will not have continous IP addresses. See allowed masks in CIDR notation here.

Ex. Subnet Mask is 255.255.255.1, In this network, we will have two subnets as the last bit is subnet Id. One subnet will have all odd IP addresses (ex. 192.168.2.15)  and the other subnet with all even IP addresses (ex. 192.168.2.16). So we cannot represent the subnets by ranges (by ranges I mean say 192.168.2.0 – 192.168.2.127, we cannot do this here) when we have subnet masks with not contiguous 1’s.

0
0

@Arjun sir, why are you trying to make same subnet?? The question says subnet mask is 255.255.31.0 and later it is asked that the hosts given in option whether they belong to the same network ( since network is subnetted so we must check whether the host bit doesn't have all 0's and all 1's and also subnet bits are not all 0's and all 1's )

it's nowhere mentioned that they must belong to same subnet, it's just same network????

1
1
21 votes
21 votes
I am solving here through elimination type procedure

The subnet mask 255.255.x.x belongs to class B type(IP address range will be from 128.1.0.1 to 191.255.255.254) so we can eliminate option B

Now we understand A, C, D belongs to class B network.

we will do a bit by bit AND operation of network and subnet mask to find the subnet.

A)172.57.88.62 and 172.56.87.23

C)191.203.31.87 and 191.234.31.88

D)128.8.129.43 and 128.8.161.55

clearly, we see the second octet of option A and C (57,56       203,234      are different.   57 & 255, 56 & 255 will give different values       203 & 255, 234 & 255 will give different values) are different so this implies that they don't belong to the same subnet.

Now we eliminated A B C then option D will be the answer.

still, if you want to check the answer for being safe side then follow below procedure

now for first option D the first two octets are same so you don't need to do  AND with 255 and waste time so now go to the third octet

         129 =1000 0001     161=1010 0001

          31=  0000 11111      31= 0000 11111

AND.............................................................

                  0000 0001             0000 0001
 

The third octet of subnets are same(first 2 octets are also same).

still not confident abt D then do fourth octet of network AND with fourth octet subnet mask.

Here anyhow fourth octet of mask is 0 so anything AND with 0 is zero

So the conclusion is, D is the correct answer.

Comments are always welcome!!!

 

There is no carry in doing AND operation. it is just bit by bit AND.
edited by

3 Comments

Awesome! :)
0
0

Please explain this line The subnet mask 255.255.x.x belongs to class B type(IP address range will be from 128.1.0.1 to 191.255.255.254) so we can eliminate option B

How did you wrote the range of ip addresses? @saiteja chekka

0
0
but they didn’t mentioned that it is classful IP addressing or classless IP Addressing
0
0
4 votes
4 votes

The subnet 255.255.31.0  belongs to Class B, since its net id is 255.255 .

So, we can conclude that either option could be (A) or (D).

Now, the question asks that the the IP should be  same network, so, to test that the IP are in same network we check that whether their netwrok address is same, by using AND operation.

IP AND MASK = network address

In case of option A, we can see that when we apply AND operation to first byte of IP and first byte of MASK both the IP will give same, but when we apply AND operation is applied on second byte then both the IP gives different. So, option A is eliminated and hence Option D is selected because both IP has first and second IP as same.

ANS: D

2 Comments

Class A can also have Subnet Mask starting with 255.255

Please do not post wrong explanation!
5
5
Wrong explanation. They have given subnet mask, not network mask. Don't just reach the answer by giving any random explanation.
1
1
1 vote
1 vote

Quick Answer

Subnet mask given is 255.255.31.0

Here,

255 is having 11111111 LSB is 1,

31 is having 00011111 that means LSB 1, which means When we AND anything it will depend on the LSB of data we are ANDing.

Now in option a) is 57(odd) LSB 1 and 56(even) LSB 0 that means when we AND this with above SUBNET Mask we will get different result for sure..So, Wrong

b) 28 & 29 again same odd and even, Wrong

c)  203 & 234 odd and even same again, Wrong

d) 129 & 161 both are odd, Hence Option left so Answer

Answer:

Related questions