Classless Addressing
Classless Addressing
1. Why was classless addressing introduced?
In classful addressing, IPv4 addresses were divided into fixed classes:
-
Class A →
/8 -
Class B →
/16 -
Class C →
/24
This created a major problem: addresses were not allocated efficiently.
For example, suppose a company needed 500 addresses.
- A Class C network provides only 256 addresses → not enough.
- A Class B network provides 65,536 addresses → far too many.
So the organization might have been forced to receive a Class B block, wasting thousands of addresses.
This contributed to IPv4 address depletion.
Solution
The Internet introduced classless addressing.
The important idea is:
Forget the fixed classes and allocate address blocks of appropriate sizes.
Therefore, an organization can receive blocks such as:
1 address 2 addresses 4 addresses 8 addresses 16 addresses 32 addresses 64 addresses 128 addresses 256 addresses 512 addresses 1024 addresses ...
The number of addresses in a block must be a power of 2.
2. Classful vs Classless Addressing
This is the first distinction students should understand.
Classful addressing
The prefix length is fixed according to the class:
| Class | Prefix |
|---|---|
| A | /8 |
| B | /16 |
| C | /24 |
For example:
192.168.10.25
By looking at the first octet, we know it is Class C, so the default prefix is /24.
Classless addressing
There is no fixed class.
The prefix length is explicitly specified:
192.168.10.25/27
Here /27 tells us that:
- 27 bits → network/prefix
- 5 bits → host/suffix
The address itself does not tell us the size of its network.
This is a fundamental difference.
3. Prefix and Suffix
An IPv4 address has 32 bits.
In classless addressing, we divide it into:
Prefix | Suffix
The prefix identifies the network/block.
The suffix identifies a particular address within that block.
For example:
167.199.170.82/27
The /27 means:
Prefix = 27 bits Suffix = 32 - 27 = 5 bits
Therefore:
So this block contains 32 addresses.
4. Slash Notation / CIDR
This slash notation and formally associates it with Classless Inter-Domain Routing (CIDR).
For example:
12.24.76.8/8 23.14.67.92/12 220.8.24.255/25 167.199.170.82/27
The number after / is the prefix length.
It can range from:
/0 to /32
Very important rule
Larger prefix → smaller block
Smaller prefix → larger block
For example:
/16 → 65,536 addresses /24 → 256 addresses /27 → 32 addresses /30 → 4 addresses
Why?
Because:
where n is the prefix length.
5. Formula for Number of Addresses
This is one of the most important formulas in classless addressing.
If the prefix length is n:
where:
-
N= number of addresses -
n= prefix length
Example 1
Consider:
192.168.1.0/24
Here:
Therefore:
So /24 represents 256 addresses.
Example 2
Consider:
192.168.1.0/28
Here:
So /28 represents 16 addresses.
Example 3
Consider:
192.168.1.0/30
So a /30 block contains 4 addresses.
6. Example : Extracting information
Let's work through the example carefully.
Given:
167.199.170.82/27
Step 1: Find the number of addresses
Prefix:
n = 27
Therefore:
So there are 32 addresses in this block.
7. Finding the First Address
167.199.170.82 10100111 11000111 10101010 01010010
Since the prefix is /27:
27 bits = prefix 5 bits = suffix
Separate the last octet:
01010010
The first 27 bits are retained.
The last 5 bits are changed to 0.
01010010 ^^^ prefix bits ^^^^^ host bits
Set the last five bits to zero:
01000000
which is:
64
Therefore:
So the block is:
167.199.170.64/27
8. Finding the Last Address
Now keep the first 27 bits unchanged and set the last 5 bits to 1.
01011111
This is:
95
Therefore:
So:
167.199.170.64 ↓ 167.199.170.95
contains exactly:
addresses.
9. Complete Example Summary
For:
167.199.170.82/27
| Information | Result |
|---|---|
| Prefix length | /27 |
| Suffix bits | 5 |
| Number of addresses | 32 |
| First address | 167.199.170.64 |
| Last address | 167.199.170.95 |
So the block is:
167.199.170.64 ─────────────── 167.199.170.95 32 addresses
10. What is the Address Mask?
Another way to find the first and last addresses: the address mask.
An address mask is a 32-bit number where:
-
first
nbits are1 -
remaining
32-nbits are0
For /27:
11111111.11111111.11111111.11100000
Convert each octet to decimal:
255.255.255.224
So:
11. Finding the First Address Using AND
Let's use:
Address = 167.199.170.82 Mask = 255.255.255.224
Binary:
Address: 10100111.11000111.10101010.01010010 Mask: 11111111.11111111.11111111.11100000
Perform AND:
10100111 11000111 10101010 01010010 AND 11111111 11111111 11111111 11100000 -------------------------------- 10100111 11000111 10101010 01000000
Therefore:
First address = 167.199.170.64
12. Finding the Last Address Using OR
For /27:
Mask = 255.255.255.224Mask: 11111111.11111111.11111111.11100000
Its complement is:
00000000.00000000.00000000.00011111
0.0.0.31
Then:
167.199.170.82 10100111.11000111.10101010.0101001010100111.11000111.10101010.01011111
OR 0.0.0.3100000000.00000000.00000000.00011111
---------------- 167.199.170.95
Therefore:
First address = 167.199.170.64 Last address = 167.199.170.95
13. Why Do We Need the Prefix Length?
This is a very important conceptual point.
Consider the address:
230.8.24.56
By itself, this address does not tell us the block.
The same address can belong to different blocks depending on the prefix.
For example:
| Address | Prefix | Block |
|---|---|---|
| 230.8.24.56 | /16 | 230.8.0.0 – 230.8.255.255 |
| 230.8.24.56 | /20 | 230.8.16.0 – 230.8.31.255 |
| 230.8.24.56 | /26 | 230.8.24.0 – 230.8.24.63 |
| 230.8.24.56 | /27 | 230.8.24.32 – 230.8.24.63 |
| 230.8.24.56 | /29 | 230.8.24.56 – 230.8.24.63 |
This illustrates why:
In classless addressing, the IP address and prefix length must be considered together.
For example:
230.8.24.56/27
and
230.8.24.56/29
are not the same network.
14. Network Address
The first address in a block is called the network address.
For example:
167.199.170.82/27
belongs to the block:
167.199.170.64 – 167.199.170.95
Therefore:
Network address = 167.199.170.64
The network address is particularly important for routing.
A router uses the destination network information to determine the appropriate outgoing interface.
15. Block Allocation
Now we come to an important part of classless addressing: how blocks are allocated.
The global authority responsible for the ultimate allocation of addresses is ICANN(Internet Corporation for Assigned Names and Numbers)
Normally, addresses are allocated to ISPs, and the ISP can further divide its block among customers.
For example:
ICANN ↓ Large address block ↓ ISP ↓ Different smaller blocks ↓ Customers
This is much more efficient than giving every organization a complete Class A, B, or C network.
16. Two Important Restrictions on Block Allocation
Rule 1: Number of addresses must be a power of 2
The block size must be:
1 2 4 8 16 32 64 128 256 512 1024 2048 ...
It cannot normally be:
100 500 1000 1500
as a single CIDR block.
Why?
Because:
The number of addresses must correspond to an integer number of bits.
17. Example: 1000 Addresses
Suppose an ISP requests:
1000 addresses
But:
1000
is not a power of 2.
The next power of 2 is:
Therefore, the ISP must be allocated:
Now calculate the prefix:
Since:
we get:
Therefore:
The textbook gives an example block:
18.14.12.0/22
This represents:
addresses.
18. Second Restriction: Addresses Must Be Contiguous
The addresses in a block must be consecutive.
For example, a /24 block contains:
192.168.10.0 through 192.168.10.255
These are contiguous.
Similarly, a /26 block contains:
192.168.10.0 – 192.168.10.63
The addresses cannot be randomly selected from different portions of the IPv4 address space.
19. Third Important Idea: First Address Must Be Properly Aligned
The textbook gives another restriction:
The first address of the block must be divisible by the number of addresses in the block.
For example, a /26 block has:
addresses.
Therefore, valid starting points in the last octet are:
0 64 128 192
So these are valid:
192.168.1.0/26 192.168.1.64/26 192.168.1.128/26 192.168.1.192/26
But something like:
192.168.1.20/26
cannot be the network address of a /26 block.
20. Another Example: /28
Suppose we have:
192.168.5.37/28
Step 1: Number of addresses
So there are 16 addresses.
Step 2: Block boundaries
For /28, blocks occur in groups of 16:
0–15 16–31 32–47 48–63 64–79 ...
The address 37 falls in:
32–47
Therefore:
Network address = 192.168.5.32 Last address = 192.168.5.47
So:
192.168.5.37/28 ↓ 192.168.5.32 – 192.168.5.47
21. Another Example: /29
Consider:
192.168.10.75/29
Number of addresses:
So blocks occur in groups of 8:
0–7 8–15 16–23 ... 64–71 72–79 80–87 ...
75 belongs to:
72–79
Therefore:
Network address = 192.168.10.72 Last address = 192.168.10.79
22. Address Block Size and Prefix Length
Students often find this relationship confusing, so this table is useful:
| Prefix | Host bits | Number of addresses |
|---|---|---|
| /8 | 24 | 16,777,216 |
| /16 | 16 | 65,536 |
| /20 | 12 | 4,096 |
| /24 | 8 | 256 |
| /25 | 7 | 128 |
| /26 | 6 | 64 |
| /27 | 5 | 32 |
| /28 | 4 | 16 |
| /29 | 3 | 8 |
| /30 | 2 | 4 |
| /31 | 1 | 2 |
| /32 | 0 | 1 |
The pattern is:
Every time the prefix increases by 1, the number of addresses becomes half.
For example:
/24 → 256 /25 → 128 /26 → 64 /27 → 32 /28 → 16
23. Classful Addressing as a Special Case
An interesting observation:
Classful addressing can be considered a special case of classless addressing.
Why?
Because classful prefixes can simply be expressed using slash notation:
Class A → /8 Class B → /16 Class C → /24
For example:
10.0.0.0
as a Class A network can be written as:
10.0.0.0/8
Similarly:
172.16.0.0/16
and
192.168.1.0/24
So classless addressing generalizes the idea by allowing any prefix length from /0 to /32.
24. Why Classless Addressing Solves the Address Depletion Problem
Consider a company that needs approximately 1000 addresses.
Under classful addressing
It cannot get exactly 1000.
It might need a Class B block:
65,536 addresses
Most would remain unused.
Under classless addressing
The next power of 2 is:
1024
So it can receive:
/22
which provides:
1024 addresses
Only a small amount is wasted.
This is the major advantage:
CIDR allows address blocks to be allocated much closer to the actual requirement.
25. The Big Picture
CLASSFUL ADDRESSING │ │ Fixed classes ↓ A → /8 B → /16 C → /24 │ │ Address wastage │ Address depletion ↓ CLASSLESS ADDRESSING / CIDR │ │ Variable prefix ↓ /8 /12 /16 /20 /22 /24 /27 /30 ... │ ↓ More efficient address allocation
26. Important Formulas for Students
I would put these four formulas on the board.
Number of addresses
Prefix length from number of addresses
First address
Last address
And remember:
n = prefix length 32 − n = suffix/host bits
27. Summary
-
Classful addressing uses fixed prefix lengths:
/8,/16,/24. - Classless addressing removes the class restriction.
- The prefix length can be 0 to 32.
-
CIDR uses slash notation, such as
192.168.20.75/26. -
/26means 26 network/prefix bits and 6 suffix bits. -
Number of addresses is:
- Smaller prefix → larger block.
- Larger prefix → smaller block.
- The number of addresses in an allocated block must be a power of 2.
- Addresses in a block must be contiguous.
- The first address must be properly aligned with the block size.
- The first address is the network address and is important for routing.
- CIDR improves IPv4 address utilization and also supports route aggregation.
- IPv6 is the long-term solution for the limited IPv4 address space, while classless addressing/CIDR was a short-term solution using the existing 32-bit IPv4 address space.
Comments
Post a Comment