Log In
31 votes

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

  1. $$ and $$

  2. $$ and $$

  3. $$ and $$

  4. $$ and $$

in Computer Networks
edited by

Option A is class a Network 

But Why are we not checking Option C?  Because Class B Ip ranges from 128 to 191.

Can Anyone Please clarify this point?

Ip Ranges

because they asked that both ips should be in the same network so in option C the ip is class B so we need 16 bits of network ID and one ip is in 191.203 network and the other ip is in 191.234 network hence they dont belong to the same network
a and c option are wrong because on bitwise AND the subnet id's are different so they are eliminated easily( or you can simpy check the second octet is different) now left is b and d so b is not the correct option as it is a class A division given by IANA so the option left is d which is correct.

How could be valid subnet mask ? Shouldn't be all the 1s should be consecutive ?
Need not be @s_dr_13.

Theoretically we can set the bits in anywhere in the remaining unset bits. But practically we don't do it though.

5 Answers

92 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)

$  \ \& \ = (28 = 11100_2)$
$ \  \& \ = (29 = 11101_2)$
So, we get different subnet numbers

Consider (D).

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

edited by
can u please elaborate your answer..i am not able to understand it.
Sir why u have not considered A,C

I dont have clarity with this
The method is simple, if we AND the IP and subnet mask, we should get the same value, for 2 different IPs to belong to the same network. For A andC, it is easy as their second bytes are different and subnet mask for second byte is 255 (all 1's) which won't give same value after AND. ,
Thank U sir
@Arjun Sir Edit Request:-

29's Binary=11101

11111=31's binary
A subnet mask is always the contiguos set of 1's so I think given subnet mask is not a valid subnet mask.Am I right if not correct?
the subnet mask is of class B and the option b is for class A, do we need to check it?

@arjun sir

29 = 111012      NOT 29 = 111112


Subnet bits for the 3rd octet:         00011111 bits for 3rd octet:       00011100 bits for 3rd octet:       00011101 bits for 3rd octet:  10000001 bits for 3rd octet:  10100001

Only for the unmasked bits of the subnet( i.e which are 1's ),  the host IP address bits must be identical for all those hosts which are to be on the same network. Otherwise, they are on different network.

Don't confuse it with longest prefix matching technique used for router packet forwarding. 


conventionally and practically, subnet mask's are taken contigous from left to right, but for framing qsns it can be present anywhere
And non contiguous subnet masks can't be represented in CIDR representation.

Option D)


subnet mask is of class B network

Now conversion of last 2 octates of the IP that is 31.0 give 00011111 00000000

Hence we have 000 11111 00000000

The underlined are host bits and bold are subnet bits.

Option B is wrong as the given IP belongs to class A

Rest all options are Class B so we will only look at the Host bits i.e. last 2 octates of the networks

Option A) 88.62 = 010 11000 00000000

                  87.23 = 010 10111 00000000

Both are valid IPs but belong to different subnets therefore the are not IPs of "this" network

Option B) 31.87 = 010 11111 00000000

subnet 11111 can't form IP as that is reserved for DBA and last subnet of this network can only be 11110

Option D)

129.43 = 100 00001 00000000

161.55 = 011 00001 00000000

Both are valid networks and belong to same subnet.




How can subnet bits be after host bits like in 00011111.00000000  you said underlined ones are host bits. If that is so they will not be continuous which is there is the definition of subnetting itself.

Subnetting:  Dividing a large block of addresses into several contiguous sub-blocks and assigning these sub-blocks to different smaller networks is called subnetting. It is a practice that is widely used when classless addressing is done.

Correct me if I am wrong.

14 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 to 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) and

C) and

D) and

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


                  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
Awesome! :)

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

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

4 votes

The subnet  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.


Class A can also have Subnet Mask starting with 255.255

Please do not post wrong explanation!
0 votes

Quick Answer

Subnet mask given is


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

–6 votes
ans c)

Related questions

33 votes
4 answers
Using a larger block size in a fixed block size file system leads to better disk throughput but poorer disk space utilization better disk throughput and better disk space utilization poorer disk throughput but better disk space utilization poorer disk throughput and poorer disk space utilization
asked Sep 16, 2014 in Operating System Kathleen 5.9k views
41 votes
3 answers
Let $G$ be an arbitrary graph with $n$ nodes and $k$ components. If a vertex is removed from $G$, the number of components in the resultant graph must necessarily lie down between $k$ and $n$ $k-1$ and $k+1$ $k-1$ and $n-1$ $k+1$ and $n-k$
asked Sep 16, 2014 in Graph Theory Kathleen 5.7k views
37 votes
5 answers
A data structure is required for storing a set of integers such that each of the following operations can be done in $O(\log n)$ time, where $n$ is the number of elements in the set. Deletion of the smallest element Insertion of an element if it is not already ... tree can be used but not a heap Both balanced binary search tree and heap can be used Neither balanced search tree nor heap can be used
asked Sep 17, 2014 in DS Kathleen 6.9k views
34 votes
3 answers
Which of the following scenarios may lead to an irrecoverable error in a database system? A transaction writes a data item after it is read by an uncommitted transaction A transaction reads a data item after it is read by an uncommitted transaction A transaction ... item after it is written by a committed transaction A transaction reads a data item after it is written by an uncommitted transaction
asked Sep 16, 2014 in Databases Kathleen 5.6k views