Subnet mask is a 32 bits long address used to distinguish between network address and host address in IP address. Subnet mask is always used with IP address. Subnet mask has only one purpose, to indentify which part of an IP address is network address and which part is host address. With subnetting, IP addresses use a 3-layer hierarchy:
Improves efficiency of IP addresses by not consuming an entire address space for each physical network. Reduces router complexity. Since external routers do not know about subnetting, the complexity of routing tables at external routers is reduced. Note: Length of the subnet mask need not be identical at all subnetworks. For example how will we figure out network partition and host partition from IP address 192.168.1.10 ? Here we need subnet mask to get details about network address and host address. In decimal notation subnet mask value 1 to 255 represent network address and value 0 [Zero] represent host address. In binary notation subnet mask on bit [ 1] represent network address while off bit represent host address.
In decimal notation
IP address 192.168.1.10
Subnet mask 255.255.255.0
Network address is 192.168.1 and host address is 10.
In binary notation
IP address 11000000.10101000.00000001.00001010
Subnet mask 11111111.11111111.11111111.00000000