Sub topic 4
Why classful addressing was replaced
This chapter assumes you can convert between binary and decimal for values 0 to 255. It also assumes you know that an IPv4 address splits into a network part and a host part. Here you will see the older scheme that fixed that split, and why it was abandoned.
How classful addressing worked
Before 1993, the network/host split was not written down anywhere. A router inferred it from the first bits of the address. Those bits placed the address in one of five classes.
| Class | First bits | First octet | Implied prefix | Usable hosts per network |
|---|---|---|---|---|
| A | 0 | 0–127 | /8 | 16,777,214 |
| B | 10 | 128–191 | /16 | 65,534 |
| C | 110 | 192–223 | /24 | 254 |
| D | 1110 | 224–239 | none (multicast) | not applicable |
| E | 1111 | 240–255 | none (reserved) | not applicable |
Classes A, B, and C carried ordinary unicast traffic. Class D was for multicast and class E was reserved. Because the class fixed the mask, routing protocols did not need to carry a mask at all.
The following script mimics that inference:
import ipaddress
def classful_prefix(addr):
first = int(ipaddress.ip_address(addr)) >> 24
if first < 128:
return "A", 8
if first < 192:
return "B", 16
if first < 224:
return "C", 24
return None, None
for addr in ["10.1.2.3", "172.16.5.9", "192.168.1.1"]:
cls, prefix = classful_prefix(addr)
print(addr, cls, prefix, 2 ** (32 - prefix) - 2)
# 10.1.2.3 A 8 16777214
# 172.16.5.9 B 16 65534
# 192.168.1.1 C 24 254Problems with fixed sizes
Only three network sizes existed, and they were far apart. This caused three problems.
- Wasted addresses. An organization with 300 hosts could not fit in a class C (254 usable). It received a class B instead, and about 65,234 of its 65,534 usable addresses (over 99%) sat unused.
- Address exhaustion. Class B space was the popular choice for mid-sized organizations, and it ran short in the early 1990s.
- Routing table growth. Organizations that were refused a class B often took several class C networks. Each one needed its own routing table entry, and the entries could not be combined, because the classful rules gave routers no way to describe a group of networks as one route. Backbone tables grew quickly.
Subnetting (RFC 950, 1985) let an organization split its own network internally. It did not help here, because the outside world still saw one fixed class boundary.
The CIDR fix
Classless Inter-Domain Routing (CIDR) dropped the classes. Every route carries an explicit prefix length, so a network can be any size from /0 to /32. This solved both problems.
- Right-sized allocation. The 300-host organization needs 302 addresses including the network and broadcast addresses. A /23 holds 512 addresses (510 usable), so it wastes far less than a class B.
- Aggregation. Contiguous blocks can be advertised as one shorter prefix. Later chapters cover this as route summarization.
Common errors
- Assuming the mask from the first octet.
192.168.1.0/25is valid and is not a class C network. The /25 is what counts. - Reading class C as "small." Class membership says nothing about how big a subnet is today.
- Forgetting 127.0.0.0/8. It sits in the old class A range but is reserved for loopback.
Exercise
A company needs 1,000 host addresses. Which classful network would it have received, how many usable addresses would go unused, and what single CIDR prefix fits the need with much less waste?
Show answer
A class C holds only 254 usable hosts, so it would have received a class B (/16, 65,534 usable). That leaves 65,534 − 1,000 = 64,534 unused. Under CIDR, a /22 provides 1,024 addresses (1,022 usable), which covers the 1,000 hosts with only 22 spare.