When you have an IP address, you can easily tell or detect the class of that IP address (For a brief summary, read IP(IPv4) Address Classes Cheat Sheet). And every IP address must be accompanied by a subnet mask (For a brief summary, read Default Subnet Masks Cheat Sheet) of that IP address class. But for any computer, the process is not such simple as you think. For any computer to determine the network of that IP address, it should need to AND the IP address and the subnet mask.
ANDing Equation:
- 0 AND 0 = 0
- 0 AND 1 = 0
- 1 AND 0 = 0
- 1 AND 1 = 1
Note: Remember when both the bits are 1 then the output is 1. Otherwise the output is 0.
Example:
An IP address is: 172.10.10.25
We have to find out the network address of that IP address. From the IP address 172.10.10.25, we could figure out the following information:
- IP address: 172.10.10.25
- Class: Class B
- Network part: 172.10.10.25 [Red colored part]
- Host Part: 172.10.10.25 [Blue colored part]
- Default Subnet Mask: 255.255.0.0
To find out the network address of the IP address, we first have to convert the IP address and the default subnet mask into binary format and then have to AND both the binary format to get the network address. So, the calculation may look like the following:
Decimal Format | Binary Format | |
IP | 172.10.10.25 | 10101100.00001010.00001010.00011001 |
Default Subnet | 255.255.0.0 | 11111111.11111111.00000000.00000000 |
AND | 172.10.0.0 | 11111111.11111111.00000000.00000000 |
So the network address of the IP address 172.10.10.25 will be:
172.10.0.0 (11111111.11111111.00000000.00000000)
Here, Network part and Host part are marked with red and blue colored text.
To sum up, ANDing the default subnet mask with the IP address, allows the computer to figure out the network part of the IP address.