Similar to the previous micromaterial on IP addresses, I decided to make something, primarily to help myself remember more details about netmasks.
The short explanation is they are used to specify subnets (sub-networks) within networks, mostly so we don’t run out of IP addresses (slide the dot all the way to the left to see the theoretical total number of available IP addresses!).
The interesting part comes in how they determine the network address and number of hosts available on the specified subnet. Since computers are all binary, we talk about the digital netmask (above, 255.255.248.0) or the bitmask (the same thing represented as 1’s and 0’s).
The way that the mask works is by calculating a bitwise AND (this is the first time I’ve actually understood what a bitwise operation is!) where all the 1’s on the netmask “let the IP bits through”, while the 0’s in the netmask turn the corresponding bits to 0 (that’s how we end up with 126.96.36.199 in the network address above).
The idea was to be able to physically move the binary mask values around to see how they affect things and get a more visual representation of what’s actually going on.
As a micromaterial, this focuses on exactly one thing and provides immediate feedback on how that thing affects some subnet properties. It also shows the CIDR suffix (which I also now FINALLY understand)…it’s just the number of 1’s in the netmask (/21 above)!
source code here