WO2015188319A1 - 一种查找装置、查找配置方法和查找方法 - Google Patents

一种查找装置、查找配置方法和查找方法 Download PDF

Info

Publication number
WO2015188319A1
WO2015188319A1 PCT/CN2014/079624 CN2014079624W WO2015188319A1 WO 2015188319 A1 WO2015188319 A1 WO 2015188319A1 CN 2014079624 W CN2014079624 W CN 2014079624W WO 2015188319 A1 WO2015188319 A1 WO 2015188319A1
Authority
WO
WIPO (PCT)
Prior art keywords
prefix
node
search unit
next hop
level
Prior art date
Application number
PCT/CN2014/079624
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 华为技术有限公司
Priority to PCT/CN2014/079624 priority Critical patent/WO2015188319A1/zh
Priority to EP14894380.6A priority patent/EP3145134B1/en
Priority to CN201480079291.6A priority patent/CN106416152B/zh
Publication of WO2015188319A1 publication Critical patent/WO2015188319A1/zh
Priority to US15/317,407 priority patent/US10164884B2/en

Links

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/48Routing tree calculation
    • 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]
    • 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/748Address table lookup; Address filtering using longest matching prefix

Definitions

  • Search device Search configuration method and search method
  • the present invention relates to the field of network communications, and in particular, to a search device, a search configuration method, and a search method. Background technique
  • the main task of the router is to forward the Internet Protocol (IP) packet, that is, forward the packet to the router's input port to the correct output port according to the destination IP address in the packet header.
  • IP Internet Protocol
  • the route lookup process is to find the routing table in the router based on the destination IP address of the packet and obtain the next hop information of the packet.
  • the route lookup uses the longest prefix match (LPM) principle.
  • LPM longest prefix match
  • TCAM Ternary Content Addressable Memory
  • Trie tree based algorithm Trie tree based algorithm
  • the TCAM algorithm can match the input IP address to all routing entries at the same time.
  • TCAM is expensive, and the cost of routing lookups with TCAM is high.
  • TCAM's integration is much lower than that of general memory, and its capacity is limited, making it difficult to handle the processing of millions of routing tables.
  • TCAM power consumption is also relatively large. Therefore, the more commonly used Trie algorithm is currently used.
  • Trie tree also called a prefix tree
  • An algorithm based on a Trie tree builds a binary tree or a multi-tree based on a bit string in the prefix. If you consider one bit at a time, create a binary tree, also known as the unit Trie tree.
  • Figure 1 shows a unit Trie tree, where 11 prefixes, p0 ⁇ pll on the left side of Figure 1, the corresponding nodes in the unit Trie tree are represented by black circles, the connection points are represented by white circles, and each node is unique Number identification. If you consider multiple bits each time, create a multi-bit Trie tree. In multiple Trie trees, the number of bits considered each time is generally fixed, called the step size of the Trie tree (English: stride).
  • a multi-bit Trie tree can be seen as dividing a unit Trie tree into multiple sub-trees by stride, and for each The subtree creates a Trie node.
  • Each Trie node has an associated prefix, and the associated prefix of a Trie node is the prefix value on the root node of the subtree corresponding to the Trie node. If a prefix is distributed in a subtree, a prefix node is also created for the subtree.
  • the prefixes in the subtree are stored in the prefix node, and each prefix corresponds to a next hop information. Generally, only the next hop pointer, that is, the pointer to the next hop information, is stored in the multi-bit Trie tree.
  • each prefix can be divided into a number of segments, and the bit string corresponding to each segment is called the segmentation key (key) of the segment in the segment.
  • the segmentation key key
  • stride is equal to 3
  • the prefix '10101 *, the first segment key value is '101, and the second segment key value is '01 *'.
  • FIG. 2 shows a multi-bit trie tree with stride equal to 3 based on the prefix in Figure 1.
  • the multi-bit Trie tree includes seven Trie nodes, such as the Trie Node Tl ⁇ Trie Node T7 shown in Figure 2.
  • Each Trie node is configured with a prefix node, as shown in Figure 2, the Prefix Node.
  • the next hop pointer of each prefix in the Trie node corresponding to the Prefix Node is stored in each Prefix Node.
  • the Prefix node corresponding to the Trie Node T4 in FIG. 2 (the Prefix node indicates the prefix node) is stored under the prefix p3.
  • One hop pointer "RE Index of P3" is stored under the prefix p3.
  • a longest prefix match (PLPM) is also stored.
  • the PLPM of a Prefix node is the longest prefix that covers the subtree corresponding to the Prefix node.
  • the "RE Index of PLPM" in the Prefix node in Figure 2 represents the next hop pointer of the PLPM of the Prefix node.
  • route lookups are generally implemented by hardware.
  • a hardware-implemented lookup device typically employs a multi-stage pipeline structure. Algorithms based on multi-bit Trie trees can be implemented by storing multi-bit Trie tree structures in various stages of the pipeline structure.
  • Figure 3 is a schematic illustration of the multi-bit Trie tree of Figure 2 placed in a five-stage pipeline structure.
  • the first three stages (stagel ⁇ stage3) in the pipeline structure hold three layers of Trie nodes
  • the fourth level (stage4) holds the Prefix nodes corresponding to seven Trie nodes
  • the fifth level (stage5) holds each Prefix.
  • the RE Index corresponding to each prefix in the node.
  • the locating device based on the above-mentioned pipeline structure searches for the IP address to be matched (ie, the search key) along the pipeline level one level, and finally obtains the search result.
  • the search keyword is 111 010 011.
  • the route lookup process includes:
  • the sub-nodes T2, ⁇ 3, ⁇ 4 of T1 are respectively accessed according to the segment key ', respectively, because the first segment key of the prefix ⁇ 3 (ie, 111*) corresponding to the node 9 in ⁇ 4 and the first of the search key
  • the segment key '111' is the longest match, so the pointer of the updated Prefix node is updated to the pointer of the Prefix node corresponding to T4, and the second segment key '010 is extracted from the search key;
  • the child node T7 of T4 is accessed according to the segment key '010', because the second segment key '010 of the prefix plO (1110100*) corresponding to the node 21 in T7, and the second score of the search key
  • the segment key '010' has the longest match, so the updated Prefix node pointer is the pointer of the Prefix node corresponding to T7, and the third segment key ' ⁇ is extracted from the search key;
  • stage4 since T7 does not have a Trie sub-node, the Prefix node corresponding to the last saved T7 is used to access the Prefix node corresponding to T7, and the third sub-key of the search key and the prefix of the Prefix node corresponding to T7 are used.
  • the third segment key is matched, wherein the third segment key '0* of the prefix plO matches the third segment key '011 of the lookup key, so the Prefix node corresponding to T7 is "RE Index of plO" (the next hop pointer corresponding to the prefix plO)
  • the position in the corresponding RE Index array is used as the output of stage4;
  • stage5 the RE Index corresponding to the prefix plO is obtained according to the position in the RE Index array obtained in stage 4.
  • the next hop information corresponding to the above search keyword can be obtained.
  • the existing route search algorithm based on multi-bit Trie algorithm puts the whole multi-bit Trie tree structure in the search device, which occupies a large amount of memory resources; and the number of stages of the pipeline structure and the multi-bit Trie tree of the hardware device The number of levels corresponds to each other. Therefore, for IPv6 routes with long masks, the number of levels of the multi-bit Trie tree is often large, and the number of stages of the corresponding pipeline structure is also large, resulting in a large search delay, which also increases the difficulty of hardware implementation. Summary of the invention
  • the embodiment of the invention provides a search device, a search configuration method and a search method, which are used to reduce the number of pipeline stages and storage overhead in the search device, thereby reducing the search delay, reducing the implementation difficulty, and reducing resource occupation.
  • a search device in a first aspect, includes:
  • Each pipeline stage includes a search unit, which is a 0th to N-1th search unit according to the sequence of execution of the N pipeline stages; each level of the search unit includes a prefix node for storing a prefix and The next hop corresponding to the prefix, where:
  • the second prefix node includes 1 to 2 stnde indirect prefix nodes, or includes 0 to 2 stnde indirect prefix nodes and a direct prefix node.
  • the direct prefix node is used to store a prefix that falls within the Trie node of the subtree
  • the indirect prefix node is used to store a prefix that falls within a branch of the Trie node of the subtree.
  • the first (i)th level search unit is further configured to include the first multi-bit Trie tree Trie node with a prefix node.
  • the first prefix Storing, in the node, an address of the first array or the first array, where the first array stores a next hop pointer corresponding to each prefix of the first prefix node;
  • the second prefix node stores an address of the second array or the second array, and the second group stores a next hop pointer corresponding to each prefix of the second prefix node.
  • the level 0 lookup unit is a three-state content addressed memory TCAM.
  • N pipeline stages are used to perform the following Steps:
  • the i-th search unit matches the prefix that is received by the first prefix node in the i-th search unit by using the lookup key, and if the prefix is matched, the length of the matched prefix and the matched prefix are matched. The corresponding next hop output is sent to the i+1th level search unit, and the process proceeds to S94, otherwise, the process proceeds to S96;
  • the i-th search unit extracts, according to the length of the prefix output by the i-1th-level search unit, a segmentation keyword of a corresponding length from the search key, and outputs a next hop according to the i-1th-level search unit. Determining a corresponding second prefix node in the i-th search unit, and matching the extracted segment key with a corresponding segment key of the prefix stored by the second prefix node;
  • the process proceeds to S96;
  • a search configuration method includes: S61: Obtain a first prefix to be configured and a next hop corresponding to the first prefix, and enter
  • S62 Store the first hop and the next hop corresponding to the first prefix in the N-1th search unit, and go to S63; where N is the number of pipeline stages, N>1, and each The pipeline stage includes a search unit, which is a 0th to N-1th search unit according to the sequence of execution of the N pipeline stages; each level of the search unit includes a prefix node for storing a prefix and a location The next hop corresponding to the prefix;
  • S63 Perform subtree partitioning on the multi-bit Trie tree formed by the associated prefix of the prefix node in the N-1th search unit, to obtain a prefix node of the N-2th search unit, where the N-2 level search
  • the next hop corresponding to the prefix stored in the prefix node of the unit points to the prefix node of the N-1th level
  • the S62 includes:
  • the S63 includes:
  • S65 Re-configuring the prefix node of the j-th search unit by subtree partitioning the multi-bit Trie tree formed by the associated prefix of the prefix node in the j+1th search unit, and searching the j+1 level search unit
  • the associated prefix of the configured prefix node is stored in the prefix node after the reconfiguration of the jth level search unit, and the process proceeds to S66;
  • S66 determining, according to the capacity of the prefix node of the j-1th search unit, whether to store the associated prefix of the prefix node reconfigured by the jth level search unit, and if so, the associated prefix of the prefix node reconfigured by the jth level search unit Stored in the prefix node of the ji-level search unit, and ends the process, otherwise it proceeds to S67;
  • the reconfiguring the prefix node of the N-1th search unit includes:
  • Reconfiguring the prefix node of the j-th search unit by subtree partitioning the multi-bit Trie tree formed by the associated prefix of the prefix node in the j+1th search unit includes:
  • the step of the second multi-bit Trie tree Long And the location of the prefix stored by the split target prefix node in the second multi-bit Trie tree, splitting the split target prefix node into multiple prefix nodes, and storing the split prefix node There is an associated prefix of the newly configured prefix node in the j+1th level search unit and a corresponding next hop. Otherwise, a new prefix node is configured in the jth level search unit to store the j+1th level search unit.
  • the first condition is that the branch of the subtree corresponding to the prefix node includes the newly configured prefix node in the j+1th search unit.
  • the method further includes:
  • a search method including:
  • the search device receives the search key, and proceeds to S92.
  • the i-th search unit matches the prefix stored in the first prefix node in the i-th search unit by using the lookup key, and if the prefix is matched, the length of the matched prefix and the matched prefix are matched. The corresponding next hop is output to the i+1th level search unit, and the process proceeds to S94, otherwise, the process proceeds to S96;
  • the i-th search unit extracts, according to the length of the prefix output by the i-1th-level search unit, a segmentation keyword of a corresponding length from the search key, and outputs a next hop according to the i-1th-level search unit. Determining a corresponding second prefix node in the i-th search unit, and matching the extracted segment key with a corresponding segment key of the prefix stored by the second prefix node;
  • the process proceeds to S96;
  • each level of the locating unit includes a prefix node for storing a prefix and a next hop corresponding to the prefix, where: the i+1th level searching unit A first prefix node is configured, a second prefix node is configured in the i-th search unit, and a next hop corresponding to the prefix stored in the second prefix node points to the first prefix node, and the second prefix node Subtree partitioning is performed by using a first multi-bit Trie tree formed by the associated prefix of the first prefix node.
  • the coverage of a subtree obtained by the division includes a Trie node in the multi-bit Trie tree and K branches of the Trie node, and a sub-tree obtained by the division corresponds to a set of prefix nodes, and therefore, only the prefix node is It is configured in the search unit to reduce the occupation of memory resources compared with the prior art; on the other hand, since the prefix node in the search unit of the previous level is based on the associated prefix of the prefix node in the search unit of the latter stage
  • the multi-bit Trie tree is obtained by subtree division, so that the subtree corresponding to a prefix node has a larger coverage area and reduces the flow. Waterline progression, which reduces search latency and reduces implementation difficulty.
  • Figure 1 is a schematic diagram of a unit Trie tree in the background art
  • FIG. 2 is a schematic diagram of a multi-bit Trie tree in the background art
  • FIG. 3 is a schematic diagram of a search structure based on the multi-bit Trie tree of FIG. 2;
  • FIG. 4 is a schematic diagram of a process for creating a multi-bit Trie structure according to an embodiment of the present invention.
  • FIG. 5 is a schematic diagram of a process of searching for a configuration according to an embodiment of the present invention.
  • FIG. 6a and FIG. 6b are schematic diagrams showing a configuration process when an entry is added in an embodiment of the present invention.
  • FIG. 7 is a schematic diagram of a configuration process when an entry is deleted in an embodiment of the present invention.
  • FIG. 8a, 8b, 8c, and 8d are schematic diagrams of an example of an incremental configuration according to an embodiment of the present invention.
  • FIG. 9a and FIG. 9b are schematic diagrams of a search process according to an embodiment of the present invention.
  • the embodiment of the present invention proposes a search device based on multi-bit Trie tree iteration, a search configuration method and a search method, because only the prefix node is saved in the pipeline stage. It can reduce the occupation of memory resources. It can reduce the number of pipeline stages, reduce the bandwidth consumption of the search device, and reduce the search delay by multi-bit Trie tree iteration.
  • the search configuration method based on the multi-bit Trie tree iteration proposed in the embodiment of the present invention configures a prefix node for one pipeline stage in one iteration process.
  • the multi-bit Trie tree corresponding to the current iterative process is composed of the associated prefix of the prefix node created by the previous iterative process, and the leaf nodes in the multi-bit Trie tree are all prefix nodes, and the current iteration can be created according to the multi-bit Trie tree.
  • the prefix node of the process, the created prefix node is configured into the pipeline stage corresponding to the current iteration process.
  • the multi-bit Trie tree corresponding to the initial iteration process is composed of a prefix to be configured, such as an IPv4/IPv6 prefix in the routing table, and the prefix node created in each iteration process corresponds to a pipeline stage, that is, a multi-bit corresponding to an iterative process.
  • the prefix nodes in the Trie tree are kept in the same pipeline stage. In this way, only the prefix nodes can be saved in the pipeline structure.
  • searching device (2) searching configuration flow, (3) searching process, and (4) other alternatives.
  • the searching device may be a device located in a network device for implementing packet forwarding, such as a router or a switch, such as a route lookup module, a processor, or a hardware-implemented search engine; or may be a router or a switch.
  • a network device used to implement packet forwarding such as a router or a switch, such as a route lookup module, a processor, or a hardware-implemented search engine; or may be a router or a switch.
  • the search device provided by the embodiment of the present invention includes N stages of pipeline stages, where N>1; each pipeline stage includes a search unit, which is 0 according to the sequence of execution of the N pipeline stages. Level to the N-1 level search unit; each level of the search unit includes a prefix node, where the prefix node is used to store a prefix and a next hop corresponding to the prefix, where:
  • next hop corresponding to the prefix in the prefix node in the N-1th level searching unit points to the specific content of the next hop, for example, the content of the next hop may be the next hop IP address.
  • the prefix node configured in the lookup unit essentially represents a data structure in which the prefix and the next hop corresponding to the prefix are stored.
  • the number of prefix nodes in each level of the search unit may be one or more.
  • Each level of search units corresponds to a multi-bit Trie tree.
  • the multi-bit Trie tree corresponding to the level 0 search unit is generated according to the prefix in the lookup table, and the prefix in the lookup table corresponds to the corresponding node in the tree.
  • the multi-bit Trie tree corresponding to the level 1 search unit is formed by the associated prefix of the prefix node in the level 0 search unit, that is, the associated prefix of the prefix node in the level 0 search unit corresponds to the corresponding node in the tree;
  • the multi-bit Trie tree corresponding to the level 2 search unit is composed of the associated prefix of the prefix node in the level 1 search unit.
  • the multi-bit Trie tree corresponding to the previous level search unit is composed of the associated prefix of the prefix node in the search unit of the latter stage.
  • Each subtree obtained according to a multi-bit Trie tree corresponds to one or more prefix nodes.
  • the foregoing second prefix node includes 1 to 2 stnde indirect prefix nodes, or includes 0 to 2 stnde indirect prefix nodes and a direct prefix node, and is used to store the subtree corresponding to the second prefix node.
  • the Trie node at the vertex position of the subtree is referred to as the Trie node of the subtree.
  • a direct prefix node is used to store a prefix that falls within the Trie node of the subtree
  • an indirect prefix node is used to store a prefix that falls within a branch of the Trie node of the subtree.
  • Each of the prefix nodes in each level of the search unit corresponds to a subtree of the multi-bit Trie tree corresponding to the search unit.
  • each Trie node has an associated prefix.
  • each prefix node also has an associated prefix.
  • the associated prefix of a prefix node is the prefix corresponding to the root node of the subtree corresponding to the prefix node.
  • the associated prefix is also known as the vertex prefix or the subtree root node prefix.
  • the lookup table may be a lookup table for guiding message forwarding. Depending on the business needs, you can configure a lookup table of the appropriate type.
  • the lookup table is an IPv4/IPv6 routing table, and the routing table includes an IPv4/IPv6 prefix and its corresponding next hop information.
  • the search algorithm used may be different for different services. For example, for route lookup, the longest prefix matching algorithm is used, so the search algorithm can be configured according to different service types.
  • the first prefix node stores an address of the first array or the first array, and the first array stores a next hop pointer corresponding to each prefix of the first prefix node; and
  • the second prefix node stores an address of the second array or the second array, and the second array stores a next hop pointer corresponding to each prefix of the second prefix node.
  • the prefix node can store an array, which can be called an array of next hop pointers; the prefix node can also store the address of the array of next hop pointers.
  • the next hop pointer stored in the prefix node stores the next hop pointer corresponding to each prefix stored by the prefix node.
  • the subscript is used to identify the prefix whose element value is the next hop pointer corresponding to the prefix identified by the element's subscript.
  • the PLPM can also be stored in the prefix node.
  • a prefix node includes a PLPM
  • the next hop pointer corresponding to the PLPM of the prefix node may be stored in the next hop pointer array of the prefix node, for example, as the first element of the array.
  • the next hop pointer corresponding to the PLPM stored in the next hop pointer array points to the next hop information corresponding to the PLPM.
  • the longest prefix that covers the subtree is the PLPM of the prefix node corresponding to the subtree.
  • the i+1th level searching unit is further configured with a Trie node that includes a prefix node in the first multi-bit Trie tree.
  • the number of prefix nodes configured in the higher-level search units is generally smaller, that is, the number of stored prefixes is smaller, so that TCAM can be used to implement, and on the one hand, there is no excessive prefix.
  • the cost of TCAM increases, and on the other hand, the performance of TCAM efficient lookups can be utilized.
  • the number of lookup units implemented by TCAM can be determined based on factors such as the size of the lookup table and the length of the prefix in the lookup table.
  • the 0th level search unit ie the most in the pipeline structure
  • the pipeline stage search unit that is executed first is implemented by TCAM.
  • the structure of the multi-bit Trie tree shown in (a) of Fig. 4 is the same as that of the multi-bit Trie tree shown in Fig. 2. If the capacity of the prefix node is relatively large, all branches of T1 and T1 can be stored in a corresponding set of prefix nodes, thus creating a Trie structure as shown in (b) of Figure 4.
  • the multi-bit Trie tree has only one Trie node ⁇ , and the corresponding set of prefix nodes includes four prefix nodes P1 ⁇ P4.
  • PI, P2, P3, and P4 correspond to T1, ⁇ 2, ⁇ 3, and ⁇ 4 in (a) of Fig. 4, respectively.
  • the PI stores the prefix in Tl;
  • P2 stores all the prefixes on the branch starting from T2, that is, the prefixes in T2, ⁇ 5, and ⁇ 6;
  • ⁇ 3 holds the prefix in ⁇ 3;
  • ⁇ 4 holds the prefix Is the prefix on the branch starting with ⁇ 4, which is the prefix in ⁇ 4 and ⁇ 7.
  • P1 is called the direct prefix node of T1
  • ⁇ 2, ⁇ 3, ⁇ 4 is called the indirect prefix node of Tl.
  • Trie structure as shown in (c) of Fig. 4 is created.
  • T2 and ⁇ 4 are Trie sub-nodes of T1.
  • T1 "The corresponding set of prefix nodes includes 2 prefix nodes P1 and P3, and the set of prefix nodes corresponding to T2" includes 3 prefix nodes P2, P5 and P6, and the corresponding set of prefix nodes of T4" includes P4 and P7 Pi and Ti correspond to Ti in (a) of Figure 4.
  • the prefix is stored in T5; the prefix in T6 is stored in P6; the prefix in T4 is stored in P4; the prefix in T7 is stored in P7.
  • all prefix nodes can be saved in the pipeline structure to form one level.
  • the associated prefix of all prefix nodes including: P1's associated prefix "*”, P2 association Prefix "000*”, P3's associated prefix "100*”, P4's associated prefix "111*”, P5's associated prefix "000010*”, P6's associated prefix "000011*”, P7's associated prefix "111010*”
  • P1's associated prefix "*” including: P1's associated prefix "*”, P2 association Prefix "000*”, P3's associated prefix "100*”, P4's associated prefix "111*”, P5's associated prefix "000010*”, P6's associated prefix "000011*”, P7's associated prefix "111010*”
  • the fourth stage (stage3) search unit is provided with prefix nodes PNODE30, PNODE31, PNODE32, PNODE33, PNODE34, PNODE35, PNODE36, wherein PNODE30 35 corresponds to FIG.
  • the third level (stage2) is equipped with prefix nodes PNODE20, PNODE21, PNODE22, where PNODE20 22 corresponds to stagel Tl, ⁇ 2, ⁇ 4 in the Trie structure;
  • the second level (stagel) search unit is configured with a prefix node PNODEIO, corresponding to T1 in the stage 1 Trie structure;
  • the first level (stageO) TCAM is configured with PNODE10 corresponding Next hop pointer.
  • next hop pointer array in the prefix node is represented as the following structure:
  • next hop pointers of the prefix nodes in the search units at each level in FIG. 5 can be expressed as:
  • PNODE30 ⁇ RE index corresponding to ⁇ , RE index corresponding to pi, RE Index ⁇ corresponding to p2, where:
  • the RE Index corresponding to ⁇ points to the RE corresponding to the prefix ⁇ ;
  • the RE index corresponding to pi points to the RE corresponding to the prefix i;
  • the RE Index corresponding to p2 points to the RE corresponding to the prefix p2;
  • PNODE31 ⁇ REPM corresponding to RE Index, p5 corresponding to RE Index ⁇ , associated prefix is 011*, PLPM is 10*, where:
  • the RE Index corresponding to the PLPM points to the RE corresponding to the prefix 10*;
  • the RE Index corresponding to P5 points to the RE corresponding to the prefix p5;
  • PNODE32 ⁇ REPM corresponding to PLPM, RE Index corresponding to p4, the associated prefix is 000*, PLPM is 0*, where:
  • the RE Index corresponding to the PLPM points to the RE corresponding to the prefix 0*;
  • the RE Index corresponding to P4 points to the RE corresponding to the prefix 4.
  • PNODE33 ⁇ REPM corresponding to RE Index, p9 corresponding to RE Index ⁇ , associated prefix is 000010*, PLPM is 0000*, where:
  • the RE Index corresponding to the PLPM points to the RE corresponding to the prefix 0000*;
  • the RE Index corresponding to P9 points to the RE corresponding to the prefix 9;
  • PNODE34 ⁇ REPM corresponding to PL Index, p8 corresponding to RE Index ⁇ , associated prefix is 000011*, PLPM is 0000*, where:
  • the RE Index corresponding to the PLPM points to the RE corresponding to the prefix 0000*;
  • the RE index corresponding to p8 points to the RE corresponding to the prefix p8;
  • PNODE35 ⁇ REPM corresponding to PL Index, RE index corresponding to p3, RE Index corresponding to p6, RE Index ⁇ corresponding to p7, associated prefix is 111*, PLPM is *, where:
  • the RE Index corresponding to the PLPM points to the RE corresponding to the prefix *;
  • the RE Index corresponding to P3 points to the RE corresponding to the prefix p3;
  • the RE Index corresponding to P6 points to the RE corresponding to the prefix 6;
  • the RE Index corresponding to P7 points to the RE corresponding to the prefix p7;
  • PNODE36 ⁇ REPM corresponding to RE Index, plO corresponding to RE Index ⁇ , associated prefix is 111010*, PLPM is 11101 * , where:
  • the RE Index corresponding to the PLPM points to the RE corresponding to the prefix 11101 *;
  • the RE Index corresponding to P10 points to the RE corresponding to the prefix plO.
  • PNODE20 ⁇ RENO index corresponding to the associated prefix of PNODE30, RE Index ⁇ corresponding to the associated prefix of PNODE31, and the associated prefix is *, where:
  • the RE Index corresponding to the associated prefix of PNODE31 points to PNODE31; PNODE21: ⁇ RE index corresponding to PLPM, RE corresponding to the associated prefix of PNODE32 Index, the RE Index corresponding to the associated prefix of PNODE33, the RE Index ⁇ corresponding to the associated prefix of PNODE34, the associated prefix is 000*, and the PLPM is *, where:
  • the RE Index corresponding to the PLPM points to the RE corresponding to the prefix *;
  • the RE Index corresponding to the associated prefix of PNODE34 points to PNODE34;
  • PNODE22: ⁇ RE index corresponding to PLPM, RE Index corresponding to the associated prefix of PNODE35, RE Index corresponding to the associated prefix of PNODE36, associated prefix is 111*, PLPM is *, where :
  • the RE Index corresponding to the PLPM points to the RE corresponding to the prefix *;
  • the RE Index corresponding to the associated prefix of PNODE35 points to PNODE35; the RE Index corresponding to the associated prefix of PNODE36 points to PNODE36; Stage 1 :
  • PNODE10 ⁇ RENO index corresponding to the association prefix of PNODE20, RE Index corresponding to the associated prefix of PNODE21, RE Index ⁇ corresponding to the associated prefix of PNODE22, and the associated prefix is *, where:
  • the RE Index corresponding to the associated prefix of PNODE20 points to PNODE20; the RE Index corresponding to the associated prefix of PNODE21 points to PNODE21; the RE Index corresponding to the associated prefix of PNODE22 points to PNODE22; StageO:
  • PNODE00 ⁇ RENODE ⁇ corresponding to the associated prefix of PNODE10, and the RE Index corresponding to the associated prefix of PNODE10 points to PNODE10.
  • each level of the locating unit includes a prefix node for storing a prefix and a next hop corresponding to the prefix, where: A first prefix node is configured in the i+1th search unit, and a second prefix node is configured in the i-th search unit, and a next hop corresponding to the prefix stored in the second prefix node points to the first prefix node
  • the second prefix node passes the associated prefix of the first prefix node
  • the first multi-bit Trie tree is constructed by subtree partitioning.
  • the coverage of a subtree obtained by the division includes a Trie node in the multi-bit Trie tree and K branches of the Trie node, and a sub-tree obtained by the division corresponds to a set of prefix nodes, and therefore, only the prefix node is It is configured in the search unit to reduce the occupation of memory resources compared with the prior art; on the other hand, since the prefix node in the search unit of the previous level is based on the associated prefix of the prefix node in the search unit of the latter stage
  • the multi-bit Trie tree is divided into sub-trees, so that the sub-tree corresponding to a prefix node has a larger coverage area, which reduces the number of pipeline stages, thereby reducing the search delay and reducing the difficulty of implementation.
  • the N pipeline stages may be implemented by hardware, and the hardware may be a Field Programmable Gate Array (FPGA), an application specific integrated circuit (Application) Specific Integrated Circuit (ASIC);
  • the N pipeline stages can also be implemented by software, for example, multiple threads in the processor implement the N pipeline stages.
  • the search configuration process in the embodiment of the present invention refers to a process of configuring a lookup table, that is, a process of configuring an entry of a lookup table into N pipeline stages, and each entry in the lookup table includes a prefix and the prefix. The corresponding next hop.
  • the lookup configuration process can include an initial configuration process and an incremental configuration process.
  • the N pipeline stages can be configured according to the existing entire lookup table.
  • the newly added prefix to be configured and the next hop corresponding to the prefix can be obtained according to the received route update command. , incrementally configuring the N pipeline stages.
  • the capacity of the prefix node refers to the size of the data structure of the prefix node, and its unit is a bit.
  • the capacity of the prefix node is related to any one or more of the following factors: the maximum bandwidth of the device is looked up, the length of the prefix in the lookup table, and so on.
  • the maximum bandwidth of the locating device represents the maximum number of bits that can be processed in parallel in one clock cycle.
  • the number of prefixes that the prefix node can store is related to the capacity and prefix length of the prefix node.
  • the prefix node can be
  • the capacity is set larger, for example, the routing lookup can be set to 256 bits.
  • the prefix nodes may be encoded to reduce storage overhead.
  • a multi-bit Trie tree can be created according to the lookup table, from the N-1 level search unit to the 0th level search unit, and the search unit is configured through N iterations, and the pipeline structure is configured as described above.
  • the specific configuration process is as follows.
  • a multi-bit Trie tree is created according to the lookup table and the predetermined stride, and the multi-bit Trie tree is subtree-divided according to the capacity of the prefix node.
  • the larger the capacity of the prefix node the larger the coverage of the subtree.
  • the corresponding prefix node is created according to the divided subtree to include one or more prefix nodes. For each subtree, the prefix falling within the subtree is stored in the prefix contained in the prefix node corresponding to the subtree.
  • the prefix node obtained by the above process is configured in the N-1th search unit. Further, the structure of the multi-bit Trie tree can be saved to a built-in or external memory of the search device and identified as a multi-bit Trie tree corresponding to the N-1th search unit.
  • each subtree obtained by the partition corresponds to a Trie node
  • the Trie node has two sets of sub-nodes, and the first set is used to save the sub-trie node of the Trie node;
  • the two groups are used to save the prefix node corresponding to the Trie node, which may include an indirect prefix node, and may further include a direct prefix node.
  • the first group of child nodes of the Trie node is empty, and the indirect prefix node of the second group of child nodes is empty. Since a Trie node has a maximum of 2 stnde Trie sub-nodes, the Trie node corresponding to a sub-tree corresponds to a maximum of 2 stnde + l.
  • a multi-bit Trie tree is created according to the associated prefix of the prefix node obtained in the first iterative process, and the multi-bit Trie tree is subtree-divided according to the capacity of the prefix node.
  • the coverage of a subtree obtained may include a Trie node or a Trie node and one or more branches.
  • the prefix falling into the subtree is the associated prefix of the prefix node obtained in the previous iteration process.
  • a corresponding set of prefix nodes is created according to the divided subtrees, and each set of prefix nodes corresponding to each subtree includes up to 2 stnde indirect prefix nodes, and may also include a direct prefix node.
  • the prefix node obtained by the above process is configured in the N-2th search unit, and the structure of the multi-bit Trie tree can be further saved to the built-in or external memory of the search device, and identified as the N-th A multi-bit Trie tree corresponding to the level 2 search unit.
  • Each subsequent iterative process is basically similar to the second iteration process. After each iterative process is completed, the prefix node obtained by the iterative process is configured in the search unit of the corresponding level, and the multi-bit Trie tree corresponding to the level search unit is further saved in the built-in or external memory of the search device. Until the level 0 search unit configuration is complete.
  • a prefix node can store the next hop corresponding to the prefix stored in the prefix node through an array or other data structure.
  • an array can be stored in the prefix node, and the array is called an array of next hop pointers, wherein the subscript of each element is used to identify the prefix, and the value of each element corresponds to the prefix identified by the subscript of the element.
  • the next hop pointer ie RE Index .
  • the prefix node can store only the address of the array (ie, the starting address), or a pointer to the array, the contents of which can be stored in the built-in or external memory of the lookup device.
  • the PLPM is also saved in the prefix node.
  • the next hop pointer (RE Index ) corresponding to the PLPM may be saved as the first element in the next hop pointer array corresponding to the prefix node.
  • next hop pointer array corresponding to each prefix node in the next hop pointer array corresponding to each prefix node, the next hop pointer corresponding to one prefix points to the specific content of the next hop corresponding to the prefix,
  • the specifics of the next hop can be stored in the built-in or external memory of the lookup device.
  • the ith search unit is used as an example.
  • the above is only a preferred implementation of the data structure of the prefix node.
  • the present invention does not limit the data structure of the prefix node.
  • the initial configuration process can also be implemented by means of an incremental configuration process. For example, first, an entry is taken from the lookup table, and the search unit at each level is configured by the incremental configuration process, and then another table is taken out. Item, use the incremental configuration process to configure the search units at each level, and so on, until the last entry in the lookup table is taken out and the incremental configuration process is used to complete the configuration of the search units at each level. Lookup table configuration process.
  • the incremental configuration process is as follows.
  • Lookup tables are usually updated periodically or irregularly, such as adding entries to a lookup table or deleting entries in a lookup table.
  • Figure 6a shows the incremental configuration process when adding a lookup table entry, which can include the following steps:
  • the lookup table used to guide message forwarding allows manual configuration or update, or can be updated according to the relevant protocol. For example, for a route lookup, you can manually configure a static route or dynamically update the routing table according to the routing protocol such as the Border Gateway Protocol (BGP), including adding a new routing entry or deleting an existing routing entry. .
  • BGP Border Gateway Protocol
  • the lookup table can determine an entry of the lookup table that needs to be added or deleted according to the command, so as to perform configuration update on the pipeline level.
  • N is the number of pipeline stages, N>1, and each pipeline stage includes a search unit, which is level 0 according to the sequence of execution of the N pipeline stages.
  • each level of the search unit includes a prefix node for storing a prefix and a next hop corresponding to the prefix.
  • S63 Perform subtree partitioning on the multi-bit Trie tree formed by the associated prefix of the prefix node in the N-1th search unit, to obtain a prefix node of the N-2th search unit, where the N-2 level search The next hop corresponding to the prefix stored in the prefix node of the unit points to the prefix node of the N-1th level.
  • the subtree partitioning the multi-bit Trie tree formed by the associated prefix of the prefix node in the N-1th search unit to obtain the prefix node of the N-2th search unit includes:
  • S62 it is determined whether the capacity of the prefix node in the N-1th search unit is allowed to store the first prefix and the next hop corresponding to the first prefix, and if yes, the first prefix and the The next hop corresponding to the first prefix is stored in the prefix node of the N-1th search unit; otherwise, the prefix node of the N-1th search unit is reconfigured, and the first prefix and the first prefix are The next hop corresponding to the first prefix is stored in the prefix node after the reconfiguration of the N-1th search unit; in S63, whether the storage is allowed according to the capacity of the prefix node in the N-2th search unit The associated prefix of the prefix node reconfigured by the N-1 level search unit, and if so, the associated prefix of the prefix node reconfigured by the N-1th search unit is stored in the prefix node of the N-2th search unit;
  • S65 Multi-bit Trie formed by the associated prefix of the prefix node in the j+1th-level search unit
  • the tree performs subtree partitioning to reconfigure the prefix node of the jth level search unit, and stores the associated prefix of the prefix node configured in the j+1th search unit in the prefix node after the reconfiguration of the jth level search unit, and transfers to the S66. ;
  • S66 determining, according to the capacity of the prefix node of the j-1th search unit, whether to store the associated prefix of the prefix node reconfigured by the jth level search unit, and if so, the associated prefix of the prefix node reconfigured by the jth level search unit Stored in the prefix node of the ji-level search unit, and ends the process, otherwise it proceeds to S67;
  • the reconfiguring the prefix node of the N-1th level searching unit includes:
  • the first condition of the sub-tree corresponding to the first prefix is the first prefix of the sub-tree corresponding to
  • the sub-tree partitioning of the multi-bit Trie tree formed by the associated prefix of the prefix node in the j+1th-level search unit is used to reconfigure the prefix node of the j-th search unit, including:
  • the step of the second multi-bit Trie tree Long and the location of the prefix stored by the split target prefix node in the second multi-bit Trie tree Splitting the split target prefix node into multiple prefix nodes, and the split prefix node obtained by the split is stored with the associated prefix of the newly configured prefix node in the j+1th search unit and the corresponding next hop.
  • a prefix node in the j-th search unit to store the associated prefix of the newly configured prefix node in the j+1th search unit and the corresponding next hop; wherein the target prefix node satisfies the first a condition and is a prefix node having the least step size of the associated prefix of the newly configured prefix node in the j+1th level searching unit among the prefix nodes satisfying the first condition, the first condition being: a prefix node
  • the associated prefix of the sub-tree includes the associated prefix of the newly configured prefix node in the j+1th-level search unit.
  • the embodiment of the present invention can update the original search structure with a minimum cost to minimize the impact on packet forwarding and ensure packet forwarding performance.
  • the incremental update of the scheme provided by the embodiment of the present invention has a time complexity of 0 (W/k), where W represents the length of the prefix and k represents Trie stride.
  • Figure 6a or Figure 6B or Figure 7 shows only a preferred implementation of the lookup table delta configuration, the present invention It is not limited to the incremental configuration shown in the figure.
  • the present invention does not impose any limitation on the specific implementation as long as the pipeline that is configured to be completed conforms to the above structure.
  • the routing table is updated, the Nth may be updated according to the updated routing table.
  • the multi-bit Trie tree corresponding to the level search unit is configured, and the N-th search unit is configured based on this, and then the search units of each level are configured step by step.
  • the six prefixes are added to an empty routing table in turn, and the six prefixes are sequentially inserted into the routing table to create a lookup structure.
  • the six prefixes are: ⁇ ( * ), pi ( 0* ), p2 ( 10* ), p3 ( 111* ), p4 ( 0000* ), p5 ( 1001* ).
  • the pipeline stage of the search device includes three stages, and the first stage (stageO) is a TCAM.
  • the complete multi-bit Trie structure is stored in the memory, the multi-bit Trie structure is updated when a new prefix is received, and an update command is generated and sent to the lookup device, which may be an instruction to write a prefix node, delete An instruction that prefixes a node, or an instruction that refreshes a prefix node.
  • the prefix ⁇ when the prefix ⁇ is inserted, the prefix ⁇ is first added to the multi-bit Trie tree corresponding to the stage2, and a prefix node PNODE20 is created according to the multi-bit Trie tree, and the prefix ⁇ and its corresponding RE Index are saved in PNODE20; then PNODE20 is packaged and written to the search unit corresponding to stage2.
  • the associated prefix plO of the prefix node in the multi-bit Trie tree corresponding to stage2 is inserted into the multi-bit Trie tree corresponding to stagel, and a prefix node PNODE10 is created, and PNODE10 is written into the search unit corresponding to stagel after encapsulation.
  • Each prefix in the multi-bit Trie tree corresponding to Stagel corresponds to a prefix node in the multi-bit Trie tree of stage2.
  • the prefix of the prefix node in the multi-bit Trie tree corresponding to stage 1 is placed in the TCAM in stageO. This way the lookup structure from stageO to stage2 is built.
  • the prefixes p3 and p4 are inserted, although they are not within the Trie node of the multi-bit Trie tree corresponding to the stage 2 (i.e., not within a stride), the prefixes p3, pi, and p2 are prefixed with p3 and After p4 is added to PNODE20, the capacity of the prefix node is not exceeded, so the next hop pointer corresponding to pi and p2 is stored in PNODE20.
  • the prefix node is split into a plurality of small prefix nodes according to stride.
  • each part can be used as a new prefix node, as shown in the figure PNODE21 ⁇ 24.
  • the minimum segmentation strategy is generally used, that is, the range covered by the segmented child nodes is as large as possible.
  • the root node of the multi-bit Trie tree associated with the prefix node can be split. In this example, splitting from the root node divides the original PNODE20 into four small prefix nodes PNODE21 24 and creates a Trie node T1 as the parent of the four prefix nodes.
  • the new prefix node PNODE21 24 is configured to the search unit corresponding to stage2 in the lookup device, and their associated prefixes are inserted into the multi-bit Trie tree corresponding to the stagel. Since the associated prefix of PNODE21 is the same as the associated prefix of the original PNODE20, and the prefix is already in the multi-bit Trie tree corresponding to the stagel, it is not necessary to repeatedly insert the associated prefix corresponding to the prefix node, and only need to update PNODE21. In the update process, the new prefix nodes PNODE22, PNODE23 and PNODE24 are first configured to correspond to stage2. Find the unit and then update the original PNODE20 to PNODE21 to avoid affecting the search process.
  • next hop pointer of the prefix node accommodated by PNODE10 If the next hop pointer of the prefix node accommodated by PNODE10 is continuously stored, the base address of the next hop pointer array can be saved only in PNODE10. When it is necessary to update PNODE10, only the new array element needs to be written first. Then update the base address of the next hop pointer array of PNODE10, and finally delete the old node.
  • the locating device in the embodiment of the present invention may be a device located in a network device for implementing packet forwarding, such as a router or a switch, such as a route lookup module, a processor, or a hardware-implemented search engine.
  • the search configuration process is performed by a control plane in a network device that implements packet forwarding, such as the router or the switch.
  • the control plane performs a lookup configuration process, and the prefix in the routing table is The next hop corresponding to the prefix is configured to the searching device.
  • the search device in the embodiment of the present invention may also be a network device for implementing packet forwarding, such as a router or a switch.
  • the search configuration process is performed by a control plane in the network device, that is, the control plane passes. The configuration process is performed, and the prefix in the routing table and the next hop corresponding to the prefix are configured to the data plane in the network device.
  • the searching process provided by the embodiment of the present invention is implemented based on the foregoing searching device.
  • FIG. 9 is a schematic diagram of a search process according to an embodiment of the present invention.
  • the process may include: S91: The search device receives a search key, and proceeds to S92.
  • the search device includes N pipeline stages, N>1;
  • the pipeline stage includes a search unit, which is a 0th to N-1th search unit according to the sequence of execution of the N pipeline stages;
  • the i-th search unit matches the prefix stored in the first prefix node in the i-th search unit by using the lookup key, and if the prefix is matched, the length of the matched prefix is The next hop corresponding to the matched prefix is output to the i+1th search unit, and the process proceeds to S94; otherwise, the process proceeds to S96;
  • the i-th search unit extracts, according to the length of the prefix output by the i-1th-level search unit, a segmentation keyword of a corresponding length from the search key, and outputs a next hop according to the i-1th-level search unit. Determining a corresponding second prefix node in the i-th search unit, and matching the extracted segment key with a corresponding segment key of the prefix stored by the second prefix node;
  • the process proceeds to S96;
  • a three-layer pipeline structure is taken as an example to describe the search process along the pipeline.
  • the process may include:
  • the lookup key is matched with the prefix contained in the prefix node configured in the search unit of the current level. If the prefix is matched, the length of the matched prefix and the next hop pointer corresponding to the matched prefix are output to the search unit corresponding to the stage1, and the next hop pointer points to the prefix node configured in the search unit corresponding to the stage1, and then Go to S1022.
  • S1022 In the searching unit corresponding to the pipeline stagel, according to the length of the prefix output by the stageO, extract the segment key of the corresponding length from the search key, and use the extracted segment key and the next hop pointer output by the stageO.
  • the prefix accommodated by the prefix node is matched, wherein the "segment key of the corresponding length" refers to all remaining keys starting from the prefix length output by the stageO. If the prefix is matched, the length of the prefix and the next hop pointer corresponding to the prefix are output to the stage 2, and the next hop pointer points to the prefix node configured in the search unit corresponding to the stage 2, and then the process proceeds to S1023. If If the prefix is not matched, it is transferred to S 1024.
  • S1023 In the search unit corresponding to the pipeline stage2, according to the length of the prefix output by the stage 1, the segment key of the corresponding length is extracted from the search key, and is indicated by the extracted segment key and the next hop pointer output by the stagel
  • the prefixes held by the prefix nodes are matched, wherein the "segment key of the corresponding length" refers to all remaining keys starting from the prefix length output by the stagel. If the prefix is matched, the next hop pointer corresponding to the prefix is output, and the next hop pointer points to the next hop information, and then proceeds to S 1025. If the prefix is not matched, it will be transferred to S 1024.
  • S1024 Acquire a PLPM corresponding to the prefix node indicated by the pointer according to the next hop pointer output by the first-level search unit, obtain a next hop pointer corresponding to the PLPM, and the next hop pointer points to the next hop information, and then Into S1025. If the prefix node indicated by the next hop pointer output by the previous level search unit does not have a PLPM, then the process proceeds to S1026.
  • S1025 Acquire next hop information according to the output next hop pointer, use the next hop information as the query result of the query keyword, and return, and end the search process.
  • S1026 Output the information of the MISS (that is, the information matching the prefix is not found), and the search process ends.
  • the manner in which the PLPM corresponding to the prefix node obtains the next hop pointer is also different. If the PLPM and the next hop pointer corresponding to the PLPM are saved in the next hop pointer array corresponding to the prefix node, the next hop pointer corresponding to the PLPM may be obtained from the next hop pointer array corresponding to the prefix node.
  • the PLPM of the prefix node may also be stored in the form of a pointer comprising a pointer to the prefix node hosting the PLPM and the location of the PLPM in the next hop pointer array of the prefix node.
  • the next hop information corresponding to the prefix accommodated by the prefix node may be obtained from the next hop pointer array of the prefix node. Specifically, if the next hop pointer array corresponding to the prefix node is stored in the search unit, the next hop pointer may be directly obtained from the next hop pointer array corresponding to the prefix node, and the corresponding next step is obtained according to the pointer.
  • Jump information in the case where the next hop pointer array is not stored in the search unit but the base address of the next hop pointer array is stored,
  • the base address of the one-hop pointer array accesses the corresponding next hop pointer array, obtains the corresponding next hop pointer from the array, and obtains corresponding next hop information according to the pointer.
  • the pipeline stage may also include a Trie node, or may be other improved structures as described above, but the search process is basically similar to the above-mentioned search process regardless of the pipeline structure, and will not be described in detail herein. .
  • the pipeline structure of the lookup device when the pipeline structure of the lookup device is configured, only the prefix nodes corresponding to the respective pipeline stages are arranged in the pipeline structure.
  • all Trie nodes with prefix nodes can also be configured into the pipeline structure, for example, the Trie with the prefix node in the multi-bit Trie tree corresponding to the i-th search unit.
  • the node and the prefix node corresponding to the Trie node are all configured into the i-th search unit.
  • each Trie node can have 2 sets of sub-nodes, one for holding Trie sub-nodes and one for storing prefix nodes. Each set of child nodes is indexed separately, but only the index of the prefix nodes can be saved in the pipeline stage of the lookup device.
  • each search unit includes two sub-units, each sub-unit corresponding to one level in the pipeline structure; according to the order of the pipeline from front to back, the first sub-unit in one search unit is configured with corresponding corresponding to the search unit. All Trie nodes with prefix nodes in the Trie tree, and the second sub-units are configured with all the prefix nodes in the multi-bit Trie tree corresponding to the search unit.
  • the options described here are compared to the solution where the prefix node is only stored in the pipeline stage. It is possible to make the associated prefix generated by each iteration less, because in general, a Trie node has multiple prefix nodes, so the number of associated prefixes of the Trie node is smaller than the number of associated prefixes of the prefix node, thereby facilitating the update speed.
  • two configuration schemes may also be used in combination, for example, for some search units, only the prefix nodes in the multi-bit Trie tree are configured in these search units, and for other search units, all the prefix nodes are The Trie node and the prefix node itself are configured into these lookup units.
  • the solution provided by the embodiment of the present invention can be used in a lookup algorithm such as an accurate search, for example, in a media access control (MAC) search. Or linear table lookup. For the exact search, only each entry in the lookup table needs to be regarded as a full-length prefix.
  • MAC media access control
  • linear table lookup For the exact search, only each entry in the lookup table needs to be regarded as a full-length prefix.
  • the embodiments of the present invention provide a multi-trie iteration to configure a finder by applying multiple Trie iterations to the existing multi-bit Trie algorithm, such as multiple pipeline stages, uncertain memory footprints, and complicated data structures.
  • Program In the process of creating a multi-bit Trie tree, on the one hand, each sub-tree is covered by as many sub-trees as possible, and a corresponding prefix node is created for each sub-tree to accommodate the prefix covered by the sub-tree, thereby making the multi-bit
  • the Trie tree structure is "flattened", and then a multi-bit Trie iteration is used to create a new multi-bit Trie tree with the associated prefix of the next-level prefix node to determine the prefix node of the previous level, thus compared with the existing multi-bit Trie algorithm. , reduces the number of stages in the pipeline, and greatly reduces the memory bandwidth and lookup delay.
  • Trie nodes or Trie nodes without prefix nodes need not be saved in the search device, which can reduce the occupation of memory resources.
  • the memory usage of each stage of the pipeline is completely independent. According to the execution sequence of the pipeline, the memory usage of each level is gradually reduced, which has obvious regularity, which is very beneficial to software/hardware implementation. Most of the memory footprint is at the last stage of the pipeline.
  • the on-chip resources that is, the built-in memory resources of the device
  • the off-chip memory is generally a low-cost Dynamic Random Access Memory (DRAM), so the present invention
  • DRAM Dynamic Random Access Memory
  • the embodiment of the present invention processes the IPv4 and IPv6 routes in exactly the same manner, and the data structure is greatly simplified by separating the implementation of the software and hardware, thereby reducing the complexity and difficulty of implementation.
  • the solution provided by the embodiment of the present invention is insensitive to the length of the prefix, has good scalability, and can support a large-scale routing table.
  • embodiments of the present invention can be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or a combination of software and hardware. Moreover, the invention can be embodied in the form of one or more computer program products embodied on a computer-usable storage medium (including but not limited to disk storage, CD-ROM, optical storage, etc.) in which computer usable program code is embodied.
  • a computer-usable storage medium including but not limited to disk storage, CD-ROM, optical storage, etc.
  • 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.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

一种查找装置、查找配置方法和查找方法,所述查找装置包括N个流水线级,每个流水线级包括一个查找单元,每级查找单元中配置前缀节点,第 N-1级查找单元配置的前缀节点是通过对查找表构成的多位Trie树进行子树划分得到的,第N-2级查找单元中配置的前缀节点是通过对第N-1级查找单元中配置的前缀节点的关联前缀构成的多位Trie树进行子树划分得到的,通过多次迭代进行前缀节点配置。采用本发明提供的查找装置,可以减少内存资源的占用和流水线级数,进而减少查找延迟并降低实现难度。

Description

一种查找装置、 查找配置方法和查找方法 技术领域
本发明涉及网络通信领域, 尤其涉及一种查找装置、 查找配置方法和查 找方法。 背景技术
路由器的主要任务是进行网际协议( Internet Protocol,简称 IP )报文转发, 也就是根据报文头中的目的 IP地址将到达路由器输入端口的报文转发到正确 的输出端口。路由查找就是根据报文的目的 IP地址,查找路由器中的路由表, 得到报文下一跳信息的过程。
路由查找釆用最长前缀匹配( longest prefix match, 简称 LPM )原则。 当 有多个前缀与输入的 IP地址匹配时,与该 IP地址匹配的前缀中掩码最长的前 缀对应的下一跳信息为最终的查找结果。
常用的路由查找算法包括三态内容可寻址存储器 (Ternary Content Addressable Memory, 简称 TCAM )算法和基于 Trie树的算法等。
TCAM 算法可以将输入的 IP 地址同时与所有的路由表项进行匹配。 TCAM的价格昂贵, 用 TCAM实现路由查找的成本较高。 TCAM的集成度比 一般的存储器低很多, 容量比较有限, 很难满足百万量级路由表的处理。 另 外, TCAM功耗也比较大。 因此目前更为常用的是多位 Trie算法。
基于 Trie树(也称前缀树) 的算法根据前缀中的位串建立一棵二叉树或 多叉树。 如果每次考虑一位, 则建立一棵二叉树, 也称为单位 Trie树。 图 1 示出了一棵单位 Trie树, 其中 11个前缀, 图 1 中左侧 p0~pll , 在单位 Trie 树中对应的节点用黑色圓圈表示, 连接点用白色圓圈表示, 每个节点用唯一 编号标识。 如果每次考虑多位, 则建立一棵多位 Trie树。 在多位 Trie树中 , 每次考虑的位数一般是固定的, 称为 Trie树的步长(英文: stride )。
多位 Trie树可以看作按 stride把一个单位 Trie树分成多个子树, 并为每 个子树创建一个 Trie节点。 每个 Trie节点均有一个关联前缀, 一个 Trie节点 的关联前缀是该 Trie节点对应的子树的根节点上的前缀值。 如果某个子树内 分布有前缀, 还要为该子树创建一个前缀节点, 位于在该子树内的前缀都保 存在该前缀节点中, 每个前缀对应一条下一跳信息。 一般在多位 Trie树中只 保存下一跳指针, 也就是指向下一跳信息的指针。 根据 stride可将每个前缀分 成很多段, 每个分段对应的位串称为该前缀在该分段的分段键值(key )。 比 如, 在 stride等于 3的情况下, 前缀 '10101 *, 的第一个分段键值为 '101,, 第二个分段键值为 '01 *'。
图 2示出了基于图 1中的前缀建立的 stride等于 3的多位 trie树。 该多位 Trie树包括 7个 Trie节点, 如图 2中所示的 Trie Node Tl~Trie Node T7 , 每个 Trie节点配置有一个前缀节点, 如图 2中所示 Prefix Node。 每个 Prefix Node 中保存有该 Prefix Node对应的 Trie节点中的各个前缀的下一跳指针, 例如, 图 2中 Trie Node T4对应的 Prefix节点( Prefix节点表示前缀节点 ) 中保存有 前缀 p3的下一跳指针 "RE Index of P3"。 除了 Trie Node Tl对应的前缀节点 以外的每个前缀节点中, 还保存一个最长前缀匹配 ( present longest prefix match , 简称 PLPM )。一个 Prefix节点的 PLPM为覆盖该 Prefix节点对应的子 树的最长前缀。 图 2中 Prefix节点中的 "RE Index of PLPM" 表示该 Prefix 节点的 PLPM的下一跳指针。
为了提高路由查找性能, 路由查找一般用硬件实现的查找装置。 由硬件 实现的查找装置一般釆用多级的流水线结构。 基于多位 Trie树的算法可以通 过将多位 Trie树结构存放在流水线结构的各级中来实现。
图 3是将图 2的多位 Trie树放在一个 5级的流水线结构中的示意图。 如 图 3所示, 流水线结构中的前 3级( stagel~stage3 )保存 3层 Trie节点, 第 4 级( stage4 )保存 7个 Trie节点对应的 Prefix节点, 第 5级( stage5 )保存每 个 Prefix节点中的各个前缀对应的 RE Index。 基于上述流水线结构的查找装 置在进行路由查找时, 将待匹配的 IP地址(即查找关键字) 沿着流水线结构 一级一级进行查找, 最终得到查找结果。 比如, 查找关键字为 111 010 011 , 则路由查找过程包括:
在 stagel ,访问 T1 , 由于 T1中的节点 1对应的前缀与任意查找关键字匹 配, 因此保存 T1对应的 Prefix节点的指针, 并从查找关键字中提取第一个分 段 key ' ΙΙΓ ;
在 stage2, 根据分段 key ' ΙΙΓ分别访问 T1的子节点 T2、 Τ3、 Τ4, 由于 Τ4中的节点 9对应的前缀 ρ3 (即 111 * )的第一个分段 key与查找关键字的第 一个分段 key ' 111 '最长匹配, 因此更新保存的 Prefix节点的指针为 T4对应的 Prefix节点的指针, 并从查找关键字中提取第二个分段 key '010,;
在 stage3 , 根据分段 key'010'访问 T4的子节点 T7 , 由于 T7中的节点 21 对应的前缀 plO ( 1110100* )的第二个分段 key'010,与查找关键字的第二个分 段 key'010'最长匹配, 因此更新保存的 Prefix节点指针为 T7对应的 Prefix节 点的指针, 并从查找关键字中提取第三个分段 key 'ΟΙΓ ;
在 stage4, 由于 T7没有 Trie子节点, 因此使用最近一次保存的 T7对应 的 Prefix节点指针访问 T7对应的 Prefix节点,用查找关键字的第三个分段 key 与 T7对应的 Prefix节点中各前缀的第三个分段 key进行匹配,其中,前缀 plO 的第三个分段 key'0*,与该查找关键字的第三个分段 key'011,最长匹配, 因此 将 T7对应的 Prefix节点中 "RE Index of plO" (前缀 plO对应的下一跳指针 ) 对应的 RE Index数组中的位置作为 stage4的输出;
在 stage5 , 根据 stage4中得到的 RE Index数组中的位置得到前缀 plO对 应的 RE Index。
最终, 根据查找装置返回的 RE Index可以得到上述查找关键字对应的下 一跳信息。
现有基于多位 Trie算法实现的路由查找算法, 将整个多位 Trie树结构放 在查找装置中, 会占用大量内存资源; 并且由于硬件实现的查找装置的流水 线结构的级数与多位 Trie树的级数对应, 因此对于掩码较长的 IPv6路由, 多 位 Trie树的级数往往较多, 相应流水线结构的级数也较多, 导致查找延迟大, 也增加了硬件实现的难度。 发明内容
本发明实施例提供了一种查找装置、 查找配置方法和查找方法, 用以减 少查找装置中的流水线级数以及存储开销, 进而减少查找延迟、 降低实现难 度, 并减少资源占用。
第一方面, 提供一种查找装置, 所述查找装置包括:
N个流水线级, 其中 N>1;
每个流水线级中包括一个查找单元, 按照所述 N个流水线级执行的先后 顺序, 分别为第 0级至第 N-1级查找单元; 每级查找单元中包括前缀节点, 用于存储前缀以及与所述前缀所对应的下一跳, 其中:
第 i+1级查找单元中配置有第一前缀节点, 第 i级查找单元中配置有第二 前缀节点, 其中 0<=i<=(N-2); 所述第二前缀节点中存储的前缀所对应的下一 跳指向所述第一前缀节点, 所述第二前缀节点通过对所述第一前缀节点的关 联前缀所构成的第一多位 Trie树进行子树划分得到;
所述第二前缀节点通过对所述第一前缀节点的关联前缀所构成的第一多 位 Trie树进行子树划分得到包括: 将所述第一多位 Trie树划分为 M个子树, M>=1 , 每个子树包括所述第一多位 Trie树的一个 Trie节点以及所述 Trie节 点的 K 个分支, 根据所述 M 个子树得到所述第二前缀节点, 其中 0<=K<=stride , 所述 stride为所述第一多位 Trie树的步长。
结合第一方面, 在第一方面的第一种可能的实现方式中, 所述第二前缀 节点包括 1至 2stnde个间接前缀节点,或者包括 0至 2stnde个间接前缀节点和一 个直接前缀节点; 其中, 直接前缀节点用于存储落入该子树的 Trie节点内的 前缀, 间接前缀节点用于存储落入该子树的 Trie节点的一个分支内的前缀。
结合第一方面的第一种可能的实现方式, 在第一方面的第二种可能的实 现方式中, 所述第 i+1级查找单元中还配置有所述第一多位 Trie树中包含有 前缀节点的 Trie节点。
结合第一方面, 在第一方面的第三种可能的实现方式中, 所述第一前缀 节点中存储第一数组或所述第一数组的地址, 所述第一数组中存储所述第一 前缀节点的每个前缀所对应的下一跳指针; 和 /或
所述第二前缀节点中存储第二数组或所述第二数组的地址, 所述第二数 组中存储所述第二前缀节点的每个前缀所对应的下一跳指针。
结合第一方面, 在第一方面的第四种可能的实现方式中, 所述第 0级查 找单元为一个三态内容寻址存储器 TCAM。
结合第一方面以及第一方面的第一种至第四种可能的实现方式中的任一 种, 在第一方面的第五种可能的实现方式中, 所述 N个流水线级用于执行以 下步骤:
S91 : 接收查找关键字, 转入 S92;
S92: 设置 i=0, 转入 S93;
S93: 第 i级查找单元用所述查找关键字与第 i级查找单元中的第一前缀 节点容纳的前缀进行匹配, 若匹配到前缀, 则将匹配到的前缀的长度以及匹 配到的前缀所对应的下一跳输出给第 i+1级查找单元, 转入 S94, 否则, 转入 S96;
S94: 设置 i=i+l , 并转入 S95;
S95: 第 i级查找单元根据第 i-1级查找单元输出的前缀的长度, 从所述 查找关键字中提取相应长度的分段关键字,根据第 i-1级查找单元输出的下一 跳确定所述第 i级查找单元中对应的第二前缀节点,用提取出的分段关键字与 所述第二前缀节点所存储的前缀的相应分段关键字进行匹配;
若匹配到前缀, 当 i=N-l时, 输出匹配到的前缀所对应的下一 ϋ ; 否则, 将匹配到的前缀的长度以及匹配到的前缀所对应的下一跳输出给第 i+1 级查 找单元, 转 S94;
若没有匹配到前缀,且所述第二前缀节点有最长前缀匹配 PLPM,则输出 所述 PLPM对应的下一跳; 如果所述第二前缀节点没有 PLPM, 则转入 S96;
S96: 输出未查找到匹配前缀的提示信息。
第二方面, 提供一种查找配置方法, 所述方法包括: S61 : 获得待配置的第一前缀以及所述第一前缀所对应的下一跳, 转入
S62;
S62: 将所述第一前缀以及所述第一前缀所对应的下一跳存储在第 N-1级 查找单元中, 转入 S63; 其中, N为流水线级的数量, N>1 , 每个流水线级中 包括一个查找单元, 按照所述 N个流水线级执行的先后顺序, 分别为第 0级 至第 N-1 级查找单元; 每级查找单元中包括前缀节点, 用于存储前缀以及与 所述前缀所对应的下一跳;
S63:对第 N-1级查找单元中的前缀节点的关联前缀所构成的多位 Trie树 进行子树划分, 以得到第 N-2级查找单元的前缀节点, 其中, 第 N-2级查找 单元的前缀节点中存储的前缀所对应的下一跳指向第 N-1 级的前缀节点; 所 述对第 N-1级查找单元中的前缀节点的关联前缀所构成的多位 Trie树进行子 树划分, 以得到第 N-2级查找单元的前缀节点, 包括: 将所述多位 Trie树划 分为 M个子树, M>=1 , 每个子树包括所述多位 Trie树的一个 Trie节点以及 所述 Trie节点的 K个分支, 其中 0<=K<=stride , 所述 stride为所述多位 Trie 树的步长。
结合第二方面, 在第二方面的第一种可能的实现方式中,
所述 S62包括:
判断第 N-1 级查找单元中的前缀节点的容量是否允许存储所述第一前缀 以及所述第一前缀所对应的下一跳, 若是, 则将所述第一前缀以及所述第一 前缀所对应的下一跳存储于所述第 N-1 级查找单元的前缀节点中; 否则, 重 新配置所述第 N-1 级查找单元的前缀节点, 将所述第一前缀以及所述第一前 缀所对应的下一跳存储于所述第 N-1级查找单元重新配置后的前缀节点; 所述 S63包括:
根据第 N-2级查找单元中的前缀节点的容量判断是否允许存储第 N-1级 查找单元重新配置的前缀节点的关联前缀, 若是, 则将第 N-1 级查找单元重 新配置的前缀节点的关联前缀存储于第 N-2级查找单元的前缀节点; 否则, 转入 S64; S64: 设置 j=N-2, 转入 S65;
S65:通过对第 j+1级查找单元中的前缀节点的关联前缀所构成的多位 Trie 树进行子树划分来重新配置第 j级查找单元的前缀节点,将第 j+1级查找单元 中配置的前缀节点的关联前缀存储于第 j级查找单元重新配置后的前缀节点, 转入 S66;
S66: 根据第 j-1级查找单元的前缀节点的容量判断是否允许存储第 j级 查找单元重新配置的前缀节点的关联前缀, 若是, 则将第 j级查找单元重新配 置的前缀节点的关联前缀存储于第 j-i级查找单元的前缀节点, 并结束流程, 否则转入 S67;
S67: 设置 j=j-l , 并转入 S68;
S68: 若 j=0则结束流程, 否则, 转入 S65。
结合第二方面的第一种可能的实现方式, 在第二方面的第二种可能的实 现方式中, 所述重新配置第 N-1级查找单元的前缀节点, 包括:
将所述第一前缀插入第 N-1级查找单元对应的第一多位 Trie树; 若第 N-1 级查找单元中存在拆分目标前缀节点, 则根据所述第一前缀在 第 N-1级查找单元对应的第一多位 Trie树中的位置、 所述第一多位 Trie树的 步长以及所述拆分目标前缀节点所存储的前缀在所述第一多位 Trie树中的位 置, 将所述拆分目标前缀节点拆分为多个前缀节点, 拆分得到的一个前缀节 点中存储有所述第一前缀以及所述第一前缀所对应的下一跳, 否则,在第 N-1 级查找单元中新配置一个前缀节点以存储所述第一前缀以及所述第一前缀所 对应的下一跳; 其中, 所述目标前缀节点满足第一条件且是所有满足所述第 一条件的前缀节点中距离所述第一前缀的步长最少的前缀节点, 所述第一条 件为: 前缀节点所对应的子树的分支上包含所述第一前缀;
所述通过对第 j+1级查找单元中的前缀节点的关联前缀所构成的多位 Trie 树进行子树划分来重新配置第 j级查找单元的前缀节点, 包括:
若第 j级查找单元中存在拆分目标前缀节点, 则根据所述第一前缀在第 j 级查找单元所对应的第二多位 Trie树中的位置、 所述第二多位 Trie树的步长 以及所述拆分目标前缀节点所存储的前缀在所述第二多位 Trie树中的位置, 将所述拆分目标前缀节点拆分为多个前缀节点, 拆分得到的一个前缀节点中 存储有第 j+1级查找单元中新配置的前缀节点的关联前缀以及对应的下一跳, 否则,在第 j级查找单元中新配置一个前缀节点以存储所述第 j+1级查找单元 中新配置的前缀节点的关联前缀以及对应的下一跳; 其中, 所述目标前缀节 点满足第一条件且是所有满足所述第一条件的前缀节点中距离所述第 j+1 级 查找单元中新配置的前缀节点的关联前缀的步长最少的前缀节点, 所述第一 条件为:前缀节点所对应的子树的分支上包含所述第 j+1级查找单元中新配置 的前缀节点的关联前缀。
结合第二方面以及第二方面的第一种和第二种可能的实现方式中的任一 种, 在第二方面的第三种可能的实现方式中, 还包括:
S71 : 获得待删除的第二前缀以及所述第二前缀对应的下一跳;
S72: 从第 N-1级查找单元中存储有所述第二前缀以及所述第二前缀对应 的下一跳的前缀节点中释放所述第二前缀以及所述第二前缀的下一跳;
S73: 若释放所述第二前缀后的前缀节点中, 已不再存储有前缀以及所述 前缀的下一跳, 则释放该前缀节点, 并转入 S74;
S74: 设置 j=N-2, 转入 S75;
S75: 针对第 j+1级查找单元中被释放的前缀节点, 从第 j级查找单元中 的前缀节点中释放相应前缀节点的关联前缀, 若释放关联前缀后的前缀节点 中已不再存储有关联前缀,则释放第 j级查找单元中已不再存储有关联前缀的 前缀节点, 并转入 S76;
S76: 设置 j=j-l ; 转入 S77;
S77: 若 j<0, 则结束流程, 否则转入 S75。
第三方面, 提供一种查找方法, 包括:
S91 : 查找装置接收查找关键字, 转入 S92; 其中, 所述查找装置包括 N 个流水线级, N>1 ; 每个流水线级中包括一个查找单元, 按照所述 N个流水 线级执行的先后顺序, 分别为第 0级至第 N-1级查找单元; S92: 设置 i=0, 转入 S93;
S93: 第 i级查找单元用所述查找关键字与第 i级查找单元中的第一前缀 节点中存储的前缀进行匹配, 若匹配到前缀, 则将匹配到的前缀的长度以及 匹配到的前缀所对应的下一跳输出给第 i+1级查找单元, 转入 S94, 否则, 转 入 S96;
S94: 设置 i=i+l , 并转入 S95;
S95: 第 i级查找单元根据第 i-1级查找单元输出的前缀的长度, 从所述 查找关键字中提取相应长度的分段关键字,根据第 i-1级查找单元输出的下一 跳确定所述第 i级查找单元中对应的第二前缀节点,用提取出的分段关键字与 所述第二前缀节点所存储的前缀的相应分段关键字进行匹配;
若匹配到前缀, 当 i=N-l时, 输出匹配到的前缀所对应的下一 ϋ ; 否则, 将匹配到的前缀的长度以及匹配到的前缀所对应的下一跳输出给第 i+1 级查 找单元, 转入 S94;
若没有匹配到前缀,且所述第二前缀节点有最长前缀匹配 PLPM,则输出 所述 PLPM所对应的下一跳;如果所述第二前缀节点没有 PLPM,则转入 S96;
S96: 输出未查找到匹配前缀的提示信息。
本发明的上述实施例中, 查找装置的 N个流水线级中, 每级查找单元中 包括前缀节点, 用于存储前缀以及与所述前缀对应的下一跳, 其中: 第 i+1 级查找单元中配置有第一前缀节点, 第 i级查找单元中配置有第二前缀节点, 所述第二前缀节点中存储的前缀对应的下一跳指向所述第一前缀节点, 所述 第二前缀节点通过对所述第一前缀节点的关联前缀所构成的第一多位 Trie树 进行子树划分得到。 划分得到的一个子树的覆盖范围包括多位 Trie树中的一 个 Trie节点以及所述 Trie节点的 K个分支, 划分得到的一个子树对应一组前 缀节点, 因此, 一方面由于仅将前缀节点配置在查找单元中, 与现有技术相 比减少了内存资源的占用; 另一方面, 由于前一级的查找单元中的前缀节点 是基于后一级的查找单元中的前缀节点的关联前缀构成的多位 Trie树进行子 树划分得到的, 使得一个前缀节点所对应的子树的覆盖范围较大, 减少了流 水线级数, 进而减少查找延迟并降低实现的难度。 附图说明
为了更清楚地说明本发明实施例中的技术方案, 下面将对实施例描述中 所需要使用的附图作简要介绍, 显而易见地, 下面描述中的附图仅仅是本发 明的一些实施例, 对于本领域的普通技术人员来讲, 在不付出创造性劳动性 的前提下, 还可以根据这些附图获得其他的附图。
图 1为背景技术中的单位 Trie树的示意图;
图 2为背景技术中的多位 Trie树的示意图;
图 3为基于图 2的多位 Trie树的查找结构示意图;
图 4为本发明实施例中多位 Trie结构创建过程的示意图;
图 5为本发明实施例中查找配置过程示意图;
图 6a、 图 6b为本发明实施例中增加表项时的配置流程示意图;
图 7为本发明实施例中删除表项时的配置流程示意图;
图 8a、 图 8b、 图 8c、 图 8d为本发明实施例中增量配置实例示意图; 图 9a、 图 9b为本发明实施例提供的查找流程示意图。 具体实施方式
为了使本发明的目的、 技术方案和优点更加清楚, 下面将结合附图对本 发明作进一步地详细描述, 显然, 所描述的实施例仅仅是本发明一部份实施 例, 而不是全部的实施例。 基于本发明中的实施例, 本领域普通技术人员在 没有做出创造性劳动前提下所获得的所有其它实施例, 都属于本发明保护的 范围。
针对现有多位 Trie算法中存在的流水线级数多等问题, 本发明实施例提 出了一种基于多位 Trie树迭代的查找装置, 查找配置方法以及查找方法, 由 于流水线级中仅保存前缀节点, 可以减少对内存资源的占用, 通过多位 Trie 树迭代可以减少流水线级数、 降低对查找装置的带宽占用, 减小查找延迟。 本发明实施例提出的基于多位 Trie树迭代的查找配置方法, 在一次迭代 过程中,针对一个流水线级配置前缀节点。具体当前迭代过程对应的多位 Trie 树是由前一次迭代过程创建的前缀节点的关联前缀构成, 并且该多位 Trie树 中的叶子节点都是前缀节点, 根据该多位 Trie树可以创建当前迭代过程的前 缀节点, 将创建的前缀节点配置到当前迭代过程对应的流水线级中。 最初一 次迭代过程对应的多位 Trie树是由待配置前缀,例如路由表中的 IPv4/IPv6前 缀构成, 且每一次迭代过程创建的前缀节点对应一个流水线级, 即, 一个迭 代过程对应的多位 Trie树中的前缀节点保存在同一流水线级中。 这样, 流水 线结构中可以仅保存前缀节点。
为了更清楚地理解本发明, 下面从以下几个方面对本发明进行详细说明: (一)查找装置、 (二)查找配置流程、 (三)查找流程、 (四)其他可选方案。
(一 )查找装置
本发明实施例提供的查找装置可以是位于路由器或交换机等用于实现报 文转发的网络设备中的装置, 例如路由查找模块, 处理器, 或硬件实现的查 找引擎; 或者也可以是路由器或交换机等用于实现报文转发的网络设备。
具体的,本发明实施例提供的查找装置中包括 N个级流水线级,其中 N>1 ; 每个流水线级中包括一个查找单元, 按照所述 N个流水线级执行的先后 顺序, 分别为第 0级至第 N-1级查找单元; 每级查找单元中包括前缀节点, 所述前缀节点用于存储前缀以及与所述前缀所对应的下一跳, 其中:
第 i+1级查找单元中配置有第一前缀节点, 第 i级查找单元中配置有第二 前缀节点, 其中 0<=i<=(N-2); 所述第二前缀节点中存储的前缀所对应的下一 跳指向所述第一前缀节点, 所述第二前缀节点通过对所述第一前缀节点的关 联前缀所构成的第一多位 Trie树进行子树划分得到。 具体地, 所述第二前缀 节点通过对所述第一前缀节点的关联前缀所构成的第一多位 Trie树进行子树 划分得到可包括: 将所述第一多位 Trie树划分为 M个子树, M>=1 , 每个子 树包括所述第一多位 Trie树的一个 Trie节点以及所述 Trie节点的 K个分支, 根据所述 M个子树得到所述第二前缀节点, 其中 0<=K<=stride, 所述 stride 为所述第一多位 Trie树的步长。
特别地, 第 N-1 级查找单元中的前缀节点中的前缀所对应的下一跳指向 下一跳的具体内容, 比如所述下一跳的内容可以是下一跳 IP地址。
查找单元中配置的前缀节点实质上表现为一种数据结构, 其中存储有前 缀以及所述前缀对应的下一跳。
每级查找单元中的前缀节点的数量可以是一个也可以是多个。
每级查找单元对应一个多位 Trie树。 其中, 第 0级查找单元对应的多位 Trie树是根据查找表中的前缀生成的 ,查找表中的前缀对应于该树中的相应节 点。 第 1级查找单元对应的多位 Trie树是由第 0级查找单元中的前缀节点的 关联前缀构成的, 即第 0级查找单元中的前缀节点的关联前缀对应于该树中 的相应节点; 第 2级查找单元对应的多位 Trie树是由第 1级查找单元中的前 缀节点的关联前缀构成的。 以此类推, 除第 0级查找单元以外的每相邻的两 级查找单元中, 前一级查找单元对应的多位 Trie树由后一级查找单元中的前 缀节点的关联前缀构成。
根据一个多位 Trie树划分得到的每个子树对应一个或多个前缀节点。 比 如, 上述第二前缀节点中包括 1至 2stnde个间接前缀节点, 或者包括 0至 2stnde 个间接前缀节点和一个直接前缀节点, 用于存储落入该第二前缀节点对应的 子树内的前缀, 其中, stride为多位 Trie树的步长。 此处, 对于划分得到的每 个子树, 将该子树的顶点位置上的 Trie节点称为该子树的 Trie节点。 在一个 子树对应的前缀节点中, 直接前缀节点用于存储落入该子树的 Trie节点内的 前缀, 一个间接前缀节点用于存储落入该子树的 Trie节点的一个分支内的前 缀。
每级查找单元中的每一个前缀节点对应于该查找单元所对应的多位 Trie 树的一个子树。 如同传统的多位 Trie算法中, 每个 Trie节点都有一个关联前 缀一样, 类似的, 在本发明实施例中, 每个前缀节点也有一个关联前缀。 一 个前缀节点的关联前缀为该前缀节点对应的子树的根节点对应的前缀。 关联 前缀也称为顶点前缀或子树根节点前缀。 所述查找表可以是用于指导报文转发的查找表。 根据不同的业务需求, 可以配置相应类型的查找表。比如,对于三层转发业务,该查找表为 IPv4/IPv6 路由表, 该路由表中包含 IPv4/IPv6前缀及其对应的下一跳信息。 对于不同的 业务, 使用的查找算法可能有所不同, 比如对于路由查找, 使用最长前缀匹 配算法, 因此可根据不同业务类型配置查找算法。
可选地, 所述第一前缀节点中存储第一数组或所述第一数组的地址, 所 述第一数组中存储所述第一前缀节点的每个前缀所对应的下一跳指针;和 /或, 所述第二前缀节点中存储第二数组或所述第二数组的地址, 所述第二数组中 存储所述第二前缀节点的每个前缀所对应的下一跳指针。
也就是说, 前缀节点可以存储一个数组, 所述数组可以称为下一跳指针 数组; 前缀节点也可以存储该下一跳指针数组的地址。 前缀节点存储的下一 跳指针数组中保存了该前缀节点存储的每个前缀对应的下一跳指针。 对于下 一跳指针数组中的每个元素, 其下标用于标识前缀, 其元素值为该元素的下 标所标识的前缀对应的下一跳指针。
进一步地,前缀节点中还可以存储 PLPM。如果一个前缀节点包括 PLPM, 则可以将该前缀节点的 PLPM对应的下一跳指针存储到该前缀节点的下一跳 指针数组中, 比如可作为该数组的第一个元素。 优选地, 下一跳指针数组中 存储的 PLPM对应的下一跳指针, 指向所述 PLPM对应的下一跳信息。 一个 多位 Trie树中, 对于中间的子树, 覆盖该子树的最长前缀即为该子树对应的 前缀节点的 PLPM。
可选地, 所述第 i+1级查找单元中还配置有所述第一多位 Trie树中包含 有前缀节点的 Trie节点。
上述流水线结构中, 级数较高的几级查找单元中配置的前缀节点数量一 般较少, 也就是说存储的前缀数量较少, 因此可以使用 TCAM来实现, 一方 面不会因前缀过多导致 TCAM成本增加,另一方面还可利用 TCAM高效查找 的性能。 用 TCAM实现的查找单元的数量, 可根据查找表的容量以及查找表 中前缀的长度等因素来确定。 优选地, 第 0级查找单元(即流水线结构中最 先执行的流水线级的查找单元)用 TCAM实现。
基于上述 N个流水线级实现的查找配置过程以及查找过程, 将在后续内 容中详述。
为了更清楚起见, 下面以图 4中 (a )所示的多位 Trie树为例, 描述配置 后的 N个流水线级中的前缀节点的数据结构。
图 4中( a )所示的多位 Trie树的结构与图 2所示的多位 Trie树结构相同。 如果前缀节点的容量比较大, 则 T1 以及 T1的所有分支都可以保存在 ΤΓ对 应的一组前缀节点中, 因此创建如图 4中 (b )所示的 Trie结构。
如图 4中(b )所示, 该多位 Trie树只有一个 Trie节点 ΤΓ , ΤΓ对应的一 组前缀节点中包括 4个前缀节点 P1~P4。 PI、 P2、 P3和 P4分别与图 4中 ( a ) 中的 Tl、 Τ2、 Τ3和 Τ4对应。 PI中保存的是 Tl中的前缀; P2中保存的是从 T2开始的分支上的所有前缀, 也就是 T2、 Τ5和 Τ6中的前缀; Ρ3中保存的 是 Τ3中的前缀; Ρ4中保存的是从 Τ4开始的分支上的所有前缀, 也就是 Τ4 和 Τ7中的前缀。 P1称为 T1的直接前缀节点, Ρ2、 Ρ3、 Ρ4称为 Tl的间接前 缀节点。
如果前缀节点的容量比较小, 则创建如图 4中 (c )所示的 Trie结构。 如图 4中 (c )所示, 该多位 Trie树中有 3个 Trie节点, 其中 T2、 Τ4是 T1的 Trie子节点。 T1 "对应的一组前缀节点中包括 2个前缀节点 P1和 P3 , T2"对应的一组前缀节点中包括 3个前缀节点 P2、 P5和 P6, T4"对应的一组 前缀节点中包括 P4和 P7。 Pi和 Ti与图 4中 ( a ) 中的 Ti相对应。 P1中保存 的是 T1中的前缀; P3中保存的是 T3中的前缀; P2中保存的是 T2中的前缀; P5中保存的是 T5中的前缀; P6中保存的是 T6中的前缀; P4中保存的是 T4 中的前缀; P7中保存的是 T7中的前缀。 P1称为 T1的直接前缀节点, P3称 为 T1的间接前缀节点; P2称为 T2的直接前缀节点, P5和 P6称为 T2的间 接前缀节点; P4称为 T4的直接前缀节点, P7称为 T4的间接前缀节点。
对于图 4中 (c ) 中的 Trie结构, 可将所有前缀节点保存在流水线结构中 形成一级。 所有前缀节点的关联前缀, 包括: P1的关联前缀 "*" , P2的关联 前缀 "000*" , P3的关联前缀 "100*" , P4的关联前缀 "111*" , P5的关联前 缀 "000010*" , P6的关联前缀 "000011*" , P7的关联前缀 "111010*" , 且成 了一个小的路由表, 釆用相同方式基于该小的路由表对应的多位 Trie树创建 前缀节点, 最终可得到如图 5所示的四级流水线结构。
在图 5所示的四级流水线结构中, 第四级(stage3 )的查找单元中配置有 前缀节点 PNODE30、 PNODE31、 PNODE32、 PNODE33、 PNODE34、 PNODE35、 PNODE36, 其中, PNODE30 35分别对应于图 4 ( c ) 中的 Trie结构中的 P1、 P3、 P2、 P5、 P6、 P4、 P7; 第三级( stage2 ) 的查找单元中配置有前缀节点 PNODE20, PNODE21 , PNODE22, 其中, PNODE20 22 分别对应于 stagel 的 Trie结构中的 Tl、 Τ2、 Τ4; 第二级(stagel ) 的查找单元中配置有前缀节 点 PNODEIO, 对应于 stagel的 Trie结构中的 T1 ; 第一级( stageO )的 TCAM 中配置 PNODE10对应的下一跳指针。
如果前缀节点中的下一跳指针数组表示为如下结构:
{PLPM对应的 RE Index, 第一个前缀节点对应的 RE Index, 第二个前缀 节点对应的 RE Index , …… }
则图 5中各级查找单元中前缀节点的下一跳指针数组可表示为:
Stage3:
PNODE30: { ρθ对应的 RE Index, pi对应的 RE Index, p2对应的 RE Index } , 其中:
θ对应的 RE Index指向前缀 ρθ对应的 RE;
pi对应的 RE Index指向前缀 i对应的 RE;
p2对应的 RE Index指向前缀 p2对应的 RE;
PNODE31: { PLPM对应的 RE Index, p5对应的 RE Index } , 关联前缀为 011* , PLPM为 10* , 其中:
PLPM对应的 RE Index指向前缀 10*对应的 RE;
P5对应的 RE Index指向前缀 p5对应的 RE;
PNODE32: { PLPM对应的 RE Index, p4对应的 RE Index } , 关联前缀为 000* , PLPM为 0* , 其中:
PLPM对应的 RE Index指向前缀 0*对应的 RE;
P4对应的 RE Index指向前缀 4对应的 RE;
PNODE33: { PLPM对应的 RE Index, p9对应的 RE Index } , 关联前缀为 000010* , PLPM为 0000* , 其中:
PLPM对应的 RE Index指向前缀 0000*对应的 RE;
P9对应的 RE Index指向前缀 9对应的 RE;
PNODE34: { PLPM对应的 RE Index, p8对应的 RE Index } , 关联前缀为 000011* , PLPM为 0000* , 其中:
PLPM对应的 RE Index指向前缀 0000*对应的 RE;
p8对应的 RE Index指向前缀 p8对应的 RE;
PNODE35: { PLPM对应的 RE Index, p3对应的 RE Index, p6对应的 RE Index, p7对应的 RE Index } , 关联前缀为 111* , PLPM为 * , 其中:
PLPM对应的 RE Index指向前缀 *对应的 RE;
P3对应的 RE Index指向前缀 p3对应的 RE;
P6对应的 RE Index指向前缀 6对应的 RE;
P7对应的 RE Index指向前缀 p7对应的 RE;
PNODE36: { PLPM对应的 RE Index, plO对应的 RE Index } , 关联前缀 为 111010* , PLPM为 11101 * , 其中:
PLPM对应的 RE Index指向前缀 11101 *对应的 RE;
P10对应的 RE Index指向前缀 plO对应的 RE。
Stage2:
PNODE20: { PNODE30的关联前缀对应的 RE Index, PNODE31的关联 前缀对应的 RE Index } , 关联前缀为 * , 其中:
PNODE30的关联前缀对应的 RE Index指向 PNODE30;
PNODE31的关联前缀对应的 RE Index指向 PNODE31; PNODE21 : { PLPM对应的 RE Index, PNODE32的关联前缀对应的 RE Index, PNODE33的关联前缀对应的 RE Index, PNODE34的关联前缀对应的 RE Index } , 关联前缀为 000* , PLPM为 * , 其中:
PLPM对应的 RE Index指向前缀 *对应的 RE;
PNODE32的关联前缀对应的 RE Index指向 PNODE32;
PNODE33的关联前缀对应的 RE Index指向 PNODE33;
PNODE34的关联前缀对应的 RE Index指向 PNODE34; PNODE22: { PLPM对应的 RE Index, PNODE35的关联前缀对应的 RE Index, PNODE36的关联前缀对应的 RE Index } ,关联前缀为 111* , PLPM为 * , 其中:
PLPM对应的 RE Index指向前缀 *对应的 RE;
PNODE35的关联前缀对应的 RE Index指向 PNODE35; PNODE36的关联前缀对应的 RE Index指向 PNODE36; Stage 1 :
PNODE10: { PNODE20的关联前缀对应的 RE Index, PNODE21的关联前 缀对应的 RE Index, PNODE22的关联前缀对应的 RE Index } , 关联前缀为 * , 其中:
PNODE20的关联前缀对应的 RE Index指向 PNODE20; PNODE21的关联前缀对应的 RE Index指向 PNODE21 ; PNODE22的关联前缀对应的 RE Index指向 PNODE22; StageO:
PNODE00: { PNODE10的关联前缀对应的 RE Index } , PNODE10的关 联前缀对应的 RE Index指向 PNODE10。
通过以上描述可以看出, 本发明的上述实施例中, 查找装置的 N个流水 线级中, 每级查找单元中包括前缀节点, 用于存储前缀以及与所述前缀对应 的下一跳, 其中: 第 i+1级查找单元中配置有第一前缀节点, 第 i级查找单元 中配置有第二前缀节点, 所述第二前缀节点中存储的前缀对应的下一跳指向 所述第一前缀节点, 所述第二前缀节点通过对所述第一前缀节点的关联前缀 所构成的第一多位 Trie树进行子树划分得到。 划分得到的一个子树的覆盖范 围包括多位 Trie树中的一个 Trie节点以及所述 Trie节点的 K个分支, 划分得 到的一个子树对应一组前缀节点, 因此, 一方面由于仅将前缀节点配置在查 找单元中, 与现有技术相比减少了内存资源的占用; 另一方面, 由于前一级 的查找单元中的前缀节点是基于后一级的查找单元中的前缀节点的关联前缀 构成的多位 Trie树进行子树划分得到的, 使得一个前缀节点所对应的子树的 覆盖范围较大, 减少了流水线级数, 进而减少查找延迟并降低实现的难度。
需要说明的是, 本发明实施例提供的查找装置中, 所述 N个流水线级可 由硬件实现, 所述硬件可以是现场可编程门阵列 (Programmable Gate Array, 简称: FPGA ), 专用集成电路 ( Application Specific Integrated Circuit, 简称 ASIC ); 所述 N个流水线级也可由软件实现, 例如处理器中多个线程实现所 述 N个流水线级。
(二)查找配置过程
本发明实施例中的查找配置过程, 是指查找表的配置过程, 即, 将查找 表的表项配置到 N个流水线级中的过程, 查找表的每个表项中包括前缀以及 所述前缀对应的下一跳。
查找配置过程可包括初始配置过程和增量配置过程。 在初始配置过程中 , 可以根据已有的整个查找表配置所述 N个流水线级, 在运行过程中, 可根据 接收到的路由更新命令获取新增的待配置前缀和该前缀对应的下一跳, 增量 配置所述 N个流水线级。
下面分别对初始配置过程和增量配置过程进行详细描述。
( 1 )初始配置过程
首先定义前缀节点的容量。 前缀节点的容量是指前缀节点的数据结构的 大小, 其单位为比特。 前缀节点的容量与如下任一或多个因素相关: 查找装 置的最大带宽, 查找表中前缀的长度等。 查找装置的最大带宽表示在一个时 钟周期内能够并行处理的最大比特数。 前缀节点可存储的前缀的个数与前缀 节点的容量和前缀长度相关。 优选地, 为了减少流水线级数, 可将前缀节点 的容量设置得较大, 比如对于路由查找可设置为 256比特。
优选地, 为了进一步使一个前缀节点能够存储更多的前缀以减少流水线 级数, 可以对前缀节点进行编码以减少存储开销。
在初始配置过程中, 可根据查找表创建多位 Trie树, 从第 N-1级查找单 元至第 0级查找单元, 通过 N次迭代过程配置查找单元, 配置后流水线结构 如前所述。 具体配置过程如下所述。
在第一次迭代过程中,首先,根据查找表以及预定的 stride,创建多位 Trie 树, 并根据前缀节点的容量对该多位 Trie树进行子树划分。 前缀节点的容量 越大, 子树的覆盖范围也就越大。 在根据前缀节点的容量对多位 Trie树进行 划分时, 尽可能使每个子树覆盖较多的前缀, 只有当超过前缀节点的容量时, 才将该子树拆分。
根据划分得到的子树创建对应的前缀节点中包括一个或多个前缀节点。 对于每个子树来说, 落入该子树内的前缀被存储到该子树对应的前缀节点所 容纳的前缀中。
最后, 将通过上述过程得到的前缀节点配置在第 N-1 级查找单元中。 进 一步地,可将该多位 Trie树的结构保存到查找装置内置的或外接的存储器中, 并标识为第 N-1级查找单元对应的多位 Trie树。
第 N-1级查找单元对应的多位 Trie树中, 划分得到的每个子树对应一个 Trie节点, 该 Trie节点有两组子节点, 第一组用于保存该 Trie节点的子 Trie 节点; 第二组用于保存该 Trie节点对应的前缀节点, 其中可包括间接前缀节 点, 还可进一步包括直接前缀节点。 在子树中未包括 Trie节点的任何分支时, 该 Trie节点的第一组子节点为空, 第二组子节点中的间接前缀节点为空。 由 于一个 Trie节点最多有 2stnde个 Trie子节点,因此一个子树对应的 Trie节点所 对应的前缀节点最多为 2stnde +l个。
在第二次迭代过程中, 首先, 根据第一次迭代过程得到的前缀节点的关 联前缀创建多位 Trie树, 并根据前缀节点的容量对该多位 Trie树进行子树划 分。 根据前缀节点的容量以及第一次迭代过程创建的前缀节点的关联前缀在 多位 Trie树上的分布, 划分得到的一个子树的覆盖范围可能包括一个 Trie节 点或者一个 Trie节点及其一个或多个分支。 在子树划分时, 尽可能使每个前 缀节点存储较多的前缀。 对于划分得到的每个子树来说, 落入该子树内的前 缀是前一次迭代过程得到的前缀节点的关联前缀。 然后, 根据划分得到的子 树创建对应的一组前缀节点 , 每个子树对应的一组前缀节点中包括最多 2stnde 个间接前缀节点, 还可包含一个直接前缀节点。 最后, 将通过上述过程得到 的前缀节点配置在第 N-2级查找单元中, 并可进一步将该多位 Trie树的结构 保存到查找装置内置的或外接的存储器中, 并标识为第 N-2级查找单元对应 的多位 Trie树。
后续每次的迭代过程, 基本与第二次迭代过程类似。 每次迭代过程完成 后, 将该次迭代过程得到的前缀节点配置在相应一级的查找单元中, 并可进 一步在查找装置的内置或外接存储器中保存该级查找单元对应的多位 Trie树, 直到第 0级查找单元配置完成。
如前所述, 一个前缀节点可通过数组或其他数据结构来保存该前缀节点 中存储的前缀所对应的下一跳。 比如, 前缀节点中可存储一数组, 该数组称 为下一跳指针数组, 其中每个元素的下标用于标识前缀, 每个元素的取值为 与该元素的下标所标识的前缀对应的下一跳指针(即 RE Index )。 釆用这种数 据结构, 可以减少流水线级数, 降低硬件实现的难度。
为了进一步减少查找装置的内存开销, 前缀节点中可以仅存储该数组的 地址(即起始地址), 或指向该数组的指针, 该数组的内容可存储在查找装置 的内置或外接存储器中。
优选地, 对于每级查找单元中配置的每个前缀节点, 如果该前缀节点存 在对应的 PLPM, 则还要在该前缀节点中保存该 PLPM。 优选地, 对于一个具 有 PLPM的前缀节点, 可将该 PLPM对应的下一跳指针(RE Index )作为该 前缀节点对应的下一跳指针数组中的第一个元素进行保存。
如前所述, 对于第 N-1 级查找单元, 每个前缀节点对应的下一跳指针数 组中, 一个前缀对应的下一跳指针指向该前缀对应的下一跳的具体内容, 该 下一跳的具体内可存储在查找装置的内置或外接存储器中。 对于除第 N-1 级 以外的其他级查找单元, 比如以第 i个查找单元为例, 该查找单元中的每个前 缀节点对应的下一跳数组指针中,一个前缀对应的下一跳指针指向第 i+1级查 找单元中保存该前缀的前缀节点。
以上仅为前缀节点的数据结构的优选实现方式, 本发明对前缀节点的数 据结构不作限制。
当然, 初始配置过程也可釆用增量配置过程的方式来实现, 比如, 首先 从查找表中取出一个表项, 釆用增量配置过程对各级查找单元进行配置, 然 后再取出另一个表项, 釆用增量配置过程对各级查找单元进行配置, 以此类 推, 直到取出查找表中的最后一个表项并釆用增量配置过程完成对各级查找 单元的配置, 至此, 完成整个查找表的配置过程。 增量配置过程具体如下所 述。
( 2 )增量配置过程
查找表通常会定时或不定时进行更新, 比如增加查找表的表项或删除查 找表的表项。
图 6a示出了增加查找表项时的增量配置过程, 可包括以下步骤:
S61 : 获得待配置的第一前缀以及所述第一前缀所对应的下一跳, 转入
S62。
通常, 用于指导报文转发的查找表允许人工配置或更新, 或者可根据相 关协议进行更新。 比如对于路由查找, 可通过人工方式配置静态路由或者根 据边界网关协议(Border Gateway Protocol, 简称: BGP )等路由选择协议动 态更新路由表, 包括增加新的路由表项或者删除已有的路由表项。 本实施例 中, 当查找装置接收到查找表更新命令后, 能够根据该命令确定出需要增加 或删除的查找表的表项, 以便对流水线级进行配置更新。
S62: 将所述第一前缀以及所述第一前缀所对应的下一跳存储在第 N-1级 查找单元中, 转入 S63。 其中, N为流水线级的数量, N>1 , 每个流水线级中 包括一个查找单元, 按照所述 N个流水线级执行的先后顺序, 分别为第 0级 至第 N-l 级查找单元; 每级查找单元中包括前缀节点, 用于存储前缀以及与 所述前缀所对应的下一跳。
S63:对第 N-1级查找单元中的前缀节点的关联前缀所构成的多位 Trie树 进行子树划分, 以得到第 N-2级查找单元的前缀节点, 其中, 第 N-2级查找 单元的前缀节点中存储的前缀所对应的下一跳指向第 N-1级的前缀节点。
其中, 所述对第 N-1 级查找单元中的前缀节点的关联前缀所构成的多位 Trie树进行子树划分, 以得到第 N-2级查找单元的前缀节点, 包括: 将所述 多位 Trie树划分为 M个子树, M>=1 , 每个子树包括所述多位 Trie树的一个 Trie节点以及所述 Trie节点的 K个分支,其中 0<=K<=stride ,所述 stride为所 述多位 Trie树的步长。
上述配置过程中, 若新增加的查找表项可容纳于第 N-1 级查找单元中配 置的前缀节点中, 则可以仅对第 N-1 级查找单元中的前缀节点进行更新, 其 他级的查找单元中配置的前缀节点无需更新。 若新增加的查找表项无法容纳 于第 N-1级查找单元中配置的前缀节点中, 则需要通过图 6b所示的以下过程 调整 Trie树结构, 新增加前缀节点, 以容纳新增加的查找表项:
在 S62中, 判断第 N-1级查找单元中的前缀节点的容量是否允许存储所 述第一前缀以及所述第一前缀所对应的下一跳, 若是, 则将所述第一前缀以 及所述第一前缀所对应的下一跳存储于所述第 N-1级查找单元的前缀节点中; 否则, 重新配置第 N-1 级查找单元的前缀节点, 将所述第一前缀以及所述第 一前缀所对应的下一跳存储于所述第 N-1级查找单元重新配置后的前缀节点; 在 S63中, 根据第 N-2级查找单元中的前缀节点的容量判断是否允许存 储第 N-1级查找单元重新配置的前缀节点的关联前缀, 若是, 则将第 N-1级 查找单元重新配置的前缀节点的关联前缀存储于第 N-2级查找单元的前缀节 点;
若所述 S63中的判断结果为否, 则转入 S64;
S64: 设置 j=N-2, 转入 S65;
S65:通过对第 j+1级查找单元中的前缀节点的关联前缀所构成的多位 Trie 树进行子树划分来重新配置第 j级查找单元的前缀节点,将第 j+1级查找单元 中配置的前缀节点的关联前缀存储于第 j级查找单元重新配置后的前缀节点, 转入 S66;
S66: 根据第 j-1级查找单元的前缀节点的容量判断是否允许存储第 j级 查找单元重新配置的前缀节点的关联前缀, 若是, 则将第 j级查找单元重新配 置的前缀节点的关联前缀存储于第 j-i级查找单元的前缀节点, 并结束流程, 否则转入 S67;
S67: 设置 j=j-l , 并转入 S68;
S68: 若 j=0则结束流程, 否则, 转入 S65。
优选地, 上述流程中, 所述重新配置第 N-1 级查找单元的前缀节点, 包 括:
将所述第一前缀插入第 N-1级查找单元对应的第一多位 Trie树; 若第 N-1 级查找单元中存在拆分目标前缀节点, 则根据所述第一前缀在 第 N-1级查找单元对应的第一多位 Trie树中的位置、 所述第一多位 Trie树的 步长以及所述拆分目标前缀节点所存储的前缀在所述第一多位 Trie树中的位 置, 将所述拆分目标前缀节点拆分为多个前缀节点, 拆分得到的一个前缀节 点中存储有所述第一前缀以及所述第一前缀所对应的下一跳, 否则,在第 N-1 级查找单元中新配置一个前缀节点以存储所述第一前缀以及所述第一前缀所 对应的下一跳; 其中, 所述目标前缀节点满足第一条件且是所有满足所述第 一条件的前缀节点中距离所述第一前缀的步长最少的前缀节点, 所述第一条 件为: 前缀节点所对应的子树的分支上包含所述第一前缀。
优选地,上述流程中, 所述通过对第 j+1级查找单元中的前缀节点的关联 前缀所构成的多位 Trie树进行子树划分来重新配置第 j级查找单元的前缀节 点, 包括:
若第 j级查找单元中存在拆分目标前缀节点, 则根据所述第一前缀在第 j 级查找单元所对应的第二多位 Trie树中的位置、 所述第二多位 Trie树的步长 以及所述拆分目标前缀节点所存储的前缀在所述第二多位 Trie树中的位置, 将所述拆分目标前缀节点拆分为多个前缀节点, 拆分得到的一个前缀节点中 存储有第 j+1级查找单元中新配置的前缀节点的关联前缀以及对应的下一跳, 否则,在第 j级查找单元中新配置一个前缀节点以存储所述第 j+1级查找单元 中新配置的前缀节点的关联前缀以及对应的下一跳; 其中, 所述目标前缀节 点满足第一条件且是所有满足所述第一条件的前缀节点中距离所述第 j+1 级 查找单元中新配置的前缀节点的关联前缀的步长最少的前缀节点, 所述第一 条件为:前缀节点所对应的子树的分支上包含所述第 j+1级查找单元中新配置 的前缀节点的关联前缀。
类似的, 当需要删除查找表项时, 其流程可如图 7所示:
S71 : 获得待删除的第二前缀以及所述第二前缀对应的下一跳;
S72: 从第 N-1级查找单元中存储有所述第二前缀以及所述第二前缀对应 的下一跳的前缀节点中释放所述第二前缀以及所述第二前缀的下一跳;
S73: 若释放所述第二前缀后的前缀节点中, 已不再存储有前缀以及所述 前缀的下一跳, 则释放该前缀节点, 并转入 S74;
S74: 设置 j=N-2, 转入 S75;
S75: 针对第 j+1级查找单元中被释放的前缀节点, 从第 j级查找单元中 的前缀节点中释放相应前缀节点的关联前缀, 若释放关联前缀后的前缀节点 中已不再存储有关联前缀,则释放第 j级查找单元中已不再存储有关联前缀的 前缀节点, 并转入 S76;
S76: 设置 j=j-l ; 转入 S77;
S77: 若 j<0, 则结束流程, 否则转入 S75。
通过以上描述可以看出, 本发明实施例能够以最小代价对原有查找结构 进行更新, 以尽量减少避免对报文转发造成的影响, 从而保证报文转发性能。 与传统的多位 Trie算法相比, 本发明实施例提供的方案的增量更新的时间复 杂度为 0(W/k), 其中 W表示前缀的长度, k表示 Trie stride。 当插入或删除一 个前缀时, 只有该前缀所在的分支会受影响, 其它分支都不变。
图 6a或图 6B或图 7仅示出了查找表增量配置的优选实现方式, 本发明 并不仅限于图中示出的增量配置方式。 基于前述已经介绍过的查找表流水线 结构, 只要能够使配置完成的流水线符合上述结构, 本发明并不对具体实现 方式做任何限制, 比如在路由表更新时, 可根据更新后的路由表更新第 N级 查找单元对应的多位 Trie树, 并基于此配置第 N级查找单元, 然后逐级向上 配置各级查找单元。
为了更清楚地对增量配置过程进行说明, 下面以一个简单的例子介绍查 找配置的过程。
在下面的例子中, 依次向一个空路由表中增加 6个前缀, 将这 6个前缀 依次插入到路由表中, 创建查找结构。 这 6个前缀为: ρθ ( * )、 pi ( 0* )、 p2 ( 10* )、 p3 ( 111* )、 p4 ( 0000* )、 p5 ( 1001* )。
查找装置的流水线级中包括三级, 第一级(stageO )为 TCAM。
完整的多位 Trie结构被存储于存储器中, 当接收到新的前缀时更新该多 位 Trie结构, 并生成更新指令发送给查找装置, 所述更新指令可以是写入一 个前缀节点的指令、 删除一个前缀节点的指令, 或者刷新一个前缀节点的指 令。
如图 8a所示, 当插入前缀 ρθ时, 先在 stage2对应的多位 Trie树中添加 前缀 ρθ, 并根据该多位 Trie树创建一个前缀节点 PNODE20, 前缀 ρθ和它对 应的 RE Index都保存在 PNODE20中;然后将 PNODE20封装之后写入 stage2 对应的查找单元。 接下来, 将 stage2对应的多位 Trie树中的前缀节点的关联 前缀 plO插入 stagel对应的多位 Trie树, 并创建一个前缀节点 PNODE10 , 并 在封装之后将 PNODE10写入 stagel对应的查找单元。 Stagel对应的多位 Trie 树中每个前缀对应 stage2的多位 Trie树中的一个前缀节点。 将 stage 1对应的 多位 Trie树中的前缀节点的前缀放在 stageO中的 TCAM中。这样从 stageO到 stage2的查找结构就被建立起来了。
如图 8b所示, 当插入前缀 pi和 p2时, 由于前缀 pi、 p2和 ρθ都在 stage2 对应的多位 Trie树中的一个 Trie节点内 (即在一个 stride内), 将 i和 p2添 加到 PNODE20后不会超出该前缀节点的容量, 因此只需要更新 PNODE20即 可, 即, 将 pi和 p2对应的下一跳指针存到 PNODE20中。 TCAM和 stage 1 的查找单元中的前缀节点都不用更新。
如图 8c所示, 当插入前缀 p3和 p4时, 虽然它们与前缀 p0、 pi和 p2不 在 stage2对应的多位 Trie树中的一个 Trie节点内 (即不在一个 stride内), 但 是将前缀 p3和 p4添加到 PNODE20后不会超出该前缀节点的容量, 因此将 pi和 p2对应的下一跳指针存到 PNODE20中。
如图 8d所示, 当插入前缀 p5 时, 如果将前缀 p5 的下一跳指针添加到 PNODE20后将会超出该前缀节点的容量, 因此此时需要对 stage2对应的多位 Trie树中的前缀节点进行拆分。
拆分时, 首先,根据前缀 p5在该多位 Trie树中的位置以及该多位 Trie树 中原有的前缀节点 PNODE20所容纳的前缀在该多位 Trie树中的位置, 确定 需被拆分的目标前缀节点, 此处由于该多位 Trie 树只有一个前缀节点 PNODE20, 因此将其作为需要被拆分的前缀节点。 接着, 根据 PNODE20 中 容纳的前缀以及前缀 p5在多位 Trie树中的位置, 按照步长( stride )将该前缀 节点拆分成多个小的前缀节点。 从图中可以看到, 6个前缀按步长划分之后, 可以分成 4 部分, 每个部分可以作为一个新的前缀节点, 如图中所示的 PNODE21~24。 为了尽可能的利用访存带宽, 一般釆用最小切分策略, 也就是 切分后的子节点所覆盖的范围尽可能大。可以使用与前缀节点关联的多位 Trie 树的根节点进行切分。在本例中,从根节点切分可以把原来的 PNODE20切分 成 4个小的前缀节点 PNODE21 24,并且创建一个 Trie节点 T1作为这 4个前 缀节点的父节点。
拆分完成之后, 产生了新的前缀节点, 将新的前缀节点 PNODE21 24配 置到查找装置中的 stage2对应的查找单元,并将它们的关联前缀插入到 stagel 对应的多位 Trie树中。由于 PNODE21的关联前缀与原来的 PNODE20的关联 前缀相同, 而该前缀已经在 stagel对应的多位 Trie树中了, 所以不需要重复 插入该前缀节点对应的关联前缀,只需要更新 PNODE21即可。在更新过程中, 先将新的前缀节点 PNODE22、 PNODE23和 PNODE24配置到 stage2对应的 查找单元中 , 然后再将原来的 PNODE20更新为 PNODE21 , 以避免对查找过 程造成影响。
如果 PNODE10 所容纳的前缀节点的下一跳指针连续存放, 则可只在 PNODE10中保存下一跳指针数组的基址, 当需要对 PNODE10进行更新时, 只需要先将新的数组元素写入, 然后更新 PNODE10 的下一跳指针数组的基 址, 最后再删除旧的节点就可以了。
在 stagel对应的多位 Trie树中, 当插入 stage2的前缀节点的关联前缀后, 如果没有超出 stagel的前缀节点的容量, 则只需要在 stage2对应的多位 Trie 树中更新 PNODE10。
如前所述, 本发明实施例中的查找装置可以是位于路由器或交换机等用 于实现报文转发的网络设备中的装置, 例如路由查找模块, 处理器, 或硬件 实现的查找引擎等。 在这种情况下, 所述查找配置流程由所述路由器或交换 机等用于实现报文转发的网络设备中的控制平面执行, 比如, 控制平面通过 执行查找配置流程, 将路由表中的前缀以及所述前缀所对应的下一跳配置到 该查找装置。 本发明实施例中的查找装置也可以是路由器或交换机等用于实 现报文转发的网络设备, 这种情况下, 所述查找配置流程由该网络设备中的 控制平面执行, 即, 控制平面通过执行查找配置流程, 将路由表中的前缀以 及所述前缀所对应的下一跳配置到该网络设备中的数据平面。
(三 )查找流程
本发明实施例提供的查找流程是基于前述查找装置实现的。
参见图 9a, 为本发明实施例提供的查找流程示意图, 该流程可包括: S91 : 查找装置接收查找关键字, 转入 S92; 其中, 所述查找装置包括 N 个流水线级, N>1 ; 每个流水线级中包括一个查找单元, 按照所述 N个流水 线级执行的先后顺序, 分别为第 0级至第 N-1级查找单元;
S92: 设置 i=0, 转入 S93;
S93: 第 i级查找单元用所述查找关键字与第 i级查找单元中的第一前缀 节点中存储的前缀进行匹配, 若匹配到前缀, 则将匹配到的前缀的长度以及 匹配到的前缀所对应的下一跳输出给第 i+1级查找单元, 转入 S94, 否则, 转 入 S96;
S94: 设置 i=i+l , 并转入 S95;
S95: 第 i级查找单元根据第 i-1级查找单元输出的前缀的长度, 从所述 查找关键字中提取相应长度的分段关键字,根据第 i-1级查找单元输出的下一 跳确定所述第 i级查找单元中对应的第二前缀节点,用提取出的分段关键字与 所述第二前缀节点所存储的前缀的相应分段关键字进行匹配;
若匹配到前缀, 当 i=N-l时, 输出匹配到的前缀所对应的下一 ϋ ; 否则, 将匹配到的前缀的长度以及匹配到的前缀所对应的下一跳输出给第 i+1 级查 找单元, 转入 S94;
若没有匹配到前缀,且所述第二前缀节点有 PLPM,则输出所述 PLPM所 对应的下一跳; 如果所述第二前缀节点没有 PLPM, 则转入 S96;
S96: 输出未查找到匹配前缀的提示信息。
图 9b中以三层流水线结构为例描述了沿流水线执行顺序的查找过程, 该 流程可包括:
S1021 : 在流水线 stageO对应的查找单元中, 用查找关键字与本级查找单 元中配置的前缀节点所容纳的前缀进行匹配。 若匹配到前缀, 则将匹配到的 前缀的长度以及匹配到的前缀对应的下一跳指针输出给 stagel对应的查找单 元, 该下一跳指针指向 stagel对应的查找单元中配置的前缀节点, 然后转入 S1022。
若 S1021中, 若未匹配到前缀, 则表明查找失败, 转入 S1026。
S1022: 在流水线 stagel对应的查找单元中, 根据 stageO输出的前缀的长 度, 从查找关键字中提取相应长度的分段 key, 用提取出的分段 key与 stageO 输出的下一跳指针所指示的前缀节点所容纳的前缀进行匹配,其中, 所述 "相 应长度的分段 key" 是指从 stageO输出的前缀长度开始的所有剩余 key。 若匹 配到前缀, 则输出该前缀的长度以及该前缀对应的下一跳指针给 stage2,该下 一跳指针指向 stage2对应的查找单元中配置的前缀节点, 然后转入 S1023。若 若未匹配到前缀, 则转入 S 1024。
S1023: 在流水线 stage2对应的查找单元中, 根据 stage 1输出的前缀的长 度, 从查找关键字中提取相应长度的分段 key, 用提取出的分段 key与 stagel 输出的下一跳指针所指示的前缀节点所容纳的前缀进行匹配,其中, 所述 "相 应长度的分段 key" 是指从 stagel输出的前缀长度开始的所有剩余 key。 若匹 配到前缀, 则输出该前缀对应的下一跳指针, 该下一跳指针指向下一跳信息, 然后转入 S 1025。 若未匹配到前缀, 则转入 S 1024。
S1024: 根据前一级查找单元输出的下一跳指针, 获取该指针所指示的前 缀节点对应的 PLPM, 获取该 PLPM对应的下一跳指针, 该下一跳指针指向 下一跳信息, 然后转入 S1025。若前一级查找单元输出的下一跳指针所指示的 前缀节点没有 PLPM, 则转入 S1026。
S1025: 根据输出的下一跳指针获取下一跳信息, 将该下一跳信息作为该 查询关键字的查询结果并返回, 结束查找流程。
S1026: 输出查找 MISS的信息(即未找到匹配前缀的信息 ), 结束查找流 程。
上述流程的 S1024中, 由于前缀节点对应的 PLPM有多种不同的存储方 式, 因此该根据前缀节点对应的 PLPM得到下一跳指针的方式也有所不同。 如果 PLPM以及该 PLPM对应的下一跳指针保存到前缀节点对应的下一跳指 针数组中, 则可以从该前缀节点对应的下一跳指针数组中获取该 PLPM对应 的下一跳指针。 前缀节点的 PLPM也可以是以指针形式存储的, 该指针包括 容纳该 PLPM的前缀节点的指针以及该 PLPM在该前缀节点的下一跳指针数 组中的位置。
上述流程的 S1025 中, 可从前缀节点的下一跳指针数组中获取该前缀节 点所容纳的前缀对应的下一跳信息。 具体地, 在查找单元中存储有前缀节点 对应的下一跳指针数组的情况下, 可直接从前缀节点对应的下一跳指针数组 中获取下一跳指针, 并根据该指针获取对应的下一跳信息; 在查找单元中未 存储下一跳指针数组而是存储下一跳指针数组的基址的情况下, 可根据该下 一跳指针数组的基址访问对应的下一跳指针数组, 从该数组中获取对应的下 一跳指针, 并根据该指针获取对应的下一跳信息。
如前所述, 流水线级中, 还可包含 Trie节点, 或者可以是如前所述的其 他改进结构, 但无论哪种流水线结构, 其查找过程基本与上述查找过程类似, 在此不再详述。
以上流程仅以三层流水线为例描述, 其他数量的流水线级数, 查找过程 与此类似。 比如, 如果流水线级中除最上一级和最下一级以外, 有多个中间 层级的 stage,则对于中间层级的每个 stage,其处理流程与上述流程中的 S1022 类似。
(四)其他可选方案
在以上描述的实施例中, 在配置查找装置的流水线结构时, 只将各流水 线级对应的前缀节点配置在流水线结构中。 在另一种优选方案中, 还可以在 此基础上将所有带有前缀节点的 Trie节点配置到流水线结构中, 比如, 将第 i 级查找单元对应的多位 Trie树中带有前缀节点的 Trie节点以及该 Trie节点所 对应的前缀节点都配置到第 i级查找单元中。
在配置流水线结构时, 对于每级查找单元对应的多位 Trie树, 将该多位 Trie树中所有带有前缀节点的 Trie节点放在一级, 所有的前缀节点放在 Trie 节点的下一级。 也就是说, 对于每一个多位 Trie树, 在查找装置的流水线结 构中产生两级, 其中一级用于放置 Trie节点, 另一级用于放置前缀节点。 如 前所述, 每个 Trie节点可以有 2组子节点, 一组用于保存 Trie子节点, 一组 用于保存前缀节点。 每组子节点单独索引, 但在查找装置的流水线级中可以 只保存对前缀节点的索引。
具体实施时, 每个查找单元中包含两个子单元, 每个子单元对应流水线 结构中的一级; 按照流水线自前向后的顺序, 一个查找单元中的第一子单元 配置有该查找单元对应的多位 Trie树中的所有带有前缀节点的 Trie节点, 第 二子单元配置有该查找单元对应的多位 Trie树中的所有前缀节点。
与只在流水线级中保存前缀节点的技术方案相比, 这里描述的可选方案 可以使得每次迭代产生的关联前缀更少, 因为一般情况下, 一个 Trie节点都 有多个前缀节点, 所以 Trie节点的关联前缀数量要小于前缀节点的关联前缀 数量, 从而有利于提高更新速度。
进一步地, 还可以将两种配置方案结合使用, 比如对于某些查找单元, 只将多位 Trie树中的前缀节点配置在这些查找单元中, 对于另外的一些查找 单元, 将所有带有前缀节点的 Trie节点以及前缀节点本身都配置到这些查找 单元中。
如前所述, 本发明实施例提供的方案除了可以用在路由查找中, 还可以 用在精确查找等查找算法中, 比如用于处理媒体接入控制 (media access control, 简称: MAC ) 查找, 或者线性表查找。 对于精确查找, 只需要将查 找表中的每个表项看做是满长前缀即可, 在流水线级的结构方面, 以及配置 过程和查找过程等方面, 基本与前述的实施例相似, 在此不再详述。
综上所述,本发明实施例针对现有多位 Trie算法中存在的流水线级数多、 各级内存占用不确定以及数据结构比较复杂等问题, 提出了一种通过多 Trie 迭代来配置查找装置的方案。 在创建多位 Trie树的过程中, 一方面通过划分 子树使每个子树尽可能多的覆盖前缀并为每个子树创建对应的前缀节点以容 纳该子树所覆盖的前缀, 从而使多位 Trie树结构 "扁平化", 然后通过多位 Trie迭代, 用下一级前缀节点的关联前缀创建新的多位 Trie树以确定上一级 的前缀节点, 从而与现有多位 Trie算法相比, 减少了流水线的级数, 并较大 降低了访存带宽和查找延迟。
另外, 所有的 Trie节点或者不带有前缀节点的 Trie节点不需要保存在查 找装置中, 可以减少内存资源的占用。 流水线各级的内存占用完全独立, 按 照流水线执行顺序各级内存占用量逐渐减少, 有明显的规律性, 非常利于软 件 /硬件实现。 大部分的内存占用都在流水线最后一级, 对于带有片外内存的 硬件架构 (即查找装置外接有存储器的架构), 可以大大减少片上资源 (即查 找装置内置存储器资源) 的占用。 片外内存一般都是价格低廉的动态随机存 取存储器(Dynamic Random Access Memory, 简称: DRAM ), 所以本发明实 施例提供的方案还可以降低硬件实现的成本。
再一方面, 本发明实施例对于 IPv4和 IPv6路由的处理完全相同, 而且通 过将软硬件的实现分离, 数据结构也大大简化, 降低了实现的复杂度和难度。 本发明实施例提供的方案对前缀的长度不敏感, 可扩展性好, 可以支持较大 规模的路由表。
本领域内的技术人员应明白, 本发明的实施例可提供为方法、 系统、 或 计算机程序产品。 因此, 本发明可釆用完全硬件实施例、 完全软件实施例、 或结合软件和硬件方面的实施例的形式。 而且, 本发明可釆用在一个或多个 其中包含有计算机可用程序代码的计算机可用存储介质 (包括但不限于磁盘 存储器、 CD-ROM、 光学存储器等)上实施的计算机程序产品的形式。
本发明是参照根据本发明实施例的方法、 设备(系统)、 和计算机程序产 品的流程图和 /或方框图来描述的。 应理解可由计算机程序指令实现流程图 和 /或方框图中的每一流程和 /或方框、 以及流程图和 /或方框图中的流程 和 /或方框的结合。 可提供这些计算机程序指令到通用计算机、 专用计算机、 嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器, 使得通 过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流 程图一个流程或多个流程和 /或方框图一个方框或多个方框中指定的功能的 装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设 备以特定方式工作的计算机可读存储器中, 使得存储在该计算机可读存储器 中的指令产生包括指令装置的制造品, 该指令装置实现在流程图一个流程或 多个流程和 /或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上, 使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的 处理, 从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图 一个流程或多个流程和 /或方框图一个方框或多个方框中指定的功能的步 骤。 尽管已描述了本发明的优选实施例, 但本领域内的技术人员一旦得知了 基本创造性概念, 则可对这些实施例作出另外的变更和修改。 所以, 所附权 利要求意欲解释为包括优选实施例以及落入本发明范围的所有变更和修改。

Claims

权 利 要 求
1、 一种查找装置, 其特征在于, 包括:
N个流水线级, 其中 N>1;
每个流水线级中包括一个查找单元, 按照所述 N个流水线级执行的先后 顺序, 分别为第 0级至第 N-1级查找单元; 每级查找单元中包括前缀节点, 用于存储前缀以及与所述前缀所对应的下一跳, 其中:
第 i+1级查找单元中配置有第一前缀节点, 第 i级查找单元中配置有第二 前缀节点, 其中 0<=i<=(N-2); 所述第二前缀节点中存储的前缀所对应的下一 跳指向所述第一前缀节点, 所述第二前缀节点通过对所述第一前缀节点的关 联前缀所构成的第一多位 Trie树进行子树划分得到;
所述第二前缀节点通过对所述第一前缀节点的关联前缀所构成的第一多 位 Trie树进行子树划分得到包括: 将所述第一多位 Trie树划分为 M个子树, M>=1 , 每个子树包括所述第一多位 Trie树的一个 Trie节点以及所述 Trie节 点的 K 个分支, 根据所述 M 个子树得到所述第二前缀节点, 其中 0<=K<=stride , 所述 stride为所述第一多位 Trie树的步长。
2、 如权利要求 1所述的方法, 其特征在于, 所述第二前缀节点包括 1至 2stnde个间接前缀节点, 或者包括 0至 2stnde个间接前缀节点和一个直接前缀节 点; 其中, 直接前缀节点用于存储落入该子树的 Trie节点内的前缀, 间接前 缀节点用于存储落入该子树的 Trie节点的一个分支内的前缀。
3、 如权利要求 2所述的装置, 其特征在于, 所述第 i+1级查找单元中还 配置有所述第一多位 Trie树中包含有前缀节点的 Trie节点。
4、 如权利要求 1所述的装置, 其特征在于, 所述第一前缀节点中存储第 一数组或所述第一数组的地址, 所述第一数组中存储所述第一前缀节点的每 个前缀所对应的下一跳指针; 和 /或
所述第二前缀节点中存储第二数组或所述第二数组的地址, 所述第二数 组中存储所述第二前缀节点的每个前缀所对应的下一跳指针。
5、 如权利要求 1所述的装置, 其特征在于, 所述第 0级查找单元为一个 三态内容寻址存储器 TCAM。
6、 如权利要求 1-5中任一项所述的装置, 其特征在于, 所述 N个流水线 级用于执行以下步骤:
S91 : 接收查找关键字, 转入 S92;
S92: 设置 i=0, 转入 S93;
S93: 第 i级查找单元用所述查找关键字与第 i级查找单元中的第一前缀 节点容纳的前缀进行匹配, 若匹配到前缀, 则将匹配到的前缀的长度以及匹 配到的前缀所对应的下一跳输出给第 i+1级查找单元, 转入 S94, 否则, 转入 S96;
S94: 设置 i=i+l , 并转入 S95;
S95: 第 i级查找单元根据第 i-1级查找单元输出的前缀的长度, 从所述 查找关键字中提取相应长度的分段关键字,根据第 i-1级查找单元输出的下一 跳确定所述第 i级查找单元中对应的第二前缀节点,用提取出的分段关键字与 所述第二前缀节点所存储的前缀的相应分段关键字进行匹配;
若匹配到前缀, 当 i=N-l时, 输出匹配到的前缀所对应的下一 ϋ ; 否则, 将匹配到的前缀的长度以及匹配到的前缀所对应的下一跳输出给第 i+1 级查 找单元, 转 S94;
若没有匹配到前缀,且所述第二前缀节点有最长前缀匹配 PLPM,则输出 所述 PLPM对应的下一跳; 如果所述第二前缀节点没有 PLPM, 则转入 S96;
S96: 输出未查找到匹配前缀的提示信息。
7、 一种查找配置方法, 其特征在于, 所述方法包括:
S61 : 获得待配置的第一前缀以及所述第一前缀所对应的下一跳, 转入
S62;
S62: 将所述第一前缀以及所述第一前缀所对应的下一跳存储在第 N-1级 查找单元中, 转入 S63; 其中, N为流水线级的数量, N>1 , 每个流水线级中 包括一个查找单元, 按照所述 N个流水线级执行的先后顺序, 分别为第 0级 至第 N-l 级查找单元; 每级查找单元中包括前缀节点, 用于存储前缀以及与 所述前缀所对应的下一跳;
S63:对第 N-1级查找单元中的前缀节点的关联前缀所构成的多位 Trie树 进行子树划分, 以得到第 N-2级查找单元的前缀节点, 其中, 第 N-2级查找 单元的前缀节点中存储的前缀所对应的下一跳指向第 N-1 级的前缀节点; 所 述对第 N-1级查找单元中的前缀节点的关联前缀所构成的多位 Trie树进行子 树划分, 以得到第 N-2级查找单元的前缀节点, 包括: 将所述多位 Trie树划 分为 M个子树, M>=1 , 每个子树包括所述多位 Trie树的一个 Trie节点以及 所述 Trie节点的 K个分支, 其中 0<=K<=stride , 所述 stride为所述多位 Trie 树的步长。
8、 如权利要求 7所述的方法, 其特征在于,
所述 S62包括:
判断第 N-1 级查找单元中的前缀节点的容量是否允许存储所述第一前缀 以及所述第一前缀所对应的下一跳, 若是, 则将所述第一前缀以及所述第一 前缀所对应的下一跳存储于所述第 N-1 级查找单元的前缀节点中; 否则, 重 新配置所述第 N-1 级查找单元的前缀节点, 将所述第一前缀以及所述第一前 缀所对应的下一跳存储于所述第 N-1级查找单元重新配置后的前缀节点; 所述 S63包括:
根据第 N-2级查找单元中的前缀节点的容量判断是否允许存储第 N-1级 查找单元重新配置的前缀节点的关联前缀, 若是, 则将第 N-1 级查找单元重 新配置的前缀节点的关联前缀存储于第 N-2级查找单元的前缀节点; 否则, 转入 S64;
S64: 设置 j=N-2, 转入 S65;
S65:通过对第 j+1级查找单元中的前缀节点的关联前缀所构成的多位 Trie 树进行子树划分来重新配置第 j级查找单元的前缀节点,将第 j+1级查找单元 中配置的前缀节点的关联前缀存储于第 j级查找单元重新配置后的前缀节点, 转入 S66; S66: 根据第 j-1级查找单元的前缀节点的容量判断是否允许存储第 j级 查找单元重新配置的前缀节点的关联前缀, 若是, 则将第 j级查找单元重新配 置的前缀节点的关联前缀存储于第 j-i级查找单元的前缀节点, 并结束流程, 否则转入 S67;
S67: 设置 j=j-l , 并转入 S68;
S68: 若 j=0则结束流程, 否则, 转入 S65。
9、 如权利要求 8所述的方法, 其特征在于, 所述重新配置第 N-1级查找 单元的前缀节点, 包括:
将所述第一前缀插入第 N-1级查找单元对应的第一多位 Trie树; 若第 N-1 级查找单元中存在拆分目标前缀节点, 则根据所述第一前缀在 第 N-1级查找单元对应的第一多位 Trie树中的位置、 所述第一多位 Trie树的 步长以及所述拆分目标前缀节点所存储的前缀在所述第一多位 Trie树中的位 置, 将所述拆分目标前缀节点拆分为多个前缀节点, 拆分得到的一个前缀节 点中存储有所述第一前缀以及所述第一前缀所对应的下一跳, 否则,在第 N-1 级查找单元中新配置一个前缀节点以存储所述第一前缀以及所述第一前缀所 对应的下一跳; 其中, 所述目标前缀节点满足第一条件且是所有满足所述第 一条件的前缀节点中距离所述第一前缀的步长最少的前缀节点, 所述第一条 件为: 前缀节点所对应的子树的分支上包含所述第一前缀;
所述通过对第 j+1级查找单元中的前缀节点的关联前缀所构成的多位 Trie 树进行子树划分来重新配置第 j级查找单元的前缀节点, 包括:
若第 j级查找单元中存在拆分目标前缀节点, 则根据所述第一前缀在第 j 级查找单元所对应的第二多位 Trie树中的位置、 所述第二多位 Trie树的步长 以及所述拆分目标前缀节点所存储的前缀在所述第二多位 Trie树中的位置, 将所述拆分目标前缀节点拆分为多个前缀节点, 拆分得到的一个前缀节点中 存储有第 j+1级查找单元中新配置的前缀节点的关联前缀以及对应的下一跳, 否则,在第 j级查找单元中新配置一个前缀节点以存储所述第 j+1级查找单元 中新配置的前缀节点的关联前缀以及对应的下一跳; 其中, 所述目标前缀节 点满足第一条件且是所有满足所述第一条件的前缀节点中距离所述第 j+1 级 查找单元中新配置的前缀节点的关联前缀的步长最少的前缀节点, 所述第一 条件为:前缀节点所对应的子树的分支上包含所述第 j+1级查找单元中新配置 的前缀节点的关联前缀。
10、 如权利要求 7至 9中任一项所述的方法, 其特征在于, 还包括: S71 : 获得待删除的第二前缀以及所述第二前缀对应的下一跳;
S72: 从第 N-1级查找单元中存储有所述第二前缀以及所述第二前缀对应 的下一跳的前缀节点中释放所述第二前缀以及所述第二前缀的下一跳;
S73: 若释放所述第二前缀后的前缀节点中, 已不再存储有前缀以及所述 前缀的下一跳, 则释放该前缀节点, 并转入 S74;
S74: 设置 j=N-2, 转入 S75;
S75: 针对第 j+1级查找单元中被释放的前缀节点, 从第 j级查找单元中 的前缀节点中释放相应前缀节点的关联前缀, 若释放关联前缀后的前缀节点 中已不再存储有关联前缀,则释放第 j级查找单元中已不再存储有关联前缀的 前缀节点, 并转入 S76;
S76: 设置 j=j-l ; 转入 S77;
S77: 若 j<0, 则结束流程, 否则转入 S75。
11、 一种查找方法, 其特征在于, 包括:
S91 : 查找装置接收查找关键字, 转入 S92; 其中, 所述查找装置包括 N 个流水线级, N>1 ; 每个流水线级中包括一个查找单元, 按照所述 N个流水 线级执行的先后顺序, 分别为第 0级至第 N-1级查找单元;
S92: 设置 i=0, 转入 S93;
S93: 第 i级查找单元用所述查找关键字与第 i级查找单元中的第一前缀 节点中存储的前缀进行匹配, 若匹配到前缀, 则将匹配到的前缀的长度以及 匹配到的前缀所对应的下一跳输出给第 i+1级查找单元, 转入 S94, 否则, 转 入 S96;
S94: 设置 i=i+l , 并转入 S95; S95: 第 i级查找单元根据第 i-1级查找单元输出的前缀的长度, 从所述 查找关键字中提取相应长度的分段关键字,根据第 i-1级查找单元输出的下一 跳确定所述第 i级查找单元中对应的第二前缀节点,用提取出的分段关键字与 所述第二前缀节点所存储的前缀的相应分段关键字进行匹配;
若匹配到前缀, 当 i=N-l时, 输出匹配到的前缀所对应的下一 ϋ ; 否则, 将匹配到的前缀的长度以及匹配到的前缀所对应的下一跳输出给第 i+1 级查 找单元, 转入 S94;
若没有匹配到前缀,且所述第二前缀节点有最长前缀匹配 PLPM,则输出 所述 PLPM所对应的下一跳;如果所述第二前缀节点没有 PLPM,则转入 S96;
S96: 输出未查找到匹配前缀的提示信息。
PCT/CN2014/079624 2014-06-10 2014-06-10 一种查找装置、查找配置方法和查找方法 WO2015188319A1 (zh)

Priority Applications (4)

Application Number Priority Date Filing Date Title
PCT/CN2014/079624 WO2015188319A1 (zh) 2014-06-10 2014-06-10 一种查找装置、查找配置方法和查找方法
EP14894380.6A EP3145134B1 (en) 2014-06-10 2014-06-10 Lookup device and lookup configuration method
CN201480079291.6A CN106416152B (zh) 2014-06-10 2014-06-10 一种查找装置、查找配置方法和查找方法
US15/317,407 US10164884B2 (en) 2014-06-10 2016-12-09 Search apparatus, search configuration method, and search method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2014/079624 WO2015188319A1 (zh) 2014-06-10 2014-06-10 一种查找装置、查找配置方法和查找方法

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US15317407 Continuation 2016-12-09

Publications (1)

Publication Number Publication Date
WO2015188319A1 true WO2015188319A1 (zh) 2015-12-17

Family

ID=54832699

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/079624 WO2015188319A1 (zh) 2014-06-10 2014-06-10 一种查找装置、查找配置方法和查找方法

Country Status (4)

Country Link
US (1) US10164884B2 (zh)
EP (1) EP3145134B1 (zh)
CN (1) CN106416152B (zh)
WO (1) WO2015188319A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112804153A (zh) * 2020-12-30 2021-05-14 中国科学院计算机网络信息中心 一种面向gpu加速ip查找的更新方法及系统

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10924381B2 (en) 2015-02-19 2021-02-16 Arista Networks, Inc. System and method of processing in-place adjacency updates
US10516613B1 (en) 2015-10-14 2019-12-24 Innovium, Inc. Network device storage of incremental prefix trees
US10230639B1 (en) * 2017-08-08 2019-03-12 Innovium, Inc. Enhanced prefix matching
CN108153907B (zh) * 2018-01-18 2021-01-22 中国计量大学 通过16位Trie树实现空间优化的词典存储管理方法
US11140078B1 (en) 2018-10-18 2021-10-05 Innovium, Inc. Multi-stage prefix matching enhancements
US20210021517A1 (en) * 2019-07-19 2021-01-21 Arista Networks, Inc. Avoiding recirculation of data packets in a network device
WO2022267018A1 (zh) * 2021-06-25 2022-12-29 新华三技术有限公司 一种报文匹配方法、装置、网络设备及介质
CN115086221B (zh) * 2022-07-27 2022-11-22 新华三半导体技术有限公司 一种报文处理方法、装置、转发设备和存储介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101572647A (zh) * 2008-04-30 2009-11-04 华为技术有限公司 一种数据查找的方法及装置
CN102307149A (zh) * 2011-09-23 2012-01-04 中国科学院计算技术研究所 Ip查找方法和装置以及路由更新方法和装置
CN102739550A (zh) * 2012-07-17 2012-10-17 中山大学 基于随机副本分配的多存储器流水路由体系结构
EP1434148B1 (en) * 2002-12-06 2013-02-20 STMicroelectronics, Inc. Apparatus and method of implementing a multi-bit trie algorithmic network search engine
US20140003436A1 (en) * 2012-06-27 2014-01-02 Futurewei Technologies, Inc. Internet Protocol and Ethernet Lookup Via a Unified Hashed Trie

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP3570323B2 (ja) * 1999-05-11 2004-09-29 日本電気株式会社 アドレスに関するプレフィクスの格納方法
US7899067B2 (en) 2002-05-31 2011-03-01 Cisco Technology, Inc. Method and apparatus for generating and using enhanced tree bitmap data structures in determining a longest prefix match
US7339930B2 (en) * 2002-11-22 2008-03-04 Sun Microsystems, Inc. Method and apparatus for performing an address lookup using a multi-bit trie with backtracking
US7299227B2 (en) * 2003-09-09 2007-11-20 Stmicroelectronics, Inc. Method and system for providing cascaded trie-based network packet search engines
EP2560327B1 (en) * 2010-04-12 2014-06-04 Huawei Technologies Co., Ltd. Routing table establishment method and device
US8923298B2 (en) * 2012-05-04 2014-12-30 Futurewei Technoligies, Inc. Optimized trie-based address lookup

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1434148B1 (en) * 2002-12-06 2013-02-20 STMicroelectronics, Inc. Apparatus and method of implementing a multi-bit trie algorithmic network search engine
CN101572647A (zh) * 2008-04-30 2009-11-04 华为技术有限公司 一种数据查找的方法及装置
CN102307149A (zh) * 2011-09-23 2012-01-04 中国科学院计算技术研究所 Ip查找方法和装置以及路由更新方法和装置
US20140003436A1 (en) * 2012-06-27 2014-01-02 Futurewei Technologies, Inc. Internet Protocol and Ethernet Lookup Via a Unified Hashed Trie
CN102739550A (zh) * 2012-07-17 2012-10-17 中山大学 基于随机副本分配的多存储器流水路由体系结构

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
HOANG, LE ET AL.: "Scalable Tree-Based Architectures for IPv4/v6 Lookup Using Prefix Partitioning", IEEE TRANSACTIONS ON COMPUTERS, vol. 7, 31 July 2012 (2012-07-31), pages 1026 - 1039, XP011445482 *
See also references of EP3145134A4 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112804153A (zh) * 2020-12-30 2021-05-14 中国科学院计算机网络信息中心 一种面向gpu加速ip查找的更新方法及系统

Also Published As

Publication number Publication date
US20170142013A1 (en) 2017-05-18
EP3145134A4 (en) 2017-06-28
CN106416152A (zh) 2017-02-15
CN106416152B (zh) 2019-09-27
EP3145134A1 (en) 2017-03-22
US10164884B2 (en) 2018-12-25
EP3145134B1 (en) 2019-12-18

Similar Documents

Publication Publication Date Title
WO2015188319A1 (zh) 一种查找装置、查找配置方法和查找方法
US8780926B2 (en) Updating prefix-compressed tries for IP route lookup
US8295286B2 (en) Apparatus and method using hashing for efficiently implementing an IP lookup solution in hardware
JP5529976B2 (ja) 高速ipルックアップのためのシストリック・アレイ・アーキテクチャ
Le et al. Scalable tree-based architectures for IPv4/v6 lookup using prefix partitioning
CN105141525B (zh) IPv6路由查找方法及装置
JP2006005636A (ja) パケット転送装置
JP3881663B2 (ja) フィールドレベルツリーを用いたパケット分類装置及び方法
EP3280104B1 (en) Ip routing lookup
Le et al. Memory-efficient and scalable virtual routers using FPGA
WO2011124030A1 (zh) 路由表项的存储方法和装置
Le et al. Scalable high throughput and power efficient ip-lookup on fpga
Pao et al. IP address lookup using bit-shuffled trie
Veeramani et al. Efficient IP lookup using hybrid trie-based partitioning of TCAM-based open flow switches
Chang et al. LayeredTrees: Most specific prefix-based pipelined design for on-chip IP address lookups
Erdem et al. Array design for trie-based ip lookup
EP3269101B1 (en) Generating a hash table in accordance with a prefix length
CN102739550B (zh) 基于随机副本分配的多存储器流水路由体系结构
Erdem Pipelined hierarchical architecture for high performance packet classification
EP3319279B1 (en) Ip routing lookup
Erdem et al. Value-coded trie structure for high-performance IPv6 lookup
Zhian et al. Parallel processing priority trie-based IP lookup approach
CN118282943A (zh) 一种查找路由表项的方法及装置
Mahini et al. Low Power TCAM Forwarding Engine for IP Packets
Meiners et al. Sequential decomposition

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: 14894380

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 15317407

Country of ref document: US

NENP Non-entry into the national phase

Ref country code: DE

REEP Request for entry into the european phase

Ref document number: 2014894380

Country of ref document: EP

WWE Wipo information: entry into national phase

Ref document number: 2014894380

Country of ref document: EP