IPv4: supernet, you are my “God”

We have all learned to divide the original large network into several small networks into subnets. But have you ever heard of a supernet that aggregates a large number of small networks into one large network?

correct! Our protagonist today – forming a supernet , is to upgrade and reorganize the original format of the IP address to create a more magical networking method.

How “magical” is it? let’s move on

1. What exactly is a supernet?

Constituting a supernet is also called CIDR (Classless Inter-Domain Routing, classless inter-domain routing).

In simple terms, it is a method of aggregating multiple IP addresses of the same type into an “address block”. The birth of the supernet allows us to allocate IPv4 address space more efficiently.

The use of supernets can allow IPv6 to continue to grow in size before large-scale use.

2. Why constitute a supernet?

In the traditional method of classifying IP addresses, no matter which type of address it is, the length occupied by the network number and the host number is fixed. As long as the network number of this address is determined, it is a fixed length.

This “stubborn” classification method is not only inflexible to use, but also directly leads to the redundancy of information generated when routers exchange routing tables.

Therefore, the use of route aggregation to construct a supernet is beneficial to reduce the exchange of routing information between routers, thereby improving the performance of the entire Internet and avoiding the redundancy of routing information. After some aggregation operations to form the supernet, the routing table that originally contained tens of thousands of forwarding information is transformed into a “thin” routing table Mini with only a few routing table entries.

3. How is the supernet aggregated?

Next, let us look at a small example, as shown in the figure below, before constructing a supernet, each time routers exchange routing information, R2 will receive 5 routing information updated by R1.

IPv4: supernet, you are my

(The conversion relationship between decimal and binary is omitted here, after all, we are all witty communicators)

To form a supernet, IP addresses with the same network prefix will form a “CIDR address block”, also known as an aggregated address block.

After converting the five addresses in the above figure into binary, we found that the first 20 bits of them are the same, so these 20 bits are taken out as the common prefix in the address block, and the remaining 12 bits will be filled with 0 by default as The host number in the address block.

After these five pieces of address information are aggregated, a CIDR address block is formed: 168.100.128.0/20. At this time, when R2 receives the routing and forwarding table of R1, it will only receive one CIDR address information.

tips

CIDR also uses “slash notation”, which is to add a slash “/” after the IP address, and then write the number of digits occupied by the network prefix.

IPv4: supernet, you are my

As long as we know any address in the CIDR address block, and then change the host number in the address to all 0 or all 1, we can get the minimum address and maximum address in this address block, and the distance between the maximum address and the minimum address All the consecutive addresses included can be represented by this CIDR address block. At the same time, according to the digit n of the host number in the address block, we can also obtain the number of addresses that can be assigned in this address block: 2 n -2.

tips

“Minus 2” is because the two addresses whose host number is all 0 and all 1 are special addresses, and are generally not used as source or destination addresses.

After the aggregated 168.100.128.0/20 is expanded into binary, the minimum address and maximum address in the address block where this address is located can be easily obtained, as shown in the following table.

IPv4: supernet, you are my

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

We were surprised to find that this minimum address is exactly the same as the aggregation address mentioned above!

4. How does the supernet match?

Since the CIDR address block is mentioned, it is necessary to mention the corresponding longest prefix matching mechanism.

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

Directly announce the correct answer: The route with the longest network prefix should be chosen from the matching results.

When the router receives an IP data packet, it will compare the destination IP address of the data packet with all the routing table entries in its local routing table bit by bit. After the comparison, it will choose the routing table with the longest matching degree. item.

for example:

Suppose the 5th floor of this building receives an email from Department X to Department Y. It is known that the IP address of Department Y is: 192.31.71.128, and the existing routing table information of a router passing through the 5th floor is: 192.31. 71.0/26, 192.31.68.0/22, then which next-hop address should the router send to after receiving this email?

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 binary number corresponding to destination address: 192.31.71.128
is: 11000000.00011111.01000111.10000000

tips

What needs to be explained here is that although CIDR does not use subnets anymore, since some networks still use subnetting and subnet masks, in order to make routing more convenient, the 32-bit address masks used by CIDR are also May continue to be referred to as a subnet mask.

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

Perform the “logical AND” operation on the subnet mask corresponding to each routing table entry and the binary expansion of the destination address, and then convert it to decimal: 192.31.71.0, 192.31.68.0. The operation steps are shown in the figure below :

We found that the addresses obtained after calculation all match the corresponding routing table entries, indicating that both routing information in the table can be allocated as next-hop addresses.

But! According to the longest prefix matching mechanism, we should select 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.

5. Summarize~

CIDR eliminates the concept of traditional A, B, C addresses and subnetting, allocates IPv4 address space more effectively, and makes IP addresses return from three-level addressing (network number, subnet number, host number) to Two-level addressing without classification, as shown in the figure below.

CIDR also uses “slash notation,” which appends a “/” to the IP address and then indicates the number of digits in the network prefix. CIDR combines consecutive IP addresses with the same network prefix into a “CIDR address block”, which constitutes a supernet.

When using CIDR, there may be more than one matching result in the routing table. At this time, a route that can match a longer network prefix should be selected from all matching results, because the longer the network prefix, the smaller the address block, and the resulting route Be more specific.

Share This Post: If you think this post can be helpful to somebody else, please share it using the buttons below!

Leave a Reply