Sub topic 5
Class Ranges and Default Masks
This chapter assumes you can convert an octet between decimal and binary, and that you know an address has a network part and a host part. It covers how the first bits of an address decided its class, what range each class spans, and which default mask each class carried.
How the first bits set the class
In the classful scheme, a router found the network/host boundary from the address alone. It read the leading bits of the first octet.
- Class A starts with
0. - Class B starts with
10. - Class C starts with
110. - Class D starts with
1110. - Class E starts with
1111.
Because the leading bits are fixed, each class covers a continuous range of first-octet values.
Ranges and default masks
| Class | Leading bits | First octet | Default mask | Prefix | Network bits | Host bits |
|---|---|---|---|---|---|---|
| A | 0 | 0-127 | 255.0.0.0 | /8 | 8 | 24 |
| B | 10 | 128-191 | 255.255.0.0 | /16 | 16 | 16 |
| C | 110 | 192-223 | 255.255.255.0 | /24 | 24 | 8 |
| D | 1110 | 224-239 | none | none | n/a | n/a |
| E | 1111 | 240-255 | none | none | n/a | n/a |
Class D is used for multicast, where one packet goes to a group of receivers. Class E is reserved. Neither has a network/host split, so neither has a default mask.
Worked example
Take 172.16.5.4. The first octet is 172, which is between 128 and 191, so the address is class B. In binary, 172 is 10101100, and the leading 10 confirms it. The default mask is 255.255.0.0, so the network part is 172.16 and the host part is 5.4. The network address is 172.16.0.0.
The function below applies the same rule and returns the class together with its default mask.
def classful_info(address):
first = int(address.split(".")[0])
if first < 128:
return "A", "255.0.0.0"
if first < 192:
return "B", "255.255.0.0"
if first < 224:
return "C", "255.255.255.0"
if first < 240:
return "D", None
return "E", None
for text in ["10.1.2.3", "172.16.5.4", "192.168.0.1", "224.0.0.5", "250.1.1.1"]:
print(text, classful_info(text))Running it prints class A, B, C, D, and E for the five inputs, with a mask only for the first three.
Common errors
- Counting 127 as an ordinary class A network. Class A spans 0-127 on paper, but
0.0.0.0/8and127.0.0.0/8are set aside for special purposes. They are covered in a later chapter. - Assuming the class is a property of the mask. The class comes only from the first octet. A host in
10.0.0.0could still be given a different mask today, which is the subject of the subnetting and CIDR chapters. - Mixing up the boundaries. 128, 192, 224, and 240 start a new class. 191 is class B, and 192 is class C.
- Giving a class D or E address a mask. These ranges have no host part, so they are not assigned to individual hosts.
Exercise
Exercise
For the address 200.100.50.25, state the class, the default mask in dotted decimal and prefix form, the network part, and the host part.
Show answer
The first octet is 200, which falls in 192-223, so the class is C. The default mask is 255.255.255.0, or /24. The network part is 200.100.50 (network address 200.100.50.0) and the host part is 25.
Exercise
A first octet is 01111111 in binary. Which class does it belong to by range, and why is it not used for normal hosts?
Show answer
It is 127, which falls in the class A range 0-127. The block 127.0.0.0/8 is reserved for loopback, so it is not assigned to ordinary hosts.