Calculating subnet made easy

 How to calculate subnet mask of a prefix


To calculate subnet mask  of any prefix we need to know the number of network bits and host bits


Let us take example of a prefix and understand


In this instance let us take example of  /18 and calculate 

As said let us first know the number of network bits and number of host bits

Host bits: To calculate network bits let us substract the prefix from 32( why 32 ..please continue to read)

32-18=14 

Let us calculate host bits 

Network bits: To calculate host bits let us substract the network bits(18) from 32

32-14=18


Now the real part comes

we need to place the network bits and host bits in their appropriate positions

Host bits are indicated by 1's and network bits are indicated by 0's

First in binary form the ones and 0's are placed from left to right

Let us keep the host bits 18 1's in the first positions i.e from left

This is the binary form of /18

111111111.11111111.11000000.00000000 

When this binary form is converted into decimal form we get subnet mask 

255.255.192.0

How this is converted into decimal form is the big thing here!!

An ipv4 address has 4 octets

Each octet has 8 bits 

so 8*4=32

Each bit is represented as 1

The total value of that group equals the sum of all the powers of 2 represented by those bits

which equals 2^n - 1, where n is the number of bits in the group.

 In an 8-bit group, the maximum value is 2^8 - 1, which equals 255.

So all the 1's are represented as 255 and rest are 0's

how did we get third octet as 192??

The sum of powers of the first two one's (from left to right) is equal to  192 

So we got 192

This is the process of determining a subnet mask of prefix

Hope you enjoyed reading the blog

Thank you

Happy reading.


Comments

Popular posts from this blog

REVIEW-1

Review-4