IPv4 Address

IPv4 Address consist of 4 numbers separated by dot(.). Each number ranges from zero to 255. Each number is an octet (each octet is of 8 bit) and that is why maximum range of each number is 255.
Since each Number is an octet and there are 4 numbers in IPv4 address so IPv4 Address is a 32 bit Address

Example of IPv4 Address: 10.8.12.9

Every device like computer, printer or router is assigned with IPv4 Address in order to uniquely identify in the network.
IPv4 address divided in to two parts
1) Network Part
2) Host Part

Left part of IPv4 Address is Network part and right part of IPv4 Address is Host part. Now the question is how much left part of IPv4 Address is Network part and likewise for Host part. Here comes the role of Subnet Mask or Mask.

Subnet Mask:
Mask or Subnet Mask decides Network and Host part in IPv4 Address.
Let us take an example to understand how Subnet Mask tells how much the left part of IPv4 address is Network and how much is Host.

IPv4 Address: 10.8.12.9
Subnet Mask: 255.255.255.0

In Subnet Mask, 255 is present for first 3 Number, so 10.8.12 becomes the network part of IPv4 Address and 9 becomes host part.
10.8.12.0 becomes the Network Address and 10.8.12. <1-255> can be the IP address assigned to the hosts in 10.8.12.0 network.
Above IP Address with Subnet mask 255.255.255.0 can be represented like 10.8.12.9/24 since first 24 bits(3 Octets) are masked as per the subnet mask.

Here zero in host part cannot be assigned as it represent in Network Address.

Let say if the subnet mask is 255.255.0.0, then IP Address will be represent as 10.8.12.9/16 and its Network address will be 10.8.0.0

There are some observations from above discussion
1. Subnet mask is all 255 and then 0. This is a property of mask. It should be contiguous i.e. all 1’s and then 0’s. It cannot be like 255.0.255.0. This is not a valid subnet mask.

2. IP Address will always be represented by below format:
<IP Address>/<Mask>

Till now we have used simple subnet mask i.e. 24 or 16 bits mask and we can easily differentiate the Network and Host part of IP Address.
But what if the mask is of 20 bits ? How will we segregate the Network and Host part of IP Address?
if the mask is of 20 bits, the subnet mask will be:
255.255.240.0
255: represent all 1 8 bits( 1111 1111)
255: represent all 18 bits( 1111 1111)
240: remaining 4 bits(1111 0000)

For this you need to understand the Decimal to Binary and Binary to Decimal conversion i.e. how to convert 240 in to binary format 1111 0000.

IP Address: 10.8.12.9
Mask: 255.255.240.0
Now to find the Network address from the above information, we will take the 3rd number from left from IP Address and subnet mask and perform AND operation since first two numbers are clear.
12: 0000 1100
AND
240: 1111 0000
its comes out 0.
So the Network Address will be 10.8.0.0
In the below figure, three Hosts with IP Address 10.8.9.1, 10.8.9.2 and 10.8.9.3 respectively are connected in a network with a subnet 255.255.255.0
Based on subnet mask, Network of above three IP Addresses is 10.8.9.0.


Related posts