What is a Subnet Mask:
As the name suggests it is a mask for IP address. It is a 32 bit number which divides the IP address into two parts i.e. the network address and host address. Subnet mask sets the networking bits to all 1s and the host bits to all 0s. Subnet mask divides the IP address into network address and host address () which is further divides the host part into subnet address and host address (). This division is done only if required. There are two host addresses which are always reserved for special purpose. These addresses are always present in all the networks. The network address is assigned all 0s and the broadcast address is assigned 255.
Subnet mask is used to know the network address of an IP address. It performs a bitwise AND operation on the net mask. For security purposes and for reorganization, big networks are divided into small and multiple networks. This process of separating a big network is called Sub-netting. In a sub network, all the nodes can view all the data packets which are transmitted by any node. At the time of heavy traffic, the performance of the network is badly affected due to the collision of multiple packets and retransmission. By using a subnet mask we can separate the network address from the host address of an IP address.