A subnet mask works like a filter, helping to route traffic inside a subnet. Basically, the subnet mask tells the router which numbers it should look at and which ones it should ignore beneath the mask.
For example, when a binary mask is laid over an IP address also translated into binary, a 1 over a number tells the router to look at the number beneath, and a 0 says to ignore the number. The subnet mask tells a router which bits to pay attention to when calculating the network ID portion of an IP address.
Calculating subnets by hand
By default, the subnet mask for a Class C IP address class is set to 255.255.255.0, meaning that the first 3 octets (24 bits) in an IP address are used to identify the network ID, and the last octet (8 bits) are dedicated to the host ID.
That means that on this particular subnet, there are 256 possible IP addresses. How did we figure this out? Remember that 255 is the highest number that can be represented in binary with 8 bits. To get to 255, all of the 8 bits must be set to 1, each one representing a number in decimal (1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 = 255). When you include the number zero that makes 256 possible values.
But if we had a subnet mask of 255.255.255.192, that would mean there are only 6 bits available to us (we get 192 because the bits representing 128 and 64 are masked out). Because 63 is the highest decimal value that can be represented with 6 binary bits (1 + 2 + 4 + 8 + 16 + 32), when you add the zero, that makes 64 possible values.
How to calculate hosts or subnets based on the subnet mask
A quicker way to figure out how many hosts will exist on a particular subnet is to use the formula 2n-2, where n is the number of bits available to the host ID, where 2n represents 2 raised to the nth power. You must then subtract two from the result because 2 addresses are reserved for the network ID and broadcast address or ID.
So in our examples above:
2^8 – 2 = 254
2^6 – 2 = 62
But you don’t have to do that work manually. If you’re going to calculate a subnet mask, ere’s a quick cheat sheet to help you figure out how many host addresses are available depending upon the CIDR notation.
|CIDR notation||Available IP Addresses||Hosts||Netmask|
So based on this 4 Pillar subnet mask is below
So our IP will be from 172.16.0.0 – 172.16.3.254