# Classless Inter Domain Routes (CIDR)

There are networks known as classful and classless. The first plan adopted and used widely by the Internet community were classful networks. So named because three address classes: A, B, and C were defined with assignable IP address space. These classes, however, disproportionately distributed the number of available IP addresses. A new method to identify networks and allocate IP addresses was needed to support the continued growth of the Internet. The new method is named classless because it does away with the idea of classes altogether. It is commonly known as Classless Inter-Domain Routing (CIDR). It is much more flexible than classful networks and is what the Internet uses today. Classful networks are still used by many devices, so it is important to understand both classful and classless networking.

### IPv4 Overview

An IPv4 address contains 32-bits. It is usually represented in dotted decimal quad notation so it is easier to read and communicate. Computers, of course, read this information in binary form. And in order to calculate subnet masks, network addresses, and broadcast addresses, the binary value must be known.

Converting a dotted decimal IP address to binary is simple. Given that there are 4 numbers, each decimal number is represented in binary as an octet. The high order bits in binary are always the leftmost ones.

The largest single value an IP address may have in decimal is 255 since this is the sum when all of the bits are added together, i.e. 27 + 26 + 25 + 24 + 23 + 22 + 21 + 20. When all of the bits are turned off, the number is 0. The range of an IP address is therefore 0 – 255, 256 values.

The following is how the IP address 68.125.16.250 would be converted and represented in binary form.

The end result looks like 01000100011111010001000011111010.

Classful Networks

Once an IP address is represented in binary format, the class of network can be determined rather easily. Beginning from the left of the IP address, the first bit that is not a “1” indicates whether it is a Class A, Class B, Class C, Class D, or Class E network.

For class A networks, the high order (leftmost) bit is always a “0”. For class B networks, the high order bits are always a “1” followed by a “0”. For class C networks, the high order bits are always a “1” followed by a “1” followed by a “0”.

Subnet masks represent what part of an IP address is used to determine network information versus host information. For a class B network, the subnet mask uses 16 bits, allowing the remaining 16 bits to be used for host information.

The total number of available hosts on a network can be determined from it’s subnet mask. Since a class B network uses 16 bits for its subnet mask, it leaves 16 bits available for host information. 216 = 65,536. All hosts need a network address and a broadcast address. The network and broadcast addresses are indicated by either all 1s or all 0s in the host information part of an IP address. With those two addresses always reserved, the total number of assignable hosts for a class B network is 216 – 2 = 65,534.

The total number of networks a class address may have is calculated by subtracting the number of bits in the subnet mask from the number of bits used to determine which class of network it is. For example, a class A network has an 8-bit subnet mask. Only 1 bit is used to determine that it is a class A network. Subtract 8 from 1 and that leaves 7 bits available for networks. 27 is 128. So, there is only room for 128 class A networks.

Classless Networks

Forget class A, B, and C now. Classless networks don’t use it at all, hence the name. Instead, CIDR networks are identified with a trailing “/” slash and a number that indicates how many bits are used to identify the network portion of the address. Like a class C address in classful networking, a /24 would indicate that 24-bits are used to identify the network and the remaining 8-bits are used to identify the host. Unlike classful networking, CIDR provides much more flexibility than 8, 16, and 24-bit network masks. Under CIDR, the number of bits used to indicate the network portion of the address can be from /8 to /30 although more commonly only /13 to /29 are used. This gives network administrators the flexibility to assign addresses from 6 – 524,286 to match the needs of an organization.

CIDR Available Hosts

The formula to calculate the number of assignable IP address to CIDR networks is similar to classful networking. Subtract the number of network bits from 32. Raise 2 to that power and subtract 2 for the network and broadcast addresses. For example, a /24 network has 232-24 – 2 addresses available for host assignment.

As the table indicates, two /29 networks equals a /28 network. Two /28 networks equals a /27 network. Two /27 networks equals a /26 network. And so on, and so on. The notion of combining two smaller networks into a larger one is another benefit of classless networks named supernetting. In order to create a supernet the smaller networks must be contiguous. For example, 192.0.2.240/29 and 192.0.2.248/29 can form a supernet 192.0.2.240/28, but 192.0.2.240/29 and 192.0.2.8/29 could not.

### CIDR Available Networks (subnetting)

How many /29 networks can fit into a /24 network? Or how many /21 networks can fit into a /17 network? The best way to explain the formula is to show it. The following illustrates how many /21 networks can fit into a /17 network.

1. Subtract the network bits from 32.
/17 = 32-17 and /21 = 32-21
2. Raise 2 to that power.
232-17 and 232-21
3. Divide the larger network by the smaller one.
232-17 / 232-21 = 215 / 211 = 215-11 = 24 = 16

As the example shows, a /17 network could be divided into sixteen /21 networks. Spot the shortcut in the steps? How many /29 networks in a /24?

• 28-3 = 25 = 32

1. Philip Edwards says: