Sub topic 4
Why Classful Addressing Was Replaced
This chapter assumes you can convert between binary and decimal for values 0 to 255, and that you know an IPv4 address has 32 bits split into a network part and a host part. It explains the system that CIDR replaced, why that system failed, and which of its habits still show up in practice.
The classful scheme
Before 1993, the network part of an IPv4 address had a fixed length that depended on the first bits of the address. There were no subnet masks in the original design. A router read the leading bits and knew immediately how many bits identified the network. The scheme defined five classes.
| Class | Leading bits | First octet range | Network bits | Host bits | Hosts per network (usable) |
|---|---|---|---|---|---|
| A | 0 | 0 to 127 | 8 | 24 | 16,777,214 |
| B | 10 | 128 to 191 | 16 | 16 | 65,534 |
| C | 110 | 192 to 223 | 24 | 8 | 254 |
| D | 1110 | 224 to 239 | not applicable | not applicable | multicast groups |
| E | 1111 | 240 to 255 | not applicable | not applicable | reserved |
Only classes A, B, and C carried ordinary host addresses. Class D was set aside for multicast, and class E was reserved for experiments.
Because the class came from the leading bits, a router could find the network boundary from the address alone. The address 172.16.37.200 starts with the bits 10, so it is class B. Its network is 172.16.0.0, and the last two octets are the host part.
Where the design failed
Three sizes of network (about 16 million, 65 thousand, or 254 hosts) fit real organizations badly. The mismatch caused two separate problems.
Wasted address space
An organization with 300 hosts could not use a class C, which holds 254. It had to take a class B, which holds 65,534. That left more than 65,000 addresses assigned to an organization that would never use them. Nobody else could use those addresses either, because the assignment was a whole network.
Class A networks were worse. Only 126 of them were usable, and each held about 16.7 million addresses. Large companies, universities, and government bodies received them, often using a small fraction of the space.
Class B was the most popular size for mid-sized organizations, and it ran out fastest. By the early 1990s, projections showed that the class B pool would be exhausted within a few years.
Routing table growth
Organizations that needed more than 254 hosts but did not want to waste a class B could request several class C networks instead. This preserved class B space but created a different problem. Each class C was a separate entry in every core router's routing table. An organization with eight class C networks consumed eight entries, and there was no rule that made those networks adjacent in the address space.
At the time, the global routing table was growing faster than router memory and processing power could follow. The two pressures pushed in opposite directions. Handing out class B networks drained the address space. Handing out many class C networks overloaded the routing tables.
Subnetting as a partial fix
Subnetting, standardized in the mid-1980s, let an organization divide one classful network into smaller internal networks by borrowing host bits. A class B network could be split into 256 subnets that each looked like a class C.
Subnetting helped organizations manage their internal space. It did not fix the problems above, for two reasons:
- It was invisible outside the organization. The rest of the Internet still saw one class B network, and the allocation of whole classful blocks did not change.
- Early classful routing protocols such as RIP version 1 did not carry the subnet mask in their updates. Every subnet of a network had to use the same mask, because a router had no way to learn a different one. This is the reason variable-length subnet masking (covered later in this tutorial) needed new protocols.
CIDR
Classless Inter-Domain Routing (CIDR) was introduced in 1993 and removed the class as a rule for finding the network boundary. Each prefix carries its own length, written after a slash, as in 203.0.113.0/24. The prefix length can be any value from 0 to 32.
CIDR addressed both problems:
- Right-sized allocation. The 300-host organization can receive a /23, which holds 510 usable hosts, instead of a /16. Allocations can grow or shrink in powers of two.
- Aggregation. A provider receives a large block and hands out pieces of it to customers. Outside the provider, the whole block appears as one routing entry. This is route summarization, which a later chapter covers.
The routing change was as important as the addressing change. Routers and routing protocols had to carry the prefix length with every route. BGP version 4 and later versions of RIP and OSPF do this.
import ipaddress
# 300 hosts: compare a classful choice with a CIDR choice
class_b = ipaddress.ip_network("172.16.0.0/16")
cidr = ipaddress.ip_network("172.16.0.0/23")
needed = 300
for label, net in (("class B", class_b), ("/23", cidr)):
usable = net.num_addresses - 2
print(label, net, "usable:", usable, "unused:", usable - needed)
# class B 172.16.0.0/16 usable: 65534 unused: 65234
# /23 172.16.0.0/23 usable: 510 unused: 210What survives from the classful era
The class system is gone from routing and allocation, but its vocabulary and defaults persist, and they cause confusion.
- Terms. People still say "class C" to mean a /24, "class B" for a /16, and "class A" for a /8. This is shorthand for the prefix length only. A /24 carved from 10.0.0.0 is not a class A network, and a /24 carved from a class A range is still a /24.
- Multicast and reserved ranges. The 224.0.0.0/4 multicast range matches the old class D, and 240.0.0.0/4 matches class E. These are still meaningful.
- Private ranges. RFC 1918 defined 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16. The sizes line up with one class A, sixteen class B networks, and 256 class C networks, but they are written and handled as CIDR prefixes.
- Legacy defaults. Some old software and equipment assume a classful mask if none is given. A device configured with 10.1.1.5 and no mask might assume /8. Always give an explicit mask or prefix length.
Common mistakes
- Saying a block is "a class C" when you mean its size. A /26 is neither a class C nor a class anything. State the prefix length.
- Assuming a router must find the network from the first octet. Modern routers use the prefix length stored with each route.
- Thinking CIDR only affects subnetting. CIDR also changed how addresses are allocated to providers and how routes are advertised between networks.
- Confusing the default classful mask with the configured mask. On a modern device, the configured mask is what counts.
Exercise
An organization needs addresses for 1,000 hosts. Under classful addressing, which class would it have to take and how many usable addresses would it receive? Which CIDR prefix fits instead, and how many usable hosts does it provide?
Show answer
A class C holds only 254 usable hosts, so the organization would need a class B, which provides 65,534 usable addresses and leaves 64,534 unused. With CIDR, a /22 fits: 32 - 22 = 10 host bits gives 1,024 addresses, and 1,022 are usable. That is enough for 1,000 hosts with 22 spare.
Exercise
The first octet of an address is 150. Under the classful rules, what class is it, how many bits identify the network, and what is the network address of 150.20.7.9? Why does this rule give the wrong answer on a modern network that uses CIDR?
Show answer
150 is between 128 and 191, so the address is class B with 16 network bits, and the classful network is 150.20.0.0. On a CIDR network the prefix length is configured separately. If 150.20.7.9 is in a /24, its network is 150.20.7.0, and if it is in a /22, its network is 150.20.4.0. The first octet does not determine the boundary.