Each device has an IP address consisting of two parts: the client or host address and the server or network address. The subnet mask divides the IP address into host and network addresses, thereby determining which part of the IP address belongs to the device and which part belongs to the network.
Why do we need a subnet mask?
The subnet mask is part of the basic structure that most networks use to communicate between devices. In addition to the mask, this includes an IP address, gateway, or router.
When organizations require additional networks, subnets divide the IP address host element into smaller subnets. The purpose of the mask is to ensure the subnet creation process. Its name came from the fact that the subnet mask uses its own 32-bit number to mask the IP address.
Because the binary system is complex, each octet is converted to an expression in dot decimal notation arithmetic. The result is a typical decimal format for IP addresses, for example, 172.16.254.1.