Calculate network ranges, subnet masks, broadcast addresses, and usable hosts for any IPv4 configuration.
An IPv4 address is a 32-bit number split into four 8-bit octets. The subnet mask determines how many bits belong to the network portion versus the host portion. Given a prefix length (CIDR), we compute the mask as all 1s for the first N bits and 0s for the remaining (32−N) bits. The network address is obtained by performing a bitwise AND of the IP and mask. The broadcast address sets all host bits to 1 (network OR inverse of mask). Usable host addresses span from network+1 to broadcast−1, giving 2(32−N) − 2 assignable addresses for subnets larger than /30.