The Mathematics of Subnetting
An IPv4 address consists of 32 binary bits divided into four 8-bit octets. A subnet mask tells routers which portion of those 32 bits identifies the Network (Subnet ID) and which portion identifies individual Hosts:
- Bitwise AND Operation: A router performs a bitwise AND between the destination IP and the subnet mask. If the resulting Network ID matches its routing table, it knows the packet belongs on the local wire.
- Network Address: All host bits set to binary
0. Reserved to identify the network. - Broadcast Address: All host bits set to binary
1. Reserved for broadcasting data to all hosts on the subnet.
