The two-level structure of the IP address may cause the IP address utilization to be low. For example, each network in the B-type network can accommodate more than 60 thousand hosts, but the average enterprise does not need such a large capacity, therefore, IP resource utilization is low. In addition, when an enterprise needs to add a new network, it needs to apply for a network from the IP address management organization, which brings a lot of inconvenience. To solve these problems, the concept of dividing subnets is proposed.
The basic idea of dividing subnets:
(1) Each network is composed of several subnets. Outside the network, you do not know the status of the subnets in the network. The whole network acts as a whole;
(2) To divide subnets, part of the host number must be used as the subnet number. At this time, two-level IP addresses are changed to three-level IP addresses: network number, subnetwork number, and host number.
(3) When sending data reports, find the vro connected to the network based on the network number of the target host, and find the sub-network based on the destination network number and the sub-network number, deliver the datagram to the target host.
Dividing subnets is inseparable from subnet masks. To obtain a subnetwork address for dividing subnets, We Need To bitwise and operate the IP addresses and subnet masks.
A router's routing table contains the subnet mask column.
Subnet Mask is an important attribute of a network or subnet. When switching information between a vro and an adjacent vro, The vro must inform the adjacent vro of its subnet mask. In each table of the router route table, in addition to the destination network address, the corresponding subnet mask of the network is also given.
After Dividing subnets, the grouping and forwarding algorithm needs to be modified as follows:
(1) extract the destination IP address D from the header of the received datagram;
(2) determine whether it is direct delivery. Check each network connected to the vro: Use the subnet mask and destination IP address of each network to perform and operations, and check whether the results match the corresponding network address. If they match, they will be delivered directly, otherwise, perform steps (3) for indirect delivery );
(3) If the route table contains a specific host route with the destination address D, the datagram is handed over to the next hop router specified in the route table; otherwise, (4 );
(4) For each row in the route table (including the destination network address, subnet mask, and next hop address), use the subnet mask and IP address to phase by phase. The result is n, if n matches the network address, the data is transmitted to the next hop router specified by the row in the route table; otherwise, the data is transmitted (5 );
(5) If the router has a default route, the datagram is forwarded to the next hop router specified by the default route; otherwise, the route is executed (6 );
(6) Report an error in data packet forwarding.
In the face of the imminent depletion of network IP addresses and the sharp increase in table items in the route table, IETF proposed unclassified addressing to solve these problems.
Classless Inter-Domain Routing)
Two main features of CIDR:
(1) the traditional concepts of A, B, and C addresses and subnet division are eliminated. CIDR divides IP addresses into two parts, with the network prefix followed by the host. CIDR adopts the diagonal line notation. the number after the diagonal line represents the number of digits occupied by the network prefix in the IP address.
(2) CIDR combines IP addresses with the same network prefix into a CIDR address block. If you know any address in the address block, we can know the minimum IP address and maximum IP address of the block.
When using CIDR, because the network prefix is used, the IP address consists of the network prefix and host number. The route table must be modified accordingly. Each project includes the network prefix and Next Hop address. When searching the route table, there may be more than one matching result. We need to select a route with the longest network prefix from the matching result.