IP Subnet Addressing
The are several reasons why you might want to subnet a network. You may want to incorporate different types of physical networks into your IP network. Implementing subnets helps to control network traffic. On an ethernet network every machine on the same physical network sees all the packets of data sent out on the network. In heavy traffic situations this can result in collisions making the network performance painfully slow. In both these situations routers or gateways are used to separate networks. The router breaks the network into multiple subnets.
Subnet masking
Applying a subnet mask to an address allows you to identify the network and node sections of an IP address. Doing a bitwise AND on the IP address and the subnet mask results in the network address. For example:
10010110.11010111.00010001.00001001 150.215.017.009
11111111.11111111.00000000.00000000 255.255.000.000
--------------------------------------------------------
10010110.11010111.00000000.00000000 150.215.000.000
This result may seem familiar to you because Class A, B and C addresses have a self encoded or default subnet mask built in.
Class A - 255.0.0.0
Class B - 255.255.0.0
Class C - 255.255.255.0
Or in binary form
Class A - 11111111.00000000.00000000.00000000
Class B - 11111111.11111111.00000000.00000000
Class C - 11111111.11111111.11111111.00000000
More restrictive subnet masks
Additional bits can be added on to the self encoded subnet mask for a given class to further subnet a network. When a bitwise and is performed between on the subnet mask and IP address the result from the addition bits defines the subnet address. However there are some restrictions on the subnet address. Network addresses of all 0's and all 1's are reserved for specifying this network (when a host does not know its network address) and all hosts (broadcast address) respectively. This also applies to subnets. Therefore:
A subnet address cannot be all 0's or all 1's.
This also implies that a 1 bit subnet mask is not allowed.
Here is an example:
10010110.11010111.00010001.00001001 150.215.017.009 IP Address
11111111.11111111.11110000.00000000 255.255.240.000 Subnet Mask
--------------------------------------------------------
10010110.11010111.00010000.00000000 150.215.016.000 Network address
In the previous example a 4 bit subnet mask was used. The subnet in this case was 1. There are 14 subnets available with this mask (remember subnets with all 0's and all 1's are not allowed). Each subnet has 4,094 nodes (because of broadcast and network restrictions). This gives a total of 57,316 nodes for the entire class B address. Notice that this is less than the 65,534 nodes an unsubnetted class B address would have. Subnetting always reduces the number of possible nodes for a given network. To calculate the number of subnets or nodes use the following where n = number of bits in either the subnet or node field.
n
Max nodes = 2 - 2
multiplying the number of subnets by the number of nodes available per subnet gives you the total number of nodes available for you class and subnet mask. Note that although subnet masks with non-contiguous mask bits are allowed they are not recommended.