[go: up one dir, main page]

CN100496019C - A Method for Rapid Search and Update of IPv6 Routing Table - Google Patents

A Method for Rapid Search and Update of IPv6 Routing Table Download PDF

Info

Publication number
CN100496019C
CN100496019C CNB200510086841XA CN200510086841A CN100496019C CN 100496019 C CN100496019 C CN 100496019C CN B200510086841X A CNB200510086841X A CN B200510086841XA CN 200510086841 A CN200510086841 A CN 200510086841A CN 100496019 C CN100496019 C CN 100496019C
Authority
CN
China
Prior art keywords
prefix
length
htl
tree
entry
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
CNB200510086841XA
Other languages
Chinese (zh)
Other versions
CN1964311A (en
Inventor
孙庆南
鲁士文
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
YANTAI HUITONG NETWORK TECHNOLOGY Co Ltd
Original Assignee
Institute of Computing Technology of CAS
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 Institute of Computing Technology of CAS filed Critical Institute of Computing Technology of CAS
Priority to CNB200510086841XA priority Critical patent/CN100496019C/en
Publication of CN1964311A publication Critical patent/CN1964311A/en
Application granted granted Critical
Publication of CN100496019C publication Critical patent/CN100496019C/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Landscapes

  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

本发明涉及计算机网络技术领域,提供一种对IPv6路由表进行快速查找和更新的方法。其中路由表快速查找的方法包括使用一级线性索引表和二级的由二分查找树组织的hash表集合,进行两阶段的查找;路由表快速更新的方法包括使用BMP-tree重新组织数据结构中各前缀之间关系,改善更新效率;为了减小存储空间,设计了两种二分查找树构建方法;本发明与传统的多重查找表以及基于地址前缀长度的二分查找法相比,具有更加适用于IPv6网络、更快的查找和更新效率等优点。

Figure 200510086841

The invention relates to the technical field of computer networks and provides a method for quickly searching and updating an IPv6 routing table. The method of fast lookup of the routing table includes using a first-level linear index table and a second-level set of hash tables organized by a binary search tree to perform a two-stage lookup; the method of fast update of the routing table includes using BMP-tree to reorganize the data structure The relationship between each prefix improves the update efficiency; in order to reduce the storage space, two binary search tree construction methods are designed; compared with the traditional multiple lookup table and the binary search method based on the length of the address prefix, the present invention is more suitable for IPv6 Network, faster search and update efficiency and other advantages.

Figure 200510086841

Description

IPv6路由表快速查找和更新的方法 A Method for Rapid Search and Update of IPv6 Routing Table

技术领域 technical field

本发明涉及计算机网络技术领域,特别是一种基于IPv6地址实现快速路由表查找和更新的方法。The invention relates to the technical field of computer networks, in particular to a method for realizing fast routing table lookup and update based on IPv6 addresses.

背景技术 Background technique

路由表查找方法是路由器转发系统中的关键技术,查找效率的高低在很大程度上影响了路由器的转发效率。路由表查找的基本思想是,给定一个地址关键字,需要在路由表中查找到匹配这个地址关键字的最长的地址前缀,根据地址前缀的下一跳端口号进行后续的处理。与传统的只能完成对关键字精确匹配的查找相比,路由表查找的难度和复杂度大大增加。The routing table lookup method is the key technology in the router forwarding system, and the lookup efficiency affects the forwarding efficiency of the router to a great extent. The basic idea of routing table lookup is that, given an address keyword, it is necessary to find the longest address prefix matching the address keyword in the routing table, and perform subsequent processing according to the next-hop port number of the address prefix. Compared with the traditional search that can only complete the exact match of keywords, the difficulty and complexity of routing table search are greatly increased.

目前针对IPv4路由器开展研究的路由查找方法已有很多,最广泛应用的包括两大类查找方法,分别为基于trie树的方法和基于地址前缀长度的二分查找法。但是,随着IPv6网络的进一步普及,这些路由表查找方法都遇到了各自的局限。At present, there are many routing search methods for IPv4 routers. The most widely used methods include two types of search methods, namely the method based on the trie tree and the binary search method based on the length of the address prefix. However, with the further popularization of IPv6 networks, these routing table lookup methods have encountered their own limitations.

基于trie树的查找方法是这样的,trie是一种树结构,它利用地址前缀中的每一位bit的值来构造树的分支。trie的一种优化方法为多分支trie树,它采用地址前缀中的多个bit构造树的每一个节点,这样可以减小查找深度,却也带来了负面的影响。它的主要问题集中在步宽的选择上,步宽大,方法效率高,内存占用大;步宽小,方法效率低,内存占用少。人们虽然已经使用了各种压缩方法来试图解决这个问题,但是,在IPv4网络中,由于地址位数少,步宽的选择范围有限,这个问题还不是特别突出,IPv6128位的网络地址使得它的问题凸显出来,造成该方法查找性能严重下降。The search method based on the trie tree is like this. The trie is a tree structure that uses the value of each bit in the address prefix to construct the branches of the tree. An optimization method of the trie is a multi-branch trie tree, which uses multiple bits in the address prefix to construct each node of the tree, which can reduce the search depth, but also has a negative impact. Its main problem is focused on the choice of step width, the step width is large, the method efficiency is high, and the memory usage is large; the step width is small, the method efficiency is low, and the memory usage is small. Although people have used various compression methods to try to solve this problem, in the IPv4 network, due to the small number of address bits and the limited selection range of the step width, this problem is not particularly prominent. The 128-bit network address of IPv6 makes its The problem is highlighted, resulting in a serious decline in the search performance of this method.

相比较而言,基于地址前缀长度的二分查找法在IPv6网络中是性能效率比较好的一种查找方法,这个方法是在基于哈希表的线性查找方法基础上发展起来的。它的基本思想是将路由表根据不同的前缀长度进行分类,将具有相同长度的前缀组成一个哈希表,这样整个路由表将由多个哈希表组成。之后根据地址关键字的长度对这些哈希表进行二分查找,再根据哈希查找法直接定位到最长匹配的前缀。该方法的实施过程中会遇到一些细节的问题,例如对于前缀表1*,00*,111*,如果要查找的地址关键字为111,首先二分查找11*,在2位的哈希表中只有00*,没有11*,这时需要引入一个机制,在2位哈希表中添加一个marker 11*,这个marker不是实际的地址前缀,只是为了查找过程的需要。找到11*后,在前缀表的后面继续查找,此时可以找到111*。虽然IPv6地址长度的增加对该方法的影响不大,但是该方法的更新效率较差,由于前缀与前缀之间,前缀与marker之间的依赖关系较大,当一个前缀遇到添加、删除、更新等操作时,需要改动多个前缀或者marker的信息,如何找到这些需要改动的前缀或者marker是非常困难的。此外,这些更新操作,即使是通过优化,也需要在一段时间之后重构整个hash表集合。In comparison, the binary search method based on the length of the address prefix is a search method with better performance and efficiency in the IPv6 network. This method is developed on the basis of the linear search method based on the hash table. Its basic idea is to classify the routing table according to different prefix lengths, and form a hash table with prefixes of the same length, so that the entire routing table will be composed of multiple hash tables. Then perform a binary search on these hash tables according to the length of the address key, and then directly locate the longest matching prefix according to the hash search method. During the implementation of this method, some details will be encountered. For example, for the prefix table 1 * , 00 * , 111 * , if the address key to be searched is 111, first binary search 11 * , in the 2-bit hash table There is only 00 * in , and there is no 11 * . At this time, a mechanism needs to be introduced to add a marker 11 * to the 2-bit hash table. This marker is not the actual address prefix, but only for the needs of the search process. After finding 11 * , continue to search behind the prefix table, and you can find 111 * at this time. Although the increase of IPv6 address length has little effect on this method, the update efficiency of this method is poor. Due to the large dependency between prefixes and between prefixes and markers, when a prefix encounters addition, deletion, When updating and other operations, it is necessary to change the information of multiple prefixes or markers. How to find these prefixes or markers that need to be changed is very difficult. In addition, these update operations, even through optimization, require reconstruction of the entire set of hash tables after a period of time.

发明内容 Contents of the invention

本发明所要解决的技术问题在于提出一种适用于IPv6网络路由器的路由表查找和更新方法,特别是在保证了路由表查找效率的同时,有效的提高路由表的更新效率。该方法可以用于IPv6网络路由器转发系统中路由表的查找与更新。The technical problem to be solved by the present invention is to propose a routing table search and update method suitable for IPv6 network routers, especially to effectively improve the routing table update efficiency while ensuring the routing table search efficiency. The method can be used for searching and updating the routing table in the router forwarding system of the IPv6 network.

本发明是这样实现的:一种基于IPv6地址实现快速路由表查找和更新的方法,其特征在于:The present invention is achieved like this: a kind of method based on IPv6 address realizes fast routing table lookup and update, is characterized in that:

首先建立三种数据结构:First create three data structures:

(1)线性索引表,其中的每一个表项对应了零个、一个或者多个长度等于或者小于16的地址前缀;(1) A linear index table, where each entry corresponds to zero, one or more address prefixes whose length is equal to or less than 16;

(2)哈希表列表(Hash Table List,HTL),将路由表中所有长度小于等于16的前缀按照长度分类存储在不同的哈希(hash)表中,这些hash表的集合构成了HTL;(2) Hash Table List (Hash Table List, HTL), all the prefixes in the routing table whose length is less than or equal to 16 are stored in different hash tables according to the length classification, and the collection of these hash tables constitutes the HTL;

(3)基于二分查找树组织的哈希表列表(Binary tree—Hash Table List,B-HTL),将路由表中所有长度大于16的前缀按照长度分类存储在不同的hash表中,这些hash表通过二分查找树组织起来构成B-HTL;(3) Based on the hash table list (Binary tree—Hash Table List, B-HTL) organized by the binary search tree, all the prefixes in the routing table with a length greater than 16 are stored in different hash tables according to the length classification. These hash tables Organized to form B-HTL through binary search tree;

当一个IPv6协议的数据分组进入路由器之后,取出目的地址的高16bit,作为索引值定位到线性索引表的对应表项,如果该表项的标志位为0,则直接取出表项中的下一跳端口作为转发端口;否则,根据表项中存储的信息,在对应的B-HTL中利用二分查找树进行查找;When a data packet of the IPv6 protocol enters the router, the upper 16 bits of the destination address are taken out and used as an index value to locate the corresponding entry in the linear index table. If the flag bit of the entry is 0, the next entry in the entry is directly taken out The jump port is used as the forwarding port; otherwise, according to the information stored in the entry, use the binary search tree to search in the corresponding B-HTL;

利用HTL中存储的数据对线性索引表进行更新操作。Use the data stored in HTL to update the linear index table.

所述的基于IPv6地址实现快速路由表查找和更新的方法,所述线性索引表固定为64k个表项,每一个表项长度为3个字节,划分为3个部分,其中高16bit为第一部分,用来表示前缀长度或者指向B-HTL的指针;接下来的一个bit为标志位,用来表示第一部分所存储内容的含义;第三部分为最后7bit,表示该表项对应的下一跳路由端口;每一个线性索引表的表项唯一的对应了一个B-HTL。In the method for realizing fast routing table lookup and update based on IPv6 addresses, the linear index table is fixed at 64k entries, each entry is 3 bytes in length, and is divided into 3 parts, wherein the high 16bit is the first One part is used to indicate the prefix length or a pointer to B-HTL; the next bit is a flag bit, which is used to indicate the meaning of the content stored in the first part; the third part is the last 7 bits, indicating the next corresponding to the entry Jump routing port; each entry in the linear index table uniquely corresponds to a B-HTL.

所述线性索引表表项第一部分,当用来表示前缀长度时,其16bit的长度每一位都置1或者置0;当一个长度为n的地址前缀对应到某个线性索引表项时,该表项第一部分的第n位置1,否则置0。When the first part of the linear index entry is used to indicate the prefix length, each bit of the 16-bit length is set to 1 or 0; when an address prefix with a length of n corresponds to a certain linear index entry, The nth bit of the first part of the entry is set to 1, otherwise it is set to 0.

在所述线性索引表中执行更新操作时,如果要更新的前缀长度L小于等于16,先将表项第一部分中第L位置1,随后判断在高于L的位中是否存在为1的位,如果不存在,则根据标记位将线性索引表表项的第三部分改写为要更新前缀的端口号;When performing an update operation in the linear index table, if the prefix length L to be updated is less than or equal to 16, first set the L-th position in the first part of the entry to 1, and then judge whether there is a bit that is 1 among the bits higher than L , if it does not exist, rewrite the third part of the linear index table entry as the port number to update the prefix according to the flag bit;

在所述线性索引表中执行删除操作时,如果要删除的前缀长度L小于等于16,先将表项第一部分中第L位置置0,随后判断高于L的位中是否存在为1的位,如果存在,则在HTL对应前缀长度的hash表中删除该前缀;如果不存在,则在低于L的那些位中查找最高的值为1的位,并根据该位的位置在HTL中查找对应的前缀,将线性索引表表项第三部分改写为所查找到前缀的端口号。When performing a deletion operation in the linear index table, if the prefix length L to be deleted is less than or equal to 16, first set the L-th position in the first part of the entry to 0, and then determine whether there is a bit of 1 among the bits higher than L , if it exists, delete the prefix in the hash table corresponding to the length of the prefix in HTL; if it does not exist, look for the bit with the highest value of 1 among those bits lower than L, and look it up in HTL according to the position of the bit For the corresponding prefix, the third part of the linear index table entry is rewritten as the port number of the found prefix.

所述的基于IPv6地址实现快速路由表查找和更新的方法,执行路由表查找的操作包括如下步骤:The method for realizing fast routing table search and update based on IPv6 address, the operation of performing routing table search includes the following steps:

5A、取出IPv6分组目的地址的前16bit作为索引值,在线性索引表中查找对应的表项;5A, taking out the first 16 bits of the IPv6 packet destination address as an index value, and searching the corresponding entry in the linear index table;

5B、如果该表项的标记位为1,执行5D;5B. If the flag bit of the entry is 1, execute 5D;

5C、取得该表项对应的输出端口,执行5F;5C. Obtain the output port corresponding to the entry, and execute 5F;

5D、取出IPv6分组目的地址的后112bit;5D. Take out the last 112 bits of the IPv6 packet destination address;

5E、在线性索引表的表项中取得B-HTL指针,在对应的B-HTL5E. Obtain the B-HTL pointer in the entry of the linear index table, and obtain the B-HTL pointer in the corresponding B-HTL

中利用后112bit地址执行二分查找,取得对应的输出端口;Use the last 112bit address to perform a binary search to obtain the corresponding output port;

5F、结束。5F, end.

所述B-HTL的二分查找树的每一个节点都指向一个hash表;hash表中每一个表项包括以下几个部分:Each node of the binary search tree of the B-HTL points to a hash table; each entry in the hash table includes the following parts:

(1)长度为16byte的IPv6地址;(1) An IPv6 address with a length of 16 bytes;

(2)长度为7bit的下一跳端口号;(2) the next hop port number with a length of 7 bits;

(3)长度为1bit的标记位,用于表示该表项是否对应了一条长度大于16的地址前缀;(3) A flag bit with a length of 1 bit, which is used to indicate whether the entry corresponds to an address prefix with a length greater than 16;

(4)长度为1bit的标记位,用于表示该表项是否对应一个marker;(4) A marker bit with a length of 1 bit, used to indicate whether the entry corresponds to a marker;

(5)长度为8bit的最长匹配前缀(Best Matched Prefix,BMP),用于表示该表项对应的的最长地址前缀长度;(5) The longest matching prefix (Best Matched Prefix, BMP) with a length of 8 bits is used to indicate the length of the longest address prefix corresponding to the entry;

(6)长度为16bit的marker计数器,用于统计该表项上叠加的marker数量;(6) A marker counter with a length of 16 bits, which is used to count the number of markers superimposed on the entry;

(7)expand指针,指向一个最长匹配地址前缀树(BMP_tree)的根节点;(7) expand pointer, pointing to the root node of a longest matching address prefix tree (BMP_tree);

(8)next_level指针,指向BMP_tree中的下级节点;(8) The next_level pointer points to the lower-level node in the BMP_tree;

(9)same_level指针,指向BMP_tree中的同级节点。(9) The same_level pointer points to the same-level node in the BMP_tree.

所述BMP_tree由B-HTL中hash表的表项组成,每一个表项的expand指针唯一对应一棵BMP_tree,BMP_tree中的每一个节点都以该表项为前缀,并且根据节点中前缀的长度由低到高设置该节点在BMP_tree中的层次,具有同样前缀长度的节点处于BMP_tree的同一层;当对B-HTL进行添加、删除或更新操作时,通过BMP_tree查找那些需要改变的hash表表项。The BMP_tree is composed of entries of the hash table in the B-HTL, and the expand pointer of each entry uniquely corresponds to a BMP_tree, and each node in the BMP_tree is prefixed with the entry, and the length of the prefix in the node is determined by Set the level of the node in the BMP_tree from low to high, and the nodes with the same prefix length are in the same level of the BMP_tree; when adding, deleting or updating the B-HTL, look for those hash table entries that need to be changed through the BMP_tree.

所述的基于IPv6地址实现快速路由表查找和更新的方法,对B-HTL添加一个前缀P2时,执行如下步骤:The method for realizing fast routing table lookup and update based on IPv6 address, when adding a prefix P2 to B-HTL, perform the following steps:

8A、在B-HTL中查找P2的最长地址前缀节点P1;8A. Find the longest address prefix node P1 of P2 in B-HTL;

8B、在P1的BMP-tree中,遍历所有层次高于P2的前缀节点,分别执行8C、8D、8E;8B. In the BMP-tree of P1, traverse all prefix nodes whose levels are higher than P2, and execute 8C, 8D, and 8E respectively;

8C、如果遍历没有结束,那么执行8D,否则,执行8F;8C. If the traversal is not over, execute 8D; otherwise, execute 8F;

8D、如果P2是该节点的前缀,那么执行8E,否则遍历到下一个节点,执行8C;8D. If P2 is the prefix of the node, then execute 8E, otherwise traverse to the next node and execute 8C;

8E、从P1的BMP-tree中取出该节点,移动到P2的BMP-tree中,遍历到下一个节点,执行8C;8E. Take out the node from the BMP-tree of P1, move to the BMP-tree of P2, traverse to the next node, and execute 8C;

8F、为P2在B-HTL中添加marker;8F, add marker in B-HTL for P2;

8G、将P2添加到P1的BMP-tree中;8G. Add P2 to the BMP-tree of P1;

8H、结束。8H, end.

所述的基于IPv6地址实现快速路由表查找和更新的方法,对B-HTL删除一个前缀P2时,执行如下步骤:The method for realizing fast routing table lookup and update based on IPv6 address, when deleting a prefix P2 to B-HTL, perform the following steps:

9A、在B-HTL中查找P2的最长地址前缀节点P1;9A. Find the longest address prefix node P1 of P2 in B-HTL;

9B、在P1的BMP-tree中,遍历所有层次高于P2的前缀节点,分别执行9C、9D、9E;9B. In the BMP-tree of P1, traverse all prefix nodes whose levels are higher than P2, and execute 9C, 9D, and 9E respectively;

9C、如果遍历没有结束,那么执行9D,否则,执行9F;9C. If the traversal is not over, execute 9D; otherwise, execute 9F;

9D、如果该节点是P2的前缀,那么执行9E,否则遍历到下一个节点,执行9C;9D. If the node is the prefix of P2, then execute 9E, otherwise traverse to the next node and execute 9C;

9E、修改该节点数据结构存储的信息,遍历到下一个节点,执行9C;9E. Modify the information stored in the data structure of the node, traverse to the next node, and execute 9C;

9F、取出P2的BMP-tree,并入P1的BMP-tree;9F. Take out the BMP-tree of P2 and merge it into the BMP-tree of P1;

9G、删除P2的前缀信息;9G. Delete the prefix information of P2;

9H、结束。9H, end.

所述B-HTL中每一个hash表对应了唯一的地址前缀长度,B-HTL中所有的hash表对应了一个地址前缀长度区间;所述二分查找树在这个前缀长度区间范围内构建,二分查找树的每一个节点覆盖B-HTL的一部分地址前缀长度区间,该节点对应的hash表的前缀长度也在这部分地址前缀长度区间中,并且将这部分地址前缀长度区间划分为两个子区间,该两个子区间分别对应该节点的左右两个子节点;在任意一个节点对应的地址前缀长度区间中,选择表项数量最多的一个hash表作为所述任意节点对应的hash表。Each hash table in the B-HTL corresponds to a unique address prefix length, and all hash tables in the B-HTL correspond to an address prefix length interval; the binary search tree is constructed within this prefix length interval, and the binary search Each node of the tree covers a part of the address prefix length interval of B-HTL, the prefix length of the hash table corresponding to this node is also in this part of the address prefix length interval, and this part of the address prefix length interval is divided into two sub-intervals, the The two sub-intervals correspond to the left and right sub-nodes of the node; in the address prefix length interval corresponding to any node, a hash table with the largest number of entries is selected as the hash table corresponding to the arbitrary node.

所述B-HTL中每一个hash表对应了唯一的地址前缀长度,B-HTL中所有的hash表对应了一个地址前缀长度区间;所述二分查找树在这个前缀长度区间范围内构建,二分查找树的每一个节点覆盖B-HTL的一部分地址前缀长度区间,该节点对应的hash表的前缀长度也在这部分地址前缀长度区间中,并且将这部分地址前缀长度区间划分为两个子区间,分别对应该节点的左右两个子节点;在任意一个节点对应的地址前缀长度区间中,选择一个hash表,用这个hash表将地址前缀长度区间划分为两个子区间,使得第一个子区间中hash表表项数量和与第二个子区间中hash表表项数量和最接近,则这个hash表作为该节点对应的hash表。Each hash table in the B-HTL corresponds to a unique address prefix length, and all hash tables in the B-HTL correspond to an address prefix length interval; the binary search tree is constructed within this prefix length interval, and the binary search Each node of the tree covers a part of the address prefix length interval of B-HTL, the prefix length of the hash table corresponding to this node is also in this part of the address prefix length interval, and this part of the address prefix length interval is divided into two sub-intervals, respectively Corresponding to the left and right sub-nodes of the node; in the address prefix length interval corresponding to any node, select a hash table, and use this hash table to divide the address prefix length interval into two sub-intervals, so that the hash table in the first sub-interval If the sum of entries is the closest to the sum of entries in the hash table in the second subinterval, then this hash table is used as the hash table corresponding to the node.

本发明采用两级查找和三种数据结构的模式,通过一级线性索引,将整个地址空间划分为64k个部分,在保证了原有的基于地址前缀的二分查找法效率的同时,每一次路由表的更新操作只需要在64k个地址空间中的一个里面进行,而无需改动其它地址空间中的路由表,提高了路由表更新和重构的效率。同时,在基于地址前缀的二分查找法的数据结构B-HTL中,增加了被称为BMP_tree的数据组织方式,通过这种数据组织方式,减少了路由表更新操作中所需要访问的hash表表项,进一步提高了路由表更新的效率。The present invention adopts two-level search and three data structure modes, and divides the entire address space into 64k parts through a first-level linear index. While ensuring the efficiency of the original binary search method based on address prefixes, each routing The update operation of the table only needs to be carried out in one of the 64k address spaces without changing the routing tables in other address spaces, which improves the efficiency of updating and reconstructing the routing table. At the same time, in the data structure B-HTL of the binary search method based on the address prefix, a data organization method called BMP_tree is added. Through this data organization method, the hash table that needs to be accessed in the routing table update operation is reduced. item, which further improves the efficiency of routing table update.

附图说明 Description of drawings

图1是IPv6地址格式示意图。Figure 1 is a schematic diagram of the IPv6 address format.

图2是本发明所使用数据结构的相互关系图。Fig. 2 is an interrelationship diagram of data structures used in the present invention.

图3是线性索引表表项结构示意图。FIG. 3 is a schematic diagram of the structure of entries in the linear index table.

图4是应用本发明进行路由表查找的流程图。Fig. 4 is a flow chart of routing table search by applying the present invention.

图5是本发明中BMP-tree结构示意图。Fig. 5 is a schematic diagram of the BMP-tree structure in the present invention.

图6(a)是在B-HTL中添加前缀P2的流程图。Fig. 6(a) is a flow chart of adding prefix P2 in B-HTL.

图6(b)是在B-HTL中删除前缀P2的流程图。Fig. 6(b) is a flow chart of deleting prefix P2 in B-HTL.

图7(a)是IPv4路由表中地址前缀按照长度的分布统计图。Fig. 7(a) is a statistical diagram of the distribution of address prefixes according to the length in the IPv4 routing table.

图7(b)是IPv6路由表中地址前缀按照长度的分布统计图。Fig. 7(b) is a statistical diagram of the distribution of address prefixes according to the length in the IPv6 routing table.

具体实施方式 Detailed ways

下面结合附图和实施例,对本发明做进一步的详细阐述.Below in conjunction with accompanying drawing and embodiment, the present invention is described in further detail.

在RFC2373、RFC2374中提出了可聚集的全球单播地址格式方案,该方案将IPv6地址划分为若干段,其中前64位为网络ID,后64位为接口ID。在网络ID中,又划分出若干网络层次,不同的子网地址由不同的互联网机构负责分配。因此,本发明取路由表地址前缀的前16位,即顶极聚集标识符所对应的范围,作为一级线性索引的索引值,并且构建HTL,再根据剩余的112位地址组成B-HTL,在其中进行二分法查找,如图1所示数据结构示意图如图2所示。其主要分为三种数据结构:线性索引表、HTL以及B-HTL。其中,B-HTL由一组hash表组成,每一个B-HTL对应线性索引表中的一个表项。B-HTL来源于基于地址前缀空间的二分查找发所使用的数据结构,只不过它的hash表中存储的地址前缀前16位都相同,都是对应的线性索引表表项的索引值。In RFC2373 and RFC2374, an aggregated global unicast address format scheme is proposed, which divides the IPv6 address into several segments, in which the first 64 bits are the network ID, and the last 64 bits are the interface ID. In the network ID, several network levels are divided, and different subnet addresses are assigned by different Internet organizations. Therefore, the present invention takes the first 16 bits of the address prefix of the routing table, that is, the range corresponding to the top-level aggregate identifier, as the index value of the first-level linear index, and constructs the HTL, and then forms the B-HTL according to the remaining 112-bit address, The dichotomy search is performed in it, and the schematic diagram of the data structure shown in FIG. 1 is shown in FIG. 2 . It is mainly divided into three data structures: linear index table, HTL and B-HTL. Wherein, the B-HTL is composed of a group of hash tables, and each B-HTL corresponds to an entry in the linear index table. B-HTL is derived from the data structure used by the binary search based on the address prefix space, except that the first 16 bits of the address prefix stored in its hash table are the same, which are the index values of the corresponding linear index table entries.

线性索引表每个表项的结构如图3所示,它有两种格式:The structure of each entry in the linear index table is shown in Figure 3. It has two formats:

当标记位为0时,表示在路由表中不存在以这个16位地址前缀为起始的长度大于16的其它的地址前缀,此时表项前16位用来表示掩码长度,即指示出有多少不同长度的前缀都对应到该表项;表项后7位为输出端口,也就是对应到该表项中前缀长度最长的一个路由表前缀的输出端口。When the flag bit is 0, it means that there is no other address prefix starting with this 16-bit address prefix in the routing table and the length is greater than 16. At this time, the first 16 bits of the entry are used to indicate the mask length, that is, indicate How many prefixes of different lengths correspond to this entry; the last 7 bits of the entry are the output port, that is, the output port corresponding to the routing table prefix with the longest prefix length in the entry.

当标记位为1时,表示存在长度大于16的地址前缀,此时表项前16位用来作为指针指向一个B-HTL,以便在其中执行基于地址前缀长度的二分查找法查找最长匹配前缀;表项后7位此时没有意义,需置0。When the flag bit is 1, it means that there is an address prefix with a length greater than 16. At this time, the first 16 bits of the entry are used as a pointer to point to a B-HTL, so as to perform a binary search method based on the length of the address prefix to find the longest matching prefix. ;The last 7 bits of the entry are meaningless at this time and need to be set to 0.

由于线性索引表查找的效率远远大于hash查找,而且,如果能将该一级索引表放置于缓存中,其查找时间更可以忽略不计。最重要的是,线性索引表将地址前缀空间划分为若干个子空间,对每一个子空间内地址前缀的添加、删除和重构数据结构,都不会影响到其它子空间的地址前缀。Since the efficiency of linear index table lookup is far greater than that of hash lookup, and if the first-level index table can be placed in the cache, the lookup time can be ignored. The most important thing is that the linear index table divides the address prefix space into several subspaces, adding, deleting and reconstructing the data structure of the address prefix in each subspace will not affect the address prefixes of other subspaces.

当一个IPv6的分组进入路由器之后,路由表查找方法流程图如图4所示。首先取出IPv6分组的目的地址的前16bit,用这16bit的内容作为索引值,假设这个值为N,直接定位到线性索引表的第N个表项上。如果该表项的标记位为0,说明在路由表中,没有以这16bit内容开头的长度大于16的前缀,此时直接取出该表项的第三部分输出端口,作为这个IPv6分组的转发端口,结束一次查找;如果该表项的标记位为1,说明在路由表中存在以这16bit内容开头的长度大于16的前缀,为了找到这个前缀,需要取出该表项的第一部分,当标记位为1时,第一部分存放着B-HTL的指针,由这个指针定位到对应的B-HTL,在B-HTL中根据IPv6目的地址的后112bit的内容进行二分法查找。此后与基于地址前缀长度的二分查找方法类似,直到找到最长匹配的路由表前缀,取出对应的下一跳端口号,结束一次查找。After an IPv6 packet enters the router, the flow chart of the routing table lookup method is shown in FIG. 4 . Firstly, the first 16 bits of the destination address of the IPv6 packet are taken out, and the content of the 16 bits is used as an index value, assuming that this value is N, and directly located on the Nth entry of the linear index table. If the flag bit of the entry is 0, it means that in the routing table, there is no prefix with a length greater than 16 starting with the 16bit content. At this time, the third part of the output port of the entry is directly taken out as the forwarding port of the IPv6 packet. , to end a search; if the flag bit of the entry is 1, it means that there is a prefix whose length is greater than 16 and starts with the 16bit content in the routing table. In order to find this prefix, it is necessary to take out the first part of the entry, when the flag bit When it is 1, the first part stores the B-HTL pointer, and the corresponding B-HTL is located by this pointer, and the binary search is performed in the B-HTL according to the content of the last 112 bits of the IPv6 destination address. After that, it is similar to the binary search method based on the address prefix length, until the longest matching routing table prefix is found, the corresponding next-hop port number is taken out, and a search ends.

原始的基于地址前缀的二分查找法更新效率很低,时间复杂度达到了O(N*logW)。在路由表很大的情况下,由于网络中路由表更新的频繁发生,这样的效率无法接受。原始查找方法中影响更新效率的关键因素在于:如何找到那些需要进行更新的marker。The update efficiency of the original binary search method based on the address prefix is very low, and the time complexity reaches O(N*logW). In the case of large routing tables, such efficiency is unacceptable due to the frequent occurrence of routing table updates in the network. The key factor affecting the update efficiency in the original search method is: how to find the markers that need to be updated.

对marker的更新包括如下几种情况。The update of the marker includes the following situations.

●替换一个地址前缀时,由于不影响该前缀节点的marker,所以只需简单替换即可。●When replacing an address prefix, since it does not affect the marker of the prefix node, it only needs to be replaced simply.

●插入一个地址前缀时,需要为该前缀添加查找时需要的marker,同时需要将以该前缀作为BMP(Best Matched Prefix)的所有marker的BMP改写为该前缀。●When inserting an address prefix, you need to add the marker required for the search to the prefix, and at the same time, you need to rewrite the BMPs of all markers with this prefix as BMP (Best Matched Prefix) to this prefix.

●删除一个前缀时,需要删除该前缀所对应的marker,注意如果某个marker有复用的情况,则不能被删除,同时需要将以该前缀作为BMP的所有marker的BMP改写为该前缀的BMP。●When deleting a prefix, you need to delete the marker corresponding to the prefix. Note that if a marker is reused, it cannot be deleted. At the same time, you need to rewrite the BMP of all markers with this prefix as BMP to the BMP of this prefix .

通过分析可知,更新一条地址前缀记录p/l时(p为前缀地址,l为前缀长度),原始查找方法需要更新两类marker,第一类是长度小于l的marker,这类marker供二分查找时使用;第二类是其BMP为p/l的marker,这类marker的作用是为了避免回溯。对第一类marker的更新较为简单,因为p的地址是已知的,它所对应的第一类marker可以直接通过在对应长度的hash表中进行hash查找获得。而第二类marker代表了p/l的前缀扩展,由于并不知道p/l在路由表中有哪些前缀扩展,因此需要遍历所有长度大于l的hash表,或者是在所有长度大于l的hash表中对前缀为p/l的完备集合进行hash查找,这个效率十分低下。Through the analysis, it can be known that when updating an address prefix record p/l (p is the prefix address, l is the prefix length), the original search method needs to update two types of markers, the first type is a marker whose length is less than l, and this type of marker is used for binary search used; the second type is a marker whose BMP is p/l, and the function of this type of marker is to avoid backtracking. The update of the first type of marker is relatively simple, because the address of p is known, and the corresponding first type of marker can be directly obtained by performing a hash lookup in the hash table of the corresponding length. The second type of marker represents the prefix extension of p/l. Since we don't know which prefix extensions p/l has in the routing table, it is necessary to traverse all hash tables with a length greater than l, or in all hashes with a length greater than l It is very inefficient to perform hash lookup on the complete set prefixed with p/l in the table.

一个简单的方法是,在构建数据结构的时候,将每个前缀表项的第二类marker通过线性链表链接起来,这样可以大大缩小查找的范围。但是,这样的查找方法执行效率仍有提高的空间。因此,本发明使用树型数据结构,BMP-tree,用来组织具有同样BMP的表项。A simple method is to link the second-type markers of each prefix entry through a linear linked list when building the data structure, which can greatly reduce the search scope. However, there is still room for improvement in the execution efficiency of such a search method. Therefore, the present invention uses a tree data structure, BMP-tree, to organize entries with the same BMP.

并不是所有的marker都有最长匹配前缀。为了一致性,在hash表中添加了两个伪前缀hash表项,在本实施例中,这两个伪前缀表项添加在长度为17的hash表中。假设这个hash表列表中所有的表项都有共同的前缀p/16,那么添加的两个伪前缀表项分别为{p,0}/17和{p,1}/17。Not all markers have a longest matching prefix. For consistency, two pseudo-prefix hash entries are added to the hash table. In this embodiment, these two pseudo-prefix entries are added to the hash table with a length of 17. Assuming that all entries in this hash table list have a common prefix p/16, then the added two pseudo-prefix entries are {p, 0}/17 and {p, 1}/17 respectively.

如图5(a)所示为BMP-tree数据结构示意图。其中图5(a)是前缀P2删除前(或添加后),图5(b)是前缀P2删除后(或添加前)。左边为二分搜索树,表明了各hash表之间的关系。右边为hash表列表以及hash表中各表项组成的BMP-tree,其中p表示该表项为纯前缀,m表示该表项为纯marker,b表示该表项既是一个前缀,也是一个marker,它们使用同一个hash表项。Figure 5(a) is a schematic diagram of the BMP-tree data structure. Figure 5(a) is before the prefix P2 is deleted (or added), and Figure 5(b) is after the prefix P2 is deleted (or added). The binary search tree on the left shows the relationship between the hash tables. On the right is the list of hash tables and the BMP-tree composed of entries in the hash table, where p indicates that the entry is a pure prefix, m indicates that the entry is a pure marker, and b indicates that the entry is both a prefix and a marker. They use the same hash entry.

对于一个hash表项而言,如果它代表了一个前缀,即标记为p或者b,那么它有一个指针指向它所对应的BMP-tree,BMP-tree中的每一个节点都是以该前缀作为BMP(最长匹配前缀)的hash表项。对BMP-tree中每一个父节点来说,它的左子节点的前缀长度大于父节点的前缀长度,而它的右子节点的前缀长度等于父节点的前缀长度。将从根节点开始,将所有左子节点组成的唯一一条路径称作该BMP-tree的主干,将主干上某一节点开始所有右节点组成的路径成为该BMP-tree的长度为l的支干,其中l为该支干上所有节点的前缀长度。For a hash entry, if it represents a prefix, that is, it is marked as p or b, then it has a pointer to its corresponding BMP-tree, and each node in the BMP-tree uses this prefix as BMP (longest matching prefix) hash entry. For each parent node in the BMP-tree, the prefix length of its left child node is greater than the prefix length of the parent node, and the prefix length of its right child node is equal to the prefix length of the parent node. Starting from the root node, the only path composed of all left child nodes is called the backbone of the BMP-tree, and the path composed of all right nodes starting from a node on the trunk becomes the branch of the BMP-tree with a length of l , where l is the prefix length of all nodes on the branch.

图中标记为P1的表项对应了一棵BMP-tree,用浅色节点表示。标记为P2的表项对应了另外一棵BMP-tree,用深色节点表示。可知,P2的BMP是P1。删除表项P2时,首先更新P2的第一类marker,如果该marker需要被删除,则在P1的BMP-tree中搜索那些长度小于P2的前缀长度的支干。然后更新P2的第二类marker,此时只需将P2的BMP-tree中所有节点的BMP都改写为P1,然后把P2的BMP-tree合并到P1的BMP-tree中即可,合并后的数据结构如图5(b)所示,其流程图见图6(a)。The entry marked as P1 in the figure corresponds to a BMP-tree, which is represented by a light-colored node. The entry marked as P2 corresponds to another BMP-tree, represented by a dark node. It can be seen that the BMP of P2 is P1. When deleting entry P2, first update the first type of marker of P2, and if the marker needs to be deleted, search for those branches whose length is less than the prefix length of P2 in the BMP-tree of P1. Then update the second type of marker of P2. At this time, you only need to rewrite the BMP of all nodes in the BMP-tree of P2 to P1, and then merge the BMP-tree of P2 into the BMP-tree of P1. The merged The data structure is shown in Figure 5(b), and its flow chart is shown in Figure 6(a).

添加路由前缀的操作与删除操作类似。例如在图5(b)所示的数据结构中添加前缀P2,首先要添加P2的第一类marker,如果涉及到新增表项的操作,那么要在P2的BMP,也就是P1的BMP-tree中对应长度的支干上添加节点。然后要构造P2的BMP-tree,在P1的BMP-tree中长度大于P2的前缀长度的支干中线性搜索,查找那些以P2为前缀的节点,将其BMP改写为P2,并且把它们从P1的BMP-tree中剪切出来,添加到P2的BMP-tree中即可。添加前缀的流程图见图6(b)。The operation of adding a route prefix is similar to the operation of deleting it. For example, to add the prefix P2 to the data structure shown in Figure 5(b), you must first add the first type of marker of P2. If the operation of adding an entry is involved, then you must add the P2 BMP, that is, the P1 BMP- Add nodes on the branches of the corresponding length in the tree. Then to construct the BMP-tree of P2, search linearly in the branch of the BMP-tree of P1 whose length is greater than the prefix length of P2, find those nodes prefixed with P2, rewrite its BMP to P2, and transfer them from P1 Cut it from the BMP-tree of the P2 and add it to the BMP-tree of P2. The flow chart of adding prefixes is shown in Figure 6(b).

通过引入BMP-tree,前缀表项的删除操作变得十分快捷,如果使用双向链表,那么删除操作的时间复杂度可以控制在O(kWlogW),其中k为单次操作链表所需内存访问次数,比起原有的需要线性搜索的方法来说效率大大提高。而添加路由表项的操作效率还不是太好,但是相比原有的方法来说,引入BMP-tree之后,可以根据地址前缀的长度,排除大量的备选表项,也在一定程度上提高了效率。By introducing BMP-tree, the deletion operation of the prefix entry becomes very fast. If a doubly linked list is used, the time complexity of the deletion operation can be controlled at O(kWlogW), where k is the number of memory accesses required for a single operation of the linked list, Compared with the original method that requires linear search, the efficiency is greatly improved. The operation efficiency of adding routing entries is not very good, but compared with the original method, after the introduction of BMP-tree, a large number of alternative entries can be excluded according to the length of the address prefix, which is also improved to a certain extent. efficiency.

图6(a)是在B-HTL中添加前缀P2的流程图。图7(a)所示为IPv4主干网路由器中路由前缀按照长度分布的统计直方图。在图中可以看到,不同长度的前缀在路由表中的数量是不同的,有特定的分布特征。如果充分利用这些特征,可以有效改善查找方法的平均效率。图6(b)是在B-HTL中删除前缀P2的流程图。类似的,如图7(b)所示为IPv6主干网路由器的路由前缀按长度分布统计直方图(仅显示了前64位网络地址)。Fig. 6(a) is a flow chart of adding prefix P2 in B-HTL. Figure 7(a) shows the statistical histogram of routing prefix distribution according to the length in IPv4 backbone network routers. It can be seen from the figure that the number of prefixes of different lengths in the routing table is different, and has specific distribution characteristics. If these features are fully utilized, the average efficiency of the search method can be effectively improved. Fig. 6(b) is a flow chart of deleting prefix P2 in B-HTL. Similarly, Figure 7(b) shows the statistical histogram of the distribution of routing prefixes of IPv6 backbone network routers according to their length (only the first 64 network addresses are shown).

为了简化说明,以IPv4路由表为例来说明采用不同的二分搜索树对于查找效率的影响,如图7所示,图7(a)是IPv4路由表中地址前缀按照长度的分布统计图。In order to simplify the description, the IPv4 routing table is taken as an example to illustrate the impact of using different binary search trees on the search efficiency, as shown in Figure 7, Figure 7 (a) is a statistical diagram of the distribution of address prefixes in the IPv4 routing table according to their length.

图7(b)是IPv6路由表中地址前缀按照长度的分布统计图。如果使用平衡二分搜索树进行查找,虽然一些hash表的前缀数量占有优势,但是它所处的位置位于搜索树较深的层次,对于大部分的搜索任务来说,需要更多的内存访问才能完成一次查找。而如果通过对二分搜索路径进行设计,将拥有前缀数量较多的hash表置于较高的层次,虽然增加了树的最大深度,使得最大搜索深度增加,但是改善了平均效率。Fig. 7(b) is a statistical diagram of the distribution of address prefixes according to the length in the IPv6 routing table. If you use a balanced binary search tree to search, although some hash tables have an advantage in the number of prefixes, they are located at a deeper level in the search tree. For most search tasks, more memory access is required to complete Find it once. However, if the binary search path is designed and the hash table with a large number of prefixes is placed at a higher level, although the maximum depth of the tree is increased, the maximum search depth is increased, but the average efficiency is improved.

此外,传统的基于地址前缀长度的二分查找法对marker的引入必然带来内存的额外消耗。由于一些marker可以与真正的路由前缀信息复用同样的内存空间,marker对空间效率的影响在一定程度上是可以控制的。为此,本实施例使用了两种不同的搜索树结构方案,尽量减少marker对内存空间的占用。In addition, the introduction of the traditional binary search method based on the address prefix length will inevitably lead to additional consumption of memory. Since some markers can reuse the same memory space as the real routing prefix information, the impact of markers on space efficiency can be controlled to a certain extent. For this reason, this embodiment uses two different search tree structure schemes to minimize the occupation of memory space by markers.

方案一使用包含前缀数量较多的hash表构成搜索树的上层节点,可以使marker有最大的可能与真正的路由前缀信息复用内存空间;方案二出于这样的考虑,对于二分搜索树中的某个节点,它的右子树中的前缀信息会在这个节点生成一个marker,如果能够尽量缩减右子树的大小,会大大降低marker的数量。一个极限情况是这棵二叉树中每一个节点只有左子节点,这样不需要额外的marker的存储,但是二叉树退化到线性搜索。为此,方案二采用了平衡左右子树的方法,在选择父节点时,其左右子树中前缀的数量尽可能相等,最好是左节点中前缀数量略大于右节点中前缀数量。Solution 1 uses a hash table with a large number of prefixes to form the upper node of the search tree, which can make the marker have the greatest possibility of multiplexing the memory space with the real routing prefix information; solution 2 is based on this consideration, for the binary search tree For a node, the prefix information in its right subtree will generate a marker at this node. If the size of the right subtree can be reduced as much as possible, the number of markers will be greatly reduced. A limit case is that each node in the binary tree has only left child nodes, so no additional marker storage is required, but the binary tree degenerates to linear search. For this reason, Scheme 2 adopts the method of balancing the left and right subtrees. When selecting a parent node, the number of prefixes in the left and right subtrees should be as equal as possible. It is best that the number of prefixes in the left node is slightly greater than the number of prefixes in the right node.

两种构造搜索树结构的方案都在很大程度上提高了搜索方法的效率,并且减少了marker的存储。The two schemes for constructing the search tree structure greatly improve the efficiency of the search method and reduce the storage of markers.

由上可知,本发明在基于地址前缀长度的二分查找法基础上,使用了两级的查找模式,通过第一级的线性索引表分隔了地址前缀空间,减小了不同子空间内地址前缀更新时的相互影响,也保证了查找的效率;在基于地址前缀长度的二分查找法所使用的数据结构中增加了一种数据组织方式BMP-tree,进一步减少了路由表更新时的开销;最后,本发明提供了两种不同的二分查找树组织方式,减小了存储的开销。As can be seen from the above, on the basis of the binary search method based on the length of the address prefix, the present invention uses a two-level search mode, separates the address prefix space through the first-level linear index table, and reduces the update of address prefixes in different subspaces. The mutual influence of time also ensures the efficiency of the search; a data organization method BMP-tree is added to the data structure used in the binary search method based on the length of the address prefix, which further reduces the overhead of updating the routing table; finally, The present invention provides two different binary search tree organization modes, which reduces storage overhead.

Claims (11)

1、一种基于IPv6地址实现快速路由表查找和更新的方法,其特征在于:1, a kind of method based on IPv6 address realizes fast routing table lookup and update, is characterized in that: 首先建立三种数据结构:First create three data structures: (1)线性索引表,其中的每一个表项对应了零个、一个或者多个长度等于或者小于16的地址前缀;(1) A linear index table, where each entry corresponds to zero, one or more address prefixes whose length is equal to or less than 16; (2)哈希表列表HTL,将路由表中所有长度小于等于16的前缀按照长度分类存储在不同的hash表中,这些哈希hash表的集合构成了HTL;(2) Hash table list HTL, all prefixes in the routing table whose length is less than or equal to 16 are stored in different hash tables according to the length classification, and the collection of these hash hash tables constitutes the HTL; (3)基于二分查找树组织的哈希表列表B-HTL,将路由表中所有长度大于16的前缀按照长度分类存储在不同的hash表中,这些hash表通过二分查找树组织起来构成B-HTL;(3) Based on the hash table list B-HTL organized by the binary search tree, all the prefixes in the routing table with a length greater than 16 are stored in different hash tables according to the length classification, and these hash tables are organized through the binary search tree to form B-HTL HTL; 当一个IPv6协议的数据分组进入路由器之后,取出目的地址的高16bit,作为索引值定位到线性索引表的对应表项,如果该表项的标志位为0,则直接取出表项中的下一跳端口作为转发端口;否则,根据表项中存储的信息,在对应的B-HTL中利用二分查找树进行查找;When a data packet of the IPv6 protocol enters the router, the upper 16 bits of the destination address are taken out and used as an index value to locate the corresponding entry in the linear index table. If the flag bit of the entry is 0, the next entry in the entry is directly taken out The jump port is used as the forwarding port; otherwise, according to the information stored in the entry, use the binary search tree to search in the corresponding B-HTL; 利用HTL中存储的数据对线性索引表进行更新操作。Use the data stored in HTL to update the linear index table. 2、根据权利要求1所述的基于IPv6地址实现快速路由表查找和更新的方法,其特征在于:所述线性索引表固定为64k个表项,每一个表项长度为3个字节,划分为3个部分,其中高16bit为第一部分,用来表示前缀长度或者指向B-HTL的指针;接下来的一个bit为标志位,用来表示第一部分所存储内容的含义;第三部分为最后7bit,表示该表项对应的下一跳路由端口;每一个线性索引表的表项唯一的对应了一个B-HTL。2. The method for realizing fast routing table lookup and update based on IPv6 address according to claim 1, characterized in that: the linear index table is fixed to 64k entries, and the length of each entry is 3 bytes, divided into It consists of 3 parts, of which the high 16bit is the first part, which is used to indicate the length of the prefix or the pointer to the B-HTL; the next bit is a flag bit, which is used to indicate the meaning of the content stored in the first part; the third part is the last 7bit, indicating the next-hop routing port corresponding to the entry; each entry in the linear index table uniquely corresponds to a B-HTL. 3、根据权利要求2所述的基于IPv6地址实现快速路由表查找和更新的方法,其特征在于:所述线性索引表表项第一部分,当用来表示前缀长度时,其16bit的长度每一位都置1或者置0;当一个长度为n的地址前缀对应到某个线性索引表项时,该表项第一部分的第n位置1,否则置0。3. The method for realizing fast routing table lookup and update based on IPv6 address according to claim 2, characterized in that: the first part of the linear index table entry, when used to represent the prefix length, has a length of 16 bits each Bits are all set to 1 or 0; when an address prefix of length n corresponds to a certain linear index entry, the nth bit of the first part of the entry is set to 1, otherwise it is set to 0. 4、根据权利要求3所述的基于IPv6地址实现快速路由表查找和更新的方法,其特征在于:4. The method for realizing fast routing table search and update based on IPv6 address according to claim 3, characterized in that: 在所述线性索引表中执行更新操作时,如果要更新的前缀长度L小于等于16,先将表项第一部分中第L位置1,随后判断在高于L的位中是否存在为1的位,如果不存在,则根据标记位将线性索引表表项的第三部分改写为要更新前缀的端口号;When performing an update operation in the linear index table, if the prefix length L to be updated is less than or equal to 16, first set the L-th position in the first part of the entry to 1, and then judge whether there is a bit that is 1 among the bits higher than L , if it does not exist, rewrite the third part of the linear index table entry as the port number to update the prefix according to the flag bit; 在所述线性索引表中执行删除操作时,如果要删除的前缀长度L小于等于16,先将表项第一部分中第L位置置0,随后判断高于L的位中是否存在为1的位,如果存在,则在HTL对应前缀长度的hash表中删除该前缀;如果不存在,则在低于L的那些位中查找最高的值为1的位,并根据该位的位置在HTL中查找对应的前缀,将线性索引表表项第三部分改写为所查找到前缀的端口号。When performing a deletion operation in the linear index table, if the prefix length L to be deleted is less than or equal to 16, first set the L-th position in the first part of the entry to 0, and then determine whether there is a bit of 1 among the bits higher than L , if it exists, delete the prefix in the hash table corresponding to the length of the prefix in HTL; if it does not exist, look for the bit with the highest value of 1 among those bits lower than L, and look it up in HTL according to the position of the bit For the corresponding prefix, the third part of the linear index table entry is rewritten as the port number of the found prefix. 5、根据权利要求2所述的基于IPv6地址实现快速路由表查找和更新的方法,其特征在于:执行路由表查找的操作包括如下步骤:5. The method for realizing fast routing table search and update based on IPv6 address according to claim 2, characterized in that: the operation of performing routing table search comprises the steps of: 5A、取出IPv6分组目的地址的前16bit作为索引值,在线性索引表中查找对应的表项;5A, taking out the first 16 bits of the IPv6 packet destination address as an index value, and searching the corresponding entry in the linear index table; 5B、如果该表项的标记位为1,执行5D;5B. If the flag bit of the entry is 1, execute 5D; 5C、取得该表项对应的输出端口,执行5F;5C. Obtain the output port corresponding to the entry, and execute 5F; 5D、取出IPv6分组目的地址的后112bit;5D. Take out the last 112 bits of the IPv6 packet destination address; 5E、在线性索引表的表项中取得B-HTL指针,在对应的B-HTL中利用后112bit地址执行二分查找,取得对应的输出端口;5E. Obtain the B-HTL pointer in the entry of the linear index table, use the last 112bit address in the corresponding B-HTL to perform binary search, and obtain the corresponding output port; 5F、结束。5F, end. 6、根据权利要求1所述的基于IPv6地址实现快速路由表查找和更新的方法,其特征在于:所述B-HTL的二分查找树的每一个节点都指向一个hash表;hash表中每一个表项包括以下几个部分:6. The method for realizing fast routing table lookup and update based on IPv6 address according to claim 1, characterized in that: each node of the binary search tree of the B-HTL points to a hash table; Table items include the following parts: (1)长度为16byte的IPv6地址;(1) An IPv6 address with a length of 16 bytes; (2)长度为7bit的下一跳端口号;(2) the next hop port number with a length of 7 bits; (3)长度为1bit的标记位,用于表示该表项是否对应了一条长度大于16的地址前缀;(3) A flag bit with a length of 1 bit, which is used to indicate whether the entry corresponds to an address prefix with a length greater than 16; (4)长度为1bit的标记位,用于表示该表项是否对应一个marker;(4) A marker bit with a length of 1 bit, used to indicate whether the entry corresponds to a marker; (5)长度为8bit的最长匹配前缀BMP,用于表示该表项对应的的最大地址前缀长度;(5) The longest matching prefix BMP with a length of 8 bits is used to indicate the maximum address prefix length corresponding to the entry; (6)长度为16bit的marker计数器,用于统计该表项上叠加的marker数量;(6) A marker counter with a length of 16 bits, which is used to count the number of markers superimposed on the entry; (7)expand指针,指向一个最长匹配地址前缀树BMP_tree的根节点;(7) expand pointer, pointing to the root node of a longest matching address prefix tree BMP_tree; (8)next_level指针,指向BMP_tree中的下级节点;(8) The next_level pointer points to the lower-level node in the BMP_tree; (9)same_level指针,指向BMP_tree中的同级节点。(9) The same_level pointer points to the same-level node in the BMP_tree. 7、根据权利要求6所述的基于IPv6地址实现快速路由表查找和更新的方法,其特征在于:所述BMP_tree由B-HTL中hash表的表项组成,每一个表项的expand指针唯一对应一棵BMP_tree,BMP_tree中的每一个节点都以该表项为前缀,并且根据节点中前缀的长度由低到高设置该节点在BMP_tree中的层次,具有同样前缀长度的节点处于BMP_tree的同一层;当对B-HTL进行添加、删除或更新操作时,通过BMP_tree查找那些需要改变的hash表表项。7. The method for realizing fast routing table search and update based on IPv6 address according to claim 6, characterized in that: said BMP_tree is composed of entries of hash table in B-HTL, and the expand pointer of each entry is uniquely corresponding A BMP_tree, each node in the BMP_tree is prefixed with this entry, and the level of the node in the BMP_tree is set from low to high according to the length of the prefix in the node, and nodes with the same prefix length are in the same layer of the BMP_tree; When adding, deleting or updating the B-HTL, look up those hash table entries that need to be changed through the BMP_tree. 8、根据权利要求7所述的基于IPv6地址实现快速路由表查找和更新的方法,其特征在于:对B-HTL添加一个前缀P2时,执行如下步骤:8. The method for realizing fast routing table search and update based on IPv6 address according to claim 7, characterized in that: when adding a prefix P2 to B-HTL, perform the following steps: 8A、在B-HTL中查找P2的最长地址前缀节点P1;8A. Find the longest address prefix node P1 of P2 in B-HTL; 8B、在P1的BMP-tree中,遍历所有层次高于P2的前缀节点,分别执行8C、8D、8E;8B. In the BMP-tree of P1, traverse all prefix nodes whose levels are higher than P2, and execute 8C, 8D, and 8E respectively; 8C、如果遍历没有结束,那么执行8D,否则,执行8F;8C. If the traversal is not over, execute 8D; otherwise, execute 8F; 8D、如果P2是该节点的前缀,那么执行8E,否则遍历到下一个节点,执行8C;8D. If P2 is the prefix of the node, then execute 8E, otherwise traverse to the next node and execute 8C; 8E、从P1的BMP-tree中取出该节点,移动到P2的BMP-tree中,遍历到下一个节点,执行8C;8E. Take out the node from the BMP-tree of P1, move to the BMP-tree of P2, traverse to the next node, and execute 8C; 8F、为P2在B-HTL中添加marker;8F, add marker in B-HTL for P2; 8G、将P2添加到P1的BMP-tree中;8G. Add P2 to the BMP-tree of P1; 8H、结束。8H, end. 9、根据权利要求7所述的基于IPv6地址实现快速路由表查找和更新的方法,其特征在于:对B-HTL删除一个前缀P2时,执行如下步骤:9. The method for realizing fast routing table lookup and update based on IPv6 address according to claim 7, characterized in that: when deleting a prefix P2 to B-HTL, perform the following steps: 9A、在B-HTL中查找P2的最长地址前缀节点P1;9A. Find the longest address prefix node P1 of P2 in B-HTL; 9B、在P1的BMP-tree中,遍历所有层次高于P2的前缀节点,分别执行9C、9D、9E;9B. In the BMP-tree of P1, traverse all prefix nodes whose levels are higher than P2, and execute 9C, 9D, and 9E respectively; 9C、如果遍历没有结束,那么执行9D,否则,执行9F;9C. If the traversal is not over, execute 9D; otherwise, execute 9F; 9D、如果该节点是P2的前缀,那么执行9E,否则遍历到下一个节点,执行9C;9D. If the node is the prefix of P2, then execute 9E, otherwise traverse to the next node and execute 9C; 9E、修改该节点数据结构存储的信息,遍历到下一个节点,执行9C;9E. Modify the information stored in the data structure of the node, traverse to the next node, and execute 9C; 9F、取出P2的BMP-tree,并入P1的BMP-tree;9F. Take out the BMP-tree of P2 and merge it into the BMP-tree of P1; 9G、删除P2的前缀信息;9G. Delete the prefix information of P2; 9H、结束。9H, end. 10、据权利要求1或6所述的基于IPv6地址实现快速路由表查找和更新的方法,其特征在于:所述B-HTL中每一个hash表对应了唯一的地址前缀长度,B-HTL中所有的hash表对应了一个地址前缀长度区间;所述二分查找树在这个前缀长度区间范围内构建,二分查找树的每一个节点覆盖B-HTL的一部分地址前缀长度区间,该节点对应的hash表的前缀长度也在这部分地址前缀长度区间中,并且将这部分地址前缀长度区间划分为两个子区间,该两个子区间分别对应该节点的左右两个子节点;在任意一个节点对应的地址前缀长度区间中,选择表项数量最多的一个hash表作为所述任意节点对应的hash表。10. The method for realizing fast routing table search and update based on IPv6 address according to claim 1 or 6, characterized in that: each hash table in the B-HTL corresponds to a unique address prefix length, and in the B-HTL All hash tables correspond to an address prefix length interval; the binary search tree is constructed within this prefix length interval, and each node of the binary search tree covers a part of the address prefix length interval of B-HTL, and the hash table corresponding to the node The prefix length of the address prefix length is also in this part of the address prefix length interval, and this part of the address prefix length interval is divided into two sub-intervals, and the two sub-intervals correspond to the left and right child nodes of the node; the address prefix length corresponding to any node In the interval, a hash table with the largest number of entries is selected as the hash table corresponding to the arbitrary node. 11、根据权利要求1或6所述的基于IPv6地址实现快速路由表查找和更新的方法,其特征在于:所述B-HTL中每一个hash表对应了唯一的地址前缀长度,B-HTL中所有的hash表对应了一个地址前缀长度区间;所述二分查找树在这个前缀长度区间范围内构建,二分查找树的每一个节点覆盖B-HTL的一部分地址前缀长度区间,该节点对应的hash表的前缀长度也在这部分地址前缀长度区间中,并且将这部分地址前缀长度区间划分为两个子区间,分别对应该节点的左右两个子节点;在任意一个节点对应的地址前缀长度区间中,选择一个hash表,用这个hash表将地址前缀长度区间划分为两个子区间,使得第一个子区间中hash表表项数量和与第二个子区间中hash表表项数量和最接近,则这个hash表作为该节点对应的hash表。11. The method for searching and updating a fast routing table based on an IPv6 address according to claim 1 or 6, wherein each hash table in the B-HTL corresponds to a unique address prefix length, and in the B-HTL All hash tables correspond to an address prefix length interval; the binary search tree is constructed within this prefix length interval, and each node of the binary search tree covers a part of the address prefix length interval of B-HTL, and the hash table corresponding to the node The prefix length of the address prefix length is also in this part of the address prefix length interval, and this part of the address prefix length interval is divided into two sub-intervals, corresponding to the left and right child nodes of the node; in the address prefix length interval corresponding to any node, select A hash table, using this hash table to divide the address prefix length range into two sub-ranges, so that the sum of the number of hash table entries in the first sub-range is closest to the sum of the number of hash table entries in the second sub-range, then the hash table as the hash table corresponding to the node.
CNB200510086841XA 2005-11-10 2005-11-10 A Method for Rapid Search and Update of IPv6 Routing Table Expired - Fee Related CN100496019C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB200510086841XA CN100496019C (en) 2005-11-10 2005-11-10 A Method for Rapid Search and Update of IPv6 Routing Table

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB200510086841XA CN100496019C (en) 2005-11-10 2005-11-10 A Method for Rapid Search and Update of IPv6 Routing Table

Publications (2)

Publication Number Publication Date
CN1964311A CN1964311A (en) 2007-05-16
CN100496019C true CN100496019C (en) 2009-06-03

Family

ID=38083209

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB200510086841XA Expired - Fee Related CN100496019C (en) 2005-11-10 2005-11-10 A Method for Rapid Search and Update of IPv6 Routing Table

Country Status (1)

Country Link
CN (1) CN100496019C (en)

Families Citing this family (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101420415B (en) * 2007-10-23 2012-08-22 华为技术有限公司 Method and apparatus for forming routing table
CN101340386B (en) * 2008-08-12 2011-08-10 华为技术有限公司 Method and router for establishing and searching route table items
CN101667958B (en) * 2008-09-01 2012-08-29 华为技术有限公司 Method for selecting hash function, and method and device for storing and searching routing table
CN102957759B (en) * 2011-08-26 2018-07-13 中兴通讯股份有限公司 A kind of distribution method and system of IPv6 address prefixes
CN102739526B (en) * 2012-06-13 2015-02-25 烽火通信科技股份有限公司 Realization method of efficient distributed routing list realizing method
CN103780490B (en) * 2012-10-17 2018-03-30 中兴通讯股份有限公司 A kind of method and device for updating route querying tree
EP2924926B1 (en) 2012-12-25 2017-04-05 Huawei Technologies Co., Ltd. Lookup table creation method and query method, and controller, forwarding device and system therefor
CN105791132B (en) * 2014-12-17 2019-08-06 深圳市中兴微电子技术有限公司 Method and device for updating table items based on multi-way search tree routing lookup
CN105827530B (en) * 2016-03-11 2019-04-16 中国互联网络信息中心 A kind of IPV4/IPV6 compatible IP binary search method and device
CN109194574B (en) * 2018-09-20 2020-09-18 南通科技职业学院 IPv6 route searching method
CN111416880A (en) * 2019-01-08 2020-07-14 阿里巴巴集团控股有限公司 IP address addressing method and device, computer storage medium and electronic equipment
CN111970176B (en) * 2020-10-21 2021-01-15 中国人民解放军国防科技大学 Data summarization method and equipment for IPv4 and IPv6 dual-stack networks
CN114726825B (en) * 2021-01-05 2024-11-08 中国移动通信有限公司研究院 Method, system, electronic device and storage medium for constructing IPv6 address library
CN113343034A (en) * 2021-06-08 2021-09-03 湖南大学 IP searching method, system and storage medium
CN116403684B (en) * 2023-06-08 2023-08-11 杭州医策科技有限公司 Digital pathological image loading method and device

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1507229A (en) * 2002-12-10 2004-06-23 ����ͨѶ�ɷ����޹�˾ Routing table organization and lookup method
CN1538663A (en) * 2003-04-16 2004-10-20 华为技术有限公司 A Method of Searching Routing Table Items Using Hash Linked List
WO2004105351A2 (en) * 2003-05-15 2004-12-02 Cisco Technology, Inc A bounded index extensible hash-based ipv6 address lookup method

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1507229A (en) * 2002-12-10 2004-06-23 ����ͨѶ�ɷ����޹�˾ Routing table organization and lookup method
CN1538663A (en) * 2003-04-16 2004-10-20 华为技术有限公司 A Method of Searching Routing Table Items Using Hash Linked List
WO2004105351A2 (en) * 2003-05-15 2004-12-02 Cisco Technology, Inc A bounded index extensible hash-based ipv6 address lookup method

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
采用哈希算法改进IP地址查找的研究. 卢秀娟,范其蓬,王林.陕西工学院学报,第20卷第4期. 2004 *

Also Published As

Publication number Publication date
CN1964311A (en) 2007-05-16

Similar Documents

Publication Publication Date Title
KR100586461B1 (en) Method, Hardware Architecture and Recording Medium for Searching IP Address by Using Pipeline Binary Tree
CN102484610B (en) Routing table construction method and device and routing table lookup method and device
US9672234B2 (en) Database and database processing methods
CN103561133B (en) A kind of IP address attribution information index method and method for quickly querying
US6691124B2 (en) Compact data structures for pipelined message forwarding lookups
CN1270487C (en) Method and apparatus for ternary content addressable meomry (TCAM) table management
CN100496019C (en) A Method for Rapid Search and Update of IPv6 Routing Table
CN102571599B (en) Rapid storage method of routing table entry
CN103107945B (en) A kind of system and method for fast finding IPV6 route
CN107967219A (en) A kind of extensive character string high-speed searching method based on TCAM
Warkhede et al. Multiway range trees: scalable IP lookup with fast updates
JP3570323B2 (en) How to store prefixes for addresses
Pao et al. Efficient hardware architecture for fast IP address lookup
CN101507191A (en) Recursively partioned static ip router tables
CN101491015A (en) Dynamic tree bitmap for IP lookup and update
US7478109B1 (en) Identification of a longest matching prefix based on a search of intervals corresponding to the prefixes
CN102597973A (en) Method and device for improving scalability of longest prefix match
CN114884877B (en) IPv6 route searching method combining hash table and HOT
CN110995876B (en) Method and device for storing and searching IP
KR100420957B1 (en) Routing table using class segmentation algorithm, searching method and apparatus thereby.
Hsieh et al. A classified multisuffix trie for IP lookup and update
KR100364433B1 (en) IP address look-up method using a bit-vector table
CN100531179C (en) Method for storing character string matching rule and character string matching by storing rule
Liu et al. Longest prefix matching with pruning
Lin et al. Improved IP lookup technology for trie-based data structures

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
ASS Succession or assignment of patent right

Owner name: YANTAI HUITONG NETWORK TECHNOLOGY CO., LTD.

Free format text: FORMER OWNER: INSTITUTE OF COMPUTING TECHNOLOGY, CHINESE ACADEMY OF SCIENCES

Effective date: 20121224

C41 Transfer of patent application or patent right or utility model
COR Change of bibliographic data

Free format text: CORRECT: ADDRESS; FROM: 100080 HAIDIAN, BEIJING TO: 264003 YANTAI, SHANDONG PROVINCE

TR01 Transfer of patent right

Effective date of registration: 20121224

Address after: 264003 Shandong Province, Yantai city Laishan District Yingchun Street No. 133

Patentee after: YANTAI HUITONG NETWORK TECHNOLOGY CO., LTD.

Address before: 100080 Haidian District, Zhongguancun Academy of Sciences, South Road, No. 6, No.

Patentee before: Institute of Computing Technology, Chinese Academy of Sciences

CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20090603

Termination date: 20161110