Packet-forwarding algorithm for dividing sub-net subnet

Source: Internet
Author: User

  1, from level two IP address to level three IP address

With the popularization of the Internet and the development of technology, the defects of early ARPANET design are undoubtedly revealed:
(1) The utilization of IP address space is sometimes very low: a Class A IP address network can connect more than 10 million hosts, and each class B IP address network can connect more than 60,000 units. However, some networks have a limit on the number of hosts connected to the network, even much smaller than the number.
(2) Assigning a network number to each physical network can make the routing table bulky and degrade network performance.
(3) Level two IP address is not flexible enough: only after the IP address can be completed after the next work, and can not be changed according to their own needs.
To solve this problem, since 1985, a " Subnet Number field " has been added to the IP address to make the level two IP address a level three IP address. This practice is called dividing subnets , or subnet addressing or subnets by selecting ~

The basic idea of

subnetting is as follows :
subnets (subnet). Division of the subnet is only a unit of internal affairs, the unit thought that the network can not know the specific number of subnets and composition, This unit is still only a network of the external display . The
(2) divides subnets by borrowing several bits from the network's host number as the subnet number Subnet-id, while the host number also reduces the corresponding number of digits (32 bits of total). This two-level IP address is variable to level three IP address:    IP address:: = {< network number >,< subnet number >,< host number;}
(3) The IP datagram sent from the external network to a host in this unit still finds a router connected to the network based on the destination network number. But then inside the network, the router finds the destination subnet based on the destination network number and subnet number, and delivers the IP datagram to the destination host.
Note: Dividing the subnet only divides the host number of the IP address, and does not change the IP address of the original network number ~

2. Subnet mask

What does a subnet mask do? We know that from the header of the IP datagram it is not possible to see whether the network of the source host and destination host is subnetting, so the witty people think of the subnet mask (subnet mask) method ~
Practice: The subnet mask of the level three IP address (depending on the subnetting) and the destination IP address of the received datagram is bit "and" (and), you can find the network address of the subnet to be found ~ that is, the host number corresponds to the location of 0, the other bits are 1~

Subnet mask is an important property of a network or a subnet, the router's routing table in addition to the destination network address, there is a subnet mask of the network, which is now the standard rules of the Internet ~

The default subnet mask for Class A addresses is 255.0.0.0;
The default subnet mask for Class B addresses is 255.255.0.0;
The default subnet mask for Class C addresses is 255.255.255.0.

Forwarding by using subnet time group

With subnetting, the routing table must contain the following three items: Destination network address, subnet mask, and next hop address.

In the case of subnetting, the algorithm for routing forwarding packets is as follows:
(1) Extract the destination IP address (d) from the header of the received datagram.
(2) First to determine whether the direct delivery. The network directly connected to the router checks one by one: with the subnet mask of each network and D phase-by "and" (and operation), see if the result and the corresponding network address match. If matched, the packet is delivered directly (and the D is converted to a physical address, the datagram is encapsulated into frames), and the forwarding task ends. Otherwise it is indirect delivery, execution (3).
(3) If the routing table has a specific host route with Destination D, the datagram is routed to the next-hop router indicated in the routing table; otherwise, it is executed (4).
(4) Each row in the routing table (destination network address, subnet mask, next hop address), with the subnet mask and D phase-by "and" (and), the result is N. If n matches the destination network address of the line, the datagram is routed to the next-hop router indicated by the line; otherwise, it is executed (5).
(5) If there is a default route in the routing table, the datagram is routed to the default router indicated in the routing table; otherwise, it is executed (6).
(6) Error reporting forwarding packet.

Ps: Can be compared with the case of no sub-network, found that the general process is unchanged: Extract IP address, determine whether the same network, determine whether there is a specific route, judge the indirect delivery, determine whether there is a default route.
Just don't have the "and" operation with the subnet mask ~

Packet-forwarding algorithm for dividing sub-net subnet

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.