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:

Number of addresses=25=32\boxed{\text{Number of addresses}=2^5=32}

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:

N=232−nN=2^{32-n}

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:

N=232−n\boxed{N=2^{32-n}}

where:

  • N = number of addresses
  • n = prefix length

Example 1

Consider:

192.168.1.0/24

Here:

n=24n=24

Therefore:


N=232−24
N=2^{32-24}
N=28=256N=2^8=256

So /24 represents 256 addresses.


Example 2

Consider:

192.168.1.0/28

Here:


N=232−28
N=2^{32-28}
N=24=16N=2^4=16

So /28 represents 16 addresses.


Example 3

Consider:

192.168.1.0/30

N=232−30
N=2^{32-30}

N=22=4
N=2^2=4

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:

N=232−27N=2^{32-27}
N=25
N=2^5
N=32\boxed{N=32}

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:

First address=167.199.170.64\boxed{\text{First address}=167.199.170.64}

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:

Last address=167.199.170.95\boxed{\text{Last address}=167.199.170.95}

So:

167.199.170.64
       ↓
167.199.170.95

contains exactly:

95−64+1=3295-64+1=32

addresses.


9. Complete Example Summary

For:

167.199.170.82/27

InformationResult
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 n bits are 1
  • remaining 32-n bits are 0

For /27:

11111111.11111111.11111111.11100000

Convert each octet to decimal:

255.255.255.224

So:

/27=255.255.255.224\boxed{/27 = 255.255.255.224}

The reason for defining a mask in this way is that it can be used by a computer program to extract the information in a block, using the three bit-wise operations NOT, AND, and OR.

1. The number of addresses in the block N = NOT (Mask) + 1.
2. The first address in the block = (Any address in the block) AND (Mask).
3. The last address in the block = (Any address in the block) OR [(NOT (Mask)].

11. Finding the First Address Using AND


First address=(Any address) AND (Mask)\boxed{\text{First address}=(\text{Any address})\ AND\ (\text{Mask})}

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


Last address=Address OR NOT(Mask)\boxed{\text{Last address}= \text{Address}\ OR\ NOT(\text{Mask})}

For /27:

Mask = 255.255.255.224
Mask:
11111111.11111111.11111111.11100000

Its complement is:

00000000.00000000.00000000.00011111
0.0.0.31

Then:

167.199.170.82   10100111.11000111.10101010.01010010
OR 0.0.0.31         00000000.00000000.00000000.00011111
---------------- 167.199.170.95
10100111.11000111.10101010.01011111

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:

AddressPrefixBlock
230.8.24.56/16230.8.0.0 – 230.8.255.255
230.8.24.56/20230.8.16.0 – 230.8.31.255
230.8.24.56/26230.8.24.0 – 230.8.24.63
230.8.24.56/27230.8.24.32 – 230.8.24.63
230.8.24.56/29230.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:

N=232−nN=2^{32-n}

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:

1024=2101024=2^{10}

Therefore, the ISP must be allocated:

1024 addresses\boxed{1024\text{ addresses}}

Now calculate the prefix:

n=32−log⁡2(1024)n=32-\log_2(1024)

Since:

log⁡2(1024)=10\log_2(1024)=10

we get:

n=32−10=22n=32-10=22

Therefore:

/22\boxed{/22}

The textbook gives an example block:

18.14.12.0/22

This represents:

232−22=210=10242^{32-22}=2^{10}=1024

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:

232−26=642^{32-26}=64

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

232−28=24=162^{32-28}=2^4=16

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:

232−29=23=82^{32-29}=2^3=8

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
/1616    65,536
/2012    4,096
/248    256
/257    128
/266    64
/275        32
/284    16
/293    8
/302    4
/311    2
/320    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

N=232−n\boxed{N=2^{32-n}}

Prefix length from number of addresses

n=32−log⁡2N\boxed{n=32-\log_2N}

First address

First=Address AND Mask\boxed{\text{First}=\text{Address AND Mask}}

Last address

Last=Address OR NOT(Mask)\boxed{\text{Last}=\text{Address OR NOT(Mask)}}

And remember:

n = prefix length
32 − n = suffix/host bits

27. Summary


  1. Classful addressing uses fixed prefix lengths: /8, /16, /24.
  2. Classless addressing removes the class restriction.
  3. The prefix length can be 0 to 32.
  4. CIDR uses slash notation, such as 192.168.20.75/26.
  5. /26 means 26 network/prefix bits and 6 suffix bits.
  6. Number of addresses is:

    232−n2^{32-n}
  7. Smaller prefix → larger block.
  8. Larger prefix → smaller block.
  9. The number of addresses in an allocated block must be a power of 2.
  10. Addresses in a block must be contiguous.
  11. The first address must be properly aligned with the block size.
  12. The first address is the network address and is important for routing.
  13. CIDR improves IPv4 address utilization and also supports route aggregation.
  14. 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

Popular posts from this blog

Computer Networks PCCST501 Semester 5 KTU CS 2024 Scheme - Dr Binu V P

Introduction to Computer Networks

TCP/IP Protocol Suite