The subnet mask helps determine which network (subnet) an IP address belongs to. The process of determining the network or subnetwork is done by ANDing the IP address and the subnet mask together. The result will provide the Network ID. Let's take a look at the following diagram:
We would like to determine which network PC1 belongs to. To do this, we need to AND both the IP address: 192.168.1.0 against the subnet mask, which is 255.255.255.0. To proceed further, we'll convert both the IP address and subnet mask into binary and use the laws of ANDing.