Subnet masks

When a host sends a message to a destination, the system must determine whether the destination is on the same network as the source or if the destination can be reached directly through one of the local interfaces. The system compares the destination address to the host address using the subnet mask.

If the destination is not local, the system sends the message on to a gateway. The gateway performs the same comparison to see if the destination address is on a network it can reach locally.

The subnet mask tells the system what the subnet partitioning scheme is. This bit mask consists of the network address portion and subnet address portion of the Internet address.

Figure 1. Class A address with corresponding subnet address
Class A address with corresponding subnet address
This illustration shows a typical class A address structure. The first 8 bits contain the network address (always beginning with a zero). The remaining 24 bits contain the local host address with the subnet address occupying the first 8 bits and the host address occupying the last 8 bits.

For example, the subnet mask of the Class A address with the partitioning scheme defined above is shown in this figure.

The subnet mask is a set of 4 bytes, just like the Internet address. The subnet mask consists of high bits (1's) corresponding to the bit positions of the network and subnetwork address, and low bits (0's) corresponding to the bit positions of the host address. A subnet mask for the previous address looks like the following figure.

Figure 2. Example subnet mask
Example subnet mask
This illustration shows a an example of a subnet mask structure. The first 8 bits contain the network address. The remaining 24 bits contain the local host address with the subnet address occupying the first 8 bits and the host address occupying the last 8 bits.