Detailed explanation of TCP/IP protocol-IP routing of series notes (1)

Source: Internet
Author: User

This chapter describes the basis of the TCP/IP protocol cluster. IP routing ensures that the correct transmission path can be found for the datagram. If it cannot be found, the sender will be notified of a failure to issue the message.

The information used in the route finding process is maintained in two ways: each host maintains its own route table (print the current route table using route print in windows ). Generally, there is only one Nic on the host, so the route table is relatively simple. It contains a loopback interface (127.0.0.1) and the currently used IP address. If there is no Nic, there is only a loopback address. All the data packets sent to 127.0.0.1 and localhost are forwarded to the IP address input table before being sent to the link layer (which is commonly the Ethernet driver layer. After the data sent to the IP address is sent to the link layer, the link layer checks that the address is itself and then sends the data to the IP address input table.

For the datagram sent to another address, the selected interface is the network card, all sent to the network card. The default route is also used.

If multiple NICs are installed, you can enable the route forwarding function for the windows Server version, that is, you can use it as a router. If only one network card is installed, the forwarding function is also used. In fact, "where to come, where to go" cannot achieve the goal of "routing.

In this way, when the host receives a data report, it first checks whether it is sent to itself. If yes, it is normal communication and can be processed directly. If not, you can decide whether to directly discard the datagram or find a suitable forwarding rule from the network interface based on the option (whether to enable route forwarding.

If you decide to forward the data, it will actually involve "finding the path ". Each host and router have a route table. First, check the table items pointing to the host in the routing table to see if any entry is the destination address to be sent. If yes, it is directly sent to the host. If not, check the table items pointing to the network number to see if the network to which the host is sent has records. If it is found, it is sent to the interface that the network is going through. If none of these are found, the datagram is sent to the default route for processing by the default route. Generally, more table items are routed by default, and more information can be found to the destination. If the default route cannot be found, it is sent to its default route until the top layer. If the top-level Core Router still cannot be found, it indicates that the datagram is indeed unable to find the destination, and the router returns an ICMP message, telling the sender that the host is "Network inaccessible ", or "host inaccessible ". The specific information is determined by the vro, but most of them receive "inaccessible hosts.

These are annoying. Imagine an example in life:

I want to take a train to Lhasa and take a bus to Hangzhou Railway Station. There are no direct trains in Hangzhou (not in the whole country before the Qinghai-Tibet line was opened to traffic :)), which means that it cannot find the host "Lhasa" and does not know which Railway Bureau it belongs to (network number ), it sends me to the transit station Xuzhou (default route ). Xuzhou station cannot be found, but it knows that the host "Lhasa" belongs to the west, maybe the network number "Zhengzhou Bureau" knows, so it sent me to "Zhengzhou ". There is no direct car in Zhengzhou, And it will send me to the closer "Xining ". Then at Xining Railway Station, I learned that the Qinghai-Tibet line is not fully connected. So I was told that "the host is not accessible", but Lhasa is not accessible.

In my life, I had to live in Hangzhou again. On the Internet, the datagram sent to "Xining" will not be sent back. The router (Railway Station) simply throws "I" and notifies the Hangzhou police.

This is a process of finding the path. If you finally find it at the end of the day, of course you are all happy, then you can "clench your hand" and find the organization. The next step is unrelated to routing.

From this process, we can see the importance of route table items. If the route table information is detailed and can be found on each host, all the data packets sent to the router can be delivered smoothly, just as there are vehicles from Hangzhou station to different parts of the country. However, such requirements are unrealistic. The number of hosts on the network is infinite, just like the number of railway stations in China. To ensure that each host has a project, the router must have a large capacity to store these records, the efficiency of searching entries in this large route table is also a problem. As a result, the current router structure, each layer of routers save local routing information. Send the unhandled data packets to the default route for processing. This reduces the requirements for a single router.

Then there is the problem of creating and updating route information. Host power-on Shutdown and router power-on Shutdown are unpredictable. That is to say, the route information may be uncertain. This one-minute route is still available, the next minute may be disconnected (shut down, crashed, attacked ...). In this case, the routing information must be updated in time to avoid incorrect routing.

The basic routing information is generally created during system startup, such as the default routing configuration. You can use the route add command to manually add a static route. More routing information is constantly enriched in the communication process, that is, the router is "learned" by itself. This is similar to ARP. In the LAN, if you want to report data to another host, for example, from A to B. If A does not know where B is at the beginning, send an ARP request to ask where B is. B answers his MAC address after receiving the message, and the ARP daemon combines the mac ip address with the IP address of B to save it. Next time you want to send data to B, you don't have to ask again. You can directly send the data to the corresponding MAC address (arp-a can be used to check the current arp table ). A vro is similar. if it knows that an interface can be sent, it is saved. The difference is that ARP works at the link layer and below the IP layer, and the router processes this information, which is much more complicated than the ARP daemon.


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.