Subnet Masks: To Stop Local Detail Reaching Every Router
Networking
The arithmetic of a network mask takes about a paragraph. Who the arithmetic was for takes longer, and a standard from 1985 and the classless plan from 2006 both answer that the same way. Neither answer is the host sitting behind the mask.
What the figure after the slash fixes
RFC 4632 carries the category Best Current Practice, the number BCP 122, and a publication date of August 2006. It defines the notation in a single clause: a prefix is written as a four-octet quantity, then a slash, then “a decimal value between 0 and 32 that describes the number of significant bits”.
Significant there means fixed. Working an example of a legacy sixteen-bit network, the document spells out what the figure stands for, which is that “the mask to extract the network portion of the prefix is a 32-bit value where the most significant 16 bits are ones and the least significant 16 bits are zeros”. Written out in full a mask looks like an address without being one. It is a run of ones followed by a run of zeros, and the figure records where the ones stop.
One rule is what makes a single figure enough. The specification accepts an arbitrary network number and mask for any routing destination, and then attaches a limit to that freedom: “The only outstanding constraint is that the mask must be left contiguous.” Ones gathered at the left can be described by counting them. Ones with gaps between them could not be, and would need all thirty-two positions written out.
Thirty-three sizes stand where three used to. What replaced the classes is not a fourth size but a scale, because “Where formerly only three network sizes were available”, a prefix may now describe “any power of two-sized block” of addresses. A table in the document runs from a single address, labelled a host route, down to a prefix of length zero, labelled the default route. Of its thirty-three rows, three carry a note naming the legacy class they used to be.
That boundary is the figure’s entire content. A host’s use of the result, on every packet it sends, is a decision of its own.
Where the mask came from, and what it beat
The mask is older than the slash. RFC 950, from August 1985, is the subnetting procedure itself, and its status section states its force plainly: “If subnetting is implemented it is strongly recommended that these procedures be followed.”
Its second section does something specifications seldom do on the page. It lists five candidate ways of marking which bits of the local part identify a subnet, weighs them, and names the winner. Two of the five are a plain field of variable or fixed width. Another two are self-encoding variants, in which the width of the subnet field would itself be encoded in the address, exactly as the class already was. The fifth is a bit mask, “to identify which bits of the local address field indicate the subnet number”.
Self-encoding was the interesting loser, and it lost on a side effect. Encoding the width in the address would have allowed a network to be divided into subnets of several sizes, and the document works that example: one subnet taking half the space, with eight small ones sharing the rest. Its cost is that every address would then announce whether its network was divided at all, where the document states that “it is useful to be able to control whether a network is subnetted independently from the assignment of host addresses”.
Cost settled the rest. Some per-network flag was needed in any case, so “the additional cost of using an integer (a subnet field width or address mask) instead of a boolean is negligible”, and an integer buys the freedom to put the boundary anywhere. One line carries the conclusion: “Therefore, we choose the address-mask scheme: it is the most flexible scheme, yet costs no more to implement than any other.”
One detail of that choice did not survive. Because a mask names the bits, the 1985 document notes that they “need not be adjacent in the address”, and recommends only that they be contiguous and sit at the front. By 2006 the recommendation had become the rule.
The values that were spoken for before you arrived
A block of a given size does not hand you that many usable addresses, and the reason predates subnetting. RFC 950 imports a convention from the Assigned Numbers memo of the day, under which a field of all zeros stands for the thing itself, as in this network, and a field of all ones stands for the whole of it, as in all hosts. An address built either way picks out a network, or everything on one, rather than a machine.
Having quoted that convention, the document extends it one level down. Its wording is that the interpretation of these special addresses “is useful to preserve and extend” in subnetted networks, and the consequence follows: “This means the values of all zeros and all ones in the subnet field should not be assigned to actual (physical) subnets.” Notice which field that sentence is about. It is the subnet part rather than the host part, so the reservation costs a network two of its subnets, on top of the addresses already spoken for inside each one. In the worked example a six-bit subnet field “may have any value except 0 and 63”, which leaves sixty-two usable out of sixty-four.
Host-side reservations survive into the modern arithmetic. RFC 4632’s history section puts the end systems in a legacy twenty-four-bit network at 254, arriving there from 256 bit combinations less the reserved all-zeros pattern and its all-ones counterpart. So the figure after the slash gives you the size of a block and nothing about your allowance inside it.
Which numbers are reserved, and for what, belongs to a different list.
Why anyone was counting bits at all
RFC 950’s motivation section starts with an organisation that has outgrown a single cable, and gives it three options. Two of the three keep a single network number for the whole organisation. The remaining one, which the document turns down, is to take a separate network number for every cable and not use subnets at all. That needs no new protocol. It is refused all the same, because it “results in an explosion in the size of Internet routing tables. Information about the internal details of local connectivity is propagated everywhere, although it is of little or no use outside the local organization.”
That sentence is the whole case for the mask. Dividing a network from the inside, with a locally chosen boundary, keeps the shape of one organisation’s cabling out of everyone else’s equipment. Nothing in the argument is about the host behind the mask. Equipment elsewhere gains one entry where it would have carried several.
In 2006 the same instrument was turned round. RFC 4632 names its own purpose as conserving the address space and “limiting the growth rate of global routing state”, and the group convened in 1992 to study the problem had ranked table growth second of three, as “Growth of routing tables in Internet routers beyond the ability of current software, hardware, and people to effectively manage”. Its answer was to drop the classes and let a boundary sit anywhere, upwards as well as downwards, so that a provider’s many customer blocks fall inside one larger block. Why nothing else was available is stated without hedging: “The only commonly understood method for reducing routing state on a packet-switched network is through aggregation of information.”
Delegation downwards is what makes that work, and it leaves a trace. Space moves from the central authority to the regional registries in bit-aligned blocks of one fixed size, and onwards to providers in smaller ones. Fetch a registry record for a single address and what comes back describes the block it was allocated from. Named in that record is the holder of a prefix rather than of one number, alongside the identifier that holder is known by.
Reading a block you did not choose
The arithmetic travels in one direction only. Given an address and a length you can say how large the block is, where it starts, where it stops, and how many smaller blocks of a chosen size fit inside it. Given the address by itself you can say none of that, because the length is not carried in it. That was the 1985 decision, taken deliberately, so that one network’s internal divisions stayed its own business.
What can still be found is what somebody else has published against the block around it, and the page that asks that question concedes its limit in the opening line, before any result appears: not every address has a useful name against it. On a home connection an empty answer is the ordinary outcome rather than a fault.
Both documents repay reading for the same reason. Each treats a mask as an administrative instrument more than a technical one, and each names the party it was meant to spare. Count the bits when you need the size of a block. The count exists because the alternative was telling everybody.