Understanding IPv4 Supernetting: The Power of CIDR

Understanding IPv4 Supernetting: The Power of CIDR

Source: ZTE Documentation

Author: ZTE Documentation

We have all learned to divide a large network into several smaller networks through subnetting. But have you ever heard of aggregating numerous small networks into a larger network called a supernet?

That’s right! Today’s main character—supernetting—is a more magical way of networking created by upgrading and reorganizing the original format of IP addresses.

How “magical” is it? Let’s continue readingUnderstanding IPv4 Supernetting: The Power of CIDR

01
What is a supernet?

A supernet, also known as CIDR (Classless Inter-Domain Routing),

In simple terms, it is a method of aggregating multiple similar IP addresses into a single “address block.” The emergence of supernetting allows us to allocate IPv4 address space more efficiently.

The application of supernetting allows the internet to continue growing in scale before the large-scale use of IPv6.

Understanding IPv4 Supernetting: The Power of CIDR

02
Why create a supernet?

In traditional classification methods based on IP addresses, regardless of the type of address, the lengths of the network number and host number are fixed. Once the network number of this address is determined, it is of fixed length.

This “rigid” classification method not only lacks flexibility but also directly leads to redundancy in the information generated when routers exchange routing tables.

Understanding IPv4 Supernetting: The Power of CIDR

Therefore, using route aggregation to construct supernets helps reduce the exchange of routing selection information between routers, thereby improving the overall performance of the internet and avoiding redundancy in routing information. After performing aggregation, the routing table, which originally contained thousands of forwarding information, transforms into a “slim” routing table with possibly only a few routing entries.

03
How does supernetting aggregate?

Next, let’s look at a small example. As shown in the figure below, before supernetting, every time the router exchanges routing information, R2 receives 5 updated routing messages from R1.

Understanding IPv4 Supernetting: The Power of CIDR

(Here we omit the conversion relationship between decimal and binary, after all, we are all clever communication peopleUnderstanding IPv4 Supernetting: The Power of CIDR)

Supernetting will group IP addresses with the same network prefix into a “CIDR address block,” also known as an aggregated address block.

When we convert the five address entries in the above figure to binary, we find that their first 20 bits are the same. Therefore, we take these 20 bits as the common prefix in the address block, while the remaining 12 bits will be defaulted to0 as the host number in the address block.

After aggregating these five address entries, we form a CIDR address block: 168.100.128.0/20. At this point, R2 will only receive one CIDR address entry when receiving R1’s routing table.

Tips

CIDR also uses “slash notation,” which adds a slash “/” after the IP address and then indicates the number of bits occupied by the network prefix.

As long as we know any address in the CIDR address block, and change the host number in the address to all 0s or all 1s, we can obtain the minimum and maximum addresses in this address block. The continuous addresses between the maximum and minimum addresses can all be represented by this CIDR address block. Simultaneously, based on the number of bits n in the host number of the address block, we can also determine the number of assignable addresses in this address block: 2n-2.

Tips

The “-2” is because the addresses where the host number is all 0s and all 1s are special addresses that are generally not used as source or destination addresses.

The aggregated address 168.100.128.0/20, when expanded to binary, allows us to easily derive the minimum and maximum addresses in this address block, as shown in the table below.

Minimum Address 168.100.128.0 10101000.01100100.1000 0000.00000000
Maximum Address 168.100.143.255 10101000.01100100.1000 1111.11111111

It is not difficult to calculate that this address block can contain 4096 addresses (4094 assignable addresses). We can indicate this address block with the minimum address in the block and the number of bits in the network prefix. For example, the minimum address block above can be noted as 168.100.128.0/20.

We are amazed to find that this minimum address is exactly the same as the aggregated address mentioned earlier!

Understanding IPv4 Supernetting: The Power of CIDR

04
How does supernetting match?

Since we mentioned the CIDR address block, we cannot overlook the longest prefix match mechanism that corresponds to it.

This is because when we look up routing table entries for routing selection, we may get more than one matching result. This raises the question: Which route should we choose from these matching results?

The correct answer is: We should choose the route with the longest network prefix from the matching results.

When a router receives an IP packet, it will compare the destination IP address of the packet with all the routing table entries in its local routing table bit by bit, and after the comparison, it will select the routing table entry with the longest match.

Understanding IPv4 Supernetting: The Power of CIDR

For example:

Suppose the 5th floor has just received an email from department X to department Y, with Y department’s IP address being: 192.31.71.128. A router on the 5th floor currently has the following routing table entries: 192.31.71.0/26 and 192.31.68.0/22. Which next-hop address should the router send the email to?

Routing Table Entry Corresponding Subnet Mask Next Hop Address
192.31.71.0/26 11111111.11111111.11111111.11000000 192.31.31.19
192.31.68.0/22 11111111.11111111.11111100.00000000 192.31.31.89
The destination address: The binary representation of 192.31.71.128 is: 11000000.00011111.01000111.10000000
Tips

It should be noted that although CIDR does not use subnetting anymore, since some networks still use subnet division and subnet masks, the 32-bit address mask used by CIDR can still be referred to as a subnet mask for convenience in routing selection.

For example, the address mask for a /20 address block is: 11111111 11111111 11110000 00000000 (20 consecutive 1s). The number after the slash in the slash notation indicates the number of 1s in the address mask.

By performing a logical AND operation between each routing table entry’s corresponding subnet mask and the binary expansion of the destination address, we can obtain: 192.31.71.0 and 192.31.68.0. The operation steps are shown in the figure below:

Understanding IPv4 Supernetting: The Power of CIDR

We find that the addresses obtained after the operation match the corresponding routing table entries, indicating that both routing entries can be used as next-hop addresses.

But! According to the longest prefix match mechanism, we should choose the next-hop address corresponding to routing table entry 1 as the forwarding address because the longer the network prefix, the smaller the address block, and the more specific the route.

05
Let’s summarize~
  • CIDR eliminates the traditional concepts of Class A, B, and C addresses and subnetting, allocating IPv4 address space more effectively, allowing IP addresses to return from three-level addressing (network number, subnet number, host number) back to a classless two-level addressing, as shown in the figure below.

Understanding IPv4 Supernetting: The Power of CIDR

  • CIDR also uses “slash notation,” which adds a slash “/” after the IP address and indicates the number of bits occupied by the network prefix. CIDR groups contiguous IP addresses with the same network prefix into a “CIDR address block,” thus forming a supernet.

  • When using CIDR, there may be more than one matching result in the routing table, in which case the route with the longest network prefix should be selected from all matching results, because the longer the network prefix, the smaller the address block, and the more specific the route.

This reprinted content only represents the author’s views.

It does not represent the position of the Institute of Semiconductors, Chinese Academy of Sciences.

Editor: Qian Niao

Understanding IPv4 Supernetting: The Power of CIDR

Leave a Comment