Article Source: http://blog.csdn.net/dog250/article/details/6596135
1. Route table
Route information is stored on the host or professional router used for the router. The route table is used to store the information. IncludingThree elements:Target address, mask, next hop.
1.1 overhead of querying a route table
Some people think that querying a route table is the same as querying a MAC address on a vswitch. querying a MAC address/port pair is a fixed data query, the MAC address is a fixed 48-byte address, and the IP address, since the emergence of CIDR, the address has become "unclassically", so the mask of any bit can become the correct mask. In addition, smart administrators have come upRoute AggregationThese guys pass the burden on the system's implementers, so that the system implementers must implement the "Longest mask" Matching. Since the mask is not fixed, the query is not fixed, this is very troublesome.
2. Forwarding Table
When a data packet arrives at the vro, you need to go to the specific port according to the "instructions". Similar to the address information table of the vswitch, the place where the "indication" is stored on the vro is calledForwarding Table.
3. Relationship between two tables
3.1 contact
The forwarding table directly acts on data packets, while the route table is the basis for generating the forwarding table. The forwarding table is generated through the route table. A specific process can combine the information in the route table with the host information, such as the NIC information, to obtain a forwarding table. The routing information has nothing to do with the host. It only describes the status and direction of the network link.
3.2 differences
The information stored in the two tables is different.. The route table only stores three elements: Target, mask, and next hop. The forwarding table stores more detailed information, such as output port information, and tag information. The forwarding table describes the host information and directs a data packet from one port to another. The route table describes network information and directs data packets from one machine to another.
4. misunderstandings
At present, many people understand the implementation of a system. These people are familiar with the Linux kernel, Cisco configurations, Windows Network Programming, and NDIS. The three types of data have very few common intersections. Therefore, most users familiar with the Linux kernel do not distinguish the route table and the forwarding table, because the Linux kernel itself does not distinguish the two tables, and each data packet will query the route table (of course, there is also a cache... But this is not a forwarding table). Cisco users will think that the two tables must be differentiated. Otherwise, how can MPLS be implemented? Who are familiar with Windows core? Windows is rarely used as a router.
5. Differentiate the benefits of two tables
MPLS is an obvious example of distinguishing between a route table and a forwarding table. First, we declare that MPLS is a network rather than a node running a specific protocol. In MPLSTagFor packet forwarding, before the MPLS network can be used for data services (the Label Distribution Protocol can also be dynamically adjusted in the middle), the MPLS Forwarding Table is created. Its table items include three elements: source data comes with labels/forwarded ports/forwarded out with labels. This table item is created through the route table. We regard it as a forwarding table. To Implement MPLS, you need to add a label to the data packet on the ingress router so that the data packet can be quickly forwarded after going out of the MPLS network, saving the overhead of directly querying the route table.
6. Configure forwarding table in Linux based on Nat principles
If the administrator can "get through one path" in advance, the administrator canPortalConfigure onDNATAnd thenExitConfigurationSNATTo implementStandard point-to-point IP LinkEach node thinks that the data is sent to the next hop instead of the next hop ". Because Nat is based on the connection, it adds a direction to the undirected IP network. Therefore, you do not need to configure reverse routing After configuring SNAT.
In view of the above method, if we can identify the tag information in the DNAT information and then directly determine the output port, and encapsulate the new egress tag in the SNAT of the output port, we do not need to enter the routing module, this is an MPLS implementation. However, the current standard Linux kernel netfilter is not implemented in this way.
7. Advantages
In addition to specific dedicated line networks such as MPLS, the biggest advantage of forwarding table and route table separation is that it can implement forwarding table using hardware to achieve high-speed link forwarding,However, it is difficult to use hardware to implement the route table because it is not exactly matched, but the "Longest prefix" match, which is filled with variables..