In computer science, a mask is an electronic filter used to extract particular portions of a unit of data. Likewise, an IP subnet mask is used to extract the NETID, or routing-specific portion, from the IP (version 4) address. The mask is the same length as the IPv4 address (i.e., 32 bits) and is usually depicted using the same dotted decimal notation used for IPv4 addresses (i.e., 255.255.0.0). In the mask, every bit that is part of the NETID is set (i.e., 1) and every bit that is part of the HOSTID is unset (i.e., 0). It is also more common today, however, to see the mask represented using the slash notation. In this case, the number of NETID bits is explicitly stated following a “/” after the IP address. For example, 22.214.171.124/16 means that the first 16 bits of this address is the NETID—126.96.36.199.
To extract the NETID using a mask, the IPv4 address is logically ANDed with the mask. In the logical AND operation, the address and mask are examined bit by bit. Each bit in the IPv4 address is ANDed to the corresponding bit in the mask. If both bits are 1, the result is a 1; any other combination results in a 0. The mask has the effect of clearing (e.g., setting to 0) all of the bits corresponding to the HOSTID.
In the example on the visual, the IP address 188.8.131.52 is ANDed with the default Class B mask 255.255.0.0. The result of this process is the new value 184.108.40.206. Note that in this Class B address the mask has effectively canceled out the HOSTID, leaving only the NETID. The concept of address class was used in the early days of the Internet. As the Internet growth exploded there was significant concern regarding the potential exhaustion of IP addresses. Today we have temporarily solved this problem by moving from the class structure with defined masks to a classless address structure where the HOSTID length is explicitly defined by a mask.
In any given network environment, extending the mask has the effect of breaking the network into smaller pieces. For example, if a network using the IP address 220.127.116.11/16 were deployed using that mask (16 bits), it would have to be deployed as a single, cohesive network capable of hosting up to 65,534 systems. It could be interconnected to other networks with routers, but it could not have any routers internally. If the same network were deployed using the 24-bit mask (i.e., 18.104.22.168/24), the extension of the mask a further 8 bits would have the effect of breaking the single network into 256 subnetworks, all of which would be interconnected using routers, each of which would be caable of supporting up to 254 hosts.
|| IP address|
|| Subnet Mask|