WO2015192742A1 - Lookup device, lookup method and configuration method - Google Patents

Lookup device, lookup method and configuration method Download PDF

Info

Publication number
WO2015192742A1
WO2015192742A1 PCT/CN2015/081357 CN2015081357W WO2015192742A1 WO 2015192742 A1 WO2015192742 A1 WO 2015192742A1 CN 2015081357 W CN2015081357 W CN 2015081357W WO 2015192742 A1 WO2015192742 A1 WO 2015192742A1
Authority
WO
WIPO (PCT)
Prior art keywords
prefix
mbt
node
subtree
length
Prior art date
Application number
PCT/CN2015/081357
Other languages
French (fr)
Chinese (zh)
Inventor
张文勇
崔秀梅
杨鸿志
汪自雄
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2015192742A1 publication Critical patent/WO2015192742A1/en

Links

Images

Definitions

  • the present invention relates to the field of data communications, and in particular, to a search device, a search method, and a configuration method.
  • 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.
  • Each route in the routing table is mainly composed of a prefix and corresponding next hop information, and the prefix can be represented by a three-valued bit string consisting of '0', '1' and '*'.
  • Route lookup uses the principle of longest prefix match (LPM). When multiple prefixes match the entered IP address, the next hop information corresponding to the longest prefix in the prefix matching the IP address is the final search result.
  • LPM longest prefix match
  • 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 containing 11 prefixes, p0 to p10 on the left side in Figure 1, corresponding nodes in the unit Trie tree are indicated by black circles, and connection points are indicated by white circles. 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).
  • the MBT (multi-bit trie) tree algorithm is a widely used route lookup algorithm.
  • MBT can be thought of as dividing a unit Trie tree into multiple subtrees by stride and creating a Trie node for each subtree.
  • 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.
  • the number of prefixes in a subtree is up to 2 stride -1. If a prefix is distributed in a subtree, a prefix (English: prefix) node is created for the subtree, and the prefixes in a subtree are saved. In the prefix node corresponding to the subtree.
  • Each prefix corresponds to one next hop information. Generally, only the next hop pointer, that is, the pointer to the next hop information, is stored in the MBT.
  • FIG. 2 shows an MBT tree with stride equal to 3 established based on the prefix in FIG. 1.
  • the MBT tree includes seven Trie nodes, such as the Trie Node T1 to Trie Node T7 shown in FIG. 2, and each Trie node is configured with a prefix node, such as the Prefix Node shown in FIG. 2.
  • Each of the Prefix Nodes stores a next hop pointer of each prefix in the Trie node corresponding to the Prefix Node.
  • the prefix node corresponding to the Trie Node T4 in FIG. 2 (the prefix node indicates a prefix node) stores the prefix p3.
  • One hop pointer "RE Index of P3" One hop pointer "RE Index of 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 Fig. 2 indicates the next hop pointer of the PLPM of the prefix node.
  • the prefixes located in a subtree are stored in the prefix node corresponding to the subtree.
  • a prefix node all prefixes in the subtree corresponding to the prefix node are usually saved, and the prefix stored in the prefix node is indicated by a bitmap, and the bitmap includes 2 stride - 1 bit.
  • the bitmap includes 2 stride - 1 bit.
  • the value of the step size is generally increased, for example, the value is 8.
  • the bitmap corresponding to the prefix node also occupies more bits. If the prefix distribution is sparse, the number of prefixes stored in the prefix node is small, but the corresponding bitmap still needs to occupy more bits, resulting in larger storage space overhead and lower utilization.
  • the embodiment of the invention provides a searching device, a searching method and a configuration method, which are used to improve the coding efficiency of the prefix node, thereby reducing the overhead of the storage space.
  • a search device comprising: a storage unit;
  • the storage unit is configured with N prefix nodes, N ⁇ 1, each prefix node includes a first data domain, and the first data domain includes M prefix sets, where M ⁇ 1, where:
  • the i-th prefix node corresponds to the first MBT sub-tree of the first step length
  • the j-th prefix set of the i-th prefix node corresponds to the second MBT sub-tree
  • the second MBT sub-tree is based on the second step
  • the second MBT subtree is divided by the first step length; wherein, 1 ⁇ i ⁇ N, 1 ⁇ j ⁇ M;
  • the first prefix information includes the associated prefix and the first location information of the second MBT subtree, where the first location information is used to sequentially indicate each prefix in the second MBT subtree in the first The location in the two MBT subtrees.
  • the ith prefix node further includes a second data domain, where the second data domain includes all the first MBT subtrees The next hop corresponding to each prefix.
  • the second data domain is disposed after the first data domain
  • the order of the next hops corresponding to the prefixes in the second data domain is the same as or opposite to the order of the prefix locations indicated by the first location information in each prefix set in the first data domain.
  • the ith prefix node further includes a third a data field, where the third data field includes the number of all prefix sets in the i-th prefix node, and header information of each of the prefix sets in all the prefix sets in the i-th prefix node, where The header information of the j prefix set includes the length of the associated prefix of the second MBT subtree.
  • the third data domain is disposed before the first data domain
  • the order of the header information of each prefix set in the third data domain is the same as or opposite to the order of each prefix set in the first data domain.
  • the M in the first data domain The prefix set includes the first to the Mth prefix sets in the search order, and the length of the associated prefix stored in the first prefix set in the M prefix sets is not less than the length of the associated prefix stored in the j+1 prefix set. 1 ⁇ j ⁇ M.
  • the ith prefix node includes first indication information, where Instructing the second MBT subtree corresponding to the jth prefix set to include a unique prefix, where the first location information in the jth prefix set is the node with the unique prefix in the second MBT subtree a location number, the length of the first location information is equal to the second step; or
  • the second i-prefix node includes second indication information, where the second MBT sub-tree corresponding to the j-th prefix set includes at least two prefixes, and the first location in the j-th prefix set
  • the information is a bitmap, and is used to indicate a position of the at least two prefixes in the second MBT subtree in the second MBT subtree, where the length of the first indication information is 2 stride -1, and the stride is The second step.
  • the storage unit is configured to perform a search process; or
  • the searching device further includes a searching unit, and the searching unit is configured to execute the searching process based on the storage unit;
  • the search process includes:
  • the first to the seventh possible implementation manners of the first aspect in an eighth possible implementation manner of the first aspect, further comprising a configuration unit, where the configuration unit is configured to configure the storage a prefix node in the unit.
  • the configuration unit is specifically configured to:
  • the prefix information to be configured, where the prefix includes at least one address prefix and a next hop corresponding to the address prefix;
  • a search method including:
  • each prefix node includes a first data domain
  • the first data domain includes M a prefix set, M ⁇ 1
  • the i-th prefix node corresponds to a first MBT sub-tree of the first step length
  • the j-th prefix set of the i-th prefix node corresponds to a second MBT sub-tree
  • the second MBT The subtree is obtained by dividing the first MBT subtree based on the second step, the second step is smaller than the first step length, 1 ⁇ i ⁇ N, 1 ⁇ j ⁇ M, the jth And the first location information is used to sequentially indicate each prefix in the second MBT subtree in the second MBT subtree.
  • the ith prefix node further includes a second data domain, where the second data domain includes all the first MBT subtrees The next hop corresponding to each prefix.
  • the second data domain is disposed after the first data domain
  • the order of the next hops corresponding to the prefixes in the second data domain is the same as or opposite to the order of the prefix locations indicated by the first location information in each prefix set in the first data domain.
  • the ith prefix node further includes a third a data field, where the third data field includes the number of all prefix sets in the i-th prefix node, and header information of each of the prefix sets in all the prefix sets in the i-th prefix node, where The header information of the j prefix set includes the length of the associated prefix of the second MBT subtree.
  • the third data domain is disposed before the first data domain
  • the order of the header information of each prefix set in the third data domain is the same as or opposite to the order of each prefix set in the first data domain.
  • the M in the first data domain The prefix set includes the first to the Mth prefix sets in the search order, and the length of the associated prefix stored in the jth prefix set in the M prefix sets is not less than the length of the associated prefix stored in the j+1 prefix set. , 1 ⁇ j ⁇ M.
  • the ith prefix node includes first indication information, where the second MBT subtree corresponding to the jth prefix set includes a unique prefix, and the first location information in the jth prefix set is Defining a node location number of the unique prefix in the second MBT subtree, the length of the first location information being equal to the second step size; or
  • the second i-prefix node includes second indication information, where the second MBT sub-tree corresponding to the j-th prefix set includes at least two prefixes, and the first location in the j-th prefix set
  • the information is a bitmap, and is used to indicate a position of the at least two prefixes in the second MBT subtree in the second MBT subtree, where the length of the first indication information is 2 stride -1, and the stride is The second step.
  • a configuration method including:
  • the prefix information to be configured, where the prefix includes at least one address prefix and a next hop corresponding to the address prefix;
  • each prefix node includes a first data domain, and the first data domain Including M prefix sets, M ⁇ 1, wherein: the i-th prefix node corresponds to the first MBT sub-tree of the first step length, and the j-th prefix set of the i-th prefix node corresponds to the second MBT sub-tree, where The second MBT subtree is obtained by dividing the first MBT subtree based on the second step, the second step is smaller than the first step length, 1 ⁇ i ⁇ N, 1 ⁇ j ⁇ M,
  • the first prefix information of the second MBT subtree includes the associated prefix and the first location information, where the first location information is used to sequentially indicate each prefix in the second MBT subtree in the second MBT The position in the subtree;
  • the ith prefix node further includes a second data domain, where the second data domain includes all the first MBT subtrees The next hop corresponding to each prefix.
  • the second data domain is disposed after the first data domain
  • the order of the next hops corresponding to the prefixes in the second data domain is the same as or opposite to the order of the prefix locations indicated by the first location information in each prefix set in the first data domain.
  • the ith prefix node further includes a third a data field, where the third data field includes the number of all prefix sets in the i-th prefix node, and header information of each of the prefix sets in all the prefix sets in the i-th prefix node, where The header information of the j prefix set includes the length of the associated prefix of the second MBT subtree.
  • the third data domain is disposed before the first data domain
  • the order of the header information of each prefix set in the third data domain is the same as or opposite to the order of each prefix set in the first data domain.
  • the M in the first data domain The prefix set includes the first to the Mth prefix sets in the search order, and the length of the associated prefix stored in the jth prefix set in the M prefix sets is not less than the length of the associated prefix stored in the j+1 prefix set. , 1 ⁇ j ⁇ M;
  • the associated prefix in the prefix set is used to match the prefix to be configured.
  • the found prefix set is determined as the longest matching prefix set of the prefix to be configured.
  • the ith prefix node includes first indication information, where the second MBT subtree corresponding to the jth prefix set includes a unique prefix, and the first location information in the jth prefix set is Defining a node location number of the unique prefix in the second MBT subtree, the length of the first location information being equal to the second step size; or
  • the second i-prefix node includes second indication information, where the second MBT sub-tree corresponding to the j-th prefix set includes at least two prefixes, and the first location in the j-th prefix set
  • the information is a bitmap, and is used to indicate a position of the at least two prefixes in the second MBT subtree in the second MBT subtree, where the length of the first indication information is 2 stride -1, and the stride is The second step.
  • a prefix set is introduced, and one prefix node may include M prefix sets, and M ⁇ 1.
  • the ith prefix node corresponds to the first MBT subtree of the first step length
  • the jth prefix set of the ith prefix node corresponds to the second MBT subtree
  • the second MBT subtree is based on the second step
  • the second step size is smaller than the first step length obtained by dividing the first MBT subtree
  • the jth prefix set includes an associated prefix and first location information of the second MBT subtree
  • the first location information is used to sequentially indicate the location of each prefix in the second MBT subtree in the second MBT subtree.
  • the data structure of the prefix node corresponding to the MBT subtree of the first step can be described by one or more prefix sets corresponding to the second step MBT subtree in the subtree. Since the second MBT subtree corresponding to one prefix set is smaller than the first MBT subtree, the number of bits used to describe the location information of the prefix on the second MBT subtree is less than that used to describe the prefix in the first MBT sub The number of bits of the location information on the tree, and considering the prefix distribution is relatively loose, the data structure of the prefix node provided by the embodiment of the present invention can improve the coding and reduce the overhead of the storage space.
  • FIG. 1 is a schematic diagram of a unit Trie tree in the background art
  • FIG. 2 is a schematic diagram of an MBT tree in the background art
  • 3a, 3b, 3c, and 3d are schematic structural views of a search device according to an embodiment of the present invention.
  • FIG. 4 is a schematic diagram of a data structure of a PCL according to an embodiment of the present invention.
  • FIG. 5 and FIG. 6 are respectively a data structure of a prefix node in an embodiment of the present invention.
  • FIG. 7 is a schematic diagram of MBT subtree division according to an embodiment of the present invention.
  • FIG. 8 is a schematic diagram showing a data structure of a prefix node based on the MBT subtree shown in FIG. 7;
  • FIG. 9 is a schematic flowchart of a search process according to an embodiment of the present invention.
  • FIG. 10 is a schematic diagram of a configuration process according to an embodiment of the present invention.
  • the embodiment of the present invention provides a search device, a search method, and a configuration method, and encodes the data structure of the prefix node by using an efficient coding manner, thereby improving the coding efficiency of the prefix node, thereby reducing The overhead of storage space.
  • the present invention will be described in detail in the following aspects: (1) the structure of the search device and the data structure of the prefix node, (2) the search process, and (3) the configuration flow.
  • the searching device may be a device located in a network device for implementing packet forwarding, such as a search module, a processor, or a hardware-implemented search engine; or a router or a switch.
  • a network device used to implement packet forwarding.
  • the prefix device stores a prefix prefix node.
  • a prefix node can be thought of as a container, that is, a prefix node corresponds to a data structure.
  • the prefix node is used to store information about the prefix.
  • the prefix node has a certain capacity limit.
  • the capacity of the prefix node refers to the size of the data structure of the prefix node, and its unit is a bit.
  • FIG. 3 is a schematic structural diagram of a search device according to an embodiment of the present invention.
  • a storage unit 31 may be included in the search device.
  • the storage unit 31 may refer to a chip implemented by a logic device, such as a ternary content addressable memory (TCAM), or a storage space in the memory.
  • TCAM ternary content addressable memory
  • the storage unit 31 is configured with N prefix nodes, N ⁇ 1, each prefix node includes a first data domain, and the first data domain includes M prefix sets, M ⁇ 1, where:
  • the i-th prefix node corresponds to the first MBT sub-tree of the first step length
  • the j-th prefix set of the i-th prefix node corresponds to the second MBT sub-tree
  • the second MBT sub-tree is based on the second step
  • the second MBT subtree is divided by the first step length; wherein, 1 ⁇ i ⁇ N, 1 ⁇ j ⁇ M;
  • the first prefix information includes the associated prefix and the first location information of the second MBT subtree, where the first location information is used to sequentially indicate each prefix in the second MBT subtree in the first The location in the two MBT subtrees.
  • the first MBT subtree is obtained according to the routing table, that is, the first MBT subtree is a subtree obtained by dividing the MBT tree corresponding to the routing table according to the first step length;
  • the subtree is a subtree obtained by dividing the "first MBT subtree" based on the second step.
  • the first MBT subtree has a smaller subtree coverage than the corresponding second MBT subtree.
  • the associated prefix of the second MBT subtree refers to the prefix corresponding to the root node of the second MBT subtree.
  • the prefix within a prefix set corresponds to the same association
  • the prefix, so a prefix set can be called prefix cluster, referred to as PCL.
  • PCL is used to represent the prefix set.
  • a larger step size is usually used for subtree partitioning, for example, the step size is 8.
  • the data structure of the prefix node in the embodiment of the present invention is sub-tree partitioned according to the step size of 8 and is again smaller than 8 in the subtree with each step size of 8 obtained by the partitioning.
  • the step size is divided into subtrees, for example, subtrees each having a step size of 8 are divided based on a step size of 3.
  • a subtree with a step size of 8 can be divided into multiple subtrees with a step size of 3. If a subtree with a step size of 3 contains a prefix, the subtree with a step size of 3 corresponds to a PCL.
  • the information about the prefix in the subtree with the step size of 3 is stored.
  • the related information may include an associated prefix corresponding to the subtree with the step size of 3, a bitmap for indicating the prefix position in the subtree, and may include the next hop information of the prefix and the like.
  • Fig. 4 exemplarily shows the data structure of one PCL. Among them, seg0 ⁇ segn saves the pre-segment of PCL, and the prefix bitmap is represented by PBM.
  • the ith prefix node further includes a second data domain, where the second data domain includes a next hop corresponding to each of the prefixes in the first MBT subtree.
  • next hop corresponding to the prefix can be set in the data structure of the prefix node as part of the PCL.
  • the second data field may be set in each PCL, so that the next hop corresponding to the prefix is placed in the corresponding PCL, or a second data field may be set in the prefix node, thereby including all the PCLs.
  • the next hop set corresponding to the prefix is placed in the data field.
  • the second data domain may be set after the first data domain; and the next hop corresponding to each prefix in the second data domain
  • the order is the same as or opposite to the order of the prefix locations indicated by the first location information in each prefix set in the first data domain.
  • the ith prefix node further includes a third data domain, where the third data domain includes the number of all prefix sets in the ith prefix node, and the ith Header information of each prefix set in all prefix sets in the prefix node, wherein the header information of the jth prefix set includes the length of the associated prefix of the second MBT subtree.
  • the length of the associated prefix may be represented by the number of pre-segments included in the associated prefix, ie, the length of the associated prefix is equal to the number of pre-segments included in the associated prefix multiplied by the second step.
  • the associated prefix corresponding to a prefix node may include one or more pre-segments, and the length of each pre-segment (ie, the number of bits) is the same as the value of the second step. For example, in the case where the second step is equal to 3, the associated prefix of a second MBT subtree is '001010*', the associated prefix contains 2 preambles, and the first preamble is '001'. The second pre-stage is '010'.
  • the number of PCLs in a prefix node is related to the first step length, the second step size, and the degree of rarity of the prefix distribution. For example, if the first step length is 8 and the second step is 3, a subtree with a step size of 8 is further divided according to the step size of 3 to obtain 21 subtrees, which requires 5 The bits represent the 21 subtrees, but considering that the prefix distribution is relatively loose, the number of PCLs in a prefix node does not exceed 16, so 4 bits can be used to represent the total number of PCLs.
  • the header information of each PCL is the same length.
  • the length of the header information of the PCL can be set to M bits.
  • IP_length represents the length of the IP address
  • stride represents the second step. Indicates rounding up. For example, if the length of the IPv6 address is 128 bits and the value of the second step is 3, the length of the header of the PCL can be set to 6 bits.
  • the third data domain is disposed before the first data domain; the order of the header information of each prefix set in the third data domain, and the order of each prefix set in the first data domain Same or opposite.
  • the total number of PCLs, the header information of the PCL, and the order of the PCLs may be: after all the PCL header information is set to the total number of PCLs, all PCLs are set to all. After the PCL header information.
  • the order in which the header information of the PCL is arranged It is in the same order as the PCL.
  • Fig. 5 exemplarily shows a data structure of a prefix node containing 6 PCLs.
  • the PCL Num field is used to store the number of PCLs, and the length is 4 bits.
  • the PCL Header field is used to store the header information of the PCL, and the length is 6 bits.
  • the PCL field is used to store the associated prefix and the first location information (such as a prefix). Bitmap), the length of a PCL is determined by the length of its associated prefix and the length of the first location information.
  • the M prefix sets in the first data domain include a first to an Mth prefix set in a search order, and a length of the associated prefix stored in the jth prefix set in the M prefix sets, Not less than the length of the associated prefix stored in the j+1 prefix set, 1 ⁇ j ⁇ M.
  • This can reduce the logical resources occupied by logical resolution. That is to say, in the data structure of a prefix node, all PCLs are arranged from front to back in descending order of the length of the associated prefix, that is, the longer PCL is always located before the shorter PCL. Accordingly, the header information of all PCLs is also arranged in descending order of the length of the associated prefix in the PCL.
  • the first location information may be a bitmap, that is, the location of the prefix in the second MBT subtree is indicated by a bitmap manner.
  • the number of the prefix in the second MBT subtree may be used as the first location information to identify the location of the prefix in the second MBT subtree.
  • the bitmap can be used as the first location information to identify the locations of these prefixes in the second MBT subtree.
  • the ith prefix node includes first indication information, where the second MBT subtree corresponding to the jth prefix set includes a unique prefix, and the first one of the jth prefix sets
  • the location information is a node location number of the unique prefix in the second MBT subtree, the length of the first location information is equal to the second step size; or the second i th prefix node includes a second
  • the indication information is used to indicate that the second MBT subtree corresponding to the jth prefix set includes at least two prefixes, and the first location information in the j th prefix set is a bitmap, and is used to indicate the The position of the at least two prefixes in the second MBT subtree in the second MBT subtree, the length of the first indication information is 2 stride -1, and the stride is the second step size.
  • the length of the first indication information and/or the second indication information is 1 bit.
  • an extra bit can be set in the header information of a PCL.
  • the value of the bit is equal to 1, it indicates that the first location information in the corresponding PCL indicates the node location number; when the value of the bit is equal to 0, indicating that the first location information in the corresponding PCL is in the form of a bitmap.
  • an extra 1 bit can be set in the data structure of the prefix node, for example, after the total number of PCLs.
  • the value of the bit is equal to 1, it indicates that the first location information in all PCLs in the prefix node indicates the node location number; when the value of the bit is equal to 0, it indicates the number of all PCLs in the prefix node.
  • a location information is in the form of a bitmap.
  • the prefix when there is only one prefix in a PCL, the prefix can be used to indicate the node position number in the 7-bit bitmap. If the node position number is used, only 3 bits are needed. So in this case, using the node location number to indicate that it will save more storage resources.
  • using the node location number to indicate that it will save more storage resources.
  • using the node location number to indicate the prefix location will significantly reduce the overhead of storage resources.
  • a subtree having a step size of 8 is divided into 7 subtrees based on a step size of 3, if one step is If there is only one prefix in the subtree of 3 and is located in the fifth node in the subtree, the node location number "110" may be used as the first location information to indicate the node location of the prefix in the subtree;
  • a subtree with a step size of 3 has two prefixes and is located in the first and fifth nodes in the subtree.
  • the bitmap "1000100" can be used to indicate that the two prefixes are in the subtree. Node location.
  • FIG. 6 exemplarily shows a data structure of a prefix node including a prefix next hop.
  • the longer PCL is always arranged before the shorter PCL.
  • the RE Index field is used to store the next hop of the prefix and is 20 bits in length. The order of the RE Index and the corresponding front The order of the suffixes is reversed.
  • an MBT tree shown in FIG. 7 is taken as an example to describe the data structure of the prefix node.
  • Figure 7 (1) shows the prefix of a distribution within an MBT subtree of step size 8;
  • Figure 7 (2) shows that the step size is 8 based on a smaller step size (3 in this example)
  • the MBT subtree is divided into smaller subtrees (T1, T2, T3, T4 as shown in the figure), and each smaller subtree corresponds to one PCL;
  • Figure 7 (3) shows each The prefix contained in the PCL;
  • Figure 7 (4) shows the data structure of each PCL.
  • PCL1 only contains 7-bit bitmap
  • PCL2 contains the associated prefix as "001 and *" 7-bit bitmap
  • PCL3 contains the associated prefix as "101*" and 7-bit bitmap, which is included in PCL4.
  • the association prefix is "001001*” and a 7-bit bitmap.
  • the corresponding prefix node structure is shown in Figure 8.
  • the associated prefix "001*" in PCL2 includes one pre-segment '001'
  • the associated prefix "101*” in PCL3 includes one pre-segment '101'
  • "001001*" contains 2 pre-segments, the first pre-segment is '001' and the second pre-segment is '001'.
  • PCL4 the longer PCL is placed in front, so the order of arrangement of the PCL is PCL4, PCL2, PCL3, and PCL1.
  • PCL2 and PCL3 are the same length and have no order requirements.
  • the length of the bitmap is fixed, so the bitmap can also be placed in the PCL header.
  • the advantage of putting a long PCL in front is to save logic resources.
  • the prefix length is 128 bits at the maximum and the MBT step size is 3
  • the operation length of the first PCL parser only needs to be set to 126 bits (a multiple of the step size, ie, ), in the latter PCL parser, the length of the operation can be decremented in turn.
  • the operation length of a PCL parser refers to the number of bits that a logical unit of a PCL parser can process in one clock cycle.
  • the operation length of the PCL parser can be successively decremented to save the logic unit.
  • the storage unit 31 may also perform a lookup process.
  • the search device may further include a lookup unit 32 for performing the search process based on the storage unit 31. The search process will be described in detail in the subsequent content.
  • the storage unit 31 may refer to a chip implemented by a logic device, such as a TCAM. In this case, the storage unit 31 may perform a lookup process.
  • the storage unit 31 may also refer to a storage space in the memory.
  • the search unit 32 may be implemented by software, such as a functional unit in the processor. In this case, the searching unit 32 is configured to perform the search based on the storage unit 31. Process.
  • the searching device may further include a configuration unit 33 for configuring a prefix node in the storage unit 31.
  • the configuration flow will be described in detail in the subsequent content.
  • the configuration unit 33 can be implemented by software, such as a functional unit in the processor.
  • the configuration unit 33 may be a functional unit in the processor, and the storage unit 31 may be a chip implemented by a logic device.
  • the configuration unit 33 is configured to configure a prefix node in the storage unit 31, a prefix node is configured in the storage unit 31, and a search process can be performed.
  • one prefix node may include M prefix sets, and M ⁇ 1.
  • the ith prefix node corresponds to the first MBT subtree of the first step
  • the jth prefix set of the ith prefix node corresponds to the second MBT.
  • the second MBT sub-tree is obtained by dividing the first MBT sub-tree based on a second step, where the second step size is smaller than the first step length; and the j-th prefix set is included
  • the associated prefix and the first location information of the second MBT subtree, the first location information is used to sequentially indicate the location of each prefix in the second MBT subtree in the second MBT subtree.
  • the data structure of the prefix node corresponding to the MBT subtree of the first step can be described by one or more prefix sets corresponding to the second step MBT subtree in the subtree.
  • the data structure of the prefix node can improve the coding and reduce the overhead of the storage space.
  • a bitmap of 128 bits is needed in a prefix node to describe the position of the prefix.
  • a subtree with a step size of 3 (hereinafter referred to as a small subtree) is obtained by using a step size of 3, each of which contains a prefix.
  • the tree is for a set of prefixes, such that a bitmap of only 8 bits is needed in a prefix set to describe the location of the prefix.
  • the traditional MBT algorithm is used, and the data structure of the prefix node includes at least a 128-bit bitmap (excluding the Re Index).
  • the data structure of the prefix node needs at most 68. Bit (does not include Re Index).
  • FIG. 9 shows the search flow.
  • the discovery process can include:
  • Step 91 Obtain a search keyword
  • Step 92 Search for the prefix node whose associated prefix matches the search key with the longest match among the configured N prefix nodes. This process can be performed in parallel.
  • the data structure of the prefix node is as described above and will not be described in detail herein.
  • Step 93 Perform the following steps for the discovered prefix node:
  • Step 94 Obtain a next hop according to a prefix that matches the search keyword, and obtain a search result of the search keyword.
  • the data structure of the prefix node may also include the total number of prefix sets in the prefix node, the header information of each prefix set, and the associated prefix of one prefix set may be one or more pre-segments.
  • the length of the associated prefix of a prefix set can be represented by the number of prefix segments included in the associated prefix, so in step 93, the preamble of the first PCL can be calculated based on the total number of PCLs. The starting position of the segment.
  • the total number of associated prefix fields of the PCL can be obtained by multiplying the number of prefix segments in the PCL header information by three. length.
  • the end position of the associated prefix field of the PCL and the prefix bitmap position can be calculated according to the starting position of the associated prefix field of the first PCL and the total length of the associated prefix field.
  • the starting position of the first PCL association prefix field is 255-4-6*PCL Num
  • the ending position is 255-4-6*PCL Num-3* PCL header+1
  • the location range of the prefix bitmap is [255-4-6*PCL Num-3*PCL header:255-4-6*PCL Num-3*PCL header-7+1]
  • the starting position of the associated prefix field of the PCL is the ending position of the prefix bitmap of the first PCL, and so on, the associated prefix field of all PCLs can be obtained.
  • the location of the prefix bitmap field is the starting position of the first PCL association prefix field.
  • the left position of the PCL associated prefix field is shifted by 1 bit to the left (ie, 1 bit is moved to the upper direction), and then moved to the right (ie, moved to the lower direction).
  • the associated prefix of the PCL is obtained. Then shift the 7 bits to the right to get the prefix bitmap field of the PCL.
  • step 93 the process of searching for a prefix set whose associated prefix matches the lookup keyword in all prefix sets is an iterative process.
  • all prefix sets can be arranged according to the length of the associated prefix.
  • the search prefix may be matched with the lookup key in the prefix set in the search order from front to back, and when the first associated prefix is found to match the search key
  • the set of prefixes is determined by the set of prefixes that are found to be the longest matching prefix of the lookup key.
  • the lookup engine is usually configured as a pipeline-level architecture, and the lookup process is performed in a pipeline-level order.
  • the corresponding PCL is configured in each level on the pipeline level, and the segmentation keyword corresponding to the search keyword of the current level is obtained according to the length of the PCL configured in the current level and the length that the search key has been matched. For example, first shifting the search key to the left by a corresponding number of lengths that have been matched in the previous stage pipeline, and then right shifting (256 - the PCL preamble length + 2) bits, the lower 2 bits indicate the The prefix bitmap of the segmentation key, the [pre-segment length +1:2] range-defined bit represents the pre-segment of the segmentation key.
  • the PCL's associated prefix is used to match the segmentation key.
  • the first matching prefix from the going to the post-matching process is the longest matching prefix with the lookup key. For example, compare the pre-segment of the PCL and the segmentation key, and compare the lower 2 bits of the segmentation key with the prefix bitmap of the PCL (compare bitmap[3:0] with the segment key, if not match Bitmap[5:4] and segment key[1], if they still do not match, check whether bitmap[6] is 1). After going to, the first prefix matching the pre-segment and the prefix bitmap is the search and lookup. The prefix that matches the longest keyword.
  • a prefix node may include first indication information, which is used to indicate that the second MBT subtree corresponding to the prefix set in the prefix node includes a unique prefix.
  • the first in the prefix set A location information is a node location number; or a prefix node may include second indication information, which is used to indicate that the second MBT subtree corresponding to the prefix set in the prefix node includes at least two prefixes.
  • the first location information in the prefix set is a bitmap.
  • step 93 it is required to determine the meaning of the first location information (that is, a node location number or a bitmap) based on the first indication information or the second indication information, thereby determining storage of the prefix set.
  • the second data field of the data structure of the prefix node may further include the next hop corresponding to all the prefixes in the prefix node, and the order of the next hop corresponding to each prefix in the second data domain,
  • the order of the prefix locations indicated by the first location information in each of the prefix sets in the first data domain is the same or opposite.
  • the next hop needs to be obtained in a different manner according to the next hop ranking order. For example, as shown in FIG.
  • one prefix node may include M prefix sets, and M ⁇ 1.
  • the ith prefix node corresponds to the first MBT subtree of the first step length
  • the jth prefix set of the ith prefix node corresponds to the second MBT subtree
  • the second MBT subtree is based on the second step
  • the second step size is smaller than the first step length obtained by dividing the first MBT subtree
  • the jth prefix set includes an associated prefix and first location information of the second MBT subtree
  • the first location information is used to sequentially indicate the location of each prefix in the second MBT subtree in the second MBT subtree.
  • the data structure of the prefix node corresponding to the MBT subtree of the first step may be described by one or more prefix sets corresponding to the second step MBT subtree in the subtree. Since the second MBT subtree corresponding to one prefix set is smaller than the first MBT subtree, the number of bits used to describe the location information of the prefix on the second MBT subtree is less than that used to describe the prefix in the first MBT sub The number of bits of the location information on the tree, and considering the prefix distribution is relatively loose, the data structure of the prefix node provided by the embodiment of the present invention can improve the coding and reduce the overhead of the storage space.
  • FIG. 10 shows the configuration flow.
  • the configuration process can include:
  • Step 101 Obtain prefix information to be configured, where the prefix includes at least one address prefix and a next hop corresponding to the address prefix.
  • Step 102 Search for the prefix node whose associated prefix is the longest match with the address prefix to be configured in the configured N prefix nodes. This process can be performed in parallel.
  • the data structure of a prefix node is the same as that described above, and is not described here.
  • Step 103 Perform the following operations on the found prefix node:
  • Step 104 Configure a next hop corresponding to the to-be-configured address prefix in the prefix node, and update first location information in the prefix set that matches the address prefix to be configured.
  • the routing table allows manual configuration or update, or can be updated according to the relevant protocol.
  • a static route can be manually configured or dynamically updated according to a routing protocol such as the Border Gateway Protocol (BGP), including adding a new routing entry or deleting an existing routing entry.
  • Border Gateway Protocol BGP
  • a prefix that needs to be added or deleted may be determined according to the received route update command for configuration update.
  • all prefix sets can be arranged according to the length of the associated prefix.
  • the associated prefix in the prefix set is matched with the prefix to be configured, and the first associated prefix is matched with the prefix to be configured.
  • the found prefix set is determined as the longest matching prefix set of the prefix to be configured.
  • the second data field in the data structure of a prefix node may further include the next hop of all the prefixes in the prefix node, and the order of the next hop corresponding to each prefix in the second data domain, and The order of the prefix locations indicated by the first location information in each prefix set in the first data domain is the same or opposite.
  • the next hop of the prefix may be added in a prescribed order.
  • a prefix node may include first indication information, which is used to indicate that the second MBT subtree corresponding to the prefix set in the prefix node includes a unique prefix.
  • the first in the prefix set A location information is a node location number; or a prefix node may include second indication information, which is used to indicate that the second MBT subtree corresponding to the prefix set in the prefix node includes at least two prefixes.
  • the first location information in the prefix set is a bitmap.
  • the prefix to be configured is a unique prefix in the prefix set
  • the first indication information is also set in the header information of the pre-level set, so that the value of the first indication information is used for
  • the first location information in the corresponding prefix set is indicated as a node location number.
  • step 102 if it is not found and to be matched in step 102 The prefix node with the longest matching prefix is used to create a corresponding prefix node for the prefix to be configured, and the corresponding information is added to the newly created prefix node according to the foregoing data structure. If the prefix set matching the prefix to be configured is not found in step 103, a corresponding prefix set is created for the prefix to be configured, and correspondingly added in the newly created prefix set and the corresponding prefix node according to the foregoing data structure. information.
  • one prefix node may include M prefix sets, and M ⁇ 1.
  • the ith prefix node corresponds to the first MBT subtree of the first step length
  • the jth prefix set of the ith prefix node corresponds to the second MBT subtree
  • the second MBT subtree is based on the second step
  • the second step size is smaller than the first step length obtained by dividing the first MBT subtree
  • the jth prefix set includes an associated prefix and first location information of the second MBT subtree
  • the first location information is used to sequentially indicate the location of each prefix in the second MBT subtree in the second MBT subtree.
  • the data structure of the prefix node corresponding to the MBT subtree of the first step can be described by one or more prefix sets corresponding to the second step MBT subtree in the subtree. Since the second MBT subtree corresponding to one prefix set is smaller than the first MBT subtree, the number of bits used to describe the location information of the prefix on the second MBT subtree is less than that used to describe the prefix in the first MBT sub The number of bits of the location information on the tree, and considering the prefix distribution is relatively loose, the data structure of the prefix node provided by the embodiment of the present invention can improve the coding and reduce the overhead of the storage space.
  • the embodiment of the present invention divides the prefix into multiple PCLs by organizing and classifying the prefixes in a prefix node by using MBT.
  • the prefixes in each PCL have the same associated prefix, and the location of the prefix contained in one PCL on the corresponding second MBT subtree can be represented by a bitmap or by a node location number.
  • the PCL is encoded by first listing the header information of each PCL, then listing the associated prefixes of all PCLs, and finally listing the bitmap or node location number indicating the prefix.
  • the number of PCL numbers included in the prefix node and each PCL header field are passed. The storage location and length of each PCL can be determined.
  • a prefix of any length can be stored in the prefix node.
  • the solution provided by the embodiment of the present invention can greatly improve coding efficiency and save memory usage.
  • the difficulty of logical parsing can be reduced, parallel parsing of multiple PCLs can be realized, and the delay of node processing can be reduced.
  • the resources used for logical parsing can be made more economical.
  • the data structure and coding mode of the prefix node provided by the embodiment of the present invention can make the MBT depth smaller by placing the prefix of any length in the same prefix node, thereby greatly improving the efficiency of the MBT algorithm, thereby reducing the delay of the search. .
  • the present invention has been described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (system), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or FIG.
  • the computer program instructions can be provided to a general purpose computer, a special purpose computer, an embedded processor, or a processor of other programmable data processing device such that instructions executed by a processor of the computer or other programmable data processing device can be implemented in a flowchart
  • the computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device.
  • the apparatus implements the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.
  • These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device.
  • the instructions provide steps for implementing the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.

Abstract

A lookup device, lookup method and configuration method. A prefix node comprises M prefix sets; the i-th prefix node corresponds to a first multi-bit trie (MBT) subtree of a first stride; the j-th prefix set in the i-th prefix node corresponds to a second MBT subtree; the second MBT subtree is obtained by dividing the first MBT subtree based on a second stride. Thus, the data structure of the prefix node corresponding to the first MBT subtree can be described by the prefix set corresponding to the second MBT subtree within the first MBT subtree. The second MBT subtree corresponding to a prefix set is smaller than the first MBT subtree, so that the number of bits for describing the location of a prefix on the second MBT subtree can be decreased. In addition, considering the sparse distribution of prefixes, the data structure of the prefix node of the present invention can improve encoding and reduce storage space overheads compared to the conventional MBT algorithm.

Description

一种查找装置、查找方法和配置方法Search device, search method and configuration method 技术领域Technical field
本发明涉及数据通信领域,尤其涉及一种查找装置、查找方法和配置方法。The present invention relates to the field of data communications, and in particular, to a search device, a search method, and a configuration method.
背景技术Background technique
路由器的主要任务是进行网际协议(Internet Protocol,简称:IP)报文转发,也就是根据报文头中的目的IP地址将到达路由器输入端口的报文转发到正确的输出端口。路由查找就是根据报文的目的IP地址,查找路由器中的路由表,得到报文下一跳信息的过程。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. 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.
路由表中的每条路由主要由一个前缀和对应的下一跳信息构成,前缀可以用‘0’,‘1’和‘*’组成的三值位串表示。路由查找采用最长前缀匹配(longest prefix match,简称LPM)原则。当有多个前缀与输入的IP地址匹配时,与该IP地址匹配的前缀中掩码最长的前缀对应的下一跳信息为最终的查找结果。Each route in the routing table is mainly composed of a prefix and corresponding next hop information, and the prefix can be represented by a three-valued bit string consisting of '0', '1' and '*'. Route lookup uses the principle of longest prefix match (LPM). When multiple prefixes match the entered IP address, the next hop information corresponding to the longest prefix in the prefix matching the IP address is the final search result.
基于Trie树(也称前缀树)的算法根据前缀中的位串建立一棵二叉树或多叉树。如果每次考虑一位,则建立一棵二叉树,也称为单位Trie树。图1示出了一棵单位Trie树,其中包含11个前缀,图1中左侧p0~p10,在单位Trie树中对应的节点用黑色圆圈表示,连接点用白色圆圈表示。如果每次考虑多位,则建立一棵多位Trie树。在多位Trie树中,每次考虑的位数一般是固定的,称为Trie树的步长(英文:stride)。An algorithm based on a Trie tree (also called a prefix 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 containing 11 prefixes, p0 to p10 on the left side in Figure 1, corresponding nodes in the unit Trie tree are indicated by black circles, and connection points are indicated by white circles. 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).
MBT(multi-bit trie,多位Trie)树算法是一种被广泛应用的路由查找算法。MBT可以看作按stride把一个单位Trie树分成多个子树,并为每个子树创建一个Trie节点。每个Trie节点均有一个关联前缀,一个Trie节点的关联前缀是该Trie节点对应的子树的根节点上的前缀值。位于一个子树内的前缀数量最多为2stride-1个,如果某个子树内分布有前缀,还要为该子 树创建一个前缀(英文:prefix)节点,位于一个子树内的前缀都保存在该子树对应的prefix节点中。每个前缀对应一条下一跳信息。一般在MBT中只保存下一跳指针,也就是指向下一跳信息的指针。The MBT (multi-bit trie) tree algorithm is a widely used route lookup algorithm. MBT can be thought of as dividing a unit Trie tree into multiple subtrees by stride and creating a Trie node for each subtree. 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. The number of prefixes in a subtree is up to 2 stride -1. If a prefix is distributed in a subtree, a prefix (English: prefix) node is created for the subtree, and the prefixes in a subtree are saved. In the prefix node corresponding to the subtree. Each prefix corresponds to one next hop information. Generally, only the next hop pointer, that is, the pointer to the next hop information, is stored in the MBT.
图2示出了基于图1中的前缀建立的stride等于3的MBT树。该MBT树包括7个Trie节点,如图2中所示的Trie Node T1~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 T1对应的前缀节点以外的每个前缀节点中,还保存一个最长前缀匹配(present longest prefix match,简称PLPM)。一个prefix节点的PLPM为覆盖该prefix节点对应的子树的最长前缀。图2中prefix节点中的“RE Index of PLPM”表示该prefix节点的PLPM的下一跳指针。FIG. 2 shows an MBT tree with stride equal to 3 established based on the prefix in FIG. 1. The MBT tree includes seven Trie nodes, such as the Trie Node T1 to Trie Node T7 shown in FIG. 2, and each Trie node is configured with a prefix node, such as the Prefix Node shown in FIG. 2. Each of the Prefix Nodes stores a next hop pointer of each prefix in the Trie node corresponding to the Prefix Node. For example, the prefix node corresponding to the Trie Node T4 in FIG. 2 (the prefix node indicates a prefix node) stores the prefix p3. One hop pointer "RE Index of P3". In addition to the prefix node corresponding to the Trie Node T1, 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 Fig. 2 indicates the next hop pointer of the PLPM of the prefix node.
位于一个子树内的前缀都保存在该子树对应的prefix节点中。一个prefix节点中,通常会保存该prefix节点对应的子树内的所有前缀,并用位图指示prefix节点中保存的前缀,位图包括2stride-1个比特(bit)。比如,图2中的子树T4内有3个前缀p3、p6和p7,用7比特的位图表示即为1000101,表示该子树中第1、5、7个节点为前缀。The prefixes located in a subtree are stored in the prefix node corresponding to the subtree. In a prefix node, all prefixes in the subtree corresponding to the prefix node are usually saved, and the prefix stored in the prefix node is indicated by a bitmap, and the bitmap includes 2 stride - 1 bit. For example, in the subtree T4 in FIG. 2, there are three prefixes p3, p6, and p7, which are represented by a 7-bit bitmap, that is, 1000101, indicating that the first, fifth, and seventh nodes in the subtree are prefixed.
现有MBT算法中,为了减小树的深度,一般会加大步长的取值,比如取值为8。当步长较大时,prefix节点对应的位图所占比特也比较多。如果前缀分布比较稀疏,prefix节点中存储的前缀数量较少,但对应的位图仍需要占用较多比特,导致存储空间的开销较大,利用率低。In the existing MBT algorithm, in order to reduce the depth of the tree, the value of the step size is generally increased, for example, the value is 8. When the step size is large, the bitmap corresponding to the prefix node also occupies more bits. If the prefix distribution is sparse, the number of prefixes stored in the prefix node is small, but the corresponding bitmap still needs to occupy more bits, resulting in larger storage space overhead and lower utilization.
发明内容Summary of the invention
本发明实施例提供了一种查找装置、查找方法和配置方法,用于提高前缀节点的编码效率,从而减少存储空间的开销。The embodiment of the invention provides a searching device, a searching method and a configuration method, which are used to improve the coding efficiency of the prefix node, thereby reducing the overhead of the storage space.
第一方面,提供一种查找装置,所述查找装置包括:存储单元; In a first aspect, a search device is provided, the search device comprising: a storage unit;
所述存储单元中配置有N个前缀节点,N≥1,每个前缀节点包括第一数据域,所述第一数据域中包括M个前缀集合,M≥1,其中:The storage unit is configured with N prefix nodes, N≥1, each prefix node includes a first data domain, and the first data domain includes M prefix sets, where M≥1, where:
第i前缀节点对应第一步长的第一MBT子树,所述第i前缀节点中的第j前缀集合对应第二MBT子树,所述第二MBT子树是基于第二步长对所述第一MBT子树划分得到的,所述第二步长小于所述第一步长;其中,1≤i≤N,1≤j≤M;The i-th prefix node corresponds to the first MBT sub-tree of the first step length, the j-th prefix set of the i-th prefix node corresponds to the second MBT sub-tree, and the second MBT sub-tree is based on the second step The second MBT subtree is divided by the first step length; wherein, 1≤i≤N, 1≤j≤M;
所述第j前缀集合中包括所述第二MBT子树的关联前缀、第一位置信息,所述第一位置信息用于按序指示所述第二MBT子树中的各个前缀在所述第二MBT子树中的位置。The first prefix information includes the associated prefix and the first location information of the second MBT subtree, where the first location information is used to sequentially indicate each prefix in the second MBT subtree in the first The location in the two MBT subtrees.
结合第一方面,在第一方面的第一种可能的实现方式中,所述第i前缀节点中还包括第二数据域,所述第二数据域中包括所述第一MBT子树中所有前缀各自所对应的下一跳。With reference to the first aspect, in a first possible implementation manner of the first aspect, the ith prefix node further includes a second data domain, where the second data domain includes all the first MBT subtrees The next hop corresponding to each prefix.
结合第一方面的第一种可能的实现方式,在第一方面的第二种可能的实现方式中,所述第二数据域设置于所述第一数据域之后;In conjunction with the first possible implementation of the first aspect, in a second possible implementation of the first aspect, the second data domain is disposed after the first data domain;
所述第二数据域中各个前缀所对应的下一跳的顺序,与所述第一数据域中各个前缀集合中的第一位置信息所指示的前缀位置的顺序,相同或相反。The order of the next hops corresponding to the prefixes in the second data domain is the same as or opposite to the order of the prefix locations indicated by the first location information in each prefix set in the first data domain.
结合第一方面、第一方面的第一种至第二种可能的实现方式中的一种,在第一方面的第三种可能的实现方式中,所述第i前缀节点中还包括第三数据域,所述第三数据域中包括所述第i前缀节点中的所有前缀集合的数量、所述第i前缀节点中的所有前缀集合中的每个前缀集合的头部信息,其中,第j前缀集合的头部信息中包含所述第二MBT子树的关联前缀的长度。With reference to the first aspect, the first to the second possible implementation manner of the first aspect, in a third possible implementation manner of the first aspect, the ith prefix node further includes a third a data field, where the third data field includes the number of all prefix sets in the i-th prefix node, and header information of each of the prefix sets in all the prefix sets in the i-th prefix node, where The header information of the j prefix set includes the length of the associated prefix of the second MBT subtree.
结合第一方面的第三种可能的实现方式,在第一方面的第四种可能的实现方式中,所述第三数据域设置于所述第一数据域之前;In conjunction with the third possible implementation of the first aspect, in a fourth possible implementation of the first aspect, the third data domain is disposed before the first data domain;
所述第三数据域中各个前缀集合的头部信息的顺序,与所述第一数据域中各个前缀集合的顺序,相同或相反。 The order of the header information of each prefix set in the third data domain is the same as or opposite to the order of each prefix set in the first data domain.
结合第一方面、第一方面的第一种至第四种可能的实现方式中的一种,在第一方面的第五种可能的实现方式中,所述第一数据域中的所述M个前缀集合按照查找顺序包括第1至第M前缀集合,所述M个前缀集合中,第前缀集合中存储的关联前缀的长度,不小于第j+1前缀集合中存储的关联前缀的长度,1≤j<M。With reference to the first aspect, the first to fourth possible implementation manners of the first aspect, in a fifth possible implementation manner of the first aspect, the M in the first data domain The prefix set includes the first to the Mth prefix sets in the search order, and the length of the associated prefix stored in the first prefix set in the M prefix sets is not less than the length of the associated prefix stored in the j+1 prefix set. 1 ≤ j < M.
结合第一方面、第一方面的第一种至第五种可能的实现方式,在第一方面的第六种可能的实现方式中,所述第i前缀节点中包含第一指示信息,用于指示所述第j前缀集合所对应的第二MBT子树中包含唯一一个前缀,所述第j前缀集合中的第一位置信息为所述唯一一个前缀在所述第二MBT子树中的节点位置编号,所述第一位置信息的长度等于所述第二步长;或者With reference to the first aspect, the first to fifth possible implementation manners of the first aspect, in a sixth possible implementation manner of the first aspect, the ith prefix node includes first indication information, where Instructing the second MBT subtree corresponding to the jth prefix set to include a unique prefix, where the first location information in the jth prefix set is the node with the unique prefix in the second MBT subtree a location number, the length of the first location information is equal to the second step; or
所述第i前缀节点中包含第二指示信息,用于指示所述第j前缀集合所对应的第二MBT子树中包含至少2个前缀,所述第j前缀集合中的所述第一位置信息为位图,用于指示所述第二MBT子树中的所述至少2个前缀在该第二MBT子树中的位置,所述第一指示信息的长度为2stride-1,stride为所述第二步长。The second i-prefix node includes second indication information, where the second MBT sub-tree corresponding to the j-th prefix set includes at least two prefixes, and the first location in the j-th prefix set The information is a bitmap, and is used to indicate a position of the at least two prefixes in the second MBT subtree in the second MBT subtree, where the length of the first indication information is 2 stride -1, and the stride is The second step.
结合第一方面、第一方面的第一种至第六种可能的实现方式中的一种,在第一方面的第七种可能的实现方式中,所述存储单元用于执行查找流程;或者,所述查找装置还包括查找单元,所述查找单元用于基于所述存储单元执行所述查找流程;With reference to the first aspect, the first to the sixth possible implementation manner of the first aspect, in a seventh possible implementation manner of the first aspect, the storage unit is configured to perform a search process; or The searching device further includes a searching unit, and the searching unit is configured to execute the searching process based on the storage unit;
所述查找流程包括:The search process includes:
获得查找关键字;Get the search keyword;
在所述N个前缀节点中查找关联前缀与所述查找关键字最长匹配的前缀节点,针对查找到的前缀节点执行以下步骤:Searching, in the N prefix nodes, a prefix node whose associated prefix matches the lookup key, and performing the following steps for the found prefix node:
根据前缀节点中前缀集合的总数量和每个前缀集合中的关联前缀的长度,确定每个前缀集合的存储位置、每个前缀集合中 的关联前缀和第一位置信息的存储位置;Determining the storage location of each prefix set, in each prefix set, according to the total number of prefix sets in the prefix node and the length of the associated prefix in each prefix set The associated prefix and the storage location of the first location information;
根据每个前缀集合中的关联前缀和第一位置信息的存储位置,获取每个前缀集合中的关联前缀和第一位置信息;Obtaining an associated prefix and first location information in each prefix set according to an association prefix in each prefix set and a storage location of the first location information;
在所有前缀集合中查找关联前缀与所述查找关键字最长匹配的前缀集合;Find a prefix set whose associated prefix matches the lookup keyword in all prefix sets;
根据查找到的前缀集合中的第一位置信息,确定与所述查找关键字最长匹配的前缀;Determining, according to the first location information in the found prefix set, a prefix that matches the lookup keyword;
根据与所述查找关键字最长匹配的前缀获得下一跳,得到所述查找关键字的查找结果。Obtaining a next hop according to a prefix that matches the search keyword longest, and obtaining a search result of the search key.
结合第一方面、第一方面的第一种至第七种可能的实现方式,在第一方面的第八种可能的实现方式中,还包括配置单元,所述配置单元用于配置所述存储单元中的前缀节点,具体的,所述配置单元具体用于:With reference to the first aspect, the first to the seventh possible implementation manners of the first aspect, in an eighth possible implementation manner of the first aspect, further comprising a configuration unit, where the configuration unit is configured to configure the storage a prefix node in the unit. Specifically, the configuration unit is specifically configured to:
获得待配置的前缀信息,所述前缀中包括至少一个地址前缀以及所述地址前缀所对应的下一跳;Obtaining the prefix information to be configured, where the prefix includes at least one address prefix and a next hop corresponding to the address prefix;
在所有前缀节点中查找关联前缀与所述待配置的地址前缀最长匹配的前缀节点;Searching, in all the prefix nodes, a prefix node whose associated prefix matches the address prefix to be configured the longest;
针对查找到的前缀节点执行以下操作:Do the following for the discovered prefix node:
根据前缀节点中前缀集合的总数量和每个前缀集合中的关联前缀的长度,确定每个前缀集合的存储位置、每个前缀集合中的关联前缀和第一位置信息的存储位置;Determining, according to the total number of prefix sets in the prefix node and the length of the associated prefix in each prefix set, a storage location of each prefix set, an associated prefix in each prefix set, and a storage location of the first location information;
根据每个前缀集合中的关联前缀和第一位置信息的存储位置,获取每个前缀集合中的关联前缀和第一位置信息;Obtaining an associated prefix and first location information in each prefix set according to an association prefix in each prefix set and a storage location of the first location information;
在所有前缀集合中查找关联前缀与所述待配置的地址前缀最长匹配的前缀集合;Finding, in all prefix sets, a prefix set whose associated prefix matches the address prefix to be configured the longest;
在前缀节点中配置所述待配置的地址前缀所对应的下一跳,并更新与所述待配置的地址前缀最长匹配的前缀集合中的第一 位置信息。Configuring a next hop corresponding to the to-be-configured address prefix in the prefix node, and updating the first one of the prefix sets that match the address prefix to be configured the longest location information.
第二方面,提供一种查找方法,包括:In a second aspect, a search method is provided, including:
获得查找关键字;Get the search keyword;
在所配置的N个前缀节点中查找关联前缀与所述查找关键字最长匹配的前缀节点;其中,N≥1,每个前缀节点包括第一数据域,所述第一数据域中包括M个前缀集合,M≥1,其中:第i前缀节点对应第一步长的第一MBT子树,所述第i前缀节点中的第j前缀集合对应第二MBT子树,所述第二MBT子树是基于第二步长对所述第一MBT子树划分得到的,所述第二步长小于所述第一步长,1≤i≤N,1≤j≤M,所述第j前缀集合中包括所述第二MBT子树的关联前缀、第一位置信息,所述第一位置信息用于按序指示所述第二MBT子树中的各个前缀在所述第二MBT子树中的位置;Searching, among the configured N prefix nodes, a prefix node whose associated prefix matches the lookup key; wherein N≥1, each prefix node includes a first data domain, and the first data domain includes M a prefix set, M≥1, wherein: the i-th prefix node corresponds to a first MBT sub-tree of the first step length, and the j-th prefix set of the i-th prefix node corresponds to a second MBT sub-tree, the second MBT The subtree is obtained by dividing the first MBT subtree based on the second step, the second step is smaller than the first step length, 1≤i≤N, 1≤j≤M, the jth And the first location information is used to sequentially indicate each prefix in the second MBT subtree in the second MBT subtree. Position in
针对查找到的前缀节点执行以下步骤:Perform the following steps for the discovered prefix node:
根据前缀节点中前缀集合的总数量和每个前缀集合中的关联前缀的长度,确定每个前缀集合的存储位置、每个前缀集合中的关联前缀和第一位置信息的存储位置;Determining, according to the total number of prefix sets in the prefix node and the length of the associated prefix in each prefix set, a storage location of each prefix set, an associated prefix in each prefix set, and a storage location of the first location information;
根据每个前缀集合中的关联前缀和第一位置信息的存储位置,获取每个前缀集合中的关联前缀和第一位置信息;Obtaining an associated prefix and first location information in each prefix set according to an association prefix in each prefix set and a storage location of the first location information;
在所有前缀集合中查找关联前缀与所述查找关键字最长匹配的前缀集合;Find a prefix set whose associated prefix matches the lookup keyword in all prefix sets;
根据查找到的前缀集合中的第一位置信息,确定与所述查找关键字最长匹配的前缀;Determining, according to the first location information in the found prefix set, a prefix that matches the lookup keyword;
根据与所述查找关键字最长匹配的前缀获得下一跳,得到所述查找关键字的查找结果。Obtaining a next hop according to a prefix that matches the search keyword longest, and obtaining a search result of the search key.
结合第二方面,在第二方面的第一种可能的实现方式中,所述第i前缀节点中还包括第二数据域,所述第二数据域中包括所述第一MBT子树中所有前缀各自所对应的下一跳。 With reference to the second aspect, in a first possible implementation manner of the second aspect, the ith prefix node further includes a second data domain, where the second data domain includes all the first MBT subtrees The next hop corresponding to each prefix.
结合第二方面的第一种可能的实现方式,在第二方面的第二种可能的实现方式中,所述第二数据域设置于所述第一数据域之后;In conjunction with the first possible implementation of the second aspect, in a second possible implementation of the second aspect, the second data domain is disposed after the first data domain;
所述第二数据域中各个前缀所对应的下一跳的顺序,与所述第一数据域中各个前缀集合中的第一位置信息所指示的前缀位置的顺序,相同或相反。The order of the next hops corresponding to the prefixes in the second data domain is the same as or opposite to the order of the prefix locations indicated by the first location information in each prefix set in the first data domain.
结合第二方面、第二方面的第一种至第二种可能的实现方式中的一种,在第二方面的第三种可能的实现方式中,所述第i前缀节点中还包括第三数据域,所述第三数据域中包括所述第i前缀节点中的所有前缀集合的数量、所述第i前缀节点中的所有前缀集合中的每个前缀集合的头部信息,其中,第j前缀集合的头部信息中包含所述第二MBT子树的关联前缀的长度。With reference to the second aspect, the first to the second possible implementation manner of the second aspect, in a third possible implementation manner of the second aspect, the ith prefix node further includes a third a data field, where the third data field includes the number of all prefix sets in the i-th prefix node, and header information of each of the prefix sets in all the prefix sets in the i-th prefix node, where The header information of the j prefix set includes the length of the associated prefix of the second MBT subtree.
结合第二方面的第三种可能的实现方式,在第二方面的第四种可能的实现方式中,所述第三数据域设置于所述第一数据域之前;In conjunction with the third possible implementation of the second aspect, in a fourth possible implementation of the second aspect, the third data domain is disposed before the first data domain;
所述第三数据域中各个前缀集合的头部信息的顺序,与所述第一数据域中各个前缀集合的顺序,相同或相反。The order of the header information of each prefix set in the third data domain is the same as or opposite to the order of each prefix set in the first data domain.
结合第二方面、第二方面的第一种至第四种可能的实现方式中的一种,在第二方面的第五种可能的实现方式中,所述第一数据域中的所述M个前缀集合按照查找顺序包括第1至第M前缀集合,所述M个前缀集合中,第j前缀集合中存储的关联前缀的长度,不小于第j+1前缀集合中存储的关联前缀的长度,1≤j<M。With reference to the second aspect, the first to fourth possible implementation manners of the second aspect, in a fifth possible implementation manner of the second aspect, the M in the first data domain The prefix set includes the first to the Mth prefix sets in the search order, and the length of the associated prefix stored in the jth prefix set in the M prefix sets is not less than the length of the associated prefix stored in the j+1 prefix set. , 1 ≤ j < M.
结合第二方面、第二方面的第一种至第五种可能的实现方式中的一种,在第二方面的第六种可能的实现方式中,With reference to the second aspect, one of the first to fifth possible implementation manners of the second aspect, in a sixth possible implementation manner of the second aspect,
所述第i前缀节点中包含第一指示信息,用于指示所述第j前缀集合所对应的第二MBT子树中包含唯一一个前缀,所述第j前缀集合中的第一位置信息为所述唯一一个前缀在所述第二MBT子树中的节点位置编号,所述第一位置信息的长度等于所述第二步长;或者The ith prefix node includes first indication information, where the second MBT subtree corresponding to the jth prefix set includes a unique prefix, and the first location information in the jth prefix set is Defining a node location number of the unique prefix in the second MBT subtree, the length of the first location information being equal to the second step size; or
所述第i前缀节点中包含第二指示信息,用于指示所述第j前缀集合所 对应的第二MBT子树中包含至少2个前缀,所述第j前缀集合中的所述第一位置信息为位图,用于指示所述第二MBT子树中的所述至少2个前缀在该第二MBT子树中的位置,所述第一指示信息的长度为2stride-1,stride为所述第二步长。The second i-prefix node includes second indication information, where the second MBT sub-tree corresponding to the j-th prefix set includes at least two prefixes, and the first location in the j-th prefix set The information is a bitmap, and is used to indicate a position of the at least two prefixes in the second MBT subtree in the second MBT subtree, where the length of the first indication information is 2 stride -1, and the stride is The second step.
第三方面,提供一种配置方法,包括:In a third aspect, a configuration method is provided, including:
获得待配置的前缀信息,所述前缀中包括至少一个地址前缀以及所述地址前缀所对应的下一跳;Obtaining the prefix information to be configured, where the prefix includes at least one address prefix and a next hop corresponding to the address prefix;
在所配置的N个前缀节点中查找关联前缀与所述待配置的地址前缀最长匹配的前缀节点;其中,N≥1,每个前缀节点包括第一数据域,所述第一数据域中包括M个前缀集合,M≥1,其中:第i前缀节点对应第一步长的第一MBT子树,所述第i前缀节点中的第j前缀集合对应第二MBT子树,所述第二MBT子树是基于第二步长对所述第一MBT子树划分得到的,所述第二步长小于所述第一步长,1≤i≤N,1≤j≤M,所述第j前缀集合中包括所述第二MBT子树的关联前缀、第一位置信息,所述第一位置信息用于按序指示所述第二MBT子树中的各个前缀在所述第二MBT子树中的位置;Searching, among the configured N prefix nodes, a prefix node whose associated prefix matches the address prefix to be configured the longest; wherein, N≥1, each prefix node includes a first data domain, and the first data domain Including M prefix sets, M≥1, wherein: the i-th prefix node corresponds to the first MBT sub-tree of the first step length, and the j-th prefix set of the i-th prefix node corresponds to the second MBT sub-tree, where The second MBT subtree is obtained by dividing the first MBT subtree based on the second step, the second step is smaller than the first step length, 1≤i≤N, 1≤j≤M, The first prefix information of the second MBT subtree includes the associated prefix and the first location information, where the first location information is used to sequentially indicate each prefix in the second MBT subtree in the second MBT The position in the subtree;
针对查找到的前缀节点执行以下操作:Do the following for the discovered prefix node:
根据前缀节点中前缀集合的总数量和每个前缀集合中的关联前缀的长度,确定每个前缀集合的存储位置、每个前缀集合中的关联前缀和第一位置信息的存储位置;Determining, according to the total number of prefix sets in the prefix node and the length of the associated prefix in each prefix set, a storage location of each prefix set, an associated prefix in each prefix set, and a storage location of the first location information;
根据每个前缀集合中的关联前缀和第一位置信息的存储位置,获取每个前缀集合中的关联前缀和第一位置信息;Obtaining an associated prefix and first location information in each prefix set according to an association prefix in each prefix set and a storage location of the first location information;
在所有前缀集合中查找关联前缀与所述待配置的地址前缀最长匹配的前缀集合;Finding, in all prefix sets, a prefix set whose associated prefix matches the address prefix to be configured the longest;
在前缀节点中配置所述待配置的地址前缀所对应的下一跳,并更新与所述待配置的地址前缀最长匹配的前缀集合中的第一 位置信息。Configuring a next hop corresponding to the to-be-configured address prefix in the prefix node, and updating the first one of the prefix sets that match the address prefix to be configured the longest location information.
结合第三方面,在第三方面的第一种可能的实现方式中,所述第i前缀节点中还包括第二数据域,所述第二数据域中包括所述第一MBT子树中所有前缀各自所对应的下一跳。With reference to the third aspect, in a first possible implementation manner of the third aspect, the ith prefix node further includes a second data domain, where the second data domain includes all the first MBT subtrees The next hop corresponding to each prefix.
结合第三方面的第一种可能的实现方式,在第三方面的第二种可能的实现方式中,所述第二数据域设置于所述第一数据域之后;With reference to the first possible implementation manner of the third aspect, in a second possible implementation manner of the third aspect, the second data domain is disposed after the first data domain;
所述第二数据域中各个前缀所对应的下一跳的顺序,与所述第一数据域中各个前缀集合中的第一位置信息所指示的前缀位置的顺序,相同或相反。The order of the next hops corresponding to the prefixes in the second data domain is the same as or opposite to the order of the prefix locations indicated by the first location information in each prefix set in the first data domain.
结合第三方面、第三方面的第一种至第二种可能的实现方式中的一种,在第三方面的第三种可能的实现方式中,所述第i前缀节点中还包括第三数据域,所述第三数据域中包括所述第i前缀节点中的所有前缀集合的数量、所述第i前缀节点中的所有前缀集合中的每个前缀集合的头部信息,其中,第j前缀集合的头部信息中包含所述第二MBT子树的关联前缀的长度。With reference to the third aspect, the first to the second possible implementation manner of the third aspect, in a third possible implementation manner of the third aspect, the ith prefix node further includes a third a data field, where the third data field includes the number of all prefix sets in the i-th prefix node, and header information of each of the prefix sets in all the prefix sets in the i-th prefix node, where The header information of the j prefix set includes the length of the associated prefix of the second MBT subtree.
结合第三方面的第三种可能的实现方式,在第三方面的第四种可能的实现方式中,所述第三数据域设置于所述第一数据域之前;With the third possible implementation of the third aspect, in a fourth possible implementation manner of the third aspect, the third data domain is disposed before the first data domain;
所述第三数据域中各个前缀集合的头部信息的顺序,与所述第一数据域中各个前缀集合的顺序,相同或相反。The order of the header information of each prefix set in the third data domain is the same as or opposite to the order of each prefix set in the first data domain.
结合第三方面、第三方面的第一种至第四种可能的实现方式中的一种,在第三方面的第五种可能的实现方式中,所述第一数据域中的所述M个前缀集合按照查找顺序包括第1至第M前缀集合,所述M个前缀集合中,第j前缀集合中存储的关联前缀的长度,不小于第j+1前缀集合中存储的关联前缀的长度,1≤j<M;With reference to the third aspect, the first to fourth possible implementation manners of the third aspect, in a fifth possible implementation manner of the third aspect, the M in the first data domain The prefix set includes the first to the Mth prefix sets in the search order, and the length of the associated prefix stored in the jth prefix set in the M prefix sets is not less than the length of the associated prefix stored in the j+1 prefix set. , 1 ≤ j < M;
所述在所有前缀集合中查找关联前缀与所述待配置的地址前缀最长匹配的前缀集合,包括:The finding, in all the prefix sets, the prefix set whose associated prefix matches the address prefix to be configured the longest, including:
按照查找顺序,用前缀集合中的关联前缀与所述待配置的前缀进行匹 配,并当查找到第一个关联前缀与所述待配置的前缀匹配的前缀集合时,将查找到的前缀集合确定为所述待配置的前缀最长匹配的前缀集合。According to the search order, the associated prefix in the prefix set is used to match the prefix to be configured. When the prefix set matching the first associated prefix and the prefix to be configured is found, the found prefix set is determined as the longest matching prefix set of the prefix to be configured.
结合第三方面、第三方面的第一种至第五种可能的实现方式中的一种,在第三方面的第六种可能的实现方式中,With reference to the third aspect, one of the first to fifth possible implementation manners of the third aspect, in a sixth possible implementation manner of the third aspect,
所述第i前缀节点中包含第一指示信息,用于指示所述第j前缀集合所对应的第二MBT子树中包含唯一一个前缀,所述第j前缀集合中的第一位置信息为所述唯一一个前缀在所述第二MBT子树中的节点位置编号,所述第一位置信息的长度等于所述第二步长;或者The ith prefix node includes first indication information, where the second MBT subtree corresponding to the jth prefix set includes a unique prefix, and the first location information in the jth prefix set is Defining a node location number of the unique prefix in the second MBT subtree, the length of the first location information being equal to the second step size; or
所述第i前缀节点中包含第二指示信息,用于指示所述第j前缀集合所对应的第二MBT子树中包含至少2个前缀,所述第j前缀集合中的所述第一位置信息为位图,用于指示所述第二MBT子树中的所述至少2个前缀在该第二MBT子树中的位置,所述第一指示信息的长度为2stride-1,stride为所述第二步长。The second i-prefix node includes second indication information, where the second MBT sub-tree corresponding to the j-th prefix set includes at least two prefixes, and the first location in the j-th prefix set The information is a bitmap, and is used to indicate a position of the at least two prefixes in the second MBT subtree in the second MBT subtree, where the length of the first indication information is 2 stride -1, and the stride is The second step.
本发明的上述实施例中引入了前缀集合,一个前缀节点中可包含M个前缀集合,M≥1。其中,第i前缀节点对应第一步长的第一MBT子树,所述第i前缀节点中的第j前缀集合对应第二MBT子树,所述第二MBT子树是基于第二步长对所述第一MBT子树划分得到的,所述第二步长小于所述第一步长;所述第j前缀集合中包括所述第二MBT子树的关联前缀、第一位置信息,所述第一位置信息用于按序指示所述第二MBT子树中的各个前缀在所述第二MBT子树中的位置。这样,一个第一步长的MBT子树对应的前缀节点的数据结构,就可以通过该子树内的第二步长MBT子树对应的一个或多个前缀集合来描述。由于一个前缀集合对应的第二MBT子树小于所述第一MBT子树,因此用于描述前缀在第二MBT子树上的位置信息的比特数量,少于用于描述前缀在第一MBT子树上的位置信息的比特数量,并且考虑到前缀分布较为稀松,因此采用本发明实施例提供的前缀节点的数据结构与传统MBT算法相比可以提高编码,减少存储空间的开销。 In the foregoing embodiment of the present invention, a prefix set is introduced, and one prefix node may include M prefix sets, and M≥1. The ith prefix node corresponds to the first MBT subtree of the first step length, the jth prefix set of the ith prefix node corresponds to the second MBT subtree, and the second MBT subtree is based on the second step The second step size is smaller than the first step length obtained by dividing the first MBT subtree; the jth prefix set includes an associated prefix and first location information of the second MBT subtree, The first location information is used to sequentially indicate the location of each prefix in the second MBT subtree in the second MBT subtree. In this way, the data structure of the prefix node corresponding to the MBT subtree of the first step can be described by one or more prefix sets corresponding to the second step MBT subtree in the subtree. Since the second MBT subtree corresponding to one prefix set is smaller than the first MBT subtree, the number of bits used to describe the location information of the prefix on the second MBT subtree is less than that used to describe the prefix in the first MBT sub The number of bits of the location information on the tree, and considering the prefix distribution is relatively loose, the data structure of the prefix node provided by the embodiment of the present invention can improve the coding and reduce the overhead of the storage space.
附图说明DRAWINGS
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简要介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域的普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments will be briefly described below. It is obvious that the drawings in the following description are only some embodiments of the present invention, Those skilled in the art can also obtain other drawings based on these drawings without paying for inventive labor.
图1为背景技术中的单位Trie树的示意图;1 is a schematic diagram of a unit Trie tree in the background art;
图2为背景技术中的MBT树的示意图;2 is a schematic diagram of an MBT tree in the background art;
图3a、图3b、图3c、图3d分别为本发明实施例提供的查找装置的结构示意图;3a, 3b, 3c, and 3d are schematic structural views of a search device according to an embodiment of the present invention;
图4为本发明实施例中的PCL的数据结构示意图;4 is a schematic diagram of a data structure of a PCL according to an embodiment of the present invention;
图5、图6分别为本发明实施例中的prefix节点的数据结构;5 and FIG. 6 are respectively a data structure of a prefix node in an embodiment of the present invention;
图7为本发明实施例中的MBT子树划分示意图;FIG. 7 is a schematic diagram of MBT subtree division according to an embodiment of the present invention;
图8为基于图7所示的MBT子树的prefix节点的数据结构示意图;8 is a schematic diagram showing a data structure of a prefix node based on the MBT subtree shown in FIG. 7;
图9为本发明实施例提供的查找流程示意图;FIG. 9 is a schematic flowchart of a search process according to an embodiment of the present invention;
图10为本发明实施例提供的配置流程示意图。FIG. 10 is a schematic diagram of a configuration process according to an embodiment of the present invention.
具体实施方式detailed description
针对现有查找算法存在的缺陷,本发明实施例提供了一种查找装置、查找方法和配置方法,通过高效的编码方式对prefix节点的数据结构进行编码,提高了prefix节点的编码效率,从而减少存储空间的开销。For the defects of the existing search algorithm, the embodiment of the present invention provides a search device, a search method, and a configuration method, and encodes the data structure of the prefix node by using an efficient coding manner, thereby improving the coding efficiency of the prefix node, thereby reducing The overhead of storage space.
为了更清楚地理解本发明,下面从以下几个方面对本发明进行详细说明:(一)查找装置的结构以及prefix节点的数据结构、(二)查找流程、(三)配置流程。In order to more clearly understand the present invention, the present invention will be described in detail in the following aspects: (1) the structure of the search device and the data structure of the prefix node, (2) the search process, and (3) the configuration flow.
(一)查找装置的结构以及prefix节点的数据结构(1) Locating the structure of the device and the data structure of the prefix node
本发明实施例提供的查找装置可以是位于路由器或交换机等用于实现报文转发的网络设备中的装置,例如查找模块,处理器,或硬件实现的查找引擎;或者也可以是路由器或交换机等用于实现报文转发的网络设备。 The searching device provided by the embodiment of the present invention may be a device located in a network device for implementing packet forwarding, such as a search module, a processor, or a hardware-implemented search engine; or a router or a switch. A network device used to implement packet forwarding.
本发明实施例提供的查找装置中存储有前缀prefix节点。一个prefix节点可以看作是一个容器,即一个prefix节点对应一个数据结构。prefix节点用于存储前缀的相关信息。prefix节点有一定的容量限制,prefix节点的容量是指前缀节点的数据结构的大小,其单位为比特。The prefix device provided by the embodiment of the present invention stores a prefix prefix node. A prefix node can be thought of as a container, that is, a prefix node corresponds to a data structure. The prefix node is used to store information about the prefix. The prefix node has a certain capacity limit. The capacity of the prefix node refers to the size of the data structure of the prefix node, and its unit is a bit.
下面对本发明实施例中的查找装置以及prefix节点的数据结构进行详细描述。The data structure of the search device and the prefix node in the embodiment of the present invention will be described in detail below.
参见图3a,为本发明实施例提供的查找装置的结构示意图。FIG. 3 is a schematic structural diagram of a search device according to an embodiment of the present invention.
该查找装置中可包括存储单元31。存储单元31可以是指逻辑器件实现的芯片,比如三态内容寻址寄存器(ternary content addressable memory,简称TCAM),也可以是指存储器中的存储空间。A storage unit 31 may be included in the search device. The storage unit 31 may refer to a chip implemented by a logic device, such as a ternary content addressable memory (TCAM), or a storage space in the memory.
存储单元31中配置有N个前缀节点,N≥1,每个前缀节点包括第一数据域,所述第一数据域中包括M个前缀集合,M≥1,其中:The storage unit 31 is configured with N prefix nodes, N≥1, each prefix node includes a first data domain, and the first data domain includes M prefix sets, M≥1, where:
第i前缀节点对应第一步长的第一MBT子树,所述第i前缀节点中的第j前缀集合对应第二MBT子树,所述第二MBT子树是基于第二步长对所述第一MBT子树划分得到的,所述第二步长小于所述第一步长;其中,1≤i≤N,1≤j≤M;The i-th prefix node corresponds to the first MBT sub-tree of the first step length, the j-th prefix set of the i-th prefix node corresponds to the second MBT sub-tree, and the second MBT sub-tree is based on the second step The second MBT subtree is divided by the first step length; wherein, 1≤i≤N, 1≤j≤M;
所述第j前缀集合中包括所述第二MBT子树的关联前缀、第一位置信息,所述第一位置信息用于按序指示所述第二MBT子树中的各个前缀在所述第二MBT子树中的位置。The first prefix information includes the associated prefix and the first location information of the second MBT subtree, where the first location information is used to sequentially indicate each prefix in the second MBT subtree in the first The location in the two MBT subtrees.
其中,所述“第一MBT子树”是根据路由表得到的,即,第一MBT子树是基于第一步长对与路由表对应的MBT树进行划分得到的子树;“第二MBT子树”是基于第二步长对“第一MBT子树”进行划分得到的子树。第一MBT子树与对应的第二MBT子树相比,后者的子树覆盖范围小于前者。The first MBT subtree is obtained according to the routing table, that is, the first MBT subtree is a subtree obtained by dividing the MBT tree corresponding to the routing table according to the first step length; The subtree is a subtree obtained by dividing the "first MBT subtree" based on the second step. The first MBT subtree has a smaller subtree coverage than the corresponding second MBT subtree.
在上述prefix节点的数据结构中,第二MBT子树的关联前缀是指第二MBT子树的根节点对应的前缀。一个前缀集合内的前缀对应于相同的关联 前缀,因此可将一个前缀集合称为prefix cluster,简称PCL,下面的描述中将使用PCL表示前缀集合。In the data structure of the prefix node, the associated prefix of the second MBT subtree refers to the prefix corresponding to the root node of the second MBT subtree. The prefix within a prefix set corresponds to the same association The prefix, so a prefix set can be called prefix cluster, referred to as PCL. In the following description, PCL is used to represent the prefix set.
举例来说,在传统的MBT算法中,通常选用较大的步长进行子树划分,比如步长取值为8。采用本发明实施例的上述prefix节点的数据结构,则在基于取值为8的步长进行子树划分后,在划分得到的每个步长为8的子树内,再次基于比8小的步长进行子树划分,比如基于取值为3的步长对每个步长为8的子树进行划分。一个步长为8的子树可划分得到多个步长为3的子树,如果一个步长为3的子树内包含有前缀,则该步长为3的子树对应有一个PCL,用于存储该步长为3的子树内的前缀的相关信息。该相关信息可包括该步长为3的子树对应的关联前缀、用于指示该子树内的前缀位置的位图,还可以包括前缀的下一跳信息等。图4示例性地示出一个PCL的数据结构。其中,seg0~segn保存PCL的前置分段,prefix位图用PBM表示。For example, in the traditional MBT algorithm, a larger step size is usually used for subtree partitioning, for example, the step size is 8. The data structure of the prefix node in the embodiment of the present invention is sub-tree partitioned according to the step size of 8 and is again smaller than 8 in the subtree with each step size of 8 obtained by the partitioning. The step size is divided into subtrees, for example, subtrees each having a step size of 8 are divided based on a step size of 3. A subtree with a step size of 8 can be divided into multiple subtrees with a step size of 3. If a subtree with a step size of 3 contains a prefix, the subtree with a step size of 3 corresponds to a PCL. The information about the prefix in the subtree with the step size of 3 is stored. The related information may include an associated prefix corresponding to the subtree with the step size of 3, a bitmap for indicating the prefix position in the subtree, and may include the next hop information of the prefix and the like. Fig. 4 exemplarily shows the data structure of one PCL. Among them, seg0~segn saves the pre-segment of PCL, and the prefix bitmap is represented by PBM.
可选地,所述第i前缀节点中还包括第二数据域,所述第二数据域中包括所述第一MBT子树中的所有前缀各自所对应的下一跳。Optionally, the ith prefix node further includes a second data domain, where the second data domain includes a next hop corresponding to each of the prefixes in the first MBT subtree.
这样,可以将前缀对应的下一跳设置在prefix节点的数据结构中,作为PCL的一部分。比如,可以在每个PCL中设置第二数据域,从而将前缀对应的下一跳放置在相应的PCL中,也可以在prefix节点中集中设置一个第二数据域,从而将所有PCL所包含的前缀对应的下一跳集中放置在该数据域中。In this way, the next hop corresponding to the prefix can be set in the data structure of the prefix node as part of the PCL. For example, the second data field may be set in each PCL, so that the next hop corresponding to the prefix is placed in the corresponding PCL, or a second data field may be set in the prefix node, thereby including all the PCLs. The next hop set corresponding to the prefix is placed in the data field.
如果在prefix节点中集中设置一个第二数据域,则优选地,可将所述第二数据域设置于所述第一数据域之后;所述第二数据域中各个前缀所对应的下一跳的顺序,与所述第一数据域中各个前缀集合中的第一位置信息所指示的前缀位置的顺序,相同或相反。If a second data field is set centrally in the prefix node, preferably, the second data domain may be set after the first data domain; and the next hop corresponding to each prefix in the second data domain The order is the same as or opposite to the order of the prefix locations indicated by the first location information in each prefix set in the first data domain.
可选地,在上述PCL中,所述第i前缀节点中还包括第三数据域,所述第三数据域中包括所述第i前缀节点中的所有前缀集合的数量、所述第i 前缀节点中的所有前缀集合中的每个前缀集合的头部信息,其中,第j前缀集合的头部信息中包含所述第二MBT子树的关联前缀的长度。关联前缀的长度可用该关联前缀所包含的前置分段的数量来表示,即,关联前缀的长度等于该关联前缀所包含的前置分段的数量乘以所述第二步长。一个prefix节点对应的关联前缀可以包括一个或多个前置分段,每个前置分段的长度(即比特数量)与所述第二步长的取值相同。比如,在第二步长等于3的情况下,一个第二MBT子树的关联前缀为‘001010*’,该关联前缀包含2个前置分段,第一个前置分段为‘001’,第二个前置分段为‘010’。Optionally, in the PCL, the ith prefix node further includes a third data domain, where the third data domain includes the number of all prefix sets in the ith prefix node, and the ith Header information of each prefix set in all prefix sets in the prefix node, wherein the header information of the jth prefix set includes the length of the associated prefix of the second MBT subtree. The length of the associated prefix may be represented by the number of pre-segments included in the associated prefix, ie, the length of the associated prefix is equal to the number of pre-segments included in the associated prefix multiplied by the second step. The associated prefix corresponding to a prefix node may include one or more pre-segments, and the length of each pre-segment (ie, the number of bits) is the same as the value of the second step. For example, in the case where the second step is equal to 3, the associated prefix of a second MBT subtree is '001010*', the associated prefix contains 2 preambles, and the first preamble is '001'. The second pre-stage is '010'.
一个prefix节点中的PCL的数量,与所述第一步长、所述第二步长以及前缀分布的稀松程度相关。比如,如果第一步长取值为8、第二步长取值为3,则一个步长为8的子树基于取值为3的步长进一步划分后可得到21个子树,需要5个比特来表示这21个子树,但考虑到前缀分布较为稀松,一个prefix节点内的PCL的数量不会超过16个,因此可用4个比特表示PCL的总数量。The number of PCLs in a prefix node is related to the first step length, the second step size, and the degree of rarity of the prefix distribution. For example, if the first step length is 8 and the second step is 3, a subtree with a step size of 8 is further divided according to the step size of 3 to obtain 21 subtrees, which requires 5 The bits represent the 21 subtrees, but considering that the prefix distribution is relatively loose, the number of PCLs in a prefix node does not exceed 16, so 4 bits can be used to represent the total number of PCLs.
每个PCL的头部信息的长度相同。为了减少存储开销,PCL的头部信息的长度可设置为M个比特,
Figure PCTCN2015081357-appb-000001
其中,IP_length表示IP地址长度,stride表示所述第二步长,
Figure PCTCN2015081357-appb-000002
表示向上取整。比如,IPv6地址的长度是128比特,第二步长的取值为3,则可将PCL的头部长度设置为6比特。
The header information of each PCL is the same length. In order to reduce the storage overhead, the length of the header information of the PCL can be set to M bits.
Figure PCTCN2015081357-appb-000001
Where IP_length represents the length of the IP address, and stride represents the second step.
Figure PCTCN2015081357-appb-000002
Indicates rounding up. For example, if the length of the IPv6 address is 128 bits and the value of the second step is 3, the length of the header of the PCL can be set to 6 bits.
可选地,所述第三数据域设置于所述第一数据域之前;所述第三数据域中各个前缀集合的头部信息的顺序,与所述第一数据域中各个前缀集合的顺序,相同或相反。Optionally, the third data domain is disposed before the first data domain; the order of the header information of each prefix set in the third data domain, and the order of each prefix set in the first data domain Same or opposite.
举例来说,prefix节点的数据结构中,PCL的总数量、PCL的头部信息、PCL的排列次序可以是:将所有PCL的头部信息设置于PCL的总数量之后,将所有PCL设置于所有PCL的头部信息之后。PCL的头部信息的排列顺序 与PCL的排列顺序一致。For example, in the data structure of the prefix node, the total number of PCLs, the header information of the PCL, and the order of the PCLs may be: after all the PCL header information is set to the total number of PCLs, all PCLs are set to all. After the PCL header information. The order in which the header information of the PCL is arranged It is in the same order as the PCL.
图5示例性地示出了一个包含6个PCL的prefix节点的数据结构。其中,PCL Num域用于存储PCL的数量,长度为4比特;PCL Header域用于存储PCL的头部信息,长度为6比特;PCL域用于存储关联前缀和第一位置信息(比如前缀的位图),一个PCL的长度由其关联前缀的长度以及第一位置信息的长度来决定。Fig. 5 exemplarily shows a data structure of a prefix node containing 6 PCLs. The PCL Num field is used to store the number of PCLs, and the length is 4 bits. The PCL Header field is used to store the header information of the PCL, and the length is 6 bits. The PCL field is used to store the associated prefix and the first location information (such as a prefix). Bitmap), the length of a PCL is determined by the length of its associated prefix and the length of the first location information.
可选地,所述第一数据域中的所述M个前缀集合按照查找顺序包括第1至第M前缀集合,所述M个前缀集合中,第j前缀集合中存储的关联前缀的长度,不小于第j+1前缀集合中存储的关联前缀的长度,1≤j<M。这样可以减少逻辑解析占用的逻辑资源。也就是说,在一个prefix节点的数据结构中,所有PCL按照关联前缀的长度从大到小的顺序从前到后进行排列,即,较长的PCL总是位于较短的PCL之前。相应地,所有PCL的头部信息也按照PCL中的关联前缀的长度从大到小的顺序排列。Optionally, the M prefix sets in the first data domain include a first to an Mth prefix set in a search order, and a length of the associated prefix stored in the jth prefix set in the M prefix sets, Not less than the length of the associated prefix stored in the j+1 prefix set, 1 ≤ j < M. This can reduce the logical resources occupied by logical resolution. That is to say, in the data structure of a prefix node, all PCLs are arranged from front to back in descending order of the length of the associated prefix, that is, the longer PCL is always located before the shorter PCL. Accordingly, the header information of all PCLs is also arranged in descending order of the length of the associated prefix in the PCL.
上述prefix节点中,所述第一位置信息可以是位图,即,通过位图方式指示出前缀在第二MBT子树中的位置。In the above prefix node, the first location information may be a bitmap, that is, the location of the prefix in the second MBT subtree is indicated by a bitmap manner.
为了进一步节省存储资源,在一个PCL中仅包含一个前缀的情况下,可用前缀在所述第二MBT子树中的编号作为第一位置信息以标识该前缀在该第二MBT子树中的位置;在一个PCL中包含至少两个前缀的情况下,可用位图作为第一位置信息以标识这些前缀在所述第二MBT子树中的位置。In order to further save storage resources, if only one prefix is included in one PCL, the number of the prefix in the second MBT subtree may be used as the first location information to identify the location of the prefix in the second MBT subtree. In the case where at least two prefixes are included in one PCL, the bitmap can be used as the first location information to identify the locations of these prefixes in the second MBT subtree.
具体来说,所述第i前缀节点中包含第一指示信息,用于指示所述第j前缀集合所对应的第二MBT子树中包含唯一一个前缀,所述第j前缀集合中的第一位置信息为所述唯一一个前缀在所述第二MBT子树中的节点位置编号,所述第一位置信息的长度等于所述第二步长;或者,所述第i前缀节点中包含第二指示信息,用于指示所述第j前缀集合所对应的第二MBT子树中包含至少2个前缀,所述第j前缀集合中的所述第一位置信息为位图, 用于指示所述第二MBT子树中的所述至少2个前缀在该第二MBT子树中的位置,所述第一指示信息的长度为2stride-1,stride为所述第二步长。Specifically, the ith prefix node includes first indication information, where the second MBT subtree corresponding to the jth prefix set includes a unique prefix, and the first one of the jth prefix sets The location information is a node location number of the unique prefix in the second MBT subtree, the length of the first location information is equal to the second step size; or the second i th prefix node includes a second The indication information is used to indicate that the second MBT subtree corresponding to the jth prefix set includes at least two prefixes, and the first location information in the j th prefix set is a bitmap, and is used to indicate the The position of the at least two prefixes in the second MBT subtree in the second MBT subtree, the length of the first indication information is 2 stride -1, and the stride is the second step size.
其中,所述第一指示信息和/或第二指示信息的长度为1比特。The length of the first indication information and/or the second indication information is 1 bit.
举例来说,可以在一个PCL的头部信息中额外设置1比特,当该比特的取值等于1时,表示对应的PCL中的第一位置信息表示节点位置编号;当该比特的取值等于0时,表示对应的PCL中的第一位置信息是位图形式。For example, an extra bit can be set in the header information of a PCL. When the value of the bit is equal to 1, it indicates that the first location information in the corresponding PCL indicates the node location number; when the value of the bit is equal to 0, indicating that the first location information in the corresponding PCL is in the form of a bitmap.
再举例来说,针对前缀分布比较稀松的情况,比如一个步长为3的子树中仅有一个前缀的情况,可以在prefix节点的数据结构中,比如在PCL的总数量之后额外设置1比特。当该比特的取值等于1时,表示该prefix节点中的所有PCL中的第一位置信息表示节点位置编号;当该比特的取值等于0时,表示该prefix节点中的所有PCL中的第一位置信息是位图形式。For another example, for a case where the prefix distribution is relatively loose, such as a case where there is only one prefix in a subtree with a step size of 3, an extra 1 bit can be set in the data structure of the prefix node, for example, after the total number of PCLs. . When the value of the bit is equal to 1, it indicates that the first location information in all PCLs in the prefix node indicates the node location number; when the value of the bit is equal to 0, it indicates the number of all PCLs in the prefix node. A location information is in the form of a bitmap.
比如,当某个PCL中只有一个前缀时,可以用该前缀在7比特位图中的节点位置编号来表示,若使用节点位置编号则只需要3比特就可以了。所以在这种情况下,用节点位置编号来表示会更节省存储资源。尤其对于IPv4虚拟专用网络(Virtual Private Network,简称VPN)或IPv6路由,由于前缀比较稀疏,用节点位置编号来指示前缀位置会明显降低存储资源的开销。For example, when there is only one prefix in a PCL, the prefix can be used to indicate the node position number in the 7-bit bitmap. If the node position number is used, only 3 bits are needed. So in this case, using the node location number to indicate that it will save more storage resources. Especially for IPv4 virtual private network (VPN) or IPv6 routing, because the prefix is sparse, using the node location number to indicate the prefix location will significantly reduce the overhead of storage resources.
举例来说,在第一步长为8、第二步长为3的情况下,一个步长为8的子树基于取值为3的步长被划分为7个子树,如果一个步长为3的子树中仅有1个前缀且位于该子树中的第5个节点,则可用节点位置编号“110”作为第一位置信息,以指示出前缀在该子树中的节点位置;如果一个步长为3的子树中有2个前缀且分别位于该子树中的第1个和第5个节点,则可以用位图“1000100”指示出这两个前缀在该子树中的节点位置。For example, in the case where the first step is 8 and the second step is 3, a subtree having a step size of 8 is divided into 7 subtrees based on a step size of 3, if one step is If there is only one prefix in the subtree of 3 and is located in the fifth node in the subtree, the node location number "110" may be used as the first location information to indicate the node location of the prefix in the subtree; A subtree with a step size of 3 has two prefixes and is located in the first and fifth nodes in the subtree. The bitmap "1000100" can be used to indicate that the two prefixes are in the subtree. Node location.
根据以上描述,图6示例性地示出了一个包含前缀下一跳的prefix节点的数据结构。其中,较长的PCL总是排列在较短的PCL之前。RE Index域用于存储前缀的下一跳,长度为20比特。RE Index的排列顺序与对应的前 缀的排列顺序相反。From the above description, FIG. 6 exemplarily shows a data structure of a prefix node including a prefix next hop. Among them, the longer PCL is always arranged before the shorter PCL. The RE Index field is used to store the next hop of the prefix and is 20 bits in length. The order of the RE Index and the corresponding front The order of the suffixes is reversed.
为了清楚理解本发明实施例,下面以图7所示的一个MBT树为例,描述prefix节点的数据结构。In order to clearly understand the embodiment of the present invention, an MBT tree shown in FIG. 7 is taken as an example to describe the data structure of the prefix node.
图7(1)示出了一个步长为8的MBT子树内分布的前缀;图7(2)示出了基于较小的步长(此例中为3)将该步长为8的MBT子树进行划分所得到的较小的子树(如图中所示的T1、T2、T3、T4),每个较小的子树对应一个PCL;图7(3)示出了每个PCL内包含的前缀;图7(4)示出了每个PCL的数据结构。其中,PCL1中仅包含7比特的位图,PCL2中包含的关联前缀为“001和*”7比特位图,PCL3中包含的关联前缀为“101*”和7比特位图,PCL4中包含的关联前缀为“001001*”和7比特位图。对应的prefix节点结构如图8所示。其中,PCL2中的关联前缀“001*”中包含1个前置分段‘001’,PCL3中的关联前缀“101*”中包含1个前置分段‘101’,PCL4中包含的关联前缀“001001*”中包含2个前置分段,第一个前置分段为‘001’,第二个前置分段为‘001’。Figure 7 (1) shows the prefix of a distribution within an MBT subtree of step size 8; Figure 7 (2) shows that the step size is 8 based on a smaller step size (3 in this example) The MBT subtree is divided into smaller subtrees (T1, T2, T3, T4 as shown in the figure), and each smaller subtree corresponds to one PCL; Figure 7 (3) shows each The prefix contained in the PCL; Figure 7 (4) shows the data structure of each PCL. Among them, PCL1 only contains 7-bit bitmap, PCL2 contains the associated prefix as "001 and *" 7-bit bitmap, and PCL3 contains the associated prefix as "101*" and 7-bit bitmap, which is included in PCL4. The association prefix is "001001*" and a 7-bit bitmap. The corresponding prefix node structure is shown in Figure 8. The associated prefix "001*" in PCL2 includes one pre-segment '001', and the associated prefix "101*" in PCL3 includes one pre-segment '101', and the associated prefix included in PCL4. "001001*" contains 2 pre-segments, the first pre-segment is '001' and the second pre-segment is '001'.
图8中,将较长的PCL放在前面,所以PCL的排列次序是PCL4、PCL2、PCL3和PCL1。PCL2和PCL3的长度相同,没有次序要求。在本例中,因为每个PCL都是用7位的位图表示前缀的节点位置,位图的长度是固定的,所以也可以将位图放在PCL header中。In Fig. 8, the longer PCL is placed in front, so the order of arrangement of the PCL is PCL4, PCL2, PCL3, and PCL1. PCL2 and PCL3 are the same length and have no order requirements. In this example, since each PCL is a node position with a 7-bit bitmap indicating the prefix, the length of the bitmap is fixed, so the bitmap can also be placed in the PCL header.
将较长的PCL放在前面的好处是节省逻辑资源。对于256比特的prefix节点结构,假设前缀的长度最大是128比特,MBT的步长为3,则只需要将第一个PCL解析器的运算长度设置为126比特(步长的倍数,即,
Figure PCTCN2015081357-appb-000003
),后面的PCL解析器,运算长度可以依次递减。一个PCL解析器的运算长度是指一个PCL的解析器中进行查表逻辑运算的逻辑单元在一个时钟周期能够处理的比特数量。比如,如果prefix节点中有两个PCL,由于每个PCL至少占33位(即,6bits的前置分段+7bits的位图+20bits 的RE Index),所以第二个PCL前置分段的长度不会超过(256–33*2–4)/2=93比特。依次类推,如果一个prefix节点中有3个PCL,则第三个PCL的前置分段的长度不会超过(256–33*3–4)/3=51比特。也就是的说对于prefix节点中的第i个PCL,其前置分段所占的比特数量不会超过(256–33*i–4)/i。这样,在逻辑解析时,PCL解析器的运算长度可以依次递减,以节省逻辑单元。
The advantage of putting a long PCL in front is to save logic resources. For the 256-bit prefix node structure, assuming that the prefix length is 128 bits at the maximum and the MBT step size is 3, the operation length of the first PCL parser only needs to be set to 126 bits (a multiple of the step size, ie,
Figure PCTCN2015081357-appb-000003
), in the latter PCL parser, the length of the operation can be decremented in turn. The operation length of a PCL parser refers to the number of bits that a logical unit of a PCL parser can process in one clock cycle. For example, if there are two PCLs in the prefix node, since each PCL occupies at least 33 bits (that is, the 6-bit pre-segment + 7-bit bitmap + 20-bit RE index), the second PCL pre-segment The length will not exceed (256–33*2–4)/2=93 bits. And so on, if there are 3 PCLs in a prefix node, the length of the pre-segment of the third PCL will not exceed (256–33*3–4)/3=51 bits. That is to say, for the i-th PCL in the prefix node, the number of bits occupied by the pre-segment does not exceed (256–33*i–4)/i. Thus, in the logic analysis, the operation length of the PCL parser can be successively decremented to save the logic unit.
可选地,存储单元31还可执行查找流程。或者,如图3b所示,所述查找装置还可包括查找单元32,查找单元32用于基于存储单元31执行所述查找流程。所述查找流程将在后续内容中进行详细描述。Alternatively, the storage unit 31 may also perform a lookup process. Alternatively, as shown in FIG. 3b, the search device may further include a lookup unit 32 for performing the search process based on the storage unit 31. The search process will be described in detail in the subsequent content.
具体来说,存储单元31可以是指逻辑器件实现的芯片,比如TCAM,这种情况下,存储单元31可执行查找流程。存储单元31也可以是指存储器中的存储空间,查找单元32可以由软件实现,比如可以是处理器中的一个功能单元,这种情况下,查找单元32用于基于存储单元31执行所述查找流程。Specifically, the storage unit 31 may refer to a chip implemented by a logic device, such as a TCAM. In this case, the storage unit 31 may perform a lookup process. The storage unit 31 may also refer to a storage space in the memory. The search unit 32 may be implemented by software, such as a functional unit in the processor. In this case, the searching unit 32 is configured to perform the search based on the storage unit 31. Process.
可选地,如图3c或图3d所示,所述查找装置还可包括配置单元33,配置单元33用于配置存储单元31中的前缀节点。所述配置流程将在后续内容中进行详细描述。Optionally, as shown in FIG. 3c or 3d, the searching device may further include a configuration unit 33 for configuring a prefix node in the storage unit 31. The configuration flow will be described in detail in the subsequent content.
具体来说,配置单元33可由软件实现,比如可以是处理器中的一个功能单元。In particular, the configuration unit 33 can be implemented by software, such as a functional unit in the processor.
比如,在图3c所示的查找装置中,配置单元33可以是处理器中的一个功能单元,存储单元31可以是逻辑器件实现的芯片。配置单元33用于配置存储单元31中的前缀节点,存储单元31中配置有前缀节点,并可执行查找流程。For example, in the lookup device shown in FIG. 3c, the configuration unit 33 may be a functional unit in the processor, and the storage unit 31 may be a chip implemented by a logic device. The configuration unit 33 is configured to configure a prefix node in the storage unit 31, a prefix node is configured in the storage unit 31, and a search process can be performed.
通过以上描述可以看出,本发明的上述实施例中引入了前缀集合,一个前缀节点中可包含M个前缀集合,M≥1。其中,第i前缀节点对应第一步长的第一MBT子树,所述第i前缀节点中的第j前缀集合对应第二MBT 子树,所述第二MBT子树是基于第二步长对所述第一MBT子树划分得到的,所述第二步长小于所述第一步长;所述第j前缀集合中包括所述第二MBT子树的关联前缀、第一位置信息,所述第一位置信息用于按序指示所述第二MBT子树中的各个前缀在所述第二MBT子树中的位置。这样,一个第一步长的MBT子树对应的前缀节点的数据结构,就可以通过该子树内的第二步长MBT子树对应的一个或多个前缀集合来描述。由于一个前缀集合对应的第二MBT子树小于所述第一MBT子树,因此用于描述前缀在第二MBT子树上的位置信息的比特数量,少于用于描述前缀在第一MBT子树上的位置信息的比特数量,并且考虑到前缀分布较为稀松,因此采用本发明实施例提供的前缀节点的数据结构与传统MBT算法相比可以提高编码,减少存储空间的开销。It can be seen from the above description that the prefix set is introduced in the foregoing embodiment of the present invention, and one prefix node may include M prefix sets, and M≥1. The ith prefix node corresponds to the first MBT subtree of the first step, and the jth prefix set of the ith prefix node corresponds to the second MBT. a sub-tree, the second MBT sub-tree is obtained by dividing the first MBT sub-tree based on a second step, where the second step size is smaller than the first step length; and the j-th prefix set is included The associated prefix and the first location information of the second MBT subtree, the first location information is used to sequentially indicate the location of each prefix in the second MBT subtree in the second MBT subtree. In this way, the data structure of the prefix node corresponding to the MBT subtree of the first step can be described by one or more prefix sets corresponding to the second step MBT subtree in the subtree. Since the second MBT subtree corresponding to one prefix set is smaller than the first MBT subtree, the number of bits used to describe the location information of the prefix on the second MBT subtree is less than that used to describe the prefix in the first MBT sub The number of bits of the location information on the tree, and considering the prefix distribution is relatively loose, the data structure of the prefix node provided by the embodiment of the present invention can improve the coding and reduce the overhead of the storage space.
举例来说,对于IPv6地址,由于其长度为128比特,使用传统MBT算法时,当stride=8时,一个前缀节点中需要使用128比特的位图来描述前缀的位置。若采用本发明实施例,对于stride=8的MBT子树,使用取值为3的步长进一步划分得到多个步长为3的子树(以下称为小子树),每个包含前缀的小子树对于一个前缀集合,这样一个前缀集合中只需8比特的位图来描述前缀的位置。对于如图7所示的前缀节点,使用传统MBT算法,该前缀节点的数据结构至少包括128比特的位图(不包含Re Index),使用本发明实施例,该前缀节点的数据结构最多需要68比特(不包含Re Index)。For example, for an IPv6 address, since the length is 128 bits, when the traditional MBT algorithm is used, when stride=8, a bitmap of 128 bits is needed in a prefix node to describe the position of the prefix. According to the embodiment of the present invention, for the MBT subtree with stride=8, a subtree with a step size of 3 (hereinafter referred to as a small subtree) is obtained by using a step size of 3, each of which contains a prefix. The tree is for a set of prefixes, such that a bitmap of only 8 bits is needed in a prefix set to describe the location of the prefix. For the prefix node shown in FIG. 7, the traditional MBT algorithm is used, and the data structure of the prefix node includes at least a 128-bit bitmap (excluding the Re Index). With the embodiment of the present invention, the data structure of the prefix node needs at most 68. Bit (does not include Re Index).
(二)查找流程(2) Search process
基于前述查找装置,图9示出了查找流程。如图所示,查找流程可包括:Based on the aforementioned finding means, FIG. 9 shows the search flow. As shown, the discovery process can include:
步骤91:获得查找关键字;Step 91: Obtain a search keyword;
步骤92:在所配置的N个前缀节点中查找关联前缀与所述查找关键字最长匹配的前缀节点。该过程可以并行执行。其中,前缀节点的数据结构如前所述,在此不再详述。 Step 92: Search for the prefix node whose associated prefix matches the search key with the longest match among the configured N prefix nodes. This process can be performed in parallel. The data structure of the prefix node is as described above and will not be described in detail herein.
步骤93:针对查找到的前缀节点执行以下步骤:Step 93: Perform the following steps for the discovered prefix node:
根据前缀节点中前缀集合的总数量和每个前缀集合中的关联前缀的长度,确定每个前缀集合的存储位置、每个前缀集合中的关联前缀和第一位置信息的存储位置;Determining, according to the total number of prefix sets in the prefix node and the length of the associated prefix in each prefix set, a storage location of each prefix set, an associated prefix in each prefix set, and a storage location of the first location information;
根据每个前缀集合中的关联前缀和第一位置信息的存储位置,获取每个前缀集合中的关联前缀和第一位置信息;Obtaining an associated prefix and first location information in each prefix set according to an association prefix in each prefix set and a storage location of the first location information;
在所有前缀集合中查找关联前缀与所述查找关键字最长匹配的前缀集合;Find a prefix set whose associated prefix matches the lookup keyword in all prefix sets;
根据查找到的前缀集合中的第一位置信息,确定与所述查找关键字最长匹配的前缀;Determining, according to the first location information in the found prefix set, a prefix that matches the lookup keyword;
步骤94:根据与所述查找关键字最长匹配的前缀获得下一跳,得到所述查找关键字的查找结果。Step 94: Obtain a next hop according to a prefix that matches the search keyword, and obtain a search result of the search keyword.
如前所述,前缀节点的数据结构中还可包含本前缀节点内的前缀集合的总数量、每个前缀集合的头部信息,并且一个前缀集合的关联前缀可由一个或多个前置分段来表示,也就是说,一个前缀集合的关联前缀的长度可由该关联前缀包含的前缀分段的数量来表示,因此在步骤93中,根据PCL的总数量可以算出第一个PCL的前置分段的起始位置。以第二步长等于3为例,由于PCL头部信息中包含前置分段的数量,因此根据PCL头部信息中的前缀分段的数量乘以3即可得到PCL的关联前缀字段的总长度。根据第一个PCL的关联前缀字段的起始位置和关联前缀字段的总长度可以算出该PCL的关联前缀字段的结束位置以及前缀位图位置。以图6所示的256比特长度的前缀节点为例,第一个PCL关联前缀字段的起始位置为255-4-6*PCL Num,结束位置为255-4-6*PCL Num-3*PCL header+1,前缀位图的域的位置范围为[255-4-6*PCL Num-3*PCL header:255-4-6*PCL Num-3*PCL header-7+1],第二个PCL的关联前缀字段的起始位置为第一个PCL的前缀位图的结束位置,依次类推可得到所有PCL的关联前缀字段及 前缀位图字段的位置。As described above, the data structure of the prefix node may also include the total number of prefix sets in the prefix node, the header information of each prefix set, and the associated prefix of one prefix set may be one or more pre-segments. To indicate, that is, the length of the associated prefix of a prefix set can be represented by the number of prefix segments included in the associated prefix, so in step 93, the preamble of the first PCL can be calculated based on the total number of PCLs. The starting position of the segment. Taking the second step equal to 3 as an example, since the PCL header information includes the number of pre-segments, the total number of associated prefix fields of the PCL can be obtained by multiplying the number of prefix segments in the PCL header information by three. length. The end position of the associated prefix field of the PCL and the prefix bitmap position can be calculated according to the starting position of the associated prefix field of the first PCL and the total length of the associated prefix field. Taking the 256-bit prefix node shown in Figure 6 as an example, the starting position of the first PCL association prefix field is 255-4-6*PCL Num, and the ending position is 255-4-6*PCL Num-3* PCL header+1, the location range of the prefix bitmap is [255-4-6*PCL Num-3*PCL header:255-4-6*PCL Num-3*PCL header-7+1], second The starting position of the associated prefix field of the PCL is the ending position of the prefix bitmap of the first PCL, and so on, the associated prefix field of all PCLs can be obtained. The location of the prefix bitmap field.
得到所有PCL的关联前缀字段及前缀位图字段的位置后,从PCL关联前缀字段的起始位置左移1个比特(即向高位方向移动1比特),然后再右移(即向低位方向移动)(256-该PCL关联前缀字段的长度)比特,即可得到该PCL的关联前缀。再右移7比特即得到该PCL的前缀位图字段。After obtaining the position of the associated prefix field and the prefix bitmap field of all PCLs, the left position of the PCL associated prefix field is shifted by 1 bit to the left (ie, 1 bit is moved to the upper direction), and then moved to the right (ie, moved to the lower direction). ) (256 - the length of the PCL associated prefix field) bits, the associated prefix of the PCL is obtained. Then shift the 7 bits to the right to get the prefix bitmap field of the PCL.
步骤93中,所述在所有前缀集合中查找关联前缀与所述查找关键字最长匹配的前缀集合的过程是一个迭代过程。如前所述,在前缀节点的数据结构中,所有前缀集合可按照关联前缀的长度进行排列。这种情况下,在步骤93中,可按照查找顺序从前到后,用前缀集合中的关联前缀与所述查找关键字进行匹配,并当查找到第一个关联前缀与所述查找关键字匹配的前缀集合时,将查找到的前缀集合确定为所述查找关键字最长匹配的前缀集合。In step 93, the process of searching for a prefix set whose associated prefix matches the lookup keyword in all prefix sets is an iterative process. As mentioned earlier, in the data structure of the prefix node, all prefix sets can be arranged according to the length of the associated prefix. In this case, in step 93, the search prefix may be matched with the lookup key in the prefix set in the search order from front to back, and when the first associated prefix is found to match the search key The set of prefixes is determined by the set of prefixes that are found to be the longest matching prefix of the lookup key.
举例来说,查找引擎通常被配为流水线级架构,查找过程按照流水线级的顺序执行。流水线级上的每级中配置对应的PCL,根据本级配置的PCL的长度和查找关键字已经匹配的长度得到本级查找关键字对应的分段关键字。比如,首先根据已经在前级流水线匹配过的长度对查找关键字左移相应数量的比特,然后再右移(256-该PCL前置分段长度+2)比特后,低位的2比特表示该分段关键字的前缀位图,[前置分段长度+1:2]范围界定的比特表示分段关键字的前置分段。For example, the lookup engine is usually configured as a pipeline-level architecture, and the lookup process is performed in a pipeline-level order. The corresponding PCL is configured in each level on the pipeline level, and the segmentation keyword corresponding to the search keyword of the current level is obtained according to the length of the PCL configured in the current level and the length that the search key has been matched. For example, first shifting the search key to the left by a corresponding number of lengths that have been matched in the previous stage pipeline, and then right shifting (256 - the PCL preamble length + 2) bits, the lower 2 bits indicate the The prefix bitmap of the segmentation key, the [pre-segment length +1:2] range-defined bit represents the pre-segment of the segmentation key.
然后,用PCL的关联前缀与分段关键字进行匹配。在前缀节点的数据结构中,从前往后匹配过程中第一个匹配到的前缀即为与查找关键字最长匹配前缀。比如,比较PCL和分段关键字的前置分段,并取分段关键字的低2比特与PCL的前缀位图进行比较(比较bitmap[3:0]与segment key,如果不匹配则比较bitmap[5:4]与segment key[1],仍然不匹配则查看bitmap[6]是否为1),从前往后,前置分段与前缀位图都匹配的第一个前缀即为与查找关键字最长匹配的前缀。 Then, the PCL's associated prefix is used to match the segmentation key. In the data structure of the prefix node, the first matching prefix from the going to the post-matching process is the longest matching prefix with the lookup key. For example, compare the pre-segment of the PCL and the segmentation key, and compare the lower 2 bits of the segmentation key with the prefix bitmap of the PCL (compare bitmap[3:0] with the segment key, if not match Bitmap[5:4] and segment key[1], if they still do not match, check whether bitmap[6] is 1). After going to, the first prefix matching the pre-segment and the prefix bitmap is the search and lookup. The prefix that matches the longest keyword.
如前所述,一个前缀节点中可包含第一指示信息,用于指示该前缀节点中的前缀集合所对应的第二MBT子树中包含唯一一个前缀,这种情况下,前缀集合中的第一位置信息为节点位置编号;或者,一个前缀节点中可包含第二指示信息,用于指示该前缀节点中的前缀集合所对应的第二MBT子树中包含至少2个前缀,这种情况下,前缀集合中的所述第一位置信息为位图。相应地,在步骤93中需要基于所述第一指示信息或所述第二指示信息来确定所述第一位置信息的含义(即,是节点位置编号还是位图),进而确定前缀集合的存储位置以及前缀集合内的前置分段和第一位置信息的存储位置。As described above, a prefix node may include first indication information, which is used to indicate that the second MBT subtree corresponding to the prefix set in the prefix node includes a unique prefix. In this case, the first in the prefix set A location information is a node location number; or a prefix node may include second indication information, which is used to indicate that the second MBT subtree corresponding to the prefix set in the prefix node includes at least two prefixes. The first location information in the prefix set is a bitmap. Correspondingly, in step 93, it is required to determine the meaning of the first location information (that is, a node location number or a bitmap) based on the first indication information or the second indication information, thereby determining storage of the prefix set. The location and the storage location of the preamble and the first location information within the prefix set.
如前所示,一个前缀节点的数据结构的第二数据域还可包括本前缀节点内所有前缀所对应的下一跳,所述第二数据域中各个前缀所对应的下一跳的顺序,与所述第一数据域中各个前缀集合中的第一位置信息所指示的前缀位置的顺序,相同或相反。相应地,在步骤94中,根据下一跳排列顺序需要采用不同的方式获得下一跳。举例来说,如图6所示,如果在一个前缀节点中,所有前缀集合按照从大到小的顺序排序且下一跳的排列顺序与该前缀节点内包含的前缀的排列顺序相反,则可通过以下方式得到与查找关键字最长匹配的前缀的下一跳:在前缀节点的数据结构中,计算所有PCL位图中最长匹配前缀之前所有1的总数量(位图中为“1”的位置上有前缀),计算结果为n,则与该最长前缀匹配的RE Index为RE index of P<n>。As shown in the foregoing, the second data field of the data structure of the prefix node may further include the next hop corresponding to all the prefixes in the prefix node, and the order of the next hop corresponding to each prefix in the second data domain, The order of the prefix locations indicated by the first location information in each of the prefix sets in the first data domain is the same or opposite. Correspondingly, in step 94, the next hop needs to be obtained in a different manner according to the next hop ranking order. For example, as shown in FIG. 6, if in a prefix node, all prefix sets are sorted in descending order and the order of the next hops is opposite to the order of the prefixes included in the prefix node, The next hop of the prefix that matches the longest match keyword is obtained by calculating the total number of all 1s before the longest matching prefix in all PCL bitmaps in the data structure of the prefix node ("1" in the bitmap) The position has a prefix), and if the result is n, the RE Index matching the longest prefix is RE index of P<n>.
通过以上描述可以看出,本发明的上述实施例中引入了前缀集合,一个前缀节点中可包含M个前缀集合,M≥1。其中,第i前缀节点对应第一步长的第一MBT子树,所述第i前缀节点中的第j前缀集合对应第二MBT子树,所述第二MBT子树是基于第二步长对所述第一MBT子树划分得到的,所述第二步长小于所述第一步长;所述第j前缀集合中包括所述第二MBT子树的关联前缀、第一位置信息,所述第一位置信息用于按序指示所述第二MBT子树中的各个前缀在所述第二MBT子树中的位置。这样,一 个第一步长的MBT子树对应的前缀节点的数据结构,就可以通过该子树内的第二步长MBT子树对应的一个或多个前缀集合来描述。由于一个前缀集合对应的第二MBT子树小于所述第一MBT子树,因此用于描述前缀在第二MBT子树上的位置信息的比特数量,少于用于描述前缀在第一MBT子树上的位置信息的比特数量,并且考虑到前缀分布较为稀松,因此采用本发明实施例提供的前缀节点的数据结构与传统MBT算法相比可以提高编码,减少存储空间的开销。It can be seen from the above description that the prefix set is introduced in the foregoing embodiment of the present invention, and one prefix node may include M prefix sets, and M≥1. The ith prefix node corresponds to the first MBT subtree of the first step length, the jth prefix set of the ith prefix node corresponds to the second MBT subtree, and the second MBT subtree is based on the second step The second step size is smaller than the first step length obtained by dividing the first MBT subtree; the jth prefix set includes an associated prefix and first location information of the second MBT subtree, The first location information is used to sequentially indicate the location of each prefix in the second MBT subtree in the second MBT subtree. In this way, one The data structure of the prefix node corresponding to the MBT subtree of the first step may be described by one or more prefix sets corresponding to the second step MBT subtree in the subtree. Since the second MBT subtree corresponding to one prefix set is smaller than the first MBT subtree, the number of bits used to describe the location information of the prefix on the second MBT subtree is less than that used to describe the prefix in the first MBT sub The number of bits of the location information on the tree, and considering the prefix distribution is relatively loose, the data structure of the prefix node provided by the embodiment of the present invention can improve the coding and reduce the overhead of the storage space.
(三)配置流程(3) Configuration process
基于前述查找装置,图10示出了配置流程。如图所示,配置流程可包括:Based on the aforementioned finding means, FIG. 10 shows the configuration flow. As shown, the configuration process can include:
步骤101:获得待配置的前缀信息,所述前缀中包括至少一个地址前缀以及所述地址前缀所对应的下一跳;Step 101: Obtain prefix information to be configured, where the prefix includes at least one address prefix and a next hop corresponding to the address prefix.
步骤102:在所配置的N个前缀节点中查找关联前缀与所述待配置的地址前缀最长匹配的前缀节点。该过程可以并行执行。其中,一个prefix节点的数据结构同前所述,在此不再赘述。Step 102: Search for the prefix node whose associated prefix is the longest match with the address prefix to be configured in the configured N prefix nodes. This process can be performed in parallel. The data structure of a prefix node is the same as that described above, and is not described here.
步骤103:针对查找到的前缀节点执行以下操作:Step 103: Perform the following operations on the found prefix node:
根据前缀节点中前缀集合的总数量和每个前缀集合中的关联前缀的长度,确定每个前缀集合的存储位置、每个前缀集合中的关联前缀和第一位置信息的存储位置;Determining, according to the total number of prefix sets in the prefix node and the length of the associated prefix in each prefix set, a storage location of each prefix set, an associated prefix in each prefix set, and a storage location of the first location information;
根据每个前缀集合中的关联前缀和第一位置信息的存储位置,获取每个前缀集合中的关联前缀和第一位置信息;Obtaining an associated prefix and first location information in each prefix set according to an association prefix in each prefix set and a storage location of the first location information;
在所有前缀集合中查找关联前缀与所述待配置的地址前缀最长匹配的前缀集合;Finding, in all prefix sets, a prefix set whose associated prefix matches the address prefix to be configured the longest;
步骤104:在前缀节点中配置所述待配置的地址前缀所对应的下一跳,并更新与所述待配置的地址前缀最长匹配的前缀集合中的第一位置信息。Step 104: Configure a next hop corresponding to the to-be-configured address prefix in the prefix node, and update first location information in the prefix set that matches the address prefix to be configured.
上述流程中,步骤102~103的实现过程与图9的步骤92~93的实现过 程类似。In the above process, the implementation process of steps 102-103 and the implementation of steps 92-93 of FIG. 9 have been implemented. The process is similar.
通常路由表允许人工配置或更新,或者可根据相关协议进行更新。比如,可通过人工方式配置静态路由或者根据边界网关协议(Border Gateway Protocol,简称BGP)等路由选择协议动态更新,包括增加新的路由表项或者删除已有的路由表项。在步骤101中,可根据接收到的路由更新命令确定出需要增加或删除的前缀,以便进行配置更新。Usually the routing table allows manual configuration or update, or can be updated according to the relevant protocol. For example, a static route can be manually configured or dynamically updated according to a routing protocol such as the Border Gateway Protocol (BGP), including adding a new routing entry or deleting an existing routing entry. In step 101, a prefix that needs to be added or deleted may be determined according to the received route update command for configuration update.
如前所述,在前缀节点的数据结构中,所有前缀集合可按照关联前缀的长度进行排列。这种情况下,在步骤103中,可按照查找顺序,用前缀集合中的关联前缀与所述待配置的前缀进行匹配,并当查找到第一个关联前缀与所述待配置的前缀匹配的前缀集合时,将查找到的前缀集合确定为所述待配置的前缀最长匹配的前缀集合。As mentioned earlier, in the data structure of the prefix node, all prefix sets can be arranged according to the length of the associated prefix. In this case, in step 103, the associated prefix in the prefix set is matched with the prefix to be configured, and the first associated prefix is matched with the prefix to be configured. When the prefix set is used, the found prefix set is determined as the longest matching prefix set of the prefix to be configured.
如前所述,一个前缀节点的数据结构中的第二数据域还可包括本前缀节点内所有前缀的下一跳,所述第二数据域中各个前缀所对应的下一跳的顺序,与所述第一数据域中各个前缀集合中的第一位置信息所指示的前缀位置的顺序,相同或相反。这种情况下,在步骤103中可在查找到待匹配的前缀归属的前缀集合后,按照规定的顺序添加该前缀的下一跳。As described above, the second data field in the data structure of a prefix node may further include the next hop of all the prefixes in the prefix node, and the order of the next hop corresponding to each prefix in the second data domain, and The order of the prefix locations indicated by the first location information in each prefix set in the first data domain is the same or opposite. In this case, in step 103, after finding the prefix set to which the prefix to be matched belongs, the next hop of the prefix may be added in a prescribed order.
如前所述,一个前缀节点中可包含第一指示信息,用于指示该前缀节点中的前缀集合所对应的第二MBT子树中包含唯一一个前缀,这种情况下,前缀集合中的第一位置信息为节点位置编号;或者,一个前缀节点中可包含第二指示信息,用于指示该前缀节点中的前缀集合所对应的第二MBT子树中包含至少2个前缀,这种情况下,前缀集合中的所述第一位置信息为位图。As described above, a prefix node may include first indication information, which is used to indicate that the second MBT subtree corresponding to the prefix set in the prefix node includes a unique prefix. In this case, the first in the prefix set A location information is a node location number; or a prefix node may include second indication information, which is used to indicate that the second MBT subtree corresponding to the prefix set in the prefix node includes at least two prefixes. The first location information in the prefix set is a bitmap.
相应地,若所述待配置的前缀是前缀集合中唯一的前缀,则还在该前级集合的头部信息中设置所述第一指示信息,使所述第一指示信息的取值用于指示对应的前缀集合中的第一位置信息是节点位置编号。Correspondingly, if the prefix to be configured is a unique prefix in the prefix set, the first indication information is also set in the header information of the pre-level set, so that the value of the first indication information is used for The first location information in the corresponding prefix set is indicated as a node location number.
在本发明实施例的上述配置流程中,若在步骤102中未查找到与待配 置的前缀最长匹配的前缀节点,则为该待配置的前缀创建对应的前缀节点,并按照前述数据结构在新创建的前缀节点中添加相应信息。若在步骤103中未查找到与待配置的前缀匹配的前缀集合,则为该待配置的前缀创建对应的前缀集合,并按照前述数据结构在新创建的前缀集合以及对应的前缀节点中添加相应信息。In the above configuration process of the embodiment of the present invention, if it is not found and to be matched in step 102 The prefix node with the longest matching prefix is used to create a corresponding prefix node for the prefix to be configured, and the corresponding information is added to the newly created prefix node according to the foregoing data structure. If the prefix set matching the prefix to be configured is not found in step 103, a corresponding prefix set is created for the prefix to be configured, and correspondingly added in the newly created prefix set and the corresponding prefix node according to the foregoing data structure. information.
通过以上描述可以看出,本发明的上述实施例中引入了前缀集合,一个前缀节点中可包含M个前缀集合,M≥1。其中,第i前缀节点对应第一步长的第一MBT子树,所述第i前缀节点中的第j前缀集合对应第二MBT子树,所述第二MBT子树是基于第二步长对所述第一MBT子树划分得到的,所述第二步长小于所述第一步长;所述第j前缀集合中包括所述第二MBT子树的关联前缀、第一位置信息,所述第一位置信息用于按序指示所述第二MBT子树中的各个前缀在所述第二MBT子树中的位置。这样,一个第一步长的MBT子树对应的前缀节点的数据结构,就可以通过该子树内的第二步长MBT子树对应的一个或多个前缀集合来描述。由于一个前缀集合对应的第二MBT子树小于所述第一MBT子树,因此用于描述前缀在第二MBT子树上的位置信息的比特数量,少于用于描述前缀在第一MBT子树上的位置信息的比特数量,并且考虑到前缀分布较为稀松,因此采用本发明实施例提供的前缀节点的数据结构与传统MBT算法相比可以提高编码,减少存储空间的开销。It can be seen from the above description that the prefix set is introduced in the foregoing embodiment of the present invention, and one prefix node may include M prefix sets, and M≥1. The ith prefix node corresponds to the first MBT subtree of the first step length, the jth prefix set of the ith prefix node corresponds to the second MBT subtree, and the second MBT subtree is based on the second step The second step size is smaller than the first step length obtained by dividing the first MBT subtree; the jth prefix set includes an associated prefix and first location information of the second MBT subtree, The first location information is used to sequentially indicate the location of each prefix in the second MBT subtree in the second MBT subtree. In this way, the data structure of the prefix node corresponding to the MBT subtree of the first step can be described by one or more prefix sets corresponding to the second step MBT subtree in the subtree. Since the second MBT subtree corresponding to one prefix set is smaller than the first MBT subtree, the number of bits used to describe the location information of the prefix on the second MBT subtree is less than that used to describe the prefix in the first MBT sub The number of bits of the location information on the tree, and considering the prefix distribution is relatively loose, the data structure of the prefix node provided by the embodiment of the present invention can improve the coding and reduce the overhead of the storage space.
综上所述,本发明实施例通过将一个prefix节点中的前缀用MBT进行组织和分类,把前缀划分成多个PCL。每个PCL中的前缀有相同的关联前缀,一个PCL中包含的前缀在相应第二MBT子树上的位置可以用位图或者在节点位置编号来表示。这样,在一个前缀节点中,通过先列出每个PCL的头部信息,然后再列出所有PCL的关联前缀,最后再列出表示前缀的位图或者节点位置编号,从而对PCL进行编码。在对一个前缀节点进行逻辑解析时,通过该前缀节点中包含的PCL个数字段以及各个PCL header字段 可以确定各PCL的存储位置和长度。In summary, the embodiment of the present invention divides the prefix into multiple PCLs by organizing and classifying the prefixes in a prefix node by using MBT. The prefixes in each PCL have the same associated prefix, and the location of the prefix contained in one PCL on the corresponding second MBT subtree can be represented by a bitmap or by a node location number. Thus, in a prefix node, the PCL is encoded by first listing the header information of each PCL, then listing the associated prefixes of all PCLs, and finally listing the bitmap or node location number indicating the prefix. When performing logical resolution on a prefix node, the number of PCL numbers included in the prefix node and each PCL header field are passed. The storage location and length of each PCL can be determined.
通过这样编码,prefix节点中可以保存任意长度的前缀。对于比较稀疏的IPv4VPN和IPv6路由,本发明实施例提供的方案可以大大提高编码效率,节省内存占用。通过把PCL header集中放在前缀节点的开始部分,可以降低逻辑解析的难度,实现对多个PCL的并行解析,减少节点处理的延迟。通过把较长的PCL放在较短PCL的前面,可以使逻辑解析使用的资源更省。By such encoding, a prefix of any length can be stored in the prefix node. For a relatively sparse IPv4 VPN and IPv6 route, the solution provided by the embodiment of the present invention can greatly improve coding efficiency and save memory usage. By concentrating the PCL header at the beginning of the prefix node, the difficulty of logical parsing can be reduced, parallel parsing of multiple PCLs can be realized, and the delay of node processing can be reduced. By placing a longer PCL in front of a shorter PCL, the resources used for logical parsing can be made more economical.
本发明实施例提供的prefix节点的数据结构和编码方式,通过把任意长度的前缀放在同一个prefix节点中,可以使MBT的深度更小,从而大大提高MBT算法的效率,进而减少查找的延迟。The data structure and coding mode of the prefix node provided by the embodiment of the present invention can make the MBT depth smaller by placing the prefix of any length in the same prefix node, thereby greatly improving the efficiency of the MBT algorithm, thereby reducing the delay of the search. .
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器,使得通过该计算机或其他可编程数据处理设备的处理器执行的指令可实现流程图中的一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。The present invention has been described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (system), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or FIG. The computer program instructions can be provided to a general purpose computer, a special purpose computer, an embedded processor, or a processor of other programmable data processing device such that instructions executed by a processor of the computer or other programmable data processing device can be implemented in a flowchart The function specified in one or more processes and/or block diagrams in one or more blocks.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。The computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device. The apparatus implements the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图的一个流程或多个流程和/或方框图的一个方框或多个方框中指定的功能的步骤。 These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device. The instructions provide steps for implementing the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.
尽管已描述了本发明的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例作出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本发明范围的所有变更和修改。 While the preferred embodiment of the invention has been described, it will be understood that Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and the modifications and

Claims (23)

  1. 一种查找装置,其特征在于,包括:存储单元;A searching device, comprising: a storage unit;
    所述存储单元中配置有N个前缀节点,N≥1,每个前缀节点包括第一数据域,所述第一数据域中包括M个前缀集合,M≥1,其中:The storage unit is configured with N prefix nodes, N≥1, each prefix node includes a first data domain, and the first data domain includes M prefix sets, where M≥1, where:
    第i前缀节点对应第一步长的第一MBT子树,所述第i前缀节点中的第j前缀集合对应第二MBT子树,所述第二MBT子树是基于第二步长对所述第一MBT子树划分得到的,所述第二步长小于所述第一步长;其中,1≤i≤N,1≤j≤M;The i-th prefix node corresponds to the first MBT sub-tree of the first step length, the j-th prefix set of the i-th prefix node corresponds to the second MBT sub-tree, and the second MBT sub-tree is based on the second step The second MBT subtree is divided by the first step length; wherein, 1≤i≤N, 1≤j≤M;
    所述第j前缀集合中包括所述第二MBT子树的关联前缀、第一位置信息,所述第一位置信息用于按序指示所述第二MBT子树中的各个前缀在所述第二MBT子树中的位置。The first prefix information includes the associated prefix and the first location information of the second MBT subtree, where the first location information is used to sequentially indicate each prefix in the second MBT subtree in the first The location in the two MBT subtrees.
  2. 如权利要求1所述的查找装置,其特征在于,所述第i前缀节点中还包括第二数据域,所述第二数据域中包括所述第一MBT子树中所有前缀各自所对应的下一跳。The locating device according to claim 1, wherein the ith prefix node further includes a second data domain, and the second data domain includes a corresponding one of all prefixes in the first MBT subtree. Next hop.
  3. 如权利要求2所述的查找装置,其特征在于,所述第二数据域设置于所述第一数据域之后;The locating device according to claim 2, wherein the second data field is disposed after the first data field;
    所述第二数据域中各个前缀所对应的下一跳的顺序,与所述第一数据域中各个前缀集合中的第一位置信息所指示的前缀位置的顺序,相同或相反。The order of the next hops corresponding to the prefixes in the second data domain is the same as or opposite to the order of the prefix locations indicated by the first location information in each prefix set in the first data domain.
  4. 如权利要求1至3中任一项所述的查找装置,其特征在于,所述第i前缀节点中还包括第三数据域,所述第三数据域中包括所述第i前缀节点中的所有前缀集合的数量、所述第i前缀节点中的所有前缀集合中的每个前缀集合的头部信息,其中,第j前缀集合的头部信息中包含所述第二MBT子树的关联前缀的长度。The locating device according to any one of claims 1 to 3, wherein the ith prefix node further includes a third data domain, and the third data domain includes the ith prefix node The number of all prefix sets, the header information of each of the prefix sets in the i-th prefix node, wherein the header information of the j-th prefix set includes the associated prefix of the second MBT sub-tree length.
  5. 如权利要求4所述的查找装置,其特征在于,所述第三数据域设置于所述第一数据域之前; The locating device according to claim 4, wherein the third data domain is disposed before the first data domain;
    所述第三数据域中各个前缀集合的头部信息的顺序,与所述第一数据域中各个前缀集合的顺序,相同或相反。The order of the header information of each prefix set in the third data domain is the same as or opposite to the order of each prefix set in the first data domain.
  6. 如权利要求1至5中任一项所述的查找装置,其特征在于,所述第一数据域中的所述M个前缀集合按照查找顺序包括第1至第M前缀集合,所述M个前缀集合中,第j前缀集合中存储的关联前缀的长度,不小于第j+1前缀集合中存储的关联前缀的长度,1≤j<M。The searching device according to any one of claims 1 to 5, wherein the M prefix sets in the first data domain include a first to an Mth prefix set according to a search order, and the M In the prefix set, the length of the associated prefix stored in the jth prefix set is not less than the length of the associated prefix stored in the j+1 prefix set, 1≤j<M.
  7. 如权利要求1至6中任一项所述的查找装置,其特征在于,A search device according to any one of claims 1 to 6, wherein
    所述第i前缀节点中包含第一指示信息,用于指示所述第j前缀集合所对应的第二MBT子树中包含唯一一个前缀,所述第j前缀集合中的第一位置信息为所述唯一一个前缀在所述第二MBT子树中的节点位置编号,所述第一位置信息的长度等于所述第二步长;或者The ith prefix node includes first indication information, where the second MBT subtree corresponding to the jth prefix set includes a unique prefix, and the first location information in the jth prefix set is Defining a node location number of the unique prefix in the second MBT subtree, the length of the first location information being equal to the second step size; or
    所述第i前缀节点中包含第二指示信息,用于指示所述第j前缀集合所对应的第二MBT子树中包含至少2个前缀,所述第j前缀集合中的所述第一位置信息为位图,用于指示所述第二MBT子树中的所述至少2个前缀在该第二MBT子树中的位置,所述第一指示信息的长度为2stride-1,stride为所述第二步长。The second i-prefix node includes second indication information, where the second MBT sub-tree corresponding to the j-th prefix set includes at least two prefixes, and the first location in the j-th prefix set The information is a bitmap, and is used to indicate a position of the at least two prefixes in the second MBT subtree in the second MBT subtree, where the length of the first indication information is 2 stride -1, and the stride is The second step.
  8. 如权利要求1至7中任一项所述的查找装置,其特征在于,所述存储单元用于执行查找流程;或者,所述查找装置还包括查找单元,所述查找单元用于基于所述存储单元执行所述查找流程;The search device according to any one of claims 1 to 7, wherein the storage unit is configured to perform a search process; or the search device further includes a search unit, the search unit is configured to The storage unit performs the search process;
    所述查找流程包括:The search process includes:
    获得查找关键字;Get the search keyword;
    在所述N个前缀节点中查找关联前缀与所述查找关键字最长匹配的前缀节点,针对查找到的前缀节点执行以下步骤:Searching, in the N prefix nodes, a prefix node whose associated prefix matches the lookup key, and performing the following steps for the found prefix node:
    根据前缀节点中前缀集合的总数量和每个前缀集合中的关联前缀的长度,确定每个前缀集合的存储位置、每个前缀集合中的关联前缀和第一位置信息的存储位置; Determining, according to the total number of prefix sets in the prefix node and the length of the associated prefix in each prefix set, a storage location of each prefix set, an associated prefix in each prefix set, and a storage location of the first location information;
    根据每个前缀集合中的关联前缀和第一位置信息的存储位置,获取每个前缀集合中的关联前缀和第一位置信息;Obtaining an associated prefix and first location information in each prefix set according to an association prefix in each prefix set and a storage location of the first location information;
    在所有前缀集合中查找关联前缀与所述查找关键字最长匹配的前缀集合;Find a prefix set whose associated prefix matches the lookup keyword in all prefix sets;
    根据查找到的前缀集合中的第一位置信息,确定与所述查找关键字最长匹配的前缀;Determining, according to the first location information in the found prefix set, a prefix that matches the lookup keyword;
    根据与所述查找关键字最长匹配的前缀获得下一跳,得到所述查找关键字的查找结果。Obtaining a next hop according to a prefix that matches the search keyword longest, and obtaining a search result of the search key.
  9. 如权利要求1至8中任一项所述的查找装置,其特征在于,还包括配置单元,所述配置单元用于配置所述存储单元中的前缀节点,具体的,所述配置单元具体用于:The locating device according to any one of claims 1 to 8, further comprising a configuration unit, wherein the configuration unit is configured to configure a prefix node in the storage unit, and specifically, the configuration unit is specifically used to:
    获得待配置的前缀信息,所述前缀中包括至少一个地址前缀以及所述地址前缀所对应的下一跳;Obtaining the prefix information to be configured, where the prefix includes at least one address prefix and a next hop corresponding to the address prefix;
    在所有前缀节点中查找关联前缀与所述待配置的地址前缀最长匹配的前缀节点;Searching, in all the prefix nodes, a prefix node whose associated prefix matches the address prefix to be configured the longest;
    针对查找到的前缀节点执行以下操作:Do the following for the discovered prefix node:
    根据前缀节点中前缀集合的总数量和每个前缀集合中的关联前缀的长度,确定每个前缀集合的存储位置、每个前缀集合中的关联前缀和第一位置信息的存储位置;Determining, according to the total number of prefix sets in the prefix node and the length of the associated prefix in each prefix set, a storage location of each prefix set, an associated prefix in each prefix set, and a storage location of the first location information;
    根据每个前缀集合中的关联前缀和第一位置信息的存储位置,获取每个前缀集合中的关联前缀和第一位置信息;Obtaining an associated prefix and first location information in each prefix set according to an association prefix in each prefix set and a storage location of the first location information;
    在所有前缀集合中查找关联前缀与所述待配置的地址前缀最长匹配的前缀集合;Finding, in all prefix sets, a prefix set whose associated prefix matches the address prefix to be configured the longest;
    在前缀节点中配置所述待配置的地址前缀所对应的下一跳,并更新与所述待配置的地址前缀最长匹配的前缀集合中的第一位置信息。 The next hop corresponding to the to-be-configured address prefix is configured in the prefix node, and the first location information in the prefix set that matches the address prefix to be configured is updated.
  10. 一种查找方法,其特征在于,包括:A search method, comprising:
    获得查找关键字;Get the search keyword;
    在所配置的N个前缀节点中查找关联前缀与所述查找关键字最长匹配的前缀节点;其中,N≥1,每个前缀节点包括第一数据域,所述第一数据域中包括M个前缀集合,M≥1,其中:第i前缀节点对应第一步长的第一MBT子树,所述第i前缀节点中的第j前缀集合对应第二MBT子树,所述第二MBT子树是基于第二步长对所述第一MBT子树划分得到的,所述第二步长小于所述第一步长,1≤i≤N,1≤j≤M,所述第j前缀集合中包括所述第二MBT子树的关联前缀、第一位置信息,所述第一位置信息用于按序指示所述第二MBT子树中的各个前缀在所述第二MBT子树中的位置;Searching, among the configured N prefix nodes, a prefix node whose associated prefix matches the lookup key; wherein N≥1, each prefix node includes a first data domain, and the first data domain includes M a prefix set, M≥1, wherein: the i-th prefix node corresponds to a first MBT sub-tree of the first step length, and the j-th prefix set of the i-th prefix node corresponds to a second MBT sub-tree, the second MBT The subtree is obtained by dividing the first MBT subtree based on the second step, the second step is smaller than the first step length, 1≤i≤N, 1≤j≤M, the jth And the first location information is used to sequentially indicate each prefix in the second MBT subtree in the second MBT subtree. Position in
    针对查找到的前缀节点执行以下步骤:Perform the following steps for the discovered prefix node:
    根据前缀节点中前缀集合的总数量和每个前缀集合中的关联前缀的长度,确定每个前缀集合的存储位置、每个前缀集合中的关联前缀和第一位置信息的存储位置;Determining, according to the total number of prefix sets in the prefix node and the length of the associated prefix in each prefix set, a storage location of each prefix set, an associated prefix in each prefix set, and a storage location of the first location information;
    根据每个前缀集合中的关联前缀和第一位置信息的存储位置,获取每个前缀集合中的关联前缀和第一位置信息;Obtaining an associated prefix and first location information in each prefix set according to an association prefix in each prefix set and a storage location of the first location information;
    在所有前缀集合中查找关联前缀与所述查找关键字最长匹配的前缀集合;Find a prefix set whose associated prefix matches the lookup keyword in all prefix sets;
    根据查找到的前缀集合中的第一位置信息,确定与所述查找关键字最长匹配的前缀;Determining, according to the first location information in the found prefix set, a prefix that matches the lookup keyword;
    根据与所述查找关键字最长匹配的前缀获得下一跳,得到所述查找关键字的查找结果。Obtaining a next hop according to a prefix that matches the search keyword longest, and obtaining a search result of the search key.
  11. 如权利要求10所述的方法,其特征在于,所述第i前缀节点中还包括第二数据域,所述第二数据域中包括所述第一MBT子树中所有前缀各自所对应的下一跳。The method according to claim 10, wherein the ith prefix node further includes a second data field, and the second data field includes a lower one of all prefixes in the first MBT subtree. One jump.
  12. 如权利要求11所述的方法,其特征在于,所述第二数据域设置于 所述第一数据域之后;The method of claim 11 wherein said second data field is set to After the first data field;
    所述第二数据域中各个前缀所对应的下一跳的顺序,与所述第一数据域中各个前缀集合中的第一位置信息所指示的前缀位置的顺序,相同或相反。The order of the next hops corresponding to the prefixes in the second data domain is the same as or opposite to the order of the prefix locations indicated by the first location information in each prefix set in the first data domain.
  13. 如权利要求10至12中任一项所述的方法,其特征在于,所述第i前缀节点中还包括第三数据域,所述第三数据域中包括所述第i前缀节点中的所有前缀集合的数量、所述第i前缀节点中的所有前缀集合中的每个前缀集合的头部信息,其中,第j前缀集合的头部信息中包含所述第二MBT子树的关联前缀的长度。The method according to any one of claims 10 to 12, wherein the ith prefix node further includes a third data domain, and the third data domain includes all of the ith prefix nodes The number of the prefix set, the header information of each of the prefix sets in the i-th prefix node, wherein the header information of the j-th prefix set includes the associated prefix of the second MBT sub-tree length.
  14. 如权利要求13所述的方法,其特征在于,所述第三数据域设置于所述第一数据域之前;The method of claim 13 wherein said third data field is disposed before said first data field;
    所述第三数据域中各个前缀集合的头部信息的顺序,与所述第一数据域中各个前缀集合的顺序,相同或相反。The order of the header information of each prefix set in the third data domain is the same as or opposite to the order of each prefix set in the first data domain.
  15. 如权利要求10至14中任一项所述的方法,其特征在于,所述第一数据域中的所述M个前缀集合按照查找顺序包括第1至第M前缀集合,所述M个前缀集合中,第j前缀集合中存储的关联前缀的长度,不小于第j+1前缀集合中存储的关联前缀的长度,1≤j<M。The method according to any one of claims 10 to 14, wherein the M prefix sets in the first data domain include a first to an Mth prefix set in a lookup order, the M prefixes In the set, the length of the associated prefix stored in the jth prefix set is not less than the length of the associated prefix stored in the j+1 prefix set, 1≤j<M.
  16. 如权利要求10至15中任一项所述的方法,其特征在于,A method according to any one of claims 10 to 15, wherein
    所述第i前缀节点中包含第一指示信息,用于指示所述第j前缀集合所对应的第二MBT子树中包含唯一一个前缀,所述第j前缀集合中的第一位置信息为所述唯一一个前缀在所述第二MBT子树中的节点位置编号,所述第一位置信息的长度等于所述第二步长;或者The ith prefix node includes first indication information, where the second MBT subtree corresponding to the jth prefix set includes a unique prefix, and the first location information in the jth prefix set is Defining a node location number of the unique prefix in the second MBT subtree, the length of the first location information being equal to the second step size; or
    所述第i前缀节点中包含第二指示信息,用于指示所述第j前缀集合所对应的第二MBT子树中包含至少2个前缀,所述第j前缀集合中的所述第一位置信息为位图,用于指示所述第二MBT子树中的所述至少2个前缀在该第二MBT子树中的位置,所述第一指示信息的长度为2stride-1,stride为 所述第二步长。The second i-prefix node includes second indication information, where the second MBT sub-tree corresponding to the j-th prefix set includes at least two prefixes, and the first location in the j-th prefix set The information is a bitmap, and is used to indicate a position of the at least two prefixes in the second MBT subtree in the second MBT subtree, where the length of the first indication information is 2 stride -1, and the stride is The second step.
  17. 一种配置方法,其特征在于,包括:A configuration method, comprising:
    获得待配置的前缀信息,所述前缀中包括至少一个地址前缀以及所述地址前缀所对应的下一跳;Obtaining the prefix information to be configured, where the prefix includes at least one address prefix and a next hop corresponding to the address prefix;
    在所配置的N个前缀节点中查找关联前缀与所述待配置的地址前缀最长匹配的前缀节点;其中,N≥1,每个前缀节点包括第一数据域,所述第一数据域中包括M个前缀集合,M≥1,其中:第i前缀节点对应第一步长的第一MBT子树,所述第i前缀节点中的第j前缀集合对应第二MBT子树,所述第二MBT子树是基于第二步长对所述第一MBT子树划分得到的,所述第二步长小于所述第一步长,1≤i≤N,1≤j≤M,所述第j前缀集合中包括所述第二MBT子树的关联前缀、第一位置信息,所述第一位置信息用于按序指示所述第二MBT子树中的各个前缀在所述第二MBT子树中的位置;Searching, among the configured N prefix nodes, a prefix node whose associated prefix matches the address prefix to be configured the longest; wherein, N≥1, each prefix node includes a first data domain, and the first data domain Including M prefix sets, M≥1, wherein: the i-th prefix node corresponds to the first MBT sub-tree of the first step length, and the j-th prefix set of the i-th prefix node corresponds to the second MBT sub-tree, where The second MBT subtree is obtained by dividing the first MBT subtree based on the second step, the second step is smaller than the first step length, 1≤i≤N, 1≤j≤M, The first prefix information of the second MBT subtree includes the associated prefix and the first location information, where the first location information is used to sequentially indicate each prefix in the second MBT subtree in the second MBT The position in the subtree;
    针对查找到的前缀节点执行以下操作:Do the following for the discovered prefix node:
    根据前缀节点中前缀集合的总数量和每个前缀集合中的关联前缀的长度,确定每个前缀集合的存储位置、每个前缀集合中的关联前缀和第一位置信息的存储位置;Determining, according to the total number of prefix sets in the prefix node and the length of the associated prefix in each prefix set, a storage location of each prefix set, an associated prefix in each prefix set, and a storage location of the first location information;
    根据每个前缀集合中的关联前缀和第一位置信息的存储位置,获取每个前缀集合中的关联前缀和第一位置信息;Obtaining an associated prefix and first location information in each prefix set according to an association prefix in each prefix set and a storage location of the first location information;
    在所有前缀集合中查找关联前缀与所述待配置的地址前缀最长匹配的前缀集合;Finding, in all prefix sets, a prefix set whose associated prefix matches the address prefix to be configured the longest;
    在前缀节点中配置所述待配置的地址前缀所对应的下一跳,并更新与所述待配置的地址前缀最长匹配的前缀集合中的第一位置信息。The next hop corresponding to the to-be-configured address prefix is configured in the prefix node, and the first location information in the prefix set that matches the address prefix to be configured is updated.
  18. 如权利要求17所述的方法,其特征在于,所述第i前缀节点中还包括第二数据域,所述第二数据域中包括所述第一MBT子树中所有前缀各 自所对应的下一跳。The method according to claim 17, wherein the ith prefix node further includes a second data field, and the second data field includes all prefixes in the first MBT subtree. Since the corresponding next hop.
  19. 如权利要求18所述的方法,其特征在于,所述第二数据域设置于所述第一数据域之后;The method of claim 18, wherein the second data field is disposed after the first data field;
    所述第二数据域中各个前缀所对应的下一跳的顺序,与所述第一数据域中各个前缀集合中的第一位置信息所指示的前缀位置的顺序,相同或相反。The order of the next hops corresponding to the prefixes in the second data domain is the same as or opposite to the order of the prefix locations indicated by the first location information in each prefix set in the first data domain.
  20. 如权利要求18至19中任一项所述的方法,其特征在于,所述第i前缀节点中还包括第三数据域,所述第三数据域中包括所述第i前缀节点中的所有前缀集合的数量、所述第i前缀节点中的所有前缀集合中的每个前缀集合的头部信息,其中,第j前缀集合的头部信息中包含所述第二MBT子树的关联前缀的长度。The method according to any one of claims 18 to 19, wherein the ith prefix node further includes a third data domain, and the third data domain includes all of the ith prefix nodes The number of the prefix set, the header information of each of the prefix sets in the i-th prefix node, wherein the header information of the j-th prefix set includes the associated prefix of the second MBT sub-tree length.
  21. 如权利要求20所述的方法,其特征在于,所述第三数据域设置于所述第一数据域之前;The method of claim 20, wherein the third data field is disposed before the first data field;
    所述第三数据域中各个前缀集合的头部信息的顺序,与所述第一数据域中各个前缀集合的顺序,相同或相反。The order of the header information of each prefix set in the third data domain is the same as or opposite to the order of each prefix set in the first data domain.
  22. 如权利要求17至21中任一项所述的方法,其特征在于,所述第一数据域中的所述M个前缀集合按照查找顺序包括第1至第M前缀集合,所述M个前缀集合中,第j前缀集合中存储的关联前缀的长度,不小于第j+1前缀集合中存储的关联前缀的长度,1≤j<M;The method according to any one of claims 17 to 21, wherein the M prefix sets in the first data domain include a first to an Mth prefix set in a lookup order, the M prefixes In the set, the length of the associated prefix stored in the jth prefix set is not less than the length of the associated prefix stored in the j+1 prefix set, 1≤j<M;
    所述在所有前缀集合中查找关联前缀与所述待配置的地址前缀最长匹配的前缀集合,包括:The finding, in all the prefix sets, the prefix set whose associated prefix matches the address prefix to be configured the longest, including:
    按照查找顺序,用前缀集合中的关联前缀与所述待配置的前缀进行匹配,并当查找到第一个关联前缀与所述待配置的前缀匹配的前缀集合时,将查找到的前缀集合确定为所述待配置的前缀最长匹配的前缀集合。Matching the prefix to be configured with the associated prefix in the prefix set, and determining the prefix set to be found when the first associated prefix matches the prefix set matching the prefix to be configured. The prefix set that is the longest match for the prefix to be configured.
  23. 如权利要求17至22中任一项所述的方法,其特征在于,A method according to any one of claims 17 to 22, wherein
    所述第i前缀节点中包含第一指示信息,用于指示所述第j前缀集合所 对应的第二MBT子树中包含唯一一个前缀,所述第j前缀集合中的第一位置信息为所述唯一一个前缀在所述第二MBT子树中的节点位置编号,所述第一位置信息的长度等于所述第二步长;或者The ith prefix node includes first indication information, and is used to indicate the jth prefix set The corresponding second MBT subtree includes a unique prefix, and the first location information in the jth prefix set is a node location number of the unique prefix in the second MBT subtree, the first location The length of the information is equal to the second step; or
    所述第i前缀节点中包含第二指示信息,用于指示所述第j前缀集合所对应的第二MBT子树中包含至少2个前缀,所述第j前缀集合中的所述第一位置信息为位图,用于指示所述第二MBT子树中的所述至少2个前缀在该第二MBT子树中的位置,所述第一指示信息的长度为2stride-1,stride为所述第二步长。 The second i-prefix node includes second indication information, where the second MBT sub-tree corresponding to the j-th prefix set includes at least two prefixes, and the first location in the j-th prefix set The information is a bitmap, and is used to indicate a position of the at least two prefixes in the second MBT subtree in the second MBT subtree, where the length of the first indication information is 2 stride -1, and the stride is The second step.
PCT/CN2015/081357 2014-06-20 2015-06-12 Lookup device, lookup method and configuration method WO2015192742A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410280969.9A CN105227468B (en) 2014-06-20 2014-06-20 A kind of lookup device, lookup method and configuration method
CN201410280969.9 2014-06-20

Publications (1)

Publication Number Publication Date
WO2015192742A1 true WO2015192742A1 (en) 2015-12-23

Family

ID=54934863

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/081357 WO2015192742A1 (en) 2014-06-20 2015-06-12 Lookup device, lookup method and configuration method

Country Status (2)

Country Link
CN (1) CN105227468B (en)
WO (1) WO2015192742A1 (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107347035B (en) 2016-05-06 2020-05-08 华为技术有限公司 Route searching method and device, distribution node, searching node and entry node
CN107547409B (en) 2016-06-24 2020-12-25 华为技术有限公司 Route searching method and device and routing equipment
CN108347384B (en) * 2018-01-26 2020-12-01 乐鑫信息科技(上海)股份有限公司 One-to-many data packet transmission method suitable for mesh network
CN112565089B (en) * 2020-11-30 2022-06-21 锐捷网络股份有限公司 Method and device for processing routing information

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030189937A1 (en) * 2002-04-03 2003-10-09 Takeshi Kawasaki Address search method and search system using the same
CN101141389A (en) * 2007-09-29 2008-03-12 华为技术有限公司 Reinforcement multidigit Trie tree searching method and apparatus
CN101286935A (en) * 2008-05-07 2008-10-15 中兴通讯股份有限公司 Route searching method based on IP address scope
CN103270727A (en) * 2010-12-31 2013-08-28 瑞典爱立信有限公司 Bank aware multi-it trie

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7782853B2 (en) * 2002-12-06 2010-08-24 Stmicroelectronics, Inc. Apparatus and method of using fully configurable memory, multi-stage pipeline logic and an embedded processor to implement multi-bit trie algorithmic network search engine

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030189937A1 (en) * 2002-04-03 2003-10-09 Takeshi Kawasaki Address search method and search system using the same
CN101141389A (en) * 2007-09-29 2008-03-12 华为技术有限公司 Reinforcement multidigit Trie tree searching method and apparatus
CN101286935A (en) * 2008-05-07 2008-10-15 中兴通讯股份有限公司 Route searching method based on IP address scope
CN103270727A (en) * 2010-12-31 2013-08-28 瑞典爱立信有限公司 Bank aware multi-it trie

Also Published As

Publication number Publication date
CN105227468B (en) 2019-01-08
CN105227468A (en) 2016-01-06

Similar Documents

Publication Publication Date Title
US8856203B1 (en) System and method for algorithmic TCAM packet classification
US7725510B2 (en) Method and system for multi-character multi-pattern pattern matching
US20120066410A1 (en) Data structure, method and system for address lookup
US10164884B2 (en) Search apparatus, search configuration method, and search method
US11762826B2 (en) Search apparatus, search method, program and recording medium
KR100586461B1 (en) Method, Hardware Architecture and Recording Medium for Searching IP Address by Using Pipeline Binary Tree
TWI645694B (en) Apparatus and method for processing alternately configured longest prefix match tables
WO2015192742A1 (en) Lookup device, lookup method and configuration method
CN110858823B (en) Data packet classification method and device and computer readable storage medium
CN102045412B (en) Method and equipment for carrying out compressed storage on internet protocol version (IPv)6 address prefix
US10771386B2 (en) IP routing search
WO2011124030A1 (en) Method and device for storing routing table entry
WO2014047863A1 (en) Generating a shape graph for a routing table
Yang et al. Fast OpenFlow table lookup with fast update
US9021098B1 (en) Allocation of interface identifiers within network device having multiple forwarding components
CN110995876B (en) Method and device for storing and searching IP
Erdem et al. Hierarchical hybrid search structure for high performance packet classification
Kekely et al. Packet classification with limited memory resources
Matoušek et al. Memory efficient IP lookup in 100 GBPS networks
US10476785B2 (en) IP routing search
CN112565089B (en) Method and device for processing routing information
Matoušek et al. Towards hardware architecture for memory efficient IPv4/IPv6 Lookup in 100 Gbps networks
JP6205463B2 (en) SEARCH DEVICE, SEARCH METHOD, PROGRAM, AND RECORDING MEDIUM
Stefanakis Design and implementation of a range trie for address lookup

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

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 15809729

Country of ref document: EP

Kind code of ref document: A1