CN107948060A - A kind of new routing table is established and IP method for searching route and device - Google Patents
A kind of new routing table is established and IP method for searching route and device Download PDFInfo
- Publication number
- CN107948060A CN107948060A CN201610892179.5A CN201610892179A CN107948060A CN 107948060 A CN107948060 A CN 107948060A CN 201610892179 A CN201610892179 A CN 201610892179A CN 107948060 A CN107948060 A CN 107948060A
- Authority
- CN
- China
- Prior art keywords
- node
- tree
- end point
- output port
- tree table
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Withdrawn
Links
- 238000000034 method Methods 0.000 title claims abstract description 71
- 238000010276 construction Methods 0.000 claims description 12
- 238000013507 mapping Methods 0.000 claims description 6
- 238000010586 diagram Methods 0.000 description 18
- 238000004590 computer program Methods 0.000 description 7
- 238000005516 engineering process Methods 0.000 description 6
- 230000006870 function Effects 0.000 description 5
- 238000003491 array Methods 0.000 description 1
- 239000002360 explosive Substances 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000012163 sequencing technique Methods 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L45/00—Routing or path finding of packets in data switching networks
- H04L45/74—Address processing for routing
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L45/00—Routing or path finding of packets in data switching networks
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L45/00—Routing or path finding of packets in data switching networks
- H04L45/58—Association of routers
- H04L45/586—Association of routers of virtual routers
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L45/00—Routing or path finding of packets in data switching networks
- H04L45/74—Address processing for routing
- H04L45/745—Address table lookup; Address filtering
- H04L45/7453—Address table lookup; Address filtering using hashing
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L45/00—Routing or path finding of packets in data switching networks
- H04L45/74—Address processing for routing
- H04L45/745—Address table lookup; Address filtering
- H04L45/74591—Address table lookup; Address filtering using content-addressable memories [CAM]
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
The embodiment of the invention discloses a kind of new routing table foundation and IP method for searching route and device, wherein, the method for building up of the routing table includes:Routing iinformation is obtained, the routing iinformation includes virtual flow-line forwarding Field Number VRF_ID, internet protocol address and the corresponding output port of the IP address;One routing entry section is combined into according to the VRF_ID and the IP address;Hash operation is carried out to the VRF_ID in the starting endpoint in the routing entry section using default hash algorithm, obtains the corresponding cryptographic Hash of the VRF_ID;A tree table is generated using the equal starting endpoint of all cryptographic Hash;Wherein, the leaf node of the tree table includes the corresponding output port of the starting endpoint, and the corresponding output port of IP address output port corresponding with the starting endpoint is identical;Main routing table is built according to all tree tables of generation.
Description
Technical Field
The present invention relates to the field of packet switching technologies, and in particular, to a novel method and apparatus for establishing a routing table and searching an IP route.
Background
With the rapid growth of the Internet (Internet), the size of the routing table is also increasing. In order to reduce the growth rate of the Routing table size and improve the utilization rate of the address space, the Internet Engineering Task Force (IETF) provides an address structure called classlessless inter-Domain Routing (CIDR) for the Internet, and the CIDR abandons the traditional class-based address allocation mode and specifies that a network address part with any length can be used, thereby generating the concept of 'network prefix'. CIDR uses network prefix with any length to replace network number and sub-network number in traditional classified address, rather than only using 1 byte, 2 byte and 3 byte network number as in classified address; therefore, under the CIDR address architecture system, the scale of the routing table is controlled to a certain extent; however, the search of the network prefix greatly complicates the design, and the search of the network prefix not only needs to perform matching search with the prefix bit, but also needs to consider the length of the network prefix.
In the prior art, current Internet Protocol (IP) routing switching devices usually use Ternary Content Addressable Memory (TCAM) to search for the longest prefix of an IP address. The TCAM adopts a parallel search technology, so that the search speed is independent of the number of entries of the table items. Meanwhile, in order to achieve a higher lookup speed and obtain an address of Longest Prefix Match (LPM), various entries are arranged in the TCAM in the sequence from long to short according to the length of the IP address Prefix, and finally, a lookup speed of hundreds of millions of times per second of the routing table can be achieved under the condition of more than one million entries.
The advantages of the TCAM technology are as follows: the parallel search enables one clock cycle to complete the search process, and a plurality of TCAMs can be cascaded to increase the capacity of the lookup table, so that the realization is simpler. However, TCAM technology still suffers from some drawbacks: firstly, the TCAM needs to compare the keyword to be searched with each entry in the TCAM routing table in the same clock cycle, so the power consumption is larger; secondly, because the structure of TCAM implementation is that each entry of the keyword to be searched and the configured routing table are compared at the same time, each entry corresponds to one comparator, so that the cost of the TCAM device is high and the price is high; thirdly, since the total number of comparators required for implementation by using the TCAM technique is equal to the total number of routing entries in the routing table, the size of the routing table implemented by using the TCAM is limited to a certain extent in practical applications.
Disclosure of Invention
In order to solve the foregoing technical problems, embodiments of the present invention desirably provide a novel method and apparatus for establishing a routing table and searching an IP route, so as to reduce the number of times of comparing routing entries, thereby reducing the number of comparators in a circuit and reducing the implementation cost and power consumption.
The technical scheme of the invention is realized as follows:
in a first aspect, an embodiment of the present invention provides a novel method for establishing a routing table, where the method includes:
acquiring routing information; the routing information comprises a virtual routing forwarding domain number VRF _ ID, an Internet protocol IP address and an output port corresponding to the IP address;
combining into a route entry interval according to the VRF _ ID and the IP address;
performing hash operation on VRF _ ID in a starting end point of the routing entry interval by using a preset hash algorithm to obtain a hash value corresponding to the VRF _ ID;
generating a tree table by using all starting end points with equal hash values; the leaf nodes of the tree table comprise output ports corresponding to the starting end points, and the output ports corresponding to the IP addresses are the same as the output ports corresponding to the starting end points;
and constructing a main routing table according to all the generated tree tables.
In the above scheme, the generating a tree table by using all starting end points with equal hash values; wherein the tree nodes of the tree table are used not only to determine matching endpoints, but also to determine search paths.
In the foregoing scheme, when the tree table is a 2-3 tree table, the generating a tree table by using the starting endpoints with equal hash values specifically includes:
sorting all the starting end points with the same hash value according to a sequence from small to large, and storing all the sorted starting end points in an array a [ n ];
extracting data of a [2 × (i-1) ] from the array a [ n ] as a left endpoint of an ith node from left to right of the first layer of the tree table; wherein i is more than or equal to 1 and less than or equal to (n +1)/2, and n is more than or equal to 1;
extracting data of a [2 x (i-1) +1] from the array a [ n ] as a right endpoint of an ith node from left to right of the first layer of the tree table;
from the array a [ n ]]Extracting alpha 2X 3(p-2)+2×3(p-1)×(k-1)]As the left end point of the kth node from left to right of the p-th layer of the tree table; wherein p is more than or equal to 2, k is more than or equal to 1 and less than or equal to (log)3t) -1, wherein t is the total number of nodes of the p-1 layer;
from the array a [ n ]]Extract a 4 x 3(p-2)+2×3(p-1)×(k-1)]As the right end point of the kth node from left to right of the p-th layer of the tree table.
In the foregoing solution, the constructing a main routing table according to all generated tree tables specifically includes: and writing the storage address indexed by the hash value into a main routing table storage area corresponding to the router to complete the construction of the main routing table.
In a second aspect, an embodiment of the present invention provides an IP routing lookup method, where the method includes:
mapping according to the input port of the received IP data packet and the VLAN _ ID of the virtual local area network to acquire the VRF _ ID corresponding to the IP data packet;
reading a destination IP address in the IP data packet, and combining the destination IP address and the VRF _ ID into a route entry to be searched;
carrying out hash operation on the VRF _ ID in the routing entry to be searched by utilizing the hash algorithm to obtain a hash value;
searching the main routing table according to the hash value, and determining an output port of the IP data packet; wherein the master routing table is the master routing table of any one of claims 1 to 4.
In the foregoing scheme, the searching the main routing table according to the hash value to determine an output port of the IP data packet specifically includes:
taking the hash value as an index of a table entry storage address of the main routing table, and obtaining a tree table node corresponding to the hash value from the index in the main routing table; wherein, the tree table node is the table item of the main routing table;
and searching for an end point matched with the routing entry to be searched according to the content of the tree table node, and acquiring an output port of the IP data packet.
In the foregoing solution, the searching for the end point matched with the to-be-searched routing entry according to the content of the tree table node and obtaining the output port of the IP data packet specifically includes:
when the node type in the node content is a root node or an intermediate node, extracting a corresponding pointer in the node according to the relation between the routing entry to be searched and the node endpoint, and reading the node content in the tree table node pointed by the pointer;
and when the node type in the node content is a leaf node, acquiring an output port of the IP data packet according to the relation between the routing entry to be searched and the leaf node end point.
In the above scheme, when the tree table is a 2-3 tree table, and when a node type in the node content is a root node or an intermediate node, taking out a corresponding pointer in the node according to a relationship between the route entry to be searched and the node endpoint, and reading the node content in the tree table node pointed by the pointer specifically includes:
when the route entry to be searched is smaller than the left endpoint of the node, taking out a left pointer in the node, and reading the node content in the tree table node pointed by the left pointer;
when the route entry to be searched is larger than or equal to the left end point of the node and smaller than the right end point of the node, taking out a middle pointer in the node, and reading the node content in the tree table node pointed by the middle pointer;
and when the route entry to be searched is larger than or equal to the right endpoint of the node, taking out a right pointer in the node, and reading the node content in the tree table node pointed by the right pointer.
In the foregoing scheme, when the tree table is a 2-3 tree table, and when the node type in the node content is a leaf node, obtaining an output port of the IP packet according to a relationship between the to-be-searched route entry and the leaf node end point specifically includes:
when the route entry to be searched is equal to the left end point of the leaf node, taking an output port corresponding to the left end point of the leaf node as an output port of the IP data packet;
when the route entry to be searched is equal to the right end point of the leaf node, taking an output port corresponding to the right end point of the leaf node as an output port of the IP data packet;
when the route entry to be searched is larger than the left end point of the leaf node and smaller than the right end point of the leaf node, taking an output port corresponding to an interval formed by the left end point and the right end point of the leaf node as an output port of the IP data packet;
and when the route entry to be searched is larger than the right end point of the leaf node, taking the corresponding output port larger than the right end point of the leaf node as the output port of the IP data packet.
In the above solution, after the node at this layer finishes processing the route lookup of the current IP packet, the method further includes: and the node of the layer immediately hands the current IP data packet to the node of the next layer for processing, and carries out IP route searching on the next IP data packet.
In the above aspect, the method further includes: and backing up the main routing table while finishing the establishment of the main routing table.
In the above solution, when the master routing table needs to be updated, the method further includes:
adjusting the data structure of the tree table according to the new configuration rule;
updating the backup routing table according to the adjusted tree table;
switching from the main routing table to the backup routing table to search for the IP route;
updating the main routing table according to the adjusted tree table;
and switching to the main routing table from the backup routing table to search the IP route.
In a third aspect, an embodiment of the present invention provides a novel routing table establishing apparatus, where the apparatus includes: the device comprises a first acquisition unit, a first combination unit, a first operation unit, a tree table generation unit, a construction unit and an updating unit; wherein,
the first obtaining unit is used for obtaining the routing information; the routing information comprises a virtual routing forwarding domain number VRF _ ID, an IP address and an output port corresponding to the IP address;
the first combination unit is used for combining the VRF _ ID and the IP address into a route entry interval;
the first operation unit is used for performing hash operation on the VRF _ ID in the starting end point of the route entry interval by using a preset hash algorithm to obtain a hash value corresponding to the VRF _ ID;
the tree table generating unit is used for generating a tree table by using all starting end points with equal hash values; the leaf nodes of the tree table comprise output ports corresponding to the starting end points, and the output ports corresponding to the IP addresses are the same as the output ports corresponding to the starting end points;
and the constructing unit is used for constructing the main routing table according to all the generated tree tables.
In the above-described aspect, the tree nodes of the tree table generated by the tree table generation unit are used not only to determine the matched end points, but also to determine the search paths.
In the foregoing solution, when the tree table is a 2-3 tree table, the tree table generating unit is specifically configured to:
sorting all the starting end points with the same hash value according to a sequence from small to large, and storing all the sorted starting end points in an array a [ n ];
extracting data of a [2 × (i-1) ] from the array a [ n ] as a left endpoint of an ith node from left to right of the first layer of the tree table; wherein i is more than or equal to 1 and less than or equal to (n +1)/2, and n is more than or equal to 1;
extracting data of a [2 x (i-1) +1] from the array a [ n ] as a right endpoint of an ith node from left to right of the first layer of the tree table;
from the array a [ n ]]Extracting alpha 2X 3(p-2)+2×3(p-1)×(k-1)]As the left end point of the kth node from left to right of the p-th layer of the tree table; wherein p is more than or equal to 2, k is more than or equal to 1 and less than or equal to (log)3t) -1, wherein t is the total number of nodes of the p-1 layer;
from the array a [ n ]]Extract a 4 x 3(p-2)+2×3(p-1)×(k-1)]As the right end point of the kth node from left to right of the p-th layer of the tree table.
In the foregoing solution, the building unit is specifically configured to: and writing the storage address indexed by the hash value into a main routing table storage area corresponding to the router to complete the construction of the main routing table.
In a fourth aspect, an embodiment of the present invention provides a novel IP routing lookup apparatus, where the apparatus includes: the device comprises a second acquisition unit, a second combination unit, a second operation unit and a search unit; wherein,
the second obtaining unit is used for obtaining the VRF _ ID corresponding to the IP data packet according to the input port of the received IP data packet and the mapping of the VLAN _ ID;
the second combination unit is used for reading a destination IP address in the IP data packet and combining the destination IP address and the VRF _ ID into a route entry to be searched;
the second operation unit is used for carrying out hash operation on the VRF _ ID in the route entry to be searched by utilizing the hash algorithm to obtain a hash value;
the searching unit is configured to search the main routing table according to the hash value, and determine an output port of the IP data packet; wherein the master routing table is the master routing table constructed by the routing table establishing device.
In the foregoing scheme, the search unit is specifically configured to:
taking the hash value as an index of a table entry storage address of the main routing table, and obtaining a tree table node corresponding to the hash value from the index in the main routing table; wherein, the tree table node is the table item of the main routing table;
and searching for an end point matched with the routing entry to be searched according to the content of the tree table node, and acquiring an output port of the IP data packet.
In the foregoing scheme, the search unit is specifically configured to:
when the node type in the node content is a root node or an intermediate node, extracting a corresponding pointer in the node according to the relation between the routing entry to be searched and the node endpoint, and reading the node content in the tree table node pointed by the pointer;
and when the node type in the node content is a leaf node, acquiring an output port of the IP data packet according to the relation between the routing entry to be searched and the leaf node end point.
In the foregoing solution, when the tree table is a 2-3 tree table, the searching unit is specifically configured to:
when the route entry to be searched is smaller than the left endpoint of the node, taking out a left pointer in the node, and reading the node content in the tree table node pointed by the left pointer;
when the route entry to be searched is larger than or equal to the left end point of the node and smaller than the right end point of the node, taking out a middle pointer in the node, and reading the node content in the tree table node pointed by the middle pointer;
and when the route entry to be searched is larger than or equal to the right endpoint of the node, taking out a right pointer in the node, and reading the node content in the tree table node pointed by the right pointer.
In the foregoing solution, when the tree table is a 2-3 tree table, the searching unit is specifically configured to:
when the route entry to be searched is equal to the left end point of the leaf node, taking an output port corresponding to the left end point of the leaf node as an output port of the IP data packet;
when the route entry to be searched is equal to the right end point of the leaf node, taking an output port corresponding to the right end point of the leaf node as an output port of the IP data packet;
when the route entry to be searched is larger than the left end point of the leaf node and smaller than the right end point of the leaf node, taking an output port corresponding to an interval formed by the left end point and the right end point of the leaf node as an output port of the IP data packet;
and when the route entry to be searched is larger than the right end point of the leaf node, taking the corresponding output port larger than the right end point of the leaf node as the output port of the IP data packet.
In the foregoing solution, the search unit is specifically further configured to: and after the node of the layer finishes the route search of the current IP data packet, immediately handing the current IP data packet to the node of the next layer for processing, and carrying out the IP route search on the next IP data packet.
In the foregoing solution, the building unit is specifically further configured to: and backing up the main routing table.
In the foregoing solution, the updating unit is specifically configured to:
adjusting the data structure of the tree table according to the new configuration rule;
updating the backup routing table according to the adjusted tree table;
switching from the main routing table to the backup routing table to search for the IP route;
updating the main routing table according to the adjusted tree table;
and switching to the main routing table from the backup routing table to search the IP route.
The embodiment of the invention provides a novel method and a device for establishing a routing table and searching an IP (Internet protocol) route, wherein the method adopts double hash operation to respectively complete the construction of a main routing table and the searching of the IP route, and adopts a tree-shaped data structure to construct the main routing table, so that the circuit structure for realizing the method is simple and feasible. In addition, in the IP route searching stage, the method utilizes hash operation to extract the hash value of the corresponding VRF _ ID, and completes the quick searching of the main route table through the hash value to realize the quick matching of the target IP address, thereby reducing the comparison times of the route entries and reducing the realization cost. In addition, from the perspective of hardware implementation, the method enables implementation area and power consumption much smaller than TCAM.
Drawings
Fig. 1 is a flowchart illustrating an implementation of a method for establishing a routing table according to an embodiment of the present invention;
fig. 2 is a schematic diagram of a tree table generation method according to an embodiment of the present invention;
fig. 3 is a schematic diagram of an IP route searching method according to an embodiment of the present invention;
fig. 4 is a schematic diagram illustrating a specific method for searching the master routing table according to the hash value according to the embodiment of the present invention;
fig. 5 is a schematic diagram illustrating a specific method for performing IP routing lookup according to the contents of the tree table nodes according to an embodiment of the present invention;
fig. 6 is a schematic diagram of a specific method for performing IP routing lookup by using a 2-3 tree table as an example according to an embodiment of the present invention;
fig. 7 is a schematic diagram illustrating a method for updating a routing table according to an embodiment of the present invention;
FIG. 8 is a schematic structural diagram of a 2-3 tree table according to an embodiment of the present invention;
fig. 9 is a schematic diagram of a storage format of a 2-3 tree table in the main routing table according to an embodiment of the present invention;
fig. 10 is a schematic structural diagram of a novel routing table establishing apparatus according to an embodiment of the present invention;
fig. 11 is a schematic structural diagram of a novel IP route searching device according to an embodiment of the present invention.
Detailed Description
The technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.
Example one
As shown in fig. 1, this figure shows a novel method for establishing a routing table according to an embodiment of the present invention, where the method specifically includes:
s110, obtaining routing information; the routing information comprises a Virtual routing Forwarding domain number (VRF _ ID), an Internet Protocol (IP) address and an output port corresponding to the IP address;
s120, combining the VRF _ ID and the IP address into a routing entry interval;
for example, if the obtained routing information includes a VRF _ ID of 8 and a destination IP address of 192.168.10, the route entry section corresponding to the destination IP address is 8.192.168.10.0 to 8.192.168.10.255.
S130, performing hash operation on the VRF _ ID in the starting end point of the route entry interval by using a preset hash algorithm to obtain a hash value corresponding to the VRF _ ID;
as in the above example, the route entry intervals are 8.192.168.10.0-8.192.168.10.255, and it is easy to obtain that the starting endpoint of the route entry interval is 8.192.168.10.0, and the VRF _ ID of the endpoint is the first byte of the endpoint.
S140, generating a tree table by using the starting end points with equal hash values; the leaf nodes of the tree table comprise output ports corresponding to the starting end points, and the output ports corresponding to the IP addresses are the same as the output ports corresponding to the starting end points;
it should be noted that the tree table may be a 2-3 tree table, or may be a binary tree table or a multi-branch tree table, but the 2-3 tree table can obtain a better lookup time. In addition, the tree table is different from a tree table on a general data structure, and tree nodes of the tree table are used for determining not only matched end points but also search paths. The structure of the tree table will be described by taking a 2-3 tree table as an example. In general, a 2-3 tree table consists of root nodes, intermediate nodes, and leaf nodes; the root node comprises a node type, a left pointer, a middle pointer, a right pointer and two starting end points; likewise, the intermediate node also includes a node type, a left pointer, a middle pointer, a right pointer, and two starting endpoints; the leaf node comprises a node type, two starting end points and output ports corresponding to the two starting end points respectively. It is easy to understand that the pointer is used to point to the node specified by the pointer address, and in practical application, we use the smaller of the two starting endpoints as the left endpoint of the node, and the larger one as the right endpoint of the node, and use 1 bit to indicate the type of the node.
S150, constructing a main routing table according to all the generated tree tables.
It should be noted that, the main routing table is constructed according to all the generated tree tables, specifically, all the generated tree tables are written into the main routing table storage area corresponding to the router according to the storage address indexed by the hash value, so as to complete the construction of the main routing table. In order to facilitate subsequent updating of the main routing table and avoid packet loss while updating the main routing table, the main routing table is backed up and written into a storage area corresponding to a backup routing table while the construction of the main routing table is completed.
For example, when the tree table is a 2-3 tree table, the generating a tree table by using starting endpoints with equal hash values as shown in fig. 2 may specifically include:
s210, sequencing all starting end points with equal hash values in a descending order, and storing all sequenced starting end points in an array a [ n ];
it should be noted that, in order to facilitate the construction of the tree table, in general, the starting end points for constructing the tree table are first sorted in the order from small to large. Wherein, the value of n in the array a [ n ] is the total number of the starting end points with equal hash values;
s220, extracting data of a [2 x (i-1) ] from the array a [ n ] as a left end point of the ith node from left to right of the first layer of the tree table; wherein i is more than or equal to 1 and less than or equal to (n +1)/2, and n is more than or equal to 1;
s230, extracting data of a [2 x (i-1) +1] from the array a [ n ] as a right endpoint of the ith node from left to right of the first layer of the tree table;
s240, from the array a [ n ]]Extracting alpha 2X 3(p-2)+2×3(p-1)×(k-1)]As the left end point of the kth node from left to right of the p-th layer of the tree table; wherein p is more than or equal to 2, k is more than or equal to 1 and less than or equal to (log)3t) -1, wherein t is the total number of nodes of the p-1 layer;
s250, from the array a [ n ]]Extract a 4 x 3(p-2)+2×3(p-1)×(k-1)]As the right end point of the kth node from left to right of the p-th layer of the tree table.
It should be noted that the bottom layer of the 2-3 tree table is a leaf layer, which is marked as a first layer; the upper layer of the leaf layer is the second layer, and the number of layers is gradually increased from bottom to top. The generation method of the binary tree table and the multi-branch tree table is similar to that of the 2-3 tree table, corresponding data are extracted from the array a [ n ] to form a tree structure, and only subscripts of the arrays are different.
After the establishment of the main routing table is completed, as shown in fig. 3, an embodiment of the present invention further provides a novel IP routing lookup method, where the method may specifically include:
s310, mapping and acquiring a virtual local Area Network (VLAN _ ID) corresponding to the IP data packet according to an input port of the received IP data packet and the VLAN _ ID;
it should be noted that the router may obtain the VRF _ ID corresponding to the IP packet through table lookup according to the input port of the received IP packet and the VLAN _ ID.
S320, reading a destination IP address in the IP data packet, and combining the destination IP address and the VRF _ ID into a route entry to be searched;
s330, carrying out hash operation on the VRF _ ID in the route entry to be searched by utilizing the hash algorithm to obtain a hash value;
it should be noted that the hash algorithm used in the IP routing lookup method is the same as the hash algorithm used in the main routing table establishment method.
S340, searching the main routing table according to the hash value, and determining an output port of the IP data packet.
Illustratively, looking up the main routing table according to the hash value, and determining an output port of the IP packet, as shown in fig. 4, may specifically include:
s410, taking the hash value as an index of a table entry storage address of the main routing table, and obtaining a tree table node corresponding to the hash value from the index in the main routing table; wherein the tree table node is an entry of the main routing table;
s420, according to the content of the tree table node, searching and obtaining an end point matched with the routing entry to be searched, and obtaining an output port of the IP data packet.
Illustratively, according to the content of the tree table node, searching for an endpoint matching with the route entry to be searched, and obtaining an output port of the IP data packet, as shown in fig. 5, specifically, the method may include:
s510, judging whether the node type in the node content is a leaf node; if yes, go to step S530; otherwise, go to step S520;
s520, extracting a corresponding pointer in the node according to the relation between the routing entry to be searched and the node endpoint, reading the node content in the tree table node pointed by the pointer, and returning to execute the step S510;
s530, obtaining the output port of the IP data packet according to the relation between the routing entry to be searched and the leaf node end point.
In order to facilitate understanding of the above IP routing specific search process, the following describes a specific implementation method for obtaining an output port of the IP data packet by searching for an endpoint matching the route entry to be searched and obtaining the end point according to the content of the tree table node, taking the tree table as a 2-3 tree table as an example, as shown in fig. 6, the specific implementation method may specifically include:
s610, judging whether the node type in the node content is a leaf node; if so, go to step S630; otherwise, go to step S620;
s620, judging whether the routing item to be searched is smaller than the left end point of the node; if yes, go to step S621; otherwise, go to step S622;
s621, taking out the left pointer in the node, reading the node content in the tree table node pointed by the left pointer, and returning to execute the step S610;
s622, judging whether the route entry to be searched is larger than or equal to the left end point of the node and smaller than the right end point of the node; if yes, go to step S623; otherwise, go to step S624;
s623, taking out the middle pointer in the node, reading the node content in the tree table node pointed by the middle pointer, and returning to execute the step S610;
s624, taking out the right pointer in the node, reading the node content in the tree table node pointed by the right pointer, and returning to execute the step S610;
s630, judging whether the routing entry to be searched is equal to the left end point of the leaf node; if yes, go to step S631; otherwise, go to step S632;
s631, taking an output port corresponding to the left endpoint of the leaf node as an output port of the IP data packet;
s632, judging whether the routing entry to be searched is equal to the right end point of the leaf node; if yes, go to step S633; otherwise, step S634 is performed;
s633, taking an output port corresponding to the right end point of the leaf node as an output port of the IP data packet;
s634, judging whether the routing entry to be searched falls between the left end point and the right end point of the leaf node; if yes, go to step S635; otherwise, go to step S636;
s635, taking an output port corresponding to an interval formed by the left endpoint and the right endpoint as an output port of the IP data packet;
and S636, taking the corresponding output port larger than the right end point as the output port of the IP data packet.
It should be noted that, due to the explosive growth of information, the network traffic also increases rapidly, and in order to make the switching device adapt to the needs of network traffic, the switching device should achieve the wire-speed switching processing capability, so the route lookup of the destination IP also needs to achieve the wire-speed processing capability. If the destination IP routing lookup engine of the IP data packet meets the linear speed processing capability of the device, in practical application, in order to meet the requirement of network traffic, the tree table may be horizontally divided, that is, after the lookup engine finishes the lookup of the node of the current layer, the currently processed IP data packet is handed over to the lookup engine of the next layer for processing, at this time, the lookup engine of the node of the current layer immediately processes the next IP data packet, and does not need to wait for the end of the lookup process of the whole tree table to process the next IP data packet.
In addition, the switching device of the carrier class needs to be able to work continuously and achieve a low packet loss rate, and the packet loss is not allowed even when the main routing table is updated; therefore, in practical application, as shown in fig. 7, the method for updating the main routing table may specifically include:
s710, adjusting the data structure of the tree table according to the new configuration rule;
s720, the central processing unit CPU starts to update the backup routing table according to the adjusted tree table;
s730, after the updating of the backup routing table is completed, the CPU requests hardware to be switched from the main routing table to the backup routing table for searching IP (Internet protocol) routing;
s740, after completing the switching of the routing table, the hardware reports an interrupt to the CPU, and the CPU starts to update the main routing table after receiving the interrupt;
s750, after the CPU finishes the updating of the main routing table, the CPU requests the hardware to switch from the backup routing table to the main routing table for searching the IP route.
The embodiment of the invention provides a novel IP route searching method, which adopts double hash operation to respectively complete the construction of the main route table and the searching of the IP route, and adopts a tree-shaped data structure to construct the main route table, thereby enabling the circuit structure for realizing the method to be simple and feasible. In addition, in the IP route searching stage, the method utilizes hash operation to extract the hash value of the corresponding VRF _ ID, and completes the quick searching of the main route table through the hash value to realize the quick matching of the target IP address, thereby reducing the comparison times of the route entries and reducing the realization cost. In addition, from the perspective of hardware implementation, the method enables implementation area and power consumption much smaller than TCAM.
Example two
Based on the same technical concept of the foregoing embodiments, this embodiment will describe the technical solution of the foregoing embodiments in more detail and intuitively with reference to fig. 8.
Assuming that the main routing table is composed of a 2-3 tree table, as shown in fig. 8, the tree table includes 9 leaf nodes, each leaf node includes 2 start endpoints, and each start endpoint is used as an entry of the main routing table, so that the total number of entries of the main routing table is 18, and the table entry of each main routing table includes two entries. When the router receives an IP packet with VRF _ ID of 8 and destination IP address of 192.168.10.19, the route entry to be searched is 8.192.168.10.19. Firstly, taking the VRF _ ID as a hash operation, and assuming that the hash function is an integer part obtained by dividing 8, the quotient of 8 by 8 is 1, namely the hash value hash _ idx is 1. And reading the table entries of the main routing table by using the addresses indicated by the hash _ idx, wherein the contents of the table entries are the tree root nodes, namely 9.192.168.10.0/10.192.168.10.0, of the 2-3 tree table shown in FIG. 8. Judging the type of the node as a root node, comparing the to-be-searched routing entry 8.192.168.10.19 with the left end point and the right end point of the root node, wherein the result is smaller than the left end point 9.192.168.10.0 of the root node, so that the left pointer is taken as the address of the main routing table to read the corresponding entry, and 8.192.168.70.0/8.192.168.110.0 is obtained. At this time, if the type of the node is determined to be an intermediate node, the to-be-searched route entry 8.192.168.10.19 is compared with the left and right end points of the intermediate node, and it is found that the to-be-searched route entry 8.192.168.10.19 is smaller than the left end point 8.192.168.70.0 of the intermediate node, so that the left pointer is taken as the address of the main route table to read the corresponding entry, and a node 8.192.168.10.0/8.192.168.20.0 is obtained, and it is determined that the node is a leaf node, and the to-be-searched route entry 8.192.168.10.19 is larger than the left end point 8.192.168.10.0 of the leaf node and smaller than the right end point 8.192.168.20.0 of the leaf node, so that the output port corresponding to 8.192.168.10.0 is taken as the output port of.
In addition, fig. 9 is a storage format of fig. 8 in the master routing table, where:
key1 is 8.192.168.10.0, and the corresponding output port is 1;
key2 is 8.192.168.20.0, and the corresponding output port is 2;
key3 is 8.192.168.70.0, and the corresponding output port is 3;
key4 is 8.192.168.90.0, and the corresponding output port is 4;
key5 is 8.192.168.110.0, and the corresponding output port is 5;
key6 is 8.192.168.140.0, and the corresponding output port is 6;
key7 is 9.192.168.10.0, and the corresponding output port is 7;
……
key13 is 10.192.168.10.0, and the corresponding output port is 13;
……
key18 is 10.192.168.140.0, and the corresponding output port is 18.
The node types are root nodes, intermediate nodes and leaf nodes. The entry formats of the root node and the intermediate node are the same, and the root node and the intermediate node both comprise a starting end point, a left pointer, a middle pointer, a right pointer and a node type (the root node or the intermediate node) of two routing entry intervals. The leaf node entry is in the format of a starting end point of a two-route entry interval, an output port corresponding to each end point and a node type (leaf node).
The main routing table corresponding to 18 items can be seen from the searching process, and the searching can be completed by adopting the searching method only by 3 times of comparison or 3 comparators; however, using TCAM requires 18 comparators to complete the search. Therefore, according to the formula (1), the method provided by the invention has 15 times of comparison or 15 comparators for realizing the longest prefix matching of the IP compared with the longest prefix matching of the IP realized by adopting the TCAM.
Wherein N is the total number of entries of the main routing table, and N is the number of comparison times or the number of comparators required by adopting the TCAM technology,showing the implementation by the method provided by the inventionThe number of comparisons required or the number of comparators.
As can be easily known from the above example, compared with the existing TCAM technology, the novel route searching method provided in the embodiment of the present invention greatly reduces the number of times of searching or resources to be implemented, and has low implementation cost and low power consumption. In addition, the invention is realized by adopting common RAM or DDR, which can be applied to the router needing large-scale routing table, while TCAM is only applied to the router needing small-scale routing table due to the physical realization.
EXAMPLE III
Based on the same technical concept as the foregoing embodiment, referring to fig. 10, a novel routing table creating apparatus 100 provided by an embodiment of the present invention is shown, and the apparatus may include: a first acquiring unit 1010, a first combining unit 1020, a first operating unit 1030, a tree table generating unit 1040, a constructing unit 1050, and an updating unit 1060; wherein,
the first obtaining unit 1010 is configured to obtain routing information; the routing information comprises a virtual routing forwarding domain number VRF _ ID, an IP address and an output port corresponding to the IP address;
the first combining unit 1020 is configured to combine the VRF _ ID and the IP address into a route entry interval;
the first operation unit 1030 is configured to perform hash operation on the VRF _ ID in the starting end point of the route entry interval by using a preset hash algorithm, so as to obtain a hash value corresponding to the VRF _ ID;
the tree table generating unit 1040, configured to generate a tree table by using all starting endpoints whose hash values are equal; the leaf nodes of the tree table comprise output ports corresponding to the starting end points, and the output ports corresponding to the IP addresses are the same as the output ports corresponding to the starting end points;
the constructing unit 1050 is configured to construct a main routing table according to all the generated tree tables.
In the above scheme, the tree nodes of the tree table generated by the tree table generating unit 1040 are not only used to determine the matched end points, but also used to determine the search paths.
In the foregoing solution, when the tree table is a 2-3 tree table, the tree table generating unit 1040 is specifically configured to:
sorting all the starting end points with the same hash value according to a sequence from small to large, and storing all the sorted starting end points in an array a [ n ];
extracting data of a [2 × (i-1) ] from the array a [ n ] as a left endpoint of an ith node from left to right of the first layer of the tree table; wherein i is more than or equal to 1 and less than or equal to (n +1)/2, and n is more than or equal to 1;
extracting data of a [2 x (i-1) +1] from the array a [ n ] as a right endpoint of an ith node from left to right of the first layer of the tree table;
from the array a [ n ]]Extracting alpha 2X 3(p-2)+2×3(p-1)×(k-1)]As the left end point of the kth node from left to right of the p-th layer of the tree table; wherein p is more than or equal to 2, k is more than or equal to 1 and less than or equal to (log)3t) -1, wherein t is the total number of nodes of the p-1 layer;
from the array a [ n ]]Extract a 4 x 3(p-2)+2×3(p-1)×(k-1)]As the right end point of the kth node from left to right of the p-th layer of the tree table.
In the foregoing scheme, the building unit 1050 is specifically configured to: and writing the storage address indexed by the hash value into a main routing table storage area corresponding to the router to complete the construction of the main routing table.
In addition, on the basis of completing the establishment of the main routing table, an embodiment of the present invention further provides a novel IP routing lookup apparatus 110, as shown in fig. 11, the apparatus includes: a second obtaining unit 1110, a second combining unit 1120, a second arithmetic unit 1130, and a search unit 1140; wherein,
the second obtaining unit 1110 is configured to obtain a VRF _ ID corresponding to the IP data packet according to the input port of the received IP data packet and the mapping of the VLAN _ ID;
the second combining unit 1120 is configured to read a destination IP address in the IP data packet, and combine the destination IP address and the VRF _ ID into a to-be-searched routing entry;
the second operation unit 1130 is configured to perform a hash operation on the VRF _ ID in the route entry to be searched by using the hash algorithm to obtain a hash value;
the hash algorithm used in the second operation unit 1130 is the same as the hash algorithm used in the first operation unit 103.
The lookup unit 1140 is configured to lookup the main routing table according to the hash value, and determine an output port of the IP data packet; wherein the master routing table is the master routing table constructed by the routing table establishing device 100.
In the foregoing solution, the search unit 1140 is specifically configured to:
taking the hash value as an index of a table entry storage address of the main routing table, and obtaining a tree table node corresponding to the hash value from the index in the main routing table; wherein, the tree table node is the table item of the main routing table;
and searching for an end point matched with the routing entry to be searched according to the content of the tree table node, and acquiring an output port of the IP data packet.
In the foregoing solution, the search unit 1140 is specifically configured to:
when the node type in the node content is a root node or an intermediate node, extracting a corresponding pointer in the node according to the relation between the routing entry to be searched and the node endpoint, and reading the node content in the tree table node pointed by the pointer;
and when the node type in the node content is a leaf node, acquiring an output port of the IP data packet according to the relation between the routing entry to be searched and the leaf node end point.
In the foregoing solution, when the tree table is a 2-3 tree table, the search unit 1140 is specifically configured to:
when the route entry to be searched is smaller than the left endpoint of the node, taking out a left pointer in the node, and reading the node content in the tree table node pointed by the left pointer;
when the route entry to be searched is larger than or equal to the left end point of the node and smaller than the right end point of the node, taking out a middle pointer in the node, and reading the node content in the tree table node pointed by the middle pointer;
and when the route entry to be searched is larger than or equal to the right endpoint of the node, taking out a right pointer in the node, and reading the node content in the tree table node pointed by the right pointer.
In the foregoing solution, when the tree table is a 2-3 tree table, the looking-up unit 1140 is further configured to:
when the route entry to be searched is equal to the left end point of the leaf node, taking an output port corresponding to the left end point of the leaf node as an output port of the IP data packet;
when the route entry to be searched is equal to the right end point of the leaf node, taking an output port corresponding to the right end point of the leaf node as an output port of the IP data packet;
when the route entry to be searched is larger than the left end point of the leaf node and smaller than the right end point of the leaf node, taking an output port corresponding to an interval formed by the left end point and the right end point of the leaf node as an output port of the IP data packet;
and when the route entry to be searched is larger than the right end point of the leaf node, taking the corresponding output port larger than the right end point of the leaf node as the output port of the IP data packet.
In the foregoing solution, the search unit 1140 is further specifically configured to: and after the node of the layer finishes the route search of the current IP data packet, immediately handing the current IP data packet to the node of the next layer for processing, and carrying out the IP route search on the next IP data packet.
In the foregoing scheme, the building unit 1050 is specifically further configured to: and backing up the main routing table.
In the above solution, the updating unit 1060 in the routing table establishing apparatus 100 is specifically configured to:
adjusting the data structure of the tree table according to the new configuration rule;
updating the backup routing table according to the adjusted tree table;
switching from the main routing table to the backup routing table to search for the IP route;
updating the main routing table according to the adjusted tree table;
and switching to the main routing table from the backup routing table to search the IP route.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of a hardware embodiment, a software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The above description is only a preferred embodiment of the present invention, and is not intended to limit the scope of the present invention.
Claims (24)
1. A novel method for establishing a routing table, the method comprising:
acquiring routing information; the routing information comprises a virtual routing forwarding domain number VRF _ ID, an Internet protocol IP address and an output port corresponding to the IP address;
combining into a route entry interval according to the VRF _ ID and the IP address;
performing hash operation on VRF _ ID in a starting end point of the routing entry interval by using a preset hash algorithm to obtain a hash value corresponding to the VRF _ ID;
generating a tree table by using all starting end points with equal hash values; the leaf nodes of the tree table comprise output ports corresponding to the starting end points, and the output ports corresponding to the IP addresses are the same as the output ports corresponding to the starting end points;
and constructing a main routing table according to all the generated tree tables.
2. The method of claim 1, wherein the generating a tree table using all starting endpoints with equal hash values; wherein the tree nodes of the tree table are used not only to determine matching endpoints, but also to determine search paths.
3. The method according to claim 1, wherein when the tree table is a 2-3 tree table, the generating a tree table by using the starting endpoints with equal hash values includes:
sorting all the starting end points with the same hash value according to a sequence from small to large, and storing all the sorted starting end points in an array a [ n ];
extracting data of a [2 × (i-1) ] from the array a [ n ] as a left endpoint of an ith node from left to right of the first layer of the tree table; wherein i is more than or equal to 1 and less than or equal to (n +1)/2, and n is more than or equal to 1;
extracting data of a [2 x (i-1) +1] from the array a [ n ] as a right endpoint of an ith node from left to right of the first layer of the tree table;
from the array a [ n ]]Extracting alpha 2X 3(p-2)+2×3(p-1)×(k-1)]As the left end point of the kth node from left to right of the p-th layer of the tree table; wherein p is more than or equal to 2, k is more than or equal to 1 and less than or equal to (log)3t) -1, wherein t is the total number of nodes of the p-1 layer;
from the array a [ n ]]Extract a 4 x 3(p-2)+2×3(p-1)×(k-1)]As the right end point of the kth node from left to right of the p-th layer of the tree table.
4. The method according to claim 1, wherein the constructing the main routing table according to all the generated tree tables specifically comprises: and writing the storage address indexed by the hash value into a main routing table storage area corresponding to the router to complete the construction of the main routing table.
5. An IP route lookup method, the method comprising:
mapping according to the input port of the received IP data packet and the VLAN _ ID of the virtual local area network to acquire the VRF _ ID corresponding to the IP data packet;
reading a destination IP address in the IP data packet, and combining the destination IP address and the VRF _ ID into a route entry to be searched;
carrying out hash operation on the VRF _ ID in the routing entry to be searched by utilizing the hash algorithm to obtain a hash value;
searching the main routing table according to the hash value, and determining an output port of the IP data packet; wherein the master routing table is the master routing table of any one of claims 1 to 4.
6. The method according to claim 5, wherein the searching the main routing table according to the hash value and determining the output port of the IP packet specifically includes:
taking the hash value as an index of a table entry storage address of the main routing table, and obtaining a tree table node corresponding to the hash value from the index in the main routing table; wherein, the tree table node is the table item of the main routing table;
and searching for an end point matched with the routing entry to be searched according to the content of the tree table node, and acquiring an output port of the IP data packet.
7. The method according to claim 6, wherein the searching for the end point matching with the routing entry to be searched and obtaining the output port of the IP packet according to the content of the tree table node specifically comprises:
when the node type in the node content is a root node or an intermediate node, extracting a corresponding pointer in the node according to the relation between the routing entry to be searched and the node endpoint, and reading the node content in the tree table node pointed by the pointer;
and when the node type in the node content is a leaf node, acquiring an output port of the IP data packet according to the relation between the routing entry to be searched and the leaf node end point.
8. The method according to claim 7, wherein when the tree table is a 2-3 tree table, and when the node type in the node content is a root node or an intermediate node, taking out a corresponding pointer in the node according to a relationship between the route entry to be searched and the node endpoint, and reading the node content in the tree table node pointed by the pointer, specifically includes:
when the route entry to be searched is smaller than the left endpoint of the node, taking out a left pointer in the node, and reading the node content in the tree table node pointed by the left pointer;
when the route entry to be searched is larger than or equal to the left end point of the node and smaller than the right end point of the node, taking out a middle pointer in the node, and reading the node content in the tree table node pointed by the middle pointer;
and when the route entry to be searched is larger than or equal to the right endpoint of the node, taking out a right pointer in the node, and reading the node content in the tree table node pointed by the right pointer.
9. The method according to claim 7, wherein when the tree table is a 2-3 tree table, and when the node type in the node content is a leaf node, obtaining an output port of the IP packet according to a relationship between the to-be-searched route entry and an end point of the leaf node, specifically includes:
when the route entry to be searched is equal to the left end point of the leaf node, taking an output port corresponding to the left end point of the leaf node as an output port of the IP data packet;
when the route entry to be searched is equal to the right end point of the leaf node, taking an output port corresponding to the right end point of the leaf node as an output port of the IP data packet;
when the route entry to be searched is larger than the left end point of the leaf node and smaller than the right end point of the leaf node, taking an output port corresponding to an interval formed by the left end point and the right end point of the leaf node as an output port of the IP data packet;
and when the route entry to be searched is larger than the right end point of the leaf node, taking the corresponding output port larger than the right end point of the leaf node as the output port of the IP data packet.
10. The method according to any of claims 7 to 9, wherein after the node at this layer processes the route lookup of the current IP packet, the method further comprises: and the node of the layer immediately hands the current IP data packet to the node of the next layer for processing, and carries out IP route searching on the next IP data packet.
11. The method of claim 1, further comprising: and backing up the main routing table while finishing the establishment of the main routing table.
12. The method according to claim 1, wherein when the master routing table needs to be updated, the method further comprises:
adjusting the data structure of the tree table according to the new configuration rule;
updating the backup routing table according to the adjusted tree table;
switching from the main routing table to the backup routing table to search for the IP route;
updating the main routing table according to the adjusted tree table;
and switching to the main routing table from the backup routing table to search the IP route.
13. A novel routing table creation apparatus, the apparatus comprising: the device comprises a first acquisition unit, a first combination unit, a first operation unit, a tree table generation unit, a construction unit and an updating unit; wherein,
the first obtaining unit is used for obtaining the routing information; the routing information comprises a virtual routing forwarding domain number VRF _ ID, an IP address and an output port corresponding to the IP address;
the first combination unit is used for combining the VRF _ ID and the IP address into a route entry interval;
the first operation unit is used for performing hash operation on the VRF _ ID in the starting end point of the route entry interval by using a preset hash algorithm to obtain a hash value corresponding to the VRF _ ID;
the tree table generating unit is used for generating a tree table by using all starting end points with equal hash values; the leaf nodes of the tree table comprise output ports corresponding to the starting end points, and the output ports corresponding to the IP addresses are the same as the output ports corresponding to the starting end points;
and the constructing unit is used for constructing the main routing table according to all the generated tree tables.
14. The apparatus according to claim 13, wherein the tree nodes of the tree table generated by the tree table generating unit are used not only for determining the matched end points but also for determining the search path.
15. The apparatus according to claim 13, wherein when the tree table is a 2-3 tree table, the tree table generating unit is specifically configured to:
sorting all the starting end points with the same hash value according to a sequence from small to large, and storing all the sorted starting end points in an array a [ n ];
extracting data of a [2 × (i-1) ] from the array a [ n ] as a left endpoint of an ith node from left to right of the first layer of the tree table; wherein i is more than or equal to 1 and less than or equal to (n +1)/2, and n is more than or equal to 1;
extracting data of a [2 x (i-1) +1] from the array a [ n ] as a right endpoint of an ith node from left to right of the first layer of the tree table;
from the array a [ n ]]Extracting alpha 2X 3(p-2)+2×3(p-1)×(k-1)]As the left end point of the kth node from left to right of the p-th layer of the tree table; wherein p is more than or equal to 2, k is more than or equal to 1 and less than or equal to (log)3t) -1, wherein t is the total number of nodes of the p-1 layer;
from the array a [ n ]]Extract a 4 x 3(p-2)+2×3(p-1)×(k-1)]As the right end point of the kth node from left to right of the p-th layer of the tree table.
16. The apparatus according to claim 13, wherein the building unit is specifically configured to: and writing the storage address indexed by the hash value into a main routing table storage area corresponding to the router to complete the construction of the main routing table.
17. A novel IP routing lookup apparatus, the apparatus comprising: the device comprises a second acquisition unit, a second combination unit, a second operation unit and a search unit; wherein,
the second obtaining unit is used for obtaining the VRF _ ID corresponding to the IP data packet according to the input port of the received IP data packet and the mapping of the VLAN _ ID;
the second combination unit is used for reading a destination IP address in the IP data packet and combining the destination IP address and the VRF _ ID into a route entry to be searched;
the second operation unit is used for carrying out hash operation on the VRF _ ID in the route entry to be searched by utilizing the hash algorithm to obtain a hash value;
the searching unit is configured to search the main routing table according to the hash value, and determine an output port of the IP data packet; wherein the master routing table is the master routing table constructed by the routing table establishing device.
18. The apparatus according to claim 17, wherein the search unit is specifically configured to:
taking the hash value as an index of a table entry storage address of the main routing table, and obtaining a tree table node corresponding to the hash value from the index in the main routing table; wherein, the tree table node is the table item of the main routing table;
and searching for an end point matched with the routing entry to be searched according to the content of the tree table node, and acquiring an output port of the IP data packet.
19. The apparatus according to claim 18, wherein the search unit is specifically configured to:
when the node type in the node content is a root node or an intermediate node, extracting a corresponding pointer in the node according to the relation between the routing entry to be searched and the node endpoint, and reading the node content in the tree table node pointed by the pointer;
and when the node type in the node content is a leaf node, acquiring an output port of the IP data packet according to the relation between the routing entry to be searched and the leaf node end point.
20. The apparatus according to claim 19, wherein when the tree table is a 2-3 tree table, the lookup unit is specifically configured to:
when the route entry to be searched is smaller than the left endpoint of the node, taking out a left pointer in the node, and reading the node content in the tree table node pointed by the left pointer;
when the route entry to be searched is larger than or equal to the left end point of the node and smaller than the right end point of the node, taking out a middle pointer in the node, and reading the node content in the tree table node pointed by the middle pointer;
and when the route entry to be searched is larger than or equal to the right endpoint of the node, taking out a right pointer in the node, and reading the node content in the tree table node pointed by the right pointer.
21. The apparatus according to claim 19, wherein when the tree table is a 2-3 tree table, the lookup unit is specifically configured to:
when the route entry to be searched is equal to the left end point of the leaf node, taking an output port corresponding to the left end point of the leaf node as an output port of the IP data packet;
when the route entry to be searched is equal to the right end point of the leaf node, taking an output port corresponding to the right end point of the leaf node as an output port of the IP data packet;
when the route entry to be searched is larger than the left end point of the leaf node and smaller than the right end point of the leaf node, taking an output port corresponding to an interval formed by the left end point and the right end point of the leaf node as an output port of the IP data packet;
and when the route entry to be searched is larger than the right end point of the leaf node, taking the corresponding output port larger than the right end point of the leaf node as the output port of the IP data packet.
22. The apparatus according to claim 17, wherein the search unit is further configured to: and after the node of the layer finishes the route search of the current IP data packet, immediately handing the current IP data packet to the node of the next layer for processing, and carrying out the IP route search on the next IP data packet.
23. The apparatus according to claim 13, wherein the building unit is further configured to: and backing up the main routing table.
24. The apparatus according to claim 13, wherein the updating unit is specifically configured to:
adjusting the data structure of the tree table according to the new configuration rule;
updating the backup routing table according to the adjusted tree table;
switching from the main routing table to the backup routing table to search for the IP route;
updating the main routing table according to the adjusted tree table;
and switching to the main routing table from the backup routing table to search the IP route.
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610892179.5A CN107948060A (en) | 2016-10-12 | 2016-10-12 | A kind of new routing table is established and IP method for searching route and device |
PCT/CN2017/088765 WO2018068524A1 (en) | 2016-10-12 | 2017-06-16 | Routing-table establishment and ip routing lookup method, device, and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610892179.5A CN107948060A (en) | 2016-10-12 | 2016-10-12 | A kind of new routing table is established and IP method for searching route and device |
Publications (1)
Publication Number | Publication Date |
---|---|
CN107948060A true CN107948060A (en) | 2018-04-20 |
Family
ID=61905016
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201610892179.5A Withdrawn CN107948060A (en) | 2016-10-12 | 2016-10-12 | A kind of new routing table is established and IP method for searching route and device |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN107948060A (en) |
WO (1) | WO2018068524A1 (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108737276A (en) * | 2018-06-19 | 2018-11-02 | 中国科学技术大学 | A method of structure routing table data structure simultaneously realizes routing forwarding |
CN116208553A (en) * | 2023-03-13 | 2023-06-02 | 苏州盛科通信股份有限公司 | Chip implementation method and application for expanding VRF routing table item |
Families Citing this family (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US10764135B2 (en) * | 2019-01-29 | 2020-09-01 | Dell Products L.P. | Method and system for solution integration labeling |
CN113098727A (en) * | 2019-12-23 | 2021-07-09 | 上海云盾信息技术有限公司 | Data packet detection processing method and device |
CN113132261B (en) * | 2019-12-31 | 2023-01-03 | 北京金山云网络技术有限公司 | Traffic data packet classification method and device and electronic equipment |
CN111404820B (en) * | 2020-03-09 | 2022-04-29 | 深信服科技股份有限公司 | Route query method, device, equipment and readable storage medium |
CN113726660B (en) * | 2021-08-27 | 2022-11-15 | 西安微电子技术研究所 | Route finder and method based on perfect hash algorithm |
CN116456422A (en) * | 2022-01-10 | 2023-07-18 | 中兴通讯股份有限公司 | Microwave network root node query method and device, microwave system and storage medium |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101707617A (en) * | 2009-12-04 | 2010-05-12 | 福建星网锐捷网络有限公司 | Message filtering method, device and network device |
CN103546380A (en) * | 2013-11-05 | 2014-01-29 | 迈普通信技术股份有限公司 | Message forwarding method and device based on strategy routing |
CN103544258A (en) * | 2013-10-16 | 2014-01-29 | 国家计算机网络与信息安全管理中心 | Cardinal number estimating method and cardinal number estimating device under multi-section query condition of big data |
EP2887584A1 (en) * | 2013-12-23 | 2015-06-24 | BAE Systems PLC | Data Capture |
CN104866502A (en) * | 2014-02-25 | 2015-08-26 | 深圳市中兴微电子技术有限公司 | Data matching method and device |
US20150281073A1 (en) * | 2014-03-31 | 2015-10-01 | Dell Products, L.P. | System and method for context aware network |
CN105391634A (en) * | 2015-12-08 | 2016-03-09 | 福建星网锐捷网络有限公司 | Message processing method, device and switch |
-
2016
- 2016-10-12 CN CN201610892179.5A patent/CN107948060A/en not_active Withdrawn
-
2017
- 2017-06-16 WO PCT/CN2017/088765 patent/WO2018068524A1/en active Application Filing
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101707617A (en) * | 2009-12-04 | 2010-05-12 | 福建星网锐捷网络有限公司 | Message filtering method, device and network device |
CN103544258A (en) * | 2013-10-16 | 2014-01-29 | 国家计算机网络与信息安全管理中心 | Cardinal number estimating method and cardinal number estimating device under multi-section query condition of big data |
CN103546380A (en) * | 2013-11-05 | 2014-01-29 | 迈普通信技术股份有限公司 | Message forwarding method and device based on strategy routing |
EP2887584A1 (en) * | 2013-12-23 | 2015-06-24 | BAE Systems PLC | Data Capture |
CN104866502A (en) * | 2014-02-25 | 2015-08-26 | 深圳市中兴微电子技术有限公司 | Data matching method and device |
US20150281073A1 (en) * | 2014-03-31 | 2015-10-01 | Dell Products, L.P. | System and method for context aware network |
CN105391634A (en) * | 2015-12-08 | 2016-03-09 | 福建星网锐捷网络有限公司 | Message processing method, device and switch |
Non-Patent Citations (1)
Title |
---|
刘尉悦等: ""基于Hash和二叉树的路由表查找算法"", 《中国科学技术大学学报》 * |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108737276A (en) * | 2018-06-19 | 2018-11-02 | 中国科学技术大学 | A method of structure routing table data structure simultaneously realizes routing forwarding |
CN108737276B (en) * | 2018-06-19 | 2020-08-25 | 中国科学技术大学 | Method for constructing routing table data structure and realizing routing forwarding |
CN116208553A (en) * | 2023-03-13 | 2023-06-02 | 苏州盛科通信股份有限公司 | Chip implementation method and application for expanding VRF routing table item |
Also Published As
Publication number | Publication date |
---|---|
WO2018068524A1 (en) | 2018-04-19 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107948060A (en) | A kind of new routing table is established and IP method for searching route and device | |
US9269411B2 (en) | Organizing data in a hybrid memory for search operations | |
US20140036918A1 (en) | High-speed content routing | |
EP3113036B1 (en) | Data matching method and apparatus and computer storage medium | |
CN102377664B (en) | TCAM (ternary content addressable memory)-based range matching device and method | |
US7873041B2 (en) | Method and apparatus for searching forwarding table | |
JP5960863B1 (en) | SEARCH DEVICE, SEARCH METHOD, PROGRAM, AND RECORDING MEDIUM | |
WO2016201930A1 (en) | Traffic classification method and device, and storage medium | |
CN107330094B (en) | Bloom filter tree structure for dynamically storing key value pairs and key value pair storage method | |
EP3280104B1 (en) | Ip routing lookup | |
US20140358886A1 (en) | Internal search engines architecture | |
EP2700194A1 (en) | Forwarding a multicast message | |
CN102045412A (en) | Method and equipment for carrying out compressed storage on internet protocol version (IPv)6 address prefix | |
CN107276916A (en) | Interchanger flow table management method based on agreement unaware retransmission technique | |
Li et al. | An improved trie-based name lookup scheme for named data networking | |
CN104252504B (en) | Data query method, apparatus and system | |
WO2016184069A1 (en) | Route lookup method and device | |
Shen et al. | High-performance IPv6 lookup with real-time updates using hierarchical-balanced search tree | |
EP3269101B1 (en) | Generating a hash table in accordance with a prefix length | |
Liu et al. | Longest prefix matching with pruning | |
CN112769704A (en) | High-speed extensible IP route lookup hardware device based on hash table | |
CN106603414B (en) | Routing table fast comparison method | |
Villaça et al. | HCube: Routing and similarity search in data centers | |
Sun et al. | Content-based route lookup using CAMs | |
CN113872863B (en) | Path searching method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
WW01 | Invention patent application withdrawn after publication |
Application publication date: 20180420 |
|
WW01 | Invention patent application withdrawn after publication |