| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
IP Subnet Masks, Notation and Subnet Calculations (Page 1 of 4) Subnetting divides an organization's network into a two-level structure of subnets and hosts. This division is entirely internal and hidden from all other organizations on the Internet. One of the many advantages of this is that each organization gets to make their own choice about how to divide the classful host ID into subnet ID and host ID. In a non-subnetted classful environment, routers use the first octet of the IP address to determine what the class is of the address, and from this they know which bits are the network ID and which are the host ID. When we use subnetting, these routers also need to know how that host ID is divided into subnet ID and host ID. However, this division can be arbitrary for each network. Furthermore, there is no way to tell how many bits belong to each simply by looking at the IP address. In a subnetting environment, the additional information about which bits are for the subnet ID and which for the host ID must be communicated to devices that interpret IP addresses. This information is given in the form of a 32-bit binary number called a subnet mask. The term mask comes from the binary mathematics concept called bit masking. This is a technique where a special pattern of ones and zeroes can be used in combination with boolean functions such as AND and OR to select or clear certain bits in a number. I explain bit masking in the background section on binary numbers and mathematics. There's something about subnet masks that seems to set people's hair on end, especially if they aren't that familiar with binary numbers. However, the idea behind them is quite straight-forward. The mask is a 32-bit number, just as the IP address is a 32-bit number. Each of the 32 bits in the subnet mask corresponds to the bit in the IP address in the same location in the number. The bits of the mask in any given subnetted network are chosen so that the bits used for either the network ID or subnet ID are ones, while the bits used for the host ID are zeroes.
Why bother doing this with a 32-bit binary number? The answer is the magic of boolean logic. We use the subnet mask by applying the boolean AND function between it and the IP address. For each of the 32 bit pairs in the IP address and subnet mask we employ the AND function, the output of which is 1 only if both bits are 1. What this means in practical terms is the following, for each of the 32 bits:
So, when we use the subnet mask on an IP address, the bits in the network ID and subnet ID are left intact, while the host ID bits are removed. Like a mask that blocks part of your face but lets other parts show, the subnet mask blocks some of the address bits (the host bits) and leaves others alone (the network and subnet bits). A router that performs this function is left with the address of the subnet. Since it knows from the class of the network what part is the network ID, it also knows what subnet the address is on.
Home - Table Of Contents - Contact Us The TCP/IP Guide (http://www.TCPIPGuide.com) Version 3.0 - Version Date: September 20, 2005 © Copyright 2001-2005 Charles M. Kozierok. All Rights Reserved. Not responsible for any loss resulting from the use of this site. |