Sub topic 4
The Original Classful Scheme
This chapter assumes you can convert between decimal and binary octets and that you know an IPv4 address has 32 bits written as four octets. It explains how the first IPv4 design divided addresses into classes, why that worked at first, and why it failed. Subnet masks and CIDR, which replaced it, come in later chapters.
The problem classes were meant to solve
A router that gets a packet must decide which network the destination address belongs to. To do that, it needs to know where the network part of the address ends and the host part begins. Every address is just 32 bits, and nothing in the bits marks the boundary.
The original IPv4 specification (RFC 791, 1981) solved this without any extra information. It built the boundary into the address itself. The first few bits of an address say which class it belongs to, and each class has a fixed boundary. A router only has to look at the leading bits.
Five classes, identified by leading bits
A class is a category of addresses that shares a fixed network/host split. The classes are named A through E. The class is set by the leading bits (the first bits of the first octet).
| Class | Leading bits | First octet range | Network bits | Host bits | Purpose |
|---|---|---|---|---|---|
| A | `0` | 0–127 | 8 | 24 | Very large networks |
| B | `10` | 128–191 | 16 | 16 | Medium networks |
| C | `110` | 192–223 | 24 | 8 | Small networks |
| D | `1110` | 224–239 | none | none | Multicast |
| E | `1111` | 240–255 | none | none | Reserved for experiments |
Only classes A, B, and C describe ordinary networks of hosts. Class D addresses name groups of receivers (multicast), and class E was set aside and never assigned for general use. Neither has a network/host split. The next chapter covers the exact ranges and default masks in detail. Here the point is the mechanism: the pattern of leading bits decides everything.
The decision is a short chain of questions about the leading bits.
Each "no" answer moves one bit further to the right. This is why the ranges look uneven: class A takes half of all addresses (the first bit is 0), class B a quarter, class C an eighth, and so on.
Worked example: classifying 172.16.5.4
- Take the first octet:
172. - Convert it to binary: 172 = 128 + 32 + 8 + 4, so
10101100. - Read the leading bits: they begin
10, so this is class B. - Class B uses 16 network bits, so the network part is the first two octets,
172.16, and the host part is the last two,5.4.
Every address that starts with 172.16. is in the same class B network, and a router needs no other information to know that.
Classifying in code
The following program reads the leading bits directly, the same way the diagram does.
def classify(address):
first = int(address.split(".")[0])
bits = format(first, "08b")
if bits[0] == "0":
return "A"
if bits[:2] == "10":
return "B"
if bits[:3] == "110":
return "C"
if bits[:4] == "1110":
return "D"
return "E"
for text in ["10.1.2.3", "172.16.5.4", "192.168.0.1", "224.0.0.5", "240.0.0.1"]:
first = int(text.split(".")[0])
print(text, format(first, "08b"), classify(text))The output is:
10.1.2.3 00001010 A
172.16.5.4 10101100 B
192.168.0.1 11000000 C
224.0.0.5 11100000 D
240.0.0.1 11110000 EComparing leading bits and comparing the numeric ranges (below 128, below 192, and so on) give identical results. The ranges in the table are just the leading-bit patterns written in decimal.
What each class could hold
The fixed split sets how many networks and how many hosts per network each class can describe. Two host addresses in every network are reserved (the all-zeros host part names the network, and the all-ones host part is the broadcast address), so usable hosts are 2^h − 2, where h is the number of host bits.
| Class | Networks | Usable hosts per network |
|---|---|---|
| A | 128 (2^7) | 16,777,214 |
| B | 16,384 (2^14) | 65,534 |
| C | 2,097,152 (2^21) | 254 |
The network count is the number of different values the free network bits can take. Class A has 7 free bits after the leading 0. Class B has 14 after 10. Class C has 21 after 110.
Why the scheme failed
Classes were simple, and in the early internet with few networks they were enough. Growth exposed three problems.
Wasted addresses
An organization could only get a whole class A, B, or C network. There was nothing between 254 hosts and 65,534 hosts. A company with 2,000 machines was too large for a class C, so it received a class B. That left roughly 63,500 addresses unused, and no one else could use them. Early large allocations of class A blocks to single organizations wasted millions of addresses the same way.
Routing table growth
An organization could instead get several class C networks. Four class C networks hold 4 × 254 = 1,016 hosts. That avoids the waste, but each network is a separate entry in every core router's routing table. As more organizations did this, the table grew faster than router memory and processing power could comfortably handle.
Exhaustion of the middle classes
Class B was the popular size, and there were only 16,384 of them. They ran out quickly. Class C networks were too small for many organizations, and class A networks were too few and too large. The address space was not exhausted in total, but the shapes on offer did not match the demand.
These problems led to two changes. Subnetting let an organization split one block into smaller networks internally. CIDR removed the fixed class boundaries altogether. Both are covered in the following chapters.
Gotchas and common errors
- Classes are not used for routing today. Modern routers use an explicit mask or prefix length for every route. An address's class says nothing about the actual size of its network. For instance,
192.168.1.0/25is in the old class C range but holds only 126 hosts. - Class survives in names and old software. Terms like "class C network" are still used informally for a /24. Some old protocols, such as RIP version 1, carry no mask in their updates and so assume the classful boundary. Mixing them with modern subnets causes missing or wrong routes.
- Reading the class from the wrong octet. Only the first octet matters.
10.200.200.200is class A because of the10, even though the later octets are large. - Treating class D and E as host ranges. Addresses from 224.0.0.0 upward are not assigned to ordinary hosts. A "host" with a 224.x address is a configuration error.
- Confusing the class with public or private status. The private ranges (such as
172.16.0.0/12) overlap several classes and do not line up with class boundaries. A later chapter covers them.
Exercise
The address 199.45.7.1 starts a new job's network plan. (a) Which class is it? (b) How many bits make up its network part under the classful scheme? (c) Why would a company that needs 3,000 hosts have found classful allocation awkward?
Show answer
(a) The first octet is 199, which is 11000111 in binary. The leading bits are 110, so it is class C. (b) Class C uses 24 network bits, so the network part is 199.45.7 and the host part is the last octet. (c) A class C holds only 254 hosts, which is too small. The next size up, class B, holds 65,534 hosts, so the company would waste about 62,500 addresses. The alternative, 12 class C networks (12 × 254 = 3,048 hosts), would need 12 separate routing table entries.
Exercise
Without converting to decimal ranges, classify addresses whose first octets in binary are 01111111, 10000001, 11011111, and 11101111.
Show answer
01111111 begins with 0, so class A (this is 127, which is reserved for loopback). 10000001 begins with 10, so class B (129). 11011111 begins with 110, so class C (223). 11101111 begins with 1110, so class D (239, multicast).