WO2018068524A1 - 路由表建立、以及ip路由查找方法、装置、存储介质 - Google Patents

路由表建立、以及ip路由查找方法、装置、存储介质 Download PDF

Info

Publication number
WO2018068524A1
WO2018068524A1 PCT/CN2017/088765 CN2017088765W WO2018068524A1 WO 2018068524 A1 WO2018068524 A1 WO 2018068524A1 CN 2017088765 W CN2017088765 W CN 2017088765W WO 2018068524 A1 WO2018068524 A1 WO 2018068524A1
Authority
WO
WIPO (PCT)
Prior art keywords
node
tree
endpoint
output port
routing table
Prior art date
Application number
PCT/CN2017/088765
Other languages
English (en)
French (fr)
Inventor
陈钦树
Original Assignee
深圳市中兴微电子技术有限公司
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by 深圳市中兴微电子技术有限公司 filed Critical 深圳市中兴微电子技术有限公司
Publication of WO2018068524A1 publication Critical patent/WO2018068524A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/74Address processing for routing
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/58Association of routers
    • H04L45/586Association of routers of virtual routers
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/74Address processing for routing
    • H04L45/745Address table lookup; Address filtering
    • H04L45/7453Address table lookup; Address filtering using hashing
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/74Address processing for routing
    • H04L45/745Address table lookup; Address filtering
    • H04L45/74591Address table lookup; Address filtering using content-addressable memories [CAM]

Definitions

  • the present invention relates to the field of packet switching technologies, and in particular, to a routing table establishment, and an IP route searching method, apparatus, and storage medium.
  • CIDR inter-domain routing
  • CIDR Classless Inter- Domain Routing's address structure
  • CIDR abandons the traditional class-based address allocation method, stipulates that the network address part of any length can be used, thus creating the concept of "network prefix".
  • CIDR uses a network prefix of any length instead of the network number and subnet number in the traditional classification address, instead of using only 1 byte, 2 bytes, and 3 bytes of network number in the classification address; therefore, in the CIDR address structure
  • the size of the routing table is controlled.
  • the search of the network prefix makes the design very complicated. The search of the network prefix not only needs to match the prefix bits, but also needs to consider the length of the network prefix.
  • the current Internet Protocol (IP) routing switching device usually uses a tri-state content addressed memory (TCAM, Ternary Content Addressable). Memory) implements the lookup of the longest prefix of the IP address.
  • TCAM uses a parallel lookup technique that makes the lookup speed independent of the number of entries in the table entry.
  • LPM Longest Prefix Matching
  • various entries are arranged in order of length from the length of the IP address prefix. 7
  • the current routing table has a search speed of hundreds of millions of times per second in the case of more than one million entries.
  • the advantage of the above TCAM technology is that the parallel search enables a search process to be completed in one clock cycle, and multiple TCAMs can be cascaded to increase the lookup table capacity, which is relatively simple to implement.
  • 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 relatively large.
  • the TCAM implementation due to the TCAM implementation. The structure is that each key of the to-be-searched keyword and the configured routing table is compared at the same time, so each entry corresponds to a comparator, which results in a relatively high cost and high price of the TCAM device.
  • Third, due to the use of TCAM technology The total number of comparators is equal to the total number of routing entries in the routing table. Therefore, in practical applications, the size of the routing table implemented by TCAM is limited to a certain extent.
  • an embodiment of the present invention is to provide a routing table establishment, an IP route searching method, apparatus, and a storage medium, which are used to reduce the number of comparisons of routing entries, thereby reducing the number of comparators in the circuit and reducing the implementation. Cost and power consumption.
  • an embodiment of the present invention provides a routing table establishing method, where the method includes:
  • routing information includes at least a virtual route forwarding domain number (VRF_ID), an IP address, and an output port corresponding to the IP address;
  • VRF_ID virtual route forwarding domain number
  • the main routing table is built from all the generated tree tables.
  • the tree node is generated by using all the starting endpoints with the same hash value; wherein the tree node of the tree table is used to determine the matching endpoint and the search path.
  • the tree table is a 2-3 tree table
  • the constructing the main routing table according to all the generated tree tables includes: writing the main routing table storage area corresponding to the router according to the storage address of the hash value index, and completing the construction of the main routing table. .
  • the method further includes: while completing the establishment of the main routing table, Back up the primary routing table.
  • the method when the main routing table needs to be updated, the method further includes:
  • the IP routing lookup is performed by switching from the backup routing table to the main routing table.
  • an embodiment of the present invention provides an IP route searching method, where the method includes:
  • main routing table And searching the main routing table according to the hash value to determine an output port of the IP data packet; wherein the main routing table is the foregoing main routing table.
  • the searching for the main routing table according to the hash value, and determining an output port of the IP data packet specifically includes:
  • the hash value is used as an index of the storage address of the main routing table entry, and the tree table node corresponding to the hash value is obtained from the index in the main routing table; wherein the tree table node is the The entry of the main routing table;
  • the obtaining and the checking are performed according to the content of the tree table node.
  • the endpoints that match the routing entries are obtained, and the output ports of the IP data packets are obtained, including:
  • the node type in the node content is a root node or an intermediate node
  • the output port of the IP data packet is obtained according to the relationship between the to-be-searched route entry and the leaf node endpoint.
  • the tree table is a 2-3 tree table
  • the node type in the node content is a root node or an intermediate node
  • the relationship is taken out of the corresponding pointer in the node, and the content of the node in the tree table node pointed by the pointer is read, which specifically includes:
  • the left pointer in the node is taken out, and the node content in the tree table node pointed by the left pointer is read;
  • the right pointer in the node is fetched, and the node content in the tree table node pointed by the right pointer is read.
  • the output port corresponding to the left endpoint of the leaf node is used as an output port of the IP data packet
  • the output port corresponding to the right end of the leaf node is used as an output port of the IP data packet
  • a corresponding output port that is larger than the right endpoint of the leaf node is used as an output port of the IP data packet.
  • the method further includes: the local layer node immediately hands the current IP data packet to the next layer node for processing, and An IP packet is used for IP route lookup.
  • an embodiment of the present invention provides a routing table establishing apparatus, where the apparatus includes: a first acquiring unit, a first combining unit, a first computing unit, a tree table generating unit, a building unit, and an updating unit;
  • the first obtaining unit is configured to acquire routing information, where the routing information includes at least a VRF_ID, an IP address, and an output port corresponding to the IP address;
  • the first combining unit is configured to combine into a routing entry interval according to the VRF_ID and the IP address;
  • the first operation unit is configured to perform a hash operation on the VRF_ID in the start endpoint 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 configured to generate a tree table by using all the starting endpoints with the same hash value; wherein the leaf node of the tree table includes an output port corresponding to the starting endpoint, and the IP The output port corresponding to the address is the same as the output port corresponding to the start endpoint;
  • the building unit is configured to build a master routing table based on all generated tree tables.
  • the tree node of the tree table generated by the tree table generating unit is used to determine a matching endpoint and a search path.
  • the tree table generating unit is configured to:
  • the building unit is configured to: write the storage table of the hash value index into the main routing table storage area corresponding to the router, and complete the construction of the main routing table.
  • the building unit is further configured to: back up the main routing table.
  • the update unit is configured to:
  • the IP routing lookup is performed by switching from the backup routing table to the main routing table.
  • an embodiment of the present invention provides an IP route searching device, where the device includes: a second acquiring unit, a second combining unit, a second computing unit, and a searching unit;
  • the second obtaining unit is configured to acquire a VRF_ID corresponding to the IP data packet according to an input port of the received IP data packet and a VLAN_ID mapping;
  • the second combining unit 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 route entry to be searched;
  • the second operation unit is configured to perform a hash operation on the VRF_ID in the to-be-find route entry by using the hash algorithm to obtain a hash value;
  • the searching unit is configured to search the main routing table according to the hash value to determine an output port of the IP data packet, where the main routing table is a main routing table constructed by the routing table establishing device .
  • the searching unit is configured to:
  • the hash value is used as an index of the storage address of the main routing table entry, and the tree table node corresponding to the hash value is obtained from the index in the main routing table; wherein the tree table node is the The entry of the main routing table;
  • the searching unit is configured to:
  • the node type in the node content is a root node or an intermediate node
  • the output port of the IP data packet is obtained according to the relationship between the to-be-searched route entry and the leaf node endpoint.
  • the searching unit is configured to:
  • the left pointer in the node is taken out, and the node content in the tree table node pointed by the left pointer is read;
  • the right pointer in the node is fetched, and the node content in the tree table node pointed by the right pointer is read.
  • the searching unit is configured to:
  • the output port corresponding to the left endpoint of the leaf node is used as an output port of the IP data packet
  • the output port corresponding to the right end of the leaf node is used as an output port of the IP data packet
  • an output port corresponding to the interval formed by the left end point and the right end point of the leaf node is used as the IP data packet Output port;
  • a corresponding output port that is larger than the right endpoint of the leaf node is used as an output port of the IP data packet.
  • the searching unit is further configured to: after the local node processes the route lookup of the current IP data packet, immediately deliver the current IP data packet to the next layer node for processing, and the next IP address.
  • the packet performs an IP route lookup.
  • the embodiment of the invention further provides a computer storage medium, wherein the computer storage medium stores computer executable instructions, and the computer executable instructions are used to execute the routing table establishing method.
  • the embodiment of the invention further provides a computer storage medium, wherein the computer storage medium stores computer executable instructions, and the computer executable instructions are used to execute the foregoing IP route searching method.
  • the embodiment of the invention provides a routing table establishment, an IP route searching method, a device, and a storage medium.
  • the method uses the double hash operation to complete the construction of the main routing table and the IP routing, respectively, and uses tree data.
  • the structure constructs the main routing table, thereby making the circuit structure implementing the method simple and feasible.
  • the method performs a hash value extraction on the corresponding VRF_ID by using a hash operation, and performs a fast search on the main routing table by using the hash value to implement fast matching of the destination IP address, thereby Reduced comparison of routing entries The number of times reduces the implementation cost.
  • this method makes the area and power consumption much smaller than TCAM.
  • FIG. 1 is a flowchart of implementing a method for establishing a routing table according to an embodiment of the present invention
  • FIG. 2 is a schematic diagram of a method for generating a tree table according to an embodiment of the present invention
  • FIG. 3 is a schematic diagram of a method for searching for an IP route according to an embodiment of the present invention
  • FIG. 4 is a schematic diagram of a specific method for searching the primary routing table according to the hash value according to an embodiment of the present disclosure
  • FIG. 5 is a schematic diagram of a specific method for performing IP route lookup according to the content of the tree table node according to an embodiment of the present invention
  • FIG. 6 is a schematic diagram of a specific method for performing IP route lookup by using a 2-3 tree table as an example according to an embodiment of the present disclosure
  • FIG. 7 is a schematic diagram of 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 disclosure.
  • FIG. 10 is a schematic structural diagram of a routing table establishing apparatus according to an embodiment of the present disclosure.
  • FIG. 11 is a schematic structural diagram of an IP route searching apparatus according to an embodiment of the present invention.
  • FIG. 1 the figure shows a method for establishing a routing table according to an embodiment of the present invention.
  • the method may specifically include:
  • routing information includes at least a VRF_ID, an Internet Protocol IP address, and an output port corresponding to the IP address.
  • the routing entry corresponding to the destination IP address is 8.192.168.10.0 to 8.192.168.10.255.
  • the routing entry interval is 8.192.168.10.0 to 8.192.168.10.255. It is easy to get the starting endpoint of the routing entry interval to be 8.192.168.10.0, and the VRF_ID of the endpoint is the first byte of the endpoint. .
  • S140 Generate a tree table by using all the starting endpoints with equal hash values.
  • the leaf node of the tree table includes an output port corresponding to the starting endpoint, and the output port corresponding to the IP address is The output ports corresponding to the start endpoint are the same;
  • the tree table may be a 2-3 tree table, a binary tree table or a multi-fork tree table, but only 2-3 tree tables can obtain better search time.
  • the tree table is different from the tree table on the normal data structure, and the tree node of the tree table is used to determine the matching endpoint and the search path. Taking the 2-3 tree table as an example, the composition of the tree table will be described.
  • a 2-3 tree table is composed of a root node, an intermediate node, and a leaf node; wherein the root node includes a node type, a left pointer, a middle pointer, a right pointer, and two start endpoints; likewise, the intermediate node also includes The node type, the left pointer, the middle pointer, the right pointer, and two start endpoints; the leaf node includes a node type, two start endpoints, and an output port corresponding to each of the two start endpoints.
  • the pointer is used to point to the node specified by the pointer address. In practical applications, we use the smaller of the two starting endpoints as the left endpoint of the node, and the larger one is the node.
  • the right endpoint with 1 bit to indicate the type of node.
  • the main routing table is constructed according to all the generated tree tables, and specifically, all the generated tree tables are written into the main routing table storage area corresponding to the router according to the storage address of the hash value index, and the completed The construction of the main routing table.
  • the main routing table is backed up and written while the main routing table is completed. Enter the storage area corresponding to the backup routing table.
  • the tree table is a 2-3 tree table
  • the tree is generated by using a starting point that is equal to all the hash values.
  • the method may include:
  • the starting endpoints for building the tree table are first sorted in ascending order.
  • n in the array a[n] is the total number of start endpoints with equal hash values
  • the bottom layer of the 2-3 tree table is the leaf layer, which is recorded as the first layer;
  • the first layer is the second layer, and the number of layers is increased from bottom to top.
  • the binary tree table and the multi-fork tree table are generated in a similar way to the 2-3 tree table.
  • the corresponding data is extracted from the array a[n] to form a tree structure, but the subscripts of the array are different.
  • the embodiment of the present invention further provides an IP route searching method, where the method may specifically include:
  • the router may obtain the VRF_ID corresponding to the IP data packet by looking up the table according to the input port of the received IP data packet and the VLAN_ID.
  • S320 Read a destination IP address in the IP data packet, and combine the destination IP address and the VRF_ID into a route entry to be searched;
  • hash algorithm used in the IP route lookup method is the same as the hash algorithm used in the master route table establishment method.
  • S340 Search the primary routing table according to the hash value, and determine an output port of the IP data packet.
  • the main routing table is searched according to the hash value, and the output port of the IP data packet is determined, as shown in FIG.
  • the hash value is used as an index of the storage address of the main routing table entry, and the tree table node corresponding to the hash value is obtained from the index in the main routing table; wherein the tree table node is An entry of the main routing table;
  • the search obtains the route bar to be searched for Obtaining an output port of the IP data packet, as shown in FIG. 5, specifically:
  • step S510 determining whether the node type in the node content is a leaf node; if yes, executing step S530; otherwise, performing step S520;
  • the tree table is taken as an example of a 2-3 tree table, and the search according to the content of the tree table node is matched to obtain the routing entry to be searched.
  • the endpoint of the method for obtaining the output port of the IP data packet is described. As shown in FIG. 6, the method may include:
  • step S610 determining whether the node type in the node content is a leaf node; if yes, executing step S630; otherwise, performing step S620;
  • step S620 determining whether the to-be-find route entry is smaller than the left endpoint of the node; if yes, executing step S621; otherwise, performing step S622;
  • step S622 determining whether the to-be-find route entry is greater than or equal to the left endpoint of the node, and is smaller than the right endpoint of the node; if yes, executing step S623; otherwise, performing step S624;
  • step S630 determining whether the to-be-find route entry is equal to the left endpoint of the leaf node; if yes, executing step S631; otherwise, performing step S632;
  • the output port corresponding to the left end of the leaf node is used as an output port of the IP data packet.
  • the output port corresponding to the right end of the leaf node is used as an output port of the IP data packet.
  • an output port corresponding to the interval formed by the left end point and the right end point is used as an output port of the IP data packet
  • the switching device In order to adapt the switching equipment to the needs of network traffic, the switching device should reach the line-speed switching processing capability. Therefore, the route lookup of the destination IP needs to be able to be achieved. Line speed processing capability. If the destination IP route lookup engine of the above IP data packet satisfies the wire-speed processing capability of the device, in the actual application, in order to adapt to the network traffic requirement, the tree table may be horizontally split, that is, the search engine processes the node of the layer. After the search, the currently processed IP data packet is handed over to the next-level node search engine for processing. At this time, the local node search engine immediately processes the next IP data packet without waiting for the entire tree table search process to end to process the next one. IP packet.
  • the carrier-class switching device needs to be able to work continuously and continuously and achieve a small packet loss rate, even when updating the main routing table, packet loss is not allowed; therefore, in practical applications, as shown in FIG.
  • the method for updating the main routing table may specifically include:
  • a central processing unit starts to update the backup routing table according to the adjusted tree table.
  • the CPU After completing the updating of the backup routing table, the CPU requests the hardware to switch from the primary routing table to the backup routing table to perform IP routing search.
  • the CPU After completing the update of the primary routing table, the CPU requests the hardware to switch from the backup routing table to the primary routing table to perform IP routing searching.
  • the embodiment of the present invention provides an IP route searching method, which uses a double hash operation to complete the construction of the main routing table and the IP routing, respectively, and constructs the main routing table by using a tree data structure, thereby The circuit structure that implements the method becomes simple and feasible.
  • the method performs a hash value extraction on the corresponding VRF_ID by using a hash operation, and performs a fast search on the main routing table by using the hash value to implement fast matching of the destination IP address, thereby Reduces the number of comparisons of routing entries and reduces implementation costs.
  • this method makes the area and power consumption much smaller than TCAM.
  • the main routing table is composed of a 2-3 tree table, as shown in FIG. 8, and the tree table contains 9 leaf nodes, each leaf node includes 2 starting endpoints, and each starting endpoint is taken as For an entry in the main routing table, the total number of entries in the main routing table is 18, and the entries in each main routing table contain two entries.
  • the router receives an IP packet, its VRF_ID is 8 and the destination IP address is 192.168.10.19, then the route entry to be searched is 8.192.168.10.19.
  • VRF_ID for hash operation, assuming that the hash function is divided into 8 to take the integer part, then 8 is divided by 8 The quotient is 1, that is, the hash value (hash_idx) is 1.
  • the entry of the main routing table is read by the address indicated by the hash_idx, and the content of the entry is the root node of the 2-3 tree table shown in FIG. 8, that is, 9.192.168.10.0/10.192.168.10.0.
  • Determine the type of the node as the root node and then compare the left and right endpoints of the root node with the to-be-find route entry 8.192.168.10.19, and the result is smaller than the left endpoint of the root node 9.192.168.10.0, so take the left pointer as the primary
  • the address of the routing table reads the corresponding entry and gets 8.192.168.70.0/8.192.168.110.0.
  • the route entry to be searched 8.192.168.10.19 is compared with the left and right endpoints of the intermediate node, and it is found that the route entry to be found 8.192.168.10.19 is smaller than the left end of the intermediate node 8.192. 168.70.0, so the left pointer is used as the address of the main routing table to read the corresponding entry, and the node 8.192.168.10.0/8.192.168.20.0 is obtained, and the node is determined to be a leaf node, and the routing entry to be found is 8.192.
  • 168.10.19 is greater than the left endpoint 8.192.168.10.0 of the leaf node and less than the right endpoint 8.192.168.20.0 of the leaf node, so the output port corresponding to 8.192.168.10.0 is taken as the output port of the packet.
  • FIG. 9 is a storage format of FIG. 8 in the main routing table, where:
  • 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.
  • Key18 is 10.192.168.140.0 and the corresponding output port is 18.
  • the node types are the root node, the intermediate node, and the leaf node.
  • the root node and the intermediate node have the same entry format, and contain the start endpoint, the left pointer, the middle pointer, the right pointer, and the node type (root node or intermediate node) of the two route entry intervals.
  • the format of the leaf node entry is the starting endpoint of the two routing entry intervals, the output port corresponding to each endpoint, and the node type (foliage node).
  • the main routing table corresponding to 18 entries can be seen.
  • the above search method only needs 3 comparisons or 3 comparators to complete the search; however, 18 comparators are required to use TCAM. Complete this search. Therefore, according to formula (1), the method for providing the longest prefix matching of IP using the method provided by the present invention has 15 fewer comparisons or 15 comparators than the IP longest prefix matching implemented by TCAM.
  • N is the total number of entries in the main routing table, and N is also the number of comparisons or comparators required by TCAM technology. It is indicated that the number of comparisons or the number of comparators required is achieved by the method provided by the present invention.
  • a route search method provided by an embodiment of the present invention greatly reduces the number of times of searching or resources realized, and has low implementation cost and low power consumption.
  • the present invention since the present invention is implemented by a common volatile random access memory (RAM, Ramdom Access Memory) or double rate synchronous dynamic random access memory (DDR), it can be applied to a router that requires a large-scale routing table, and TCAM. Due to physical implementation, it only applies to routers that require small-scale routing tables.
  • RAM volatile random access memory
  • DDR double rate synchronous dynamic random access memory
  • the apparatus may include: a first acquiring unit 1010, a first combining unit 1020, and a first An operation unit 1030, a tree table generation unit 1040, and a construction unit 1050 and an update unit 1060; wherein
  • the first obtaining unit 1010 is configured to obtain routing information, where the routing information includes at least a VRF_ID, an IP address, and an output port corresponding to the IP address.
  • the first combining unit 1020 is configured to combine into a routing entry interval according to the VRF_ID and the IP address;
  • the first operation unit 1030 is configured to perform a hash operation on the VRF_ID in the start endpoint of the routing entry interval by using a preset hash algorithm to obtain a hash value corresponding to the VRF_ID.
  • the tree table generating unit 1040 is configured to generate a tree table by using all the starting endpoints with the same hash value, wherein the leaf node of the tree table includes an output port corresponding to the starting endpoint, and the The output port corresponding to the IP address is the same as the output port corresponding to the start endpoint;
  • the building unit 1050 is configured to build a master routing table based on all generated tree tables.
  • the tree node of the tree table generated by the tree table generating unit 1040 is used to determine a matching endpoint and a search path.
  • the tree table generating unit 1040 is configured to:
  • p ⁇ 2, 1 ⁇ k ⁇ (log 3 t) -1, t is the total number of nodes in the p-1th layer;
  • the constructing unit 1050 is configured to: write the main routing table storage area corresponding to the router according to the storage address of the hash value index, and complete the construction of the main routing table.
  • the building unit 1050 is further configured to: back up the main routing table.
  • the updating unit 1060 in the routing table establishing apparatus 100 is configured to:
  • the IP routing lookup is performed by switching from the backup routing table to the main routing table.
  • the embodiment of the present invention further provides an IP route searching device 110.
  • the device includes: a second acquiring unit 1110 and a second combining unit 1120. a second operation 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 an input port of the received IP data packet and a VLAN_ID mapping;
  • 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 route entry to be searched;
  • the second operation unit 1130 is configured to perform a hash operation on the VRF_ID in the to-be-find route entry by using the hash algorithm to obtain a hash value;
  • hash algorithm used in the second operation unit 1130 is the same as the hash algorithm used in the first operation unit 1030.
  • the searching unit 1140 is configured to search the main routing table according to the hash value to determine an output port of the IP data packet, where the primary routing table is a master constructed by the routing table establishing apparatus 100. Routing table.
  • the searching unit 1140 is configured to:
  • the hash value is used as an index of the storage address of the main routing table entry, and the tree table node corresponding to the hash value is obtained from the index in the main routing table; wherein the tree table node is the The entry of the main routing table;
  • the searching unit 1140 is configured to:
  • the node type in the node content is a root node or an intermediate node
  • the output port of the IP data packet is obtained according to the relationship between the to-be-searched route entry and the leaf node endpoint.
  • the searching unit 1140 is configured to:
  • the left pointer in the node is taken out, and the node content in the tree table node pointed by the left pointer is read;
  • the right pointer in the node is fetched, and the node content in the tree table node pointed by the right pointer is read.
  • the searching unit 1140 is further configured Set to:
  • the output port corresponding to the left endpoint of the leaf node is used as an output port of the IP data packet
  • the output port corresponding to the right end of the leaf node is used as an output port of the IP data packet
  • an output port corresponding to the interval formed by the left end point and the right end point of the leaf node is used as the IP data packet Output port;
  • a corresponding output port that is larger than the right endpoint of the leaf node is used as an output port of the IP data packet.
  • the searching unit 1140 is further configured to: after the local node processes the route lookup of the current IP data packet, immediately hand the current IP data packet to the next layer node for processing, and the next one IP packets are used for IP route lookup.
  • the first obtaining unit 1010, the first combining unit 1020, the first computing unit 1030, the tree table generating unit 1040, the building unit 1050, and the updating unit 1060 in the routing table establishing apparatus proposed in the embodiment of the present invention may all be processed by a processor.
  • the implementation can of course be implemented by a specific logic circuit; in practical applications, the processor can be a CPU, a microprocessor (MPU), a digital signal processor (DSP) or a field programmable gate array (FPGA).
  • the second obtaining unit 1110, the second combining unit 1120, the second computing unit 1130, and the searching unit 1140 in the IP routing and searching device proposed in the embodiment of the present invention may all be implemented by a processor, and may also pass through a specific logic circuit.
  • the processor can be a CPU, MPU, DSP or FPGA.
  • the technical solution of the embodiment of the present invention is essentially or right
  • the portion of the technology contribution can be embodied in the form of a software product stored in a storage medium, including instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) All or part of the methods described in the various embodiments of the invention are performed.
  • the foregoing storage medium includes various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read only memory (ROM), a magnetic disk, or an optical disk.
  • program codes such as a USB flash drive, a mobile hard disk, a read only memory (ROM), a magnetic disk, or an optical disk.
  • the embodiment of the present invention further provides a computer storage medium, where the computer storage medium stores a computer program, and the computer program is used to execute the routing table establishing method of the embodiment of the present invention.
  • the embodiment of the present invention further provides a computer storage medium, where the computer storage medium stores a computer program for performing the above IP route searching method according to an embodiment of the present invention.
  • embodiments of the present invention can be provided as a method, system, or computer program product. Accordingly, the present invention can take the form of a hardware embodiment, a software embodiment, or a combination of software and hardware. Moreover, the invention can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) including computer usable program code.
  • the computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device.
  • the apparatus implements the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.
  • These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device.
  • the instructions provide steps for implementing the functions specified in one or more of the flow or in a block or blocks of a flow diagram.
  • the embodiment of the present invention obtains routing information including an output port corresponding to the VRF_ID, the IP address, and the IP address; combining the VRF_ID and the IP address into a routing entry interval; and using the preset hash algorithm to the routing
  • the VRF_ID in the start endpoint of the entry interval is hashed to obtain a hash value corresponding to the VRF_ID; a tree table is generated by using all the starting endpoints with the same hash value; wherein the leaf node of the tree table An output port corresponding to the start endpoint is included, and an output port corresponding to the IP address is the same as an output port corresponding to the start endpoint; and a main routing table is constructed according to all generated tree tables.
  • the circuit structure that implements the method becomes simple and feasible.
  • the VRF_ID corresponding to the IP data packet is obtained according to the input port of the received IP data packet and the VLAN_ID mapping; the destination IP address in the IP data packet is read, and the destination IP address is The VRF_ID is combined into a route to be searched; the VRF_ID in the to-be-find route entry is hashed by the hash algorithm to obtain a hash value; the main routing table is searched according to the hash value, and the The output port of the IP packet. In this way, the number of comparisons of routing entries is reduced, and the implementation cost is reduced.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

本发明实施例公开了一种路由表建立、以及IP路由查找方法、装置、存储介质,所述路由表的建立方法包括:获取路由信息,所述路由信息包括虚拟路由转发域编号VRF_ID、互联网协议IP地址和所述IP地址对应的输出端口;根据所述VRF_ID和所述IP地址组合成一个路由条目区间;利用预设的哈希算法对所述路由条目区间的起始端点中的VRF_ID进行哈希运算,获得所述VRF_ID对应的哈希值;利用所有所述哈希值相等的起始端点生成一个树表;其中,所述树表的叶子节点包含所述起始端点对应的输出端口,且所述IP地址对应的输出端口与所述起始端点对应的输出端口相同;根据生成的所有树表构建主路由表。

Description

路由表建立、以及IP路由查找方法、装置、存储介质
相关申请的交叉引用
本申请基于申请号为201610892179.5、申请日为2016年10月12日的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此引入本申请作为参考。
技术领域
本发明涉及分组交换技术领域,尤其涉及一种路由表建立、以及IP路由查找方法、装置、存储介质。
背景技术
随着因特网(Internet)的快速发展,路由表的规模也随之增大。为了能够降低路由表规模的增长速度以及提高地址空间的利用率,国际互联网工程任务组(IETF,Internet Engineering Task Force)为Internet提出了一种称之为无类域间路由(CIDR,Classless Inter-Domain Routing)的地址结构,CIDR抛弃了传统基于类的地址分配方式,规定可以使用任意长度的网络地址部分,因此产生了“网络前缀”的概念。CIDR使用任意长度的网络前缀来代替传统分类地址中的网络号和子网号,而不是像分类地址中只能使用1字节、2字节和3字节的网络号;因此,在CIDR地址结构体系下,路由表的规模得到了一定控制;但是,网络前缀的查找让设计变得非常复杂,网络前缀的查找不仅需要与前缀比特位进行匹配查找,还需要考虑网络前缀的长度。
在现有技术中,现行的互联网协议(IP,Internet Protocol)路由交换设备通常采用三态内容寻址存储器(TCAM,Ternary Content Addressable  Memory)实现IP地址最长前缀的查找。TCAM采用并行查找技术,使得查找速度和表项的条目数量无关。同时,为了实现较高的查找速度并得到最长前缀匹配(LPM,Longest Prefix Matching)的地址,在TCAM中要按照IP地址前缀的长度由长到短的顺序排列各类表项,最终可以实7现路由表在一百多万条条目的情况下,每秒上亿次的查找速度。
上述TCAM技术的优势在于:并行查找使得一个时钟周期可以完成查找过程,且可以级联多个TCAM来增加查找表容量,其实现比较简单。但是,TCAM技术仍然存在一些不足:第一、TCAM在同一时钟周期内需要将待查找的关键字和TCAM路由表中的每一个条目进行比较,所以功耗比较大;第二、由于TCAM实现的结构是待查找关键字和配置的路由表的每个条目同时进行比较,因此每个条目都对应一个比较器,从而导致TCAM器件成本比较高,价格昂贵;第三、由于采用TCAM技术实现所需的比较器总数与路由表中的路由条目总数相等,因此,在实际应用中,在一定程度上限制了采用TCAM实现的路由表的规模。
发明内容
为解决上述技术问题,本发明实施例期望提供一种路由表建立、以及IP路由查找方法、装置、存储介质,用以减少路由条目的比较次数,从而减少电路中比较器的个数,降低实现的成本和功耗。
本发明的技术方案是这样实现的:
第一方面,本发明实施例提供了一种路由表建立方法,所述方法包括:
获取路由信息;其中,所述路由信息至少包括虚拟路由转发域编号(VRF_ID,Virtual Route Forwarding ID)、IP地址和所述IP地址对应的输出端口;
根据所述VRF_ID和所述IP地址组合成一个路由条目区间;
利用预设的哈希算法对所述路由条目区间的起始端点中的VRF_ID进 行哈希运算,获得所述VRF_ID对应的哈希值;
利用所有所述哈希值相等的起始端点生成一个树表;其中,所述树表的叶子节点包含所述起始端点对应的输出端口,且所述IP地址对应的输出端口与所述起始端点对应的输出端口相同;
根据生成的所有树表构建主路由表。
在上述方案中,所述利用所有所述哈希值相等的起始端点生成一个树表;其中,所述树表的树节点用于确定匹配的端点及搜索路径。
在上述方案中,当所述树表为2-3树表时,所述利用所有所述哈希值相等的起始端点生成一个树表,具体包括:
将所有所述哈希值相等的起始端点按照由小到大的顺序排序,并将排序后的所有起始端点存放在数组a[n]中;
从所述数组a[n]中提取a[2×(i-1)]的数据作为所述树表的第一层从左至右的第i个节点的左端点;其中,1≤i≤(n+1)/2,n≥1;
从所述数组a[n]中提取a[2×(i-1)+1]的数据作为所述树表的第一层从左至右的第i个节点的右端点;
从所述数组a[n]中提取a[2×3(p-2)+2×3(p-1)×(k-1)]的数据作为所述树表的第p层从左至右的第k个节点的左端点;其中,p≥2,1≤k≤(log3t)-1,t为第p-1层的节点总数;
从所述数组a[n]中提取a[4×3(p-2)+2×3(p-1)×(k-1)]的数据作为所述树表的第p层从左至右的第k个节点的右端点。
在上述方案中,所述根据生成的所有树表构建主路由表,具体包括:根据所述哈希值索引的存储地址写入路由器对应的主路由表存储区,完成所述主路由表的构建。
在上述方案中,所述方法还包括:在完成所述主路由表建立的同时, 对所述主路由表进行备份。
在上述方案中,当需要对所述主路由表进行更新时,所述方法还包括:
根据新的配置规则调整所述树表的数据结构;
根据调整后的树表更新所述备份路由表;
从所述主路由表切换到所述备份路由表上进行IP路由的查找;
根据调整后的树表更新所述主路由表;
从所述备份路由表切换到所述主路由表上进行IP路由的查找。
第二方面,本发明实施例提供了一种IP路由查找方法,所述方法包括:
根据接收的IP数据包的输入端口和VLAN_ID映射获取所述IP数据包对应的VRF_ID;
读取所述IP数据包中的目的IP地址,并将所述目的IP地址与所述VRF_ID组合成一条待查找路由条目;
利用所述哈希算法对所述待查找路由条目中的VRF_ID进行哈希运算获得哈希值;
根据所述哈希值查找所述主路由表,确定所述IP数据包的输出端口;其中,所述主路由表为上述的主路由表。
在上述方案中,所述根据所述哈希值查找所述主路由表,确定所述IP数据包的输出端口,具体包括:
将所述哈希值作为所述主路由表表项存储地址的索引,从所述主路由表中索引获得所述哈希值对应的树表节点;其中,所述树表节点即为所述主路由表的表项;
根据所述树表节点的内容,查找获得与所述待查找路由条目相匹配的端点,获取所述IP数据包的输出端口。
在上述方案中,所述根据所述树表节点的内容,查找获得与所述待查 找路由条目相匹配的端点,获取所述IP数据包的输出端口,具体包括:
当所述节点内容中的节点类型为根节点或者中间节点时,根据所述待查找路由条目与所述节点端点的关系取出所述节点中的对应指针,并读取所述指针所指向的树表节点中的节点内容;
当所述节点内容中的节点类型为叶子节点时,根据所述待查找路由条目与所述叶子节点端点的关系,获取所述IP数据包的输出端口。
在上述方案中,当所述树表是2-3树表时,所述当所述节点内容中的节点类型为根节点或者中间节点时,根据所述待查找路由条目与所述节点端点的关系取出所述节点中的对应指针,并读取所述指针所指向的树表节点中的节点内容,具体包括:
当所述待查找路由条目小于所述节点的左端点时,取出所述节点中的左指针,读取所述左指针所指向的树表节点中的节点内容;
当所述待查找路由条目大于或等于所述节点的左端点,且小于所述节点的右端点时,取出所述节点中的中指针,读取所述中指针所指向的树表节点中的节点内容;
当所述待查找路由条目大于或等于所述节点的右端点时,取出所述节点中的右指针,读取所述右指针所指向的树表节点中的节点内容。
在上述方案中,当所述树表是2-3树表时,所述当所述节点内容中的节点类型为叶子节点时,根据所述待查找路由条目与所述叶子节点端点的关系,获取所述IP数据包的输出端口,具体包括:
当所述待查找路由条目与所述叶子节点的左端点相等时,将所述叶子节点的左端点对应的输出端口作为所述IP数据包的输出端口;
当所述待查找路由条目与所述叶子节点的右端点相等时,将所述叶子节点的右端点对应的输出端口作为所述IP数据包的输出端口;
当所述待查找路由条目大于所述叶子节点的左端点且小于所述叶子节 点的右端点时,将所述叶子节点的左端点和右端点组成的区间对应的输出端口作为所述IP数据包的输出端口;
当所述待查找路由条目大于所述叶子节点的右端点时,将大于所述叶子节点右端点的对应输出端口作为所述IP数据包的输出端口。
在上述方案中,当本层节点处理完当前IP数据包的路由查找后,所述方法还包括:所述本层节点立即将所述当前IP数据包交给下一层节点处理,并对下一个IP数据包进行IP路由查找。
第三方面,本发明实施例提供了一种路由表建立装置,所述装置包括:第一获取单元、第一组合单元、第一运算单元、树表生成单元、构建单元和更新单元;其中,
所述第一获取单元,配置为获取路由信息;其中,所述路由信息至少包括VRF_ID、IP地址和所述IP地址对应的输出端口;
所述第一组合单元,配置为根据所述VRF_ID和所述IP地址组合成一个路由条目区间;
所述第一运算单元,配置为利用预设的哈希算法对所述路由条目区间的起始端点中的VRF_ID进行哈希运算,获得所述VRF_ID对应的哈希值;
所述树表生成单元,配置为利用所有所述哈希值相等的起始端点生成一个树表;其中,所述树表的叶子节点包含所述起始端点对应的输出端口,且所述IP地址对应的输出端口与所述起始端点对应的输出端口相同;
所述构建单元,配置为根据生成的所有树表构建主路由表。
在上述方案中,所述树表生成单元生成的所述树表的树节点用于确定匹配的端点及搜索路径。
在上述方案中,当所述树表为2-3树表时,所述树表生成单元,配置为:
将所有所述哈希值相等的起始端点按照由小到大的顺序排序,并将排序后的所有起始端点存放在数组a[n]中;
从所述数组a[n]中提取a[2×(i-1)]的数据作为所述树表的第一层从左至右的第i个节点的左端点;其中,1≤i≤(n+1)/2,n≥1;
从所述数组a[n]中提取a[2×(i-1)+1]的数据作为所述树表的第一层从左至右的第i个节点的右端点;
从所述数组a[n]中提取a[2×3(p-2)+2×3(p-1)×(k-1)]的数据作为所述树表的第p层从左至右的第k个节点的左端点;其中,p≥2,1≤k≤(log3t)-1,t为第p-1层的节点总数;
从所述数组a[n]中提取a[4×3(p-2)+2×3(p-1)×(k-1)]的数据作为所述树表的第p层从左至右的第k个节点的右端点。
在上述方案中,所述构建单元,配置为:根据所述哈希值索引的存储地址写入路由器对应的主路由表存储区,完成所述主路由表的构建。
在上述方案中,所述构建单元,还配置为:对所述主路由表进行备份。
在上述方案中,所述更新单元,配置为:
根据新的配置规则调整所述树表的数据结构;
根据调整后的树表更新所述备份路由表;
从所述主路由表切换到所述备份路由表上进行IP路由的查找;
根据调整后的树表更新所述主路由表;
从所述备份路由表切换到所述主路由表上进行IP路由的查找。
第四方面,本发明实施例提供了一种IP路由查找装置,所述装置包括:第二获取单元、第二组合单元、第二运算单元和查找单元;其中,
所述第二获取单元,配置为根据接收的IP数据包的输入端口和VLAN_ID映射获取所述IP数据包对应的VRF_ID;
所述第二组合单元,配置为读取所述IP数据包中的目的IP地址,并将所述目的IP地址与所述VRF_ID组合成一条待查找路由条目;
所述第二运算单元,配置为利用所述哈希算法对所述待查找路由条目中的VRF_ID进行哈希运算获得哈希值;
所述查找单元,配置为根据所述哈希值查找所述主路由表,确定所述IP数据包的输出端口;其中,所述主路由表为所述路由表建立装置所构建的主路由表。
在上述方案中,所述查找单元,配置为:
将所述哈希值作为所述主路由表表项存储地址的索引,从所述主路由表中索引获得所述哈希值对应的树表节点;其中,所述树表节点即为所述主路由表的表项;
根据所述树表节点的内容,查找获得与所述待查找路由条目相匹配的端点,获取所述IP数据包的输出端口。
在上述方案中,所述查找单元,配置为:
当所述节点内容中的节点类型为根节点或者中间节点时,根据所述待查找路由条目与所述节点端点的关系取出所述节点中的对应指针,并读取所述指针所指向的树表节点中的节点内容;
当所述节点内容中的节点类型为叶子节点时,根据所述待查找路由条目与所述叶子节点端点的关系,获取所述IP数据包的输出端口。
在上述方案中,当所述树表为2-3树表时,所述查找单元,配置为:
当所述待查找路由条目小于所述节点的左端点时,取出所述节点中的左指针,读取所述左指针所指向的树表节点中的节点内容;
当所述待查找路由条目大于或等于所述节点的左端点,且小于所述节点的右端点时,取出所述节点中的中指针,读取所述中指针所指向的树表节点中的节点内容;
当所述待查找路由条目大于或等于所述节点的右端点时,取出所述节点中的右指针,读取所述右指针所指向的树表节点中的节点内容。
在上述方案中,当所述树表为2-3树表时,所述查找单元,配置为:
当所述待查找路由条目与所述叶子节点的左端点相等时,将所述叶子节点的左端点对应的输出端口作为所述IP数据包的输出端口;
当所述待查找路由条目与所述叶子节点的右端点相等时,将所述叶子节点的右端点对应的输出端口作为所述IP数据包的输出端口;
当所述待查找路由条目大于所述叶子节点的左端点且小于所述叶子节点的右端点时,将所述叶子节点的左端点和右端点组成的区间对应的输出端口作为所述IP数据包的输出端口;
当所述待查找路由条目大于所述叶子节点的右端点时,将大于所述叶子节点右端点的对应输出端口作为所述IP数据包的输出端口。
在上述方案中,所述查找单元,还配置为:当本层节点处理完当前IP数据包的路由查找后,立即将所述当前IP数据包交给下一层节点处理,并对下一个IP数据包进行IP路由查找。
本发明实施例还提供一种计算机存储介质,所述计算机存储介质中存储有计算机可执行指令,所述计算机可执行指令用于执行上述的路由表建立方法。
本发明实施例还提供一种计算机存储介质,所述计算机存储介质中存储有计算机可执行指令,所述计算机可执行指令用于执行上述的IP路由查找方法。
本发明实施例提供了一种路由表建立、以及IP路由查找方法、装置、存储介质,该方法采用双哈希运算分别完成所述主路由表的构建和IP路由的查找,并且采用树形数据结构构建所述主路由表,从而使得实现该方法的电路结构变得简单可行。另外,在IP路由查找阶段,该方法利用哈希运算对对应的VRF_ID进行哈希值提取,通过所述哈希值完成对所述主路由表的快速查找,实现目的IP地址的快速匹配,从而减少了路由条目的比较 次数,降低了实现成本。另外,从硬件实现的角度来讲,该方法使得实现的面积和功耗都远远小于TCAM。
附图说明
图1为本发明实施例提供的一种路由表建立方法的实现流程图;
图2为本发明实施例提供的一种树表生成方法示意图;
图3为本发明实施例提供的一种IP路由查找方法示意图;
图4为本发明实施例提供的一种根据所述哈希值查找所述主路由表的具体方法示意图;
图5为本发明实施例提供的一种根据所述树表节点的内容进行IP路由查找的具体方法示意图;
图6为本发明实施例提供的一种以2-3树表为例进行IP路由查找的具体方法示意图;
图7为本发明实施例提供的一种路由表更新方法示意图;
图8为本发明实施例提供的一种2-3树表的结构示意图;
图9为本发明实施例提供的一种2-3树表在所述主路由表中的存储格式示意图;
图10为本发明实施例提供的一种路由表建立装置的结构示意图;
图11为本发明实施例提供的一种IP路由查找装置的结构示意图。
具体实施方式
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述。
实施例一
如图1所示,该图给出了本发明实施例提供的一种路由表建立方法,所述方法具体可以包括:
S110、获取路由信息;其中,所述路由信息至少包括VRF_ID、互联网协议IP地址和所述IP地址对应的输出端口;
S120、根据所述VRF_ID和所述IP地址组合成一个路由条目区间;
例如,获取的路由信息包含的VRF_ID为8,目的IP地址为192.168.10.*,那么该目的IP地址对应的路由条目区间为8.192.168.10.0~8.192.168.10.255。
S130、利用预设的哈希算法对所述路由条目区间的起始端点中的VRF_ID进行哈希运算,获得所述VRF_ID对应的哈希值;
如上述例子,路由条目区间为8.192.168.10.0~8.192.168.10.255,容易得到该路由条目区间的起始端点为8.192.168.10.0,该端点的VRF_ID为该端点的第一个字节。
S140、利用所有哈希值相等的起始端点生成一个树表;其中,所述树表的叶子节点包含所述起始端点对应的输出端口,且所述IP地址对应的输出端口与所述起始端点对应的输出端口相同;
需要说明的是,所述树表可以是2-3树表,也可以是二叉树表或者多叉树表,只是2-3树表能够获得更好的查找时间。另外,所述树表与普通数据结构上的树表不同,所述树表的树节点用于确定匹配的端点及搜索路径。以2-3树表为例,对树表的构成进行说明。通常情况下,2-3树表由根节点、中间节点和叶子节点组成;其中,根节点包括节点类型、左指针、中指针、右指针和两个起始端点;同样地,中间节点也包括节点类型、左指针、中指针、右指针和两个起始端点;叶子节点包括节点类型、两个起始端点和两个起始端点分别对应的输出端口。容易理解地,指针用于指向指针地址指定的节点,在实际应用中,我们将两个起始端点中较小的那个起始端点作为节点的左端点,较大的那个起始端点作为节点的右端点,并用1比特来指示节点的类型。
S150、根据生成的所有树表构建主路由表。
需要说明的是,所述根据生成的所有树表构建主路由表,具体地,将生成的所有树表按照所述哈希值索引的存储地址写入路由器对应的主路由表存储区,完成所述主路由表的构建。为了方便后续对所述主路由表的更新,并在所述主路由表更新的同时避免出现丢包的情况,在完成所述主路由表构建的同时,将所述主路由表进行备份,写入备份路由表对应的存储区中。
示例性地,当所述树表为2-3树表时,所述利用所有哈希值相等的起始端点生成一个树表,如图2所示,具体可以包括:
S210、将所有哈希值相等的起始端点按照由小到大的顺序排序,并将排序后的所有起始端点存放在数组a[n]中;
需要说明的是,为了方便树表的构建,通常情况下,先将用于构建树表的起始端点按照由小到大的顺序排序。其中,数组a[n]中n的值为所有哈希值相等的起始端点的总数;
S220、从所述数组a[n]中提取a[2×(i-1)]的数据作为所述树表的第一层从左至右的第i个节点的左端点;其中,1≤i≤(n+1)/2,n≥1;
S230、从所述数组a[n]中提取a[2×(i-1)+1]的数据作为所述树表的第一层从左至右的第i个节点的右端点;
S240、从所述数组a[n]中提取a[2×3(p-2)+2×3(p-1)×(k-1)]的数据作为所述树表的第p层从左至右的第k个节点的左端点;其中,p≥2,1≤k≤(log3t)-1,t为第p-1层的节点总数;
S250、从所述数组a[n]中提取a[4×3(p-2)+2×3(p-1)×(k-1)]的数据作为所述树表的第p层从左至右的第k个节点的右端点。
需要说明的是,2-3树表的最底层为叶子层,记为第一层;叶子层的上 一层为第二层,层数由下而上依次递增。二叉树表和多叉树表的生成方法与2-3树表类似,都是从数组a[n]中提取出对应的数据组成树形结构,只是数组的下标不同而已。
在完成所述主路由表的建立后,如图3所示,本发明实施例还提供了一种IP路由查找方法,所述方法具体可以包括:
S310、根据接收的IP数据包的输入端口和VLAN_ID映射获取所述IP数据包对应的VRF_ID;
需要说明的是,路由器可以根据接收的IP数据包的输入端口和VLAN_ID通过查表获得所述IP数据包对应的VRF_ID。
S320、读取所述IP数据包中的目的IP地址,并将所述目的IP地址与所述VRF_ID组合成一条待查找路由条目;
S330、利用所述哈希算法对所述待查找路由条目中的VRF_ID进行哈希运算获得哈希值;
需要说明的是,IP路由查找方法中所采用的哈希算法与所述主路由表建立方法中所采用的哈希算法是相同的。
S340、根据所述哈希值查找所述主路由表,确定所述IP数据包的输出端口。
示例性地,根据所述哈希值查找所述主路由表,确定所述IP数据包的输出端口,如图4所示,具体可以包括:
S410、将所述哈希值作为所述主路由表表项存储地址的索引,从所述主路由表中索引获得所述哈希值对应的树表节点;其中,所述树表节点就是所述主路由表的表项;
S420、根据所述树表节点的内容,查找获得与所述待查找路由条目相匹配的端点,获取所述IP数据包的输出端口。
示例性地,根据所述树表节点的内容,查找获得与所述待查找路由条 目相匹配的端点,获取所述IP数据包的输出端口,如图5所示,具体可以包括:
S510、判断所述节点内容中的节点类型是否是叶子节点;如果是,执行步骤S530;否则,执行步骤S520;
S520、根据所述待查找路由条目与所述节点端点的关系取出所述节点中的对应指针,读取所述指针所指向的树表节点中的节点内容,并返回执行步骤S510;
S530、根据所述待查找路由条目与所述叶子节点端点的关系,获取所述IP数据包的输出端口。
为了方便对上述IP路由具体查找过程的理解,以下以所述树表为2-3树表为例,对所述根据所述树表节点的内容,查找获得与所述待查找路由条目相匹配的端点,获取所述IP数据包的输出端口的具体实现方法进行说明,如图6所示,具体可以包括:
S610、判断所述节点内容中的节点类型是否是叶子节点;如果是,则执行步骤S630;否则,执行步骤S620;
S620、判断所述待查找路由条目是否小于所述节点的左端点;如果是,执行步骤S621;否则,执行步骤S622;
S621、取出所述节点中的左指针,读取所述左指针所指向的树表节点中的节点内容,并返回执行步骤S610;
S622、判断所述待查找路由条目是否大于或等于所述节点的左端点,且小于所述节点的右端点;如果是,执行步骤S623;否则,执行步骤S624;
S623、取出所述节点中的中指针,读取所述中指针所指向的树表节点中的节点内容,并返回执行步骤S610;
S624、取出所述节点中的右指针,读取所述右指针所指向的树表节点中的节点内容,并返回执行步骤S610;
S630、判断所述待查找路由条目与所述叶子节点的左端点是否相等;如果是,执行步骤S631;否则,执行步骤S632;
S631、将所述叶子节点的左端点对应的输出端口作为所述IP数据包的输出端口;
S632、判断所述待查找路由条目与所述叶子节点的右端点是否相等;如果是,执行步骤S633;否则,执行步骤S634;
S633、将所述叶子节点的右端点对应的输出端口作为所述IP数据包的输出端口;
S634、判断所述待查找路由条目是否落在所述叶子节点的左端点和右端点之间;如果是,执行步骤S635;否则,执行步骤S636;
S635、将所述左端点和所述右端点组成的区间对应的输出端口作为所述IP数据包的输出端口;
S636、将大于所述右端点的对应输出端口作为所述IP数据包的输出端口。
需要说明的是,由于信息爆炸性的增长,所以网络流量也迅速增大,为了使交换设备能够适应网络流量的需要,交换设备应该达到线速交换处理能力,因此目的IP的路由查找也需要能够达到线速处理能力。如果上述一个IP数据包的目的IP路由查找引擎满足设备的线速处理能力,那么在实际应用中,为了适应网络流量的需求,可以将树表进行水平分割,即查找引擎处理完本层节点的查找后,将当前处理的IP数据包交给下一层节点查找引擎处理,此时,本层节点查找引擎立即处理下一个IP数据包,而不必等待整个树表的查找过程结束才处理下一个IP数据包。
另外,电信级交换设备需要能够连续不间断地工作并且达到一个较小的丢包率,即使在更新所述主路由表的时候也不允许丢包;因此,在实际应用中,如图7所示,所述主路由表的更新方法具体可以包括:
S710、根据新的配置规则调整所述树表的数据结构;
S720、中央处理器(CPU,Central Processing Unit)开始根据调整后的树表更新所述备份路由表;
S730、完成所述备份路由表的更新后,CPU请求硬件从所述主路由表切换到所述备份路由表上进行IP路由的查找;
S740、硬件完成路由表的切换后上报中断给CPU,CPU接收到中断后开始更新所述主路由表;
S750、CPU完成所述主路由表的更新后请求硬件从所述备份路由表切换到所述主路由表上进行IP路由的查找。
本发明实施例提供了一种IP路由查找方法,该方法采用双哈希运算分别完成所述主路由表的构建和IP路由的查找,并且采用树形数据结构构建所述主路由表,从而使得实现该方法的电路结构变得简单可行。另外,在IP路由查找阶段,该方法利用哈希运算对对应的VRF_ID进行哈希值提取,通过所述哈希值完成对所述主路由表的快速查找,实现目的IP地址的快速匹配,从而减少了路由条目的比较次数,降低了实现成本。另外,从硬件实现的角度来讲,该方法使得实现的面积和功耗都远远小于TCAM。
实施例二
基于前述实施例相同的技术构思,本实施例将结合图8对前述实施例的技术方案作更为直观、详细的说明。
假设所述主路由表由一个2-3树表构成,如图8所示,且该树表包含9个叶子节点,每个叶子节点包含2个起始端点,将每个起始端点作为所述主路由表的一个条目,则该主路由表的条目总数为18,每个主路由表的表项包含两个条目。当路由器接收到一个IP数据包时,其VRF_ID为8,目的IP地址为192.168.10.19,那么待查找的路由条目为8.192.168.10.19。首先取VRF_ID做哈希运算,假设哈希函数为除8取整数部分,那么8除以8 的商为1,即哈希值(hash_idx)为1。用hash_idx指示的地址读取所述主路由表的表项,表项内容为图8所示的2-3树表的树根节点,即9.192.168.10.0/10.192.168.10.0。判断节点的类型为根节点,然后用待查找路由条目8.192.168.10.19和该根节点的左右端点进行比较,结果小于根节点的左端点9.192.168.10.0,所以取左指针作为所述主路由表的地址读取对应的表项,得到8.192.168.70.0/8.192.168.110.0。此时判断节点的类型为中间节点,则用待查找路由条目8.192.168.10.19和该中间节点的左右端点进行比较,发现待查找路由条目8.192.168.10.19小于该中间节点的左端点8.192.168.70.0,所以取左指针作为所述主路由表的地址读取对应的表项,得到节点8.192.168.10.0/8.192.168.20.0,判断该节点为叶子节点,待查找路由条目8.192.168.10.19大于该叶子节点的左端点8.192.168.10.0并且小于该叶子节点的右端点8.192.168.20.0,所以取8.192.168.10.0对应的输出端口作为该数据包的输出端口。
另外,需要说明的是,图9为图8在所述主路由表中的存储格式,其中:
Key1为8.192.168.10.0,对应的输出端口为1;
Key2为8.192.168.20.0,对应的输出端口为2;
Key3为8.192.168.70.0,对应的输出端口为3;
Key4为8.192.168.90.0,对应的输出端口为4;
Key5为8.192.168.110.0,对应的输出端口为5;
Key6为8.192.168.140.0,对应的输出端口为6;
Key7为9.192.168.10.0,对应的输出端口为7;
……
Key13为10.192.168.10.0,对应的输出端口为13;
……
Key18为10.192.168.140.0,对应的输出端口为18。
节点类型为根节点、中间节点和叶子节点。根节点和中间节点的条目格式一样,都包含两个路由条目区间的起始端点、左指针、中指针、右指针和节点类型(根节点或中间节点)。叶子节点条目的格式为两个路由条目区间的起始端点、每个端点对应的输出端口和节点类型(叶子节点)。
从上述的查找过程可以看出对应18个条目的主路由表,采用上述的查找方法只需要3次比较或采用3个比较器就可以完成本次查找;但是,采用TCAM需要18个比较器才能完成本次查找。因此,根据公式(1)可知,采用本发明所提供的方法实现IP最长前缀匹配比采用TCAM实现的IP最长前缀匹配少了15次比较或15个比较器。
Figure PCTCN2017088765-appb-000001
其中,N为主路由表的条目总数,同时N也是采用TCAM技术所需的比较次数或比较器个数,
Figure PCTCN2017088765-appb-000002
表示采用本发明所提供的方法实现所需的比较次数或比较器个数。
从上述实例中可以容易知道,相比于现有的TCAM技术,本发明实施例所提供的一种路由查找方法极大的减少了查找次数或实现的资源,其实现成本低,功耗小。此外,由于本发明采用普通的易挥发性随机存取存储器(RAM,RamdomAccessMemory)或双倍速率同步动态随机存储器(DDR,Dual Data Rate)实现,可以适用于需要大规模路由表的路由器,而TCAM由于物理实现的原因只适用于需要小规模路由表的路由器。
实施例三
基于前述实施例相同的技术构思,参见图10,其示出了本发明实施例提供的一种路由表建立装置100,所述装置可以包括:第一获取单元1010、第一组合单元1020、第一运算单元1030、树表生成单元1040、构建单元 1050和更新单元1060;其中,
所述第一获取单元1010,配置为获取路由信息;其中,所述路由信息至少包括VRF_ID、IP地址和所述IP地址对应的输出端口;
所述第一组合单元1020,配置为根据所述VRF_ID和所述IP地址组合成一个路由条目区间;
所述第一运算单元1030,配置为利用预设的哈希算法对所述路由条目区间的起始端点中的VRF_ID进行哈希运算,获得所述VRF_ID对应的哈希值;
所述树表生成单元1040,配置为利用所有所述哈希值相等的起始端点生成一个树表;其中,所述树表的叶子节点包含所述起始端点对应的输出端口,且所述IP地址对应的输出端口与所述起始端点对应的输出端口相同;
所述构建单元1050,配置为根据生成的所有树表构建主路由表。
在上述方案中,所述树表生成单元1040生成的所述树表的树节点用于确定匹配的端点及搜索路径。
在上述方案中,当所述树表为2-3树表时,所述树表生成单元1040,配置为:
将所有所述哈希值相等的起始端点按照由小到大的顺序排序,并将排序后的所有起始端点存放在数组a[n]中;
从所述数组a[n]中提取a[2×(i-1)]的数据作为所述树表的第一层从左至右的第i个节点的左端点;其中,1≤i≤(n+1)/2,n≥1;
从所述数组a[n]中提取a[2×(i-1)+1]的数据作为所述树表的第一层从左至右的第i个节点的右端点;
从所述数组a[n]中提取a[2×3(p-2)+2×3(p-1)×(k-1)]的数据作为所述树表的第p层从左至右的第k个节点的左端点;其中,p≥2,1≤k≤(log3t)-1,t为 第p-1层的节点总数;
从所述数组a[n]中提取a[4×3(p-2)+2×3(p-1)×(k-1)]的数据作为所述树表的第p层从左至右的第k个节点的右端点。
在上述方案中,所述构建单元1050,配置为:根据所述哈希值索引的存储地址写入路由器对应的主路由表存储区,完成所述主路由表的构建。
在上述方案中,所述构建单元1050,还配置为:对所述主路由表进行备份。
在上述方案中,所述路由表建立装置100中的所述更新单元1060,配置为:
根据新的配置规则调整所述树表的数据结构;
根据调整后的树表更新所述备份路由表;
从所述主路由表切换到所述备份路由表上进行IP路由的查找;
根据调整后的树表更新所述主路由表;
从所述备份路由表切换到所述主路由表上进行IP路由的查找。
另外,在完成所述主路由表建立的基础上,本发明实施例还提供一种IP路由查找装置110,如图11所示,所述装置包括:第二获取单元1110、第二组合单元1120、第二运算单元1130和查找单元1140;其中,
所述第二获取单元1110,配置为根据接收的IP数据包的输入端口和VLAN_ID映射获取所述IP数据包对应的VRF_ID;
所述第二组合单元1120,配置为读取所述IP数据包中的目的IP地址,并将所述目的IP地址与所述VRF_ID组合成一条待查找路由条目;
所述第二运算单元1130,配置为利用所述哈希算法对所述待查找路由条目中的VRF_ID进行哈希运算获得哈希值;
需要说明的是,所述第二运算单元1130中所采用的哈希算法与所述第一运算单元1030中所采用的哈希算法是相同的。
所述查找单元1140,配置为根据所述哈希值查找所述主路由表,确定所述IP数据包的输出端口;其中,所述主路由表为所述路由表建立装置100所构建的主路由表。
在上述方案中,所述查找单元1140,配置为:
将所述哈希值作为所述主路由表表项存储地址的索引,从所述主路由表中索引获得所述哈希值对应的树表节点;其中,所述树表节点即为所述主路由表的表项;
根据所述树表节点的内容,查找获得与所述待查找路由条目相匹配的端点,获取所述IP数据包的输出端口。
在上述方案中,所述查找单元1140,配置为:
当所述节点内容中的节点类型为根节点或者中间节点时,根据所述待查找路由条目与所述节点端点的关系取出所述节点中的对应指针,并读取所述指针所指向的树表节点中的节点内容;
当所述节点内容中的节点类型为叶子节点时,根据所述待查找路由条目与所述叶子节点端点的关系,获取所述IP数据包的输出端口。
在上述方案中,当所述树表为2-3树表时,所述查找单元1140,配置为:
当所述待查找路由条目小于所述节点的左端点时,取出所述节点中的左指针,读取所述左指针所指向的树表节点中的节点内容;
当所述待查找路由条目大于或等于所述节点的左端点,且小于所述节点的右端点时,取出所述节点中的中指针,读取所述中指针所指向的树表节点中的节点内容;
当所述待查找路由条目大于或等于所述节点的右端点时,取出所述节点中的右指针,读取所述右指针所指向的树表节点中的节点内容。
在上述方案中,当所述树表为2-3树表时,所述查找单元1140,还配 置为:
当所述待查找路由条目与所述叶子节点的左端点相等时,将所述叶子节点的左端点对应的输出端口作为所述IP数据包的输出端口;
当所述待查找路由条目与所述叶子节点的右端点相等时,将所述叶子节点的右端点对应的输出端口作为所述IP数据包的输出端口;
当所述待查找路由条目大于所述叶子节点的左端点且小于所述叶子节点的右端点时,将所述叶子节点的左端点和右端点组成的区间对应的输出端口作为所述IP数据包的输出端口;
当所述待查找路由条目大于所述叶子节点的右端点时,将大于所述叶子节点右端点的对应输出端口作为所述IP数据包的输出端口。
在上述方案中,所述查找单元1140,还配置为:当本层节点处理完当前IP数据包的路由查找后,立即将所述当前IP数据包交给下一层节点处理,并对下一个IP数据包进行IP路由查找。
本发明实施例中提出的路由表建立装置中的第一获取单元1010、第一组合单元1020、第一运算单元1030、树表生成单元1040、构建单元1050和更新单元1060都可以通过处理器来实现,当然也可通过具体的逻辑电路实现;在实际应用中,处理器可以为CPU、微处理器(MPU)、数字信号处理器(DSP)或现场可编程门阵列(FPGA)等。
本发明实施例中提出的IP路由查找装置中的第二获取单元1110、第二组合单元1120、第二运算单元1130和查找单元1140都可以通过处理器来实现,当然也可通过具体的逻辑电路实现;在实际应用中,处理器可以为CPU、MPU、DSP或FPGA等。
本发明实施例中,如果以软件功能模块的形式实现上述减少时延的方法,并作为独立的产品销售或使用时,也可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明实施例的技术方案本质上或者说对现 有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机、服务器、或者网络设备等)执行本发明各个实施例所述方法的全部或部分。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read Only Memory,ROM)、磁碟或者光盘等各种可以存储程序代码的介质。这样,本发明实施例不限制于任何特定的硬件和软件结合。
相应地,本发明实施例还提供一种计算机存储介质,该计算机存储介质中存储有计算机程序,该计算机程序用于执行本发明实施例的上述路由表建立方法。
本发明实施例还提供一种计算机存储介质,该计算机存储介质中存储有计算机程序,该计算机程序用于执行本发明实施例的上述IP路由查找方法。
本领域内的技术人员应明白,本发明的实施例可提供为方法、系统、或计算机程序产品。因此,本发明可采用硬件实施例、软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器和光学存储器等)上实施的计算机程序产品的形式。
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
以上所述,仅为本发明的较佳实施例而已,并非用于限定本发明的保护范围。
工业实用性
本发明实施例获取包括VRF_ID、IP地址和所述IP地址对应的输出端口的路由信息;根据所述VRF_ID和所述IP地址组合成一个路由条目区间;利用预设的哈希算法对所述路由条目区间的起始端点中的VRF_ID进行哈希运算,获得所述VRF_ID对应的哈希值;利用所有所述哈希值相等的起始端点生成一个树表;其中,所述树表的叶子节点包含所述起始端点对应的输出端口,且所述IP地址对应的输出端口与所述起始端点对应的输出端口相同;根据生成的所有树表构建主路由表。如此,使得实现该方法的电路结构变得简单可行。在IP路由查找阶段,根据接收的IP数据包的输入端口和VLAN_ID映射获取所述IP数据包对应的VRF_ID;读取所述IP数据包中的目的IP地址,并将所述目的IP地址与所述VRF_ID组合成一条待查找路由条目;利用所述哈希算法对所述待查找路由条目中的VRF_ID进行哈希运算获得哈希值;根据所述哈希值查找所述主路由表,确定所述IP数据包的输出端口。如此,减少了路由条目的比较次数,降低了实现成本。

Claims (26)

  1. 一种路由表建立方法,所述方法包括:
    获取路由信息;其中,所述路由信息至少包括虚拟路由转发域编号VRF_ID、互联网协议IP地址和所述IP地址对应的输出端口;
    根据所述VRF_ID和所述IP地址组合成一个路由条目区间;
    利用预设的哈希算法对所述路由条目区间的起始端点中的VRF_ID进行哈希运算,获得所述VRF_ID对应的哈希值;
    利用所有所述哈希值相等的起始端点生成一个树表;其中,所述树表的叶子节点包含所述起始端点对应的输出端口,且所述IP地址对应的输出端口与所述起始端点对应的输出端口相同;
    根据生成的所有树表构建主路由表。
  2. 根据权利要求1所述的方法,其中,所述树表的树节点用于确定匹配的端点及搜索路径。
  3. 根据权利要求1所述的方法,其中,当所述树表为2-3树表时,所述利用所有所述哈希值相等的起始端点生成一个树表,包括:
    将所有所述哈希值相等的起始端点按照由小到大的顺序排序,并将排序后的所有起始端点存放在数组a[n]中;
    从所述数组a[n]中提取a[2×(i-1)]的数据作为所述树表的第一层从左至右的第i个节点的左端点;其中,1≤i≤(n+1)/2,n≥1;
    从所述数组a[n]中提取a[2×(i-1)+1]的数据作为所述树表的第一层从左至右的第i个节点的右端点;
    从所述数组a[n]中提取a[2×3(p-2)+2×3(p-1)×(k-1)]的数据作为所述树表的第p层从左至右的第k个节点的左端点;其中,p≥2,1≤k≤(log3t)-1,t为第p-1层的节点总数;
    从所述数组a[n]中提取a[4×3(p-2)+2×3(p-1)×(k-1)]的数据作为所述树表的第p层从左至右的第k个节点的右端点。
  4. 根据权利要求1所述的方法,其中,所述根据生成的所有树表构建主路由表,包括:
    根据所述哈希值索引的存储地址写入路由器对应的主路由表存储区,完成所述主路由表的构建。
  5. 根据权利要求1所述的方法,其中,所述方法还包括:
    在完成所述主路由表建立的同时,对所述主路由表进行备份。
  6. 根据权利要求1所述的方法,其中,当需要对所述主路由表进行更新时,所述方法还包括:
    根据新的配置规则调整所述树表的数据结构;
    根据调整后的树表更新所述备份路由表;
    从所述主路由表切换到所述备份路由表上进行IP路由的查找;
    根据调整后的树表更新所述主路由表;
    从所述备份路由表切换到所述主路由表上进行IP路由的查找。
  7. 一种IP路由查找方法,所述方法包括:
    根据接收的IP数据包的输入端口和虚拟局域网编号VLAN_ID映射获取所述IP数据包对应的VRF_ID;
    读取所述IP数据包中的目的IP地址,并将所述目的IP地址与所述VRF_ID组合成一条待查找路由条目;
    利用所述哈希算法对所述待查找路由条目中的VRF_ID进行哈希运算获得哈希值;
    根据所述哈希值查找所述主路由表,确定所述IP数据包的输出端口;其中,所述主路由表为权利要求1至6任一项所述的主路由表。
  8. 根据权利要求7所述的方法,其中,所述根据所述哈希值查找所 述主路由表,确定所述IP数据包的输出端口,包括:
    将所述哈希值作为所述主路由表表项存储地址的索引,从所述主路由表中索引获得所述哈希值对应的树表节点;其中,所述树表节点即为所述主路由表的表项;
    根据所述树表节点的内容,查找获得与所述待查找路由条目相匹配的端点,获取所述IP数据包的输出端口。
  9. 根据权利要求8所述的方法,其中,所述根据所述树表节点的内容,查找获得与所述待查找路由条目相匹配的端点,获取所述IP数据包的输出端口,包括:
    当所述节点内容中的节点类型为根节点或者中间节点时,根据所述待查找路由条目与所述节点端点的关系取出所述节点中的对应指针,并读取所述指针所指向的树表节点中的节点内容;
    当所述节点内容中的节点类型为叶子节点时,根据所述待查找路由条目与所述叶子节点端点的关系,获取所述IP数据包的输出端口。
  10. 根据权利要求9所述的方法,其中,当所述树表是2-3树表时,所述当所述节点内容中的节点类型为根节点或者中间节点时,根据所述待查找路由条目与所述节点端点的关系取出所述节点中的对应指针,并读取所述指针所指向的树表节点中的节点内容,包括:
    当所述待查找路由条目小于所述节点的左端点时,取出所述节点中的左指针,读取所述左指针所指向的树表节点中的节点内容;
    当所述待查找路由条目大于或等于所述节点的左端点,且小于所述节点的右端点时,取出所述节点中的中指针,读取所述中指针所指向的树表节点中的节点内容;
    当所述待查找路由条目大于或等于所述节点的右端点时,取出所述节点中的右指针,读取所述右指针所指向的树表节点中的节点内容。
  11. 根据权利要求9所述的方法,其中,当所述树表是2-3树表时,所述当所述节点内容中的节点类型为叶子节点时,根据所述待查找路由条目与所述叶子节点端点的关系,获取所述IP数据包的输出端口,包括:
    当所述待查找路由条目与所述叶子节点的左端点相等时,将所述叶子节点的左端点对应的输出端口作为所述IP数据包的输出端口;
    当所述待查找路由条目与所述叶子节点的右端点相等时,将所述叶子节点的右端点对应的输出端口作为所述IP数据包的输出端口;
    当所述待查找路由条目大于所述叶子节点的左端点且小于所述叶子节点的右端点时,将所述叶子节点的左端点和右端点组成的区间对应的输出端口作为所述IP数据包的输出端口;
    当所述待查找路由条目大于所述叶子节点的右端点时,将大于所述叶子节点右端点的对应输出端口作为所述IP数据包的输出端口。
  12. 根据权利要求9至11任一项中所述的方法,其中,当本层节点处理完当前IP数据包的路由查找后,所述方法还包括:
    所述本层节点立即将所述当前IP数据包交给下一层节点处理,并对下一个IP数据包进行IP路由查找。
  13. 一种路由表建立装置,所述装置包括:第一获取单元、第一组合单元、第一运算单元、树表生成单元、构建单元和更新单元;其中,
    所述第一获取单元,配置为获取路由信息;其中,所述路由信息至少包括虚拟路由转发域编号VRF_ID、IP地址和所述IP地址对应的输出端口;
    所述第一组合单元,配置为根据所述VRF_ID和所述IP地址组合成一个路由条目区间;
    所述第一运算单元,配置为利用预设的哈希算法对所述路由条目区间的起始端点中的VRF_ID进行哈希运算,获得所述VRF_ID对应的哈 希值;
    所述树表生成单元,配置为利用所有所述哈希值相等的起始端点生成一个树表;其中,所述树表的叶子节点包含所述起始端点对应的输出端口,且所述IP地址对应的输出端口与所述起始端点对应的输出端口相同;
    所述构建单元,配置为根据生成的所有树表构建主路由表。
  14. 根据权利要求13所述的装置,其特征在于,所述树表生成单元生成的所述树表的树节点用于确定匹配的端点及搜索路径。
  15. 根据权利要求13所述的装置,其中,当所述树表为2-3树表时,所述树表生成单元,配置为:
    将所有所述哈希值相等的起始端点按照由小到大的顺序排序,并将排序后的所有起始端点存放在数组a[n]中;
    从所述数组a[n]中提取a[2×(i-1)]的数据作为所述树表的第一层从左至右的第i个节点的左端点;其中,1≤i≤(n+1)/2,n≥1;
    从所述数组a[n]中提取a[2×(i-1)+1]的数据作为所述树表的第一层从左至右的第i个节点的右端点;
    从所述数组a[n]中提取a[2×3(p-2)+2×3(p-1)×(k-1)]的数据作为所述树表的第p层从左至右的第k个节点的左端点;其中,p≥2,1≤k≤(log3t)-1,t为第p-1层的节点总数;
    从所述数组a[n]中提取a[4×3(p-2)+2×3(p-1)×(k-1)]的数据作为所述树表的第p层从左至右的第k个节点的右端点。
  16. 根据权利要求13所述的装置,其中,所述构建单元,配置为:根据所述哈希值索引的存储地址写入路由器对应的主路由表存储区,完成所述主路由表的构建。
  17. 根据权利要求13所述的装置,其中,所述构建单元,还配置为:对所述主路由表进行备份。
  18. 根据权利要求13所述的装置,其特征在于,所述更新单元,配置为:
    根据新的配置规则调整所述树表的数据结构;
    根据调整后的树表更新所述备份路由表;
    从所述主路由表切换到所述备份路由表上进行IP路由的查找;
    根据调整后的树表更新所述主路由表;
    从所述备份路由表切换到所述主路由表上进行IP路由的查找。
  19. 一种IP路由查找装置,其中,所述装置包括:第二获取单元、第二组合单元、第二运算单元和查找单元;其中,
    所述第二获取单元,配置为根据接收的IP数据包的输入端口和虚拟局域网编号VLAN_ID映射获取所述IP数据包对应的VRF_ID;
    所述第二组合单元,配置为读取所述IP数据包中的目的IP地址,并将所述目的IP地址与所述VRF_ID组合成一条待查找路由条目;
    所述第二运算单元,配置为利用所述哈希算法对所述待查找路由条目中的VRF_ID进行哈希运算获得哈希值;
    所述查找单元,配置为根据所述哈希值查找所述主路由表,确定所述IP数据包的输出端口;所述主路由表为所述路由表建立装置所构建的主路由表。
  20. 根据权利要求19所述的装置,其中,所述查找单元,配置为:
    将所述哈希值作为所述主路由表表项存储地址的索引,从所述主路由表中索引获得所述哈希值对应的树表节点;其中,所述树表节点即为所述主路由表的表项;
    根据所述树表节点的内容,查找获得与所述待查找路由条目相匹配 的端点,获取所述IP数据包的输出端口。
  21. 根据权利要求20所述的装置,其中,所述查找单元,配置为:
    当所述节点内容中的节点类型为根节点或者中间节点时,根据所述待查找路由条目与所述节点端点的关系取出所述节点中的对应指针,并读取所述指针所指向的树表节点中的节点内容;
    当所述节点内容中的节点类型为叶子节点时,根据所述待查找路由条目与所述叶子节点端点的关系,获取所述IP数据包的输出端口。
  22. 根据权利要求20所述的装置,其中,当所述树表为2-3树表时,所述查找单元,配置为:
    当所述待查找路由条目小于所述节点的左端点时,取出所述节点中的左指针,读取所述左指针所指向的树表节点中的节点内容;
    当所述待查找路由条目大于或等于所述节点的左端点,且小于所述节点的右端点时,取出所述节点中的中指针,读取所述中指针所指向的树表节点中的节点内容;
    当所述待查找路由条目大于或等于所述节点的右端点时,取出所述节点中的右指针,读取所述右指针所指向的树表节点中的节点内容。
  23. 根据权利要求20所述的装置,其中,当所述树表为2-3树表时,所述查找单元,配置为:
    当所述待查找路由条目与所述叶子节点的左端点相等时,将所述叶子节点的左端点对应的输出端口作为所述IP数据包的输出端口;
    当所述待查找路由条目与所述叶子节点的右端点相等时,将所述叶子节点的右端点对应的输出端口作为所述IP数据包的输出端口;
    当所述待查找路由条目大于所述叶子节点的左端点且小于所述叶子节点的右端点时,将所述叶子节点的左端点和右端点组成的区间对应的输出端口作为所述IP数据包的输出端口;
    当所述待查找路由条目大于所述叶子节点的右端点时,将大于所述叶子节点右端点的对应输出端口作为所述IP数据包的输出端口。
  24. 根据权利要求19所述的装置,其中,所述查找单元,还配置为:当本层节点处理完当前IP数据包的路由查找后,立即将所述当前IP数据包交给下一层节点处理,并对下一个IP数据包进行IP路由查找。
  25. 一种计算机存储介质,所述计算机存储介质中存储有计算机可执行指令,所述计算机可执行指令用于执行权利要求1至6任一项所述的路由表建立方法。
  26. 一种计算机存储介质,所述计算机存储介质中存储有计算机可执行指令,所述计算机可执行指令用于执行权利要求7至12任一项所述的IP路由查找方法。
PCT/CN2017/088765 2016-10-12 2017-06-16 路由表建立、以及ip路由查找方法、装置、存储介质 WO2018068524A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201610892179.5A CN107948060A (zh) 2016-10-12 2016-10-12 一种新型的路由表建立、以及ip路由查找方法和装置
CN201610892179.5 2016-10-12

Publications (1)

Publication Number Publication Date
WO2018068524A1 true WO2018068524A1 (zh) 2018-04-19

Family

ID=61905016

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/088765 WO2018068524A1 (zh) 2016-10-12 2017-06-16 路由表建立、以及ip路由查找方法、装置、存储介质

Country Status (2)

Country Link
CN (1) CN107948060A (zh)
WO (1) WO2018068524A1 (zh)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111404820A (zh) * 2020-03-09 2020-07-10 深信服科技股份有限公司 一种路由查询方法、装置、设备及可读存储介质
CN111488178A (zh) * 2019-01-29 2020-08-04 戴尔产品有限公司 用于解决方案集成标记的方法和系统
CN113098727A (zh) * 2019-12-23 2021-07-09 上海云盾信息技术有限公司 一种数据包检测处理方法与设备
CN113132261A (zh) * 2019-12-31 2021-07-16 北京金山云网络技术有限公司 一种流量数据包分类方法、装置及电子设备
CN113726660A (zh) * 2021-08-27 2021-11-30 西安微电子技术研究所 一种基于完美哈希算法的路由查找器和方法
WO2023131307A1 (zh) * 2022-01-10 2023-07-13 中兴通讯股份有限公司 微波网络根节点查询方法及装置、微波系统和存储介质

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108737276B (zh) * 2018-06-19 2020-08-25 中国科学技术大学 一种构建路由表数据结构并实现路由转发的方法
CN116208553A (zh) * 2023-03-13 2023-06-02 苏州盛科通信股份有限公司 扩大vrf路由表项的芯片实现方法及应用

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101707617A (zh) * 2009-12-04 2010-05-12 福建星网锐捷网络有限公司 报文过滤方法、装置及网络设备
CN103546380A (zh) * 2013-11-05 2014-01-29 迈普通信技术股份有限公司 一种基于策略路由的报文转发方法和装置
CN104866502A (zh) * 2014-02-25 2015-08-26 深圳市中兴微电子技术有限公司 数据匹配的方法及装置
US20150281073A1 (en) * 2014-03-31 2015-10-01 Dell Products, L.P. System and method for context aware network
CN105391634A (zh) * 2015-12-08 2016-03-09 福建星网锐捷网络有限公司 一种报文处理方法、装置及交换机

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2887584A1 (en) * 2013-12-23 2015-06-24 BAE Systems PLC Data Capture

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101707617A (zh) * 2009-12-04 2010-05-12 福建星网锐捷网络有限公司 报文过滤方法、装置及网络设备
CN103546380A (zh) * 2013-11-05 2014-01-29 迈普通信技术股份有限公司 一种基于策略路由的报文转发方法和装置
CN104866502A (zh) * 2014-02-25 2015-08-26 深圳市中兴微电子技术有限公司 数据匹配的方法及装置
US20150281073A1 (en) * 2014-03-31 2015-10-01 Dell Products, L.P. System and method for context aware network
CN105391634A (zh) * 2015-12-08 2016-03-09 福建星网锐捷网络有限公司 一种报文处理方法、装置及交换机

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111488178A (zh) * 2019-01-29 2020-08-04 戴尔产品有限公司 用于解决方案集成标记的方法和系统
CN111488178B (zh) * 2019-01-29 2023-09-05 戴尔产品有限公司 用于解决方案集成标记的方法和系统
CN113098727A (zh) * 2019-12-23 2021-07-09 上海云盾信息技术有限公司 一种数据包检测处理方法与设备
CN113132261A (zh) * 2019-12-31 2021-07-16 北京金山云网络技术有限公司 一种流量数据包分类方法、装置及电子设备
CN111404820A (zh) * 2020-03-09 2020-07-10 深信服科技股份有限公司 一种路由查询方法、装置、设备及可读存储介质
CN111404820B (zh) * 2020-03-09 2022-04-29 深信服科技股份有限公司 一种路由查询方法、装置、设备及可读存储介质
CN113726660A (zh) * 2021-08-27 2021-11-30 西安微电子技术研究所 一种基于完美哈希算法的路由查找器和方法
CN113726660B (zh) * 2021-08-27 2022-11-15 西安微电子技术研究所 一种基于完美哈希算法的路由查找器和方法
WO2023131307A1 (zh) * 2022-01-10 2023-07-13 中兴通讯股份有限公司 微波网络根节点查询方法及装置、微波系统和存储介质

Also Published As

Publication number Publication date
CN107948060A (zh) 2018-04-20

Similar Documents

Publication Publication Date Title
WO2018068524A1 (zh) 路由表建立、以及ip路由查找方法、装置、存储介质
WO2015127721A1 (zh) 数据匹配的方法、装置及计算机存储介质
US9178806B2 (en) High-speed content routing
US9729669B2 (en) Method and system for fast and large-scale longest prefix matching
US8290934B2 (en) Method and system for processing access control lists using a hashing scheme
JP2016116215A (ja) ハードウェア支援ハッシュテーブルを使用したccnルーティング
US20180109454A1 (en) Forwarding information base architecture for a hybrid ip and content centric network router
WO2020114239A1 (zh) 组播报文的处理方法及装置、存储介质、处理器
WO2012106916A1 (zh) 哈希计算处理方法及装置
US10771386B2 (en) IP routing search
WO2020038399A1 (zh) 数据包的分类方法、装置及计算机可读存储介质
US9485179B2 (en) Apparatus and method for scalable and flexible table search in a network switch
US20200267081A1 (en) Forwarding Table Management
WO2013078644A1 (zh) 路由前缀存储方法、装置及路由地址查找方法、装置
Li et al. An improved trie-based name lookup scheme for named data networking
WO2015131720A1 (zh) 报文处理方法及装置
WO2020248690A1 (zh) 报文匹配查表方法、系统、存储介质和终端
WO2014206208A1 (zh) 数据查询方法、设备和系统
WO2016184069A1 (zh) 一种路由查询方法及装置
Shekhar et al. Parallel binary search trees for rapid IP lookup using graphic processors
Kniesburges et al. Hashed Patricia Trie: Efficient longest prefix matching in peer-to-peer systems
EP3269101B1 (en) Generating a hash table in accordance with a prefix length
Sun et al. Content-based route lookup using CAMs
US10476785B2 (en) IP routing search
WO2023024799A1 (zh) 一种报文的转发方法、网络转发设备及计算机存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17859569

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 17859569

Country of ref document: EP

Kind code of ref document: A1