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.
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.
|Counting in Binary|
|Powers of 2||27||26||25||24||23||22||21||20|
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 22.214.171.124 would be converted and represented in binary form.
|Decimal||Broken Down||Binary Addition||Binary|
|First Octet||68||64 + 4||26 + 22||01000100|
|Second Octet||125||64 + 32 + 16 + 8 + 4 + 1||26 + 25 + 24 + 23 + 22 + 20||01111101|
|Fourth Octet||250||128 + 64 + 32 + 16 + 8 + 2||27 + 26 + 25 + 24 + 23 + 21||11111010|
The end result looks like 01000100011111010001000011111010.
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”.
|First Bit||Start Address||End Address|
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.
|Subnet Mask||Binary Format||Decimal Format|
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.
|Host Bits||Host Formula||Available Hosts|
|Class A||24-bit||224 – 2||16,777,214|
|Class B||16-bit||216 – 2||65,534|
|Class C||8-bit||28 – 2||254|
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.
|Subnet Mask||Network ID||Network Formula||Available 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.
|CIDR Notation||Host Formula||Available Hosts|
|/8||232-8 – 2||16,777,214|
|/9||232-9 – 2||8,388,606|
|/10||232-10 – 2||4,194,302|
|/11||232-11 – 2||2,097,150|
|/12||232-12 – 2||1,048,574|
|/13||232-13 – 2||524,286|
|/14||232-14 – 2||262,142|
|/15||232-15 – 2||131,070|
|/16||232-16 – 2||65,534|
|/17||232-17 – 2||32,766|
|/18||232-18 – 2||16,382|
|/19||232-19 – 2||8,190|
|/20||232-20 – 2||4,094|
|/21||232-21 – 2||2,046|
|/22||232-22 – 2||1,022|
|/23||232-23 – 2||510|
|/24||232-24 – 2||254|
|/25||232-25 – 2||126|
|/26||232-26 – 2||62|
|/27||232-27 – 2||30|
|/28||232-28 – 2||14|
|/29||232-29 – 2||6|
|/30||232-30 – 2||2|
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.
- Subtract the network bits from 32.
/17 = 32-17 and /21 = 32-21
- Raise 2 to that power.
232-17 and 232-21
- 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
CIDR Subnet Mask
The process to determine the subnet mask for a CIDR address is straight forward. The number of bits in the network portion of the address are converted to 1s and right padded with 0s until there are 32 numbers. The sequence of numbers is then divided into 4 octets. From then, it is a matter of converting the 4 octets from binary to decimal.
|CIDR Notation||Convert to 1s and Right Pad||Subnet Mask|