In simple IP networks, the subnet mask defines full octets as part of the network ID and host ID. A 255 represents an octet that is the part of the network ID, and 0 represents an octet that is part of the host ID. In complex IP networks, octets can be subdivided.
Why a subnet mask is required ?
When a computer delivers an IP packet, it uses the subnet mask to validate whether the destination is on the same network or on a remote network. If the destination is on the same network, the packet can be delivered by the computer. If the destination is on the different network, the computer must send the packet to a router for delivery.
In this above picture I have taken 3 users named emdadblog, blogspot, com.
For the first user Emdadblog I use 192.168.1.1 as a Host ID and 255.255.255.0 as a Subnet Mask.
For the Second user Blogspot I use 192.168.1.2 as a Host ID and 255.255.255.0 as a Subnet Mask.
For the Third user Com I use 192.168.2.1 as a Host ID and 255.255.255.0 as a Subnet Mask.
Now if I want to send a file through internet from Emdadblog to Blogspot, I can send the file easily. Because the subnet mask between Emdadblog and Blogspot are same. Although their Host ID is different but their Network ID are same
If I want to send to a file through internet from Emdadblog to Com, I can not send the file. Because Emdadblog user is using 192.168.1.0 Network ID and Com user is using 192.168.2.0 and their Network ID are not same. In this situation to send a file through internet from Emdadblog user to Com user, we need to use ROUTER.
Note : Router helps you to connect two different Network and it's works like as a connector.
Valid Subnet Masks
In a simple IP network, a subnet mask is composed of only 255s and 0s. Other values are not used. In addition, 255s appear at the beginning of the subnet mask and 0s appear at the end. In a valid subnet mask, 0s cannot be interspersed with 255s. Example of valid and invalid subnet masks are shown in the following table
|Valid Subnet Mask||Invalid Subnet Mask|