CN103561133B - A kind of IP address attribution information index method and method for quickly querying - Google Patents
A kind of IP address attribution information index method and method for quickly querying Download PDFInfo
- Publication number
- CN103561133B CN103561133B CN201310581441.0A CN201310581441A CN103561133B CN 103561133 B CN103561133 B CN 103561133B CN 201310581441 A CN201310581441 A CN 201310581441A CN 103561133 B CN103561133 B CN 103561133B
- Authority
- CN
- China
- Prior art keywords
- node
- address
- tree
- information
- cidr
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 46
- RJKFOVLPORLFTN-LEKSSAKUSA-N Progesterone Chemical compound C1CC2=CC(=O)CC[C@]2(C)[C@@H]2[C@@H]1[C@@H]1CC[C@H](C(=O)C)[C@@]1(C)CC2 RJKFOVLPORLFTN-LEKSSAKUSA-N 0.000 claims description 124
- 241000712062 Patricia Species 0.000 description 12
- 230000008520 organization Effects 0.000 description 11
- 238000012544 monitoring process Methods 0.000 description 9
- 238000004364 calculation method Methods 0.000 description 6
- 238000010276 construction Methods 0.000 description 5
- 238000010586 diagram Methods 0.000 description 5
- 238000005516 engineering process Methods 0.000 description 4
- 238000003780 insertion Methods 0.000 description 3
- 230000037431 insertion Effects 0.000 description 3
- 230000006835 compression Effects 0.000 description 2
- 238000007906 compression Methods 0.000 description 2
- 238000012217 deletion Methods 0.000 description 2
- 230000037430 deletion Effects 0.000 description 2
- 230000008676 import Effects 0.000 description 2
- 230000000717 retained effect Effects 0.000 description 2
- 238000010845 search algorithm Methods 0.000 description 2
- 238000004891 communication Methods 0.000 description 1
- 230000003247 decreasing effect Effects 0.000 description 1
- 238000009826 distribution Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000001914 filtration Methods 0.000 description 1
- 238000005111 flow chemistry technique Methods 0.000 description 1
- 230000007774 longterm Effects 0.000 description 1
- 238000005457 optimization Methods 0.000 description 1
- 230000008092 positive effect Effects 0.000 description 1
- 238000003860 storage Methods 0.000 description 1
- 239000002699 waste material Substances 0.000 description 1
Landscapes
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
Description
技术领域technical field
本发明涉及计算机网络领域,通信领域,尤其涉及一种基于Patricia查询树的IP地址归属信息的快速查询方法。The invention relates to the field of computer network and communication field, in particular to a fast query method of IP address attribution information based on Patricia query tree.
背景技术Background technique
目前互联网上提供的基于IP地址的服务(如天气预报等),网管系统以及安全软件中都需要用到IP地址的归属信息,如国家信息,城市信息,机构信息,AS信息,经纬度信息等。通过查询某个IP地址对应的归属信息,天气预报服务便可以返回给该IP主机对应城市的天气信息;网管系统可以监控某个给定的监控对象(国家,机构等)的流量等相关信息;安全软件也可以指定相应的安全策略清洗指定的流量,如过滤来自某个国家的流量等等。At present, IP address-based services (such as weather forecast, etc.), network management systems and security software provided on the Internet all need to use IP address attribution information, such as country information, city information, organization information, AS information, latitude and longitude information, etc. By querying the attribution information corresponding to an IP address, the weather forecast service can return the weather information of the city corresponding to the IP host; the network management system can monitor the traffic and other related information of a given monitoring object (country, institution, etc.); Security software can also specify corresponding security policies to clean specified traffic, such as filtering traffic from a certain country and so on.
IP归属信息查询目前已经有成熟的技术和产品了,如MaxMind的GeoIP数据库专门用于IP地理信息查询,同时提供免费版本和精度更高的商业版本,GeoIP数据库有两种形式,一种是二进制版本的库,并提供各种语言的API接口,一种是csv格式的文件;国内的QQ纯真IP数据库也是用的比较广泛的免费IP数据库,QQ IP数据库也提供二进制版本和非二进制格式版本两种。上述两种IP数据库以及其他类似的产品都是根据已知的分配给各个国家,地区或者运营商的IP CIDR地址块来关联其归属信息(包括国家信息,城市信息,机构信息,AS信息,经纬度信息等),并组织成IP数据库。对于一个归属信息未知的IP地址,通过查询IP数据库找到所属CIDR,便可以查询出其对应的归属信息。There are already mature technologies and products for IP attribution information query. For example, MaxMind’s GeoIP database is specially used for IP geographic information query. It also provides a free version and a commercial version with higher accuracy. The GeoIP database has two forms, one is binary version of the library, and provide API interfaces in various languages, one is a file in csv format; the domestic QQ pure IP database is also a widely used free IP database, and the QQ IP database also provides two versions in binary format and non-binary format kind. The above two IP databases and other similar products associate their attribution information (including country information, city information, institution information, AS information, longitude and latitude) based on known IP CIDR address blocks assigned to each country, region or operator information, etc.) and organized into an IP database. For an IP address whose attribution information is unknown, by querying the IP database to find the CIDR to which it belongs, the corresponding attribution information can be queried.
CIDR无类别域间路由技术是为了解决IP地址子网划分带来的不能合理使用IP地址的问题,CIDR采用变长的网络前缀来代替分类地址中的网络号和子网号,可以将多个网络前缀部分相同的IP地址组成CIDR地址块,每个CIDR地址块都是由起始地址和一个表示网络前缀长度的后缀组成,并用‘/’隔开,例如192.168.0.0/16表示该CIDR块地址的从192.168.0.0开始,前面16位为网络地址,总共有216个连续地址。CIDR地址块还可以进一步聚合,例如16个原来的C类(/24)网络可以聚合在一起对外显示为一个/20的网络(如果这些网络的的地址前20位都相同)。两个对齐的/20网络又可进一步聚合为/19,依此类推。CIDR技术为网络管理带来了很大的便利,因此IPV4和IPV6目前都采用了CIDR技术。CIDR classless inter-domain routing technology is to solve the problem that IP addresses cannot be used rationally caused by IP address subnetting. CIDR uses variable-length network prefixes to replace network numbers and subnet numbers in classified addresses, and multiple networks can be assigned to each other. IP addresses with the same prefix part form a CIDR address block. Each CIDR address block is composed of a start address and a suffix indicating the length of the network prefix, separated by '/', for example, 192.168.0.0/16 indicates the CIDR block address Starting from 192.168.0.0, the first 16 bits are network addresses, and there are a total of 216 consecutive addresses. CIDR address blocks can be further aggregated. For example, 16 original Class C (/24) networks can be aggregated together and displayed as a /20 network (if the first 20 bits of the addresses of these networks are all the same). Two aligned /20 networks can be further aggregated into a /19, and so on. CIDR technology brings great convenience to network management, so both IPV4 and IPV6 currently use CIDR technology.
GeoIP数据库和QQ纯真IP数据库的查询有两种方式,一种方式是通过二进制库的接口进行查询,另一种方式是通过将csv格式或者文本格式的IP归属信息文件数据导入到数据库中(如MySQL数据库),然后通过数据库进行查询,然而这两种查询方式都有一些不足之处。对于二进制形式的IP数据库,为了提高查询速度和节约资源在组织IP归属信息记录时采取了优化措施,例如采用索引和归属信息重定向等方法,而且可以常驻内存,查询算法采用二分法等比较快速的算法,因此查询速度比较快,然而其不足和局限在于灵活度不够好,不能满足一些特殊的应用场合,例如对于某机构A,其内部又有更小的自定义机构,然而GeoIP和QQIP数据库中可能只有A的记录但却没有A下面自定义机构的记录,因此无法对A的子机构进行相关操作,即使向二进制库中增加自定义形式的归属信息,由于二进制库组织形式的黑盒性,对开发人员也是一件困难的事情;另外,一些应用场景中存在一个IP地址对应多个归属信息的情况(例如一个IP地址对应机构A,A机构属于B机构,因此该IP地址也属于B机构),要求每次查询返回所有的归属信息,然而查询二进制库方式无法实现;还有一些应用场景中,GeoIP和QQIP数据库中定义的IP地址归属信息字段可能只有其中一部分会被用到,因此使用GeoIP和QQIP会产生额外的资源浪费。总之,对于IP地址归属信息应该根据实际情况进行自定义,以便于实际的查询。第二种查询方式灵活性高,开发者可以根据自己的需要从csv格式(或者文本格式)的GeoIP或者QQ IP数据库文件中提取出所需的相关信息,组织成IP CIDR块归属信息,而且可以添加自定义的IP CIDR归属信息,然后将其导入到数据库中(如MySQL数据库),但是这种查询方式每次都需要访问数据库,执行SQL查询语句操作,因此会增加查询时间,影响查询速度。目前使用最广的IPV4地址为32位,其CIDR块数量相对来说还不是太巨大,这种查询数据库的方法还可以满足实时查询的要求。然而随着IPV6地址的广泛使用,需要对越来越多的IPV6地址提供相应的归属信息查询服务,由于IPV6地址拥有2128的地址空间,相应的IPV6地址的CIDR块数量也会越来越多,而且随着进一步的细化,IPV6的CIDR块数量将更是庞大无比,因此这种查询数据库的方法面对CIDR块数量惊人的IPV6地址查询时会有很大的延迟,尤其对于运营商骨干网,他们使用的网络流量监控系统经常要求毫秒级的实时网络流处理延迟,这个需求更是无法满足。总之,如何将如此庞大的IPCIDR块地址组织起来,建立高效的索引并能够有效实时的提供地址归属查询是一项很重要的工作。There are two ways to query the GeoIP database and QQ pure IP database. One way is to query through the interface of the binary library, and the other way is to import the IP attribution information file data in csv format or text format into the database (such as MySQL database), and then query through the database, but these two query methods have some shortcomings. For the IP database in binary form, in order to improve the query speed and save resources, optimization measures have been taken when organizing IP attribution information records, such as indexing and attribution information redirection, and can be resident in memory. The query algorithm uses dichotomy, etc. for comparison Fast algorithm, so the query speed is relatively fast, but its shortcomings and limitations are that the flexibility is not good enough to meet some special applications. For example, for an organization A, there are smaller custom organizations inside, but GeoIP and QQIP There may be only records of A in the database but no records of the custom organization under A, so related operations cannot be performed on the sub-organizations of A, even if the attribution information of a custom form is added to the binary library, due to the black box of the binary library organization form In addition, in some application scenarios, one IP address corresponds to multiple attribution information (for example, one IP address corresponds to organization A, and organization A belongs to organization B, so the IP address also belongs to Institution B), it is required to return all attribution information for each query, but the query binary library method cannot be realized; in some application scenarios, only a part of the IP address attribution information fields defined in the GeoIP and QQIP databases may be used. Therefore, using GeoIP and QQIP will generate additional waste of resources. In short, the attribution information of the IP address should be customized according to the actual situation, so as to facilitate actual query. The second query method is highly flexible. Developers can extract the required relevant information from GeoIP or QQ IP database files in csv format (or text format) according to their own needs, organize them into IP CIDR block attribution information, and can Add custom IP CIDR attribution information, and then import it into the database (such as MySQL database), but this query method needs to access the database every time and execute SQL query statement operations, so it will increase the query time and affect the query speed. Currently the most widely used IPV4 address is 32 bits, and the number of its CIDR blocks is relatively small. This method of querying the database can also meet the requirements of real-time query. However, with the widespread use of IPV6 addresses, it is necessary to provide corresponding attribution information query services for more and more IPV6 addresses. Since IPV6 addresses have an address space of 2128 , the number of CIDR blocks corresponding to IPV6 addresses will also increase. , and with further refinement, the number of CIDR blocks of IPV6 will be even more enormous, so this method of querying the database will have a large delay in querying IPV6 addresses with an astonishing number of CIDR blocks, especially for the backbone of operators Network, the network traffic monitoring system they use often requires millisecond-level real-time network flow processing delay, which cannot be met. In short, how to organize such a huge IPCIDR block address, establish an efficient index and be able to effectively provide address attribution query in real time is a very important task.
发明内容Contents of the invention
针对现有技术中存在的技术问题,本发明的目的是提供一种基于Patricia查找树的IP地址归属信息索引方法及快速查询方法,能够实时高效的用于IPV4地址、IPV6地址(尤其是IPV6地址)自定义形式归属信息的查询。For the technical problems existing in the prior art, the purpose of the present invention is to provide a kind of IP address attribution information indexing method and fast query method based on Patricia search tree, can be used for IPV4 address, IPV6 address (especially IPV6 address) in real time and efficiently ) query of custom form attribution information.
Patricia树是一种基于Trie树思想的压缩二叉查询树,将所有单分支节点都和其父节点合并,从而达到压缩的效果。Patricia树的节点分为两类,一类称为外部节点,也即叶子节点;一类称为内部节点,也即非叶子节点。在Patricia树中,关键词的具体信息以二进制串的形式保存在叶子节点上,Patricia树的内部节点则用来记录关键词的路径,它有三个基本的数据项:比较位、左指针、右指针,其中左指针和右指针分别指向该节点的左、右子树,比较位记录的是进行下一次比较前需要跳过的位数,途经该节点的位串将选择不同的后继路径,当比较位值为0时,位串转向左子树,比较位值为1时,位串转向右子树,每一个内部节点都有左、右两个子节点,其根节点是一个特殊的内部节点。Patricia树查找的时间复杂度和树的深度有关,而Patricia树的深度又跟关键词的二进制串长度N,记录数量n以及不同bit位上0,1的分布以及压缩情况有关,最好情况下是平衡二叉树结构,最坏情况下是其内部节点形成的树是一棵单支树,因此时间复杂度最优为O(log N),最差为O(N)。当Patricia树中存有n个关键词即n个叶子节点时,其内部节点为n-1个,总节点数为2n-1,因此其空间复杂度为O(n)。The Patricia tree is a compressed binary query tree based on the idea of a Trie tree. All single-branch nodes are merged with their parent nodes to achieve the effect of compression. The nodes of the Patricia tree are divided into two types, one is called external nodes, that is, leaf nodes; the other is called internal nodes, that is, non-leaf nodes. In the Patricia tree, the specific information of the keyword is stored on the leaf node in the form of a binary string, and the internal node of the Patricia tree is used to record the path of the keyword. It has three basic data items: comparison bit, left pointer, right Pointers, where the left pointer and right pointer point to the left and right subtrees of the node respectively, and the comparison bit records the number of digits that need to be skipped before the next comparison, and the bit string passing through the node will choose a different subsequent path. When the comparison bit value is 0, the bit string turns to the left subtree, when the comparison bit value is 1, the bit string turns to the right subtree, each internal node has left and right child nodes, and its root node is a special internal node . The time complexity of Patricia tree search is related to the depth of the tree, and the depth of the Patricia tree is related to the length N of the binary string of keywords, the number of records n, the distribution of 0 and 1 on different bits, and the compression situation. In the best case It is a balanced binary tree structure. In the worst case, the tree formed by its internal nodes is a single branch tree, so the time complexity is optimally O(log N), and worst is O(N). When there are n keywords in the Patricia tree, that is, n leaf nodes, there are n-1 internal nodes, and the total number of nodes is 2n-1, so its space complexity is O(n).
本发明的技术方案为:Technical scheme of the present invention is:
一种IP地址归属信息索引方法,其步骤为:A method for indexing IP address attribution information, the steps of which are:
1)选取或创建一IP CIDR地址块归属信息配置文件;初始化IP地址归属信息查询树及其子树,其分别为IPV4查询子树与IPV6查询子树;1) Select or create an IP CIDR address block attribution information configuration file; initialize the IP address attribution information query tree and its subtrees, which are respectively the IPV4 query subtree and the IPV6 query subtree;
2)读取所述配置文件中的CIDR块记录;对于每一CIDR块记录,以CIDR地址块作为键值,以其网络前缀长度作为比较位来创建所述查询树的新节点;2) Read the CIDR block record in the configuration file; for each CIDR block record, use the CIDR address block as the key value, and use its network prefix length as the comparison bit to create a new node of the query tree;
21)如果该CIDR块属于IPV4地址块,且当前IPV4查询子树的头节点为空,则以该新节点作为IPV4查询子树的头节点,并将其归属信息关联到该新节点,如果头节点不为空,则选择IPV4查询子树的头节点进行步骤22);如果该CIDR块属于IPV6地址块,且当前IPV6查询子树的头节点为空,则以该新节点作为IPV6查询子树的头节点,并将其归属信息关联到该新节点,如果头节点不为空,则选择IPV6查询子树的头节点进行步骤22);21) If the CIDR block belongs to the IPV4 address block, and the head node of the current IPV4 query subtree is empty, use the new node as the head node of the IPV4 query subtree, and associate its attribution information to the new node, if the head node If the node is not empty, select the head node of the IPV4 query subtree and proceed to step 22); if the CIDR block belongs to the IPV6 address block, and the head node of the current IPV6 query subtree is empty, then use this new node as the IPV6 query subtree and associate its attribution information with the new node, if the head node is not empty, select the head node of the IPV6 query subtree and proceed to step 22);
22)从所选头节点开始遍历对应的查询子树,直到满足条件一或条件二为止,计算查询子树中遍历到的当前节点与该新节点共同的网络前缀长度L;若该L值大于当前节点的比较位,则回退到当前节点的父节点,并设置该父节点为当前节点,直到回退到该L值小于或者等于查询子树中当前节点的比较位为止;22) Traverse the corresponding query subtree from the selected head node until condition 1 or condition 2 is met, and calculate the network prefix length L common to the current node traversed in the query subtree and the new node; if the value of L is greater than For the comparison bit of the current node, roll back to the parent node of the current node, and set the parent node as the current node until the value of L is less than or equal to the comparison bit of the current node in the query subtree;
23)根据该L值和步骤22)所确定的当前节点确定该新节点的插入位置,将该新节点插入到查询子树中,并将其归属信息关联到该新节点;23) Determine the insertion position of the new node according to the L value and the current node determined in step 22), insert the new node into the query subtree, and associate its attribution information with the new node;
其中,条件一:已经遍历到达查询树中叶节点;条件二:遍历到的当前节点为比较位大于该新节点的比较位,且包含CIDR块信息的内部节点。Among them, condition one: the leaf node in the query tree has been traversed; condition two: the current node traversed is an internal node whose comparison bit is greater than that of the new node and contains CIDR block information.
进一步的,遍历对应的查询子树的方法为:设查询子树中遍历到的当前节点比较位为n,若该新节点键值的第n+1位为0,则遍历查询子树中当前节点左子节点,若该新节点键值的第n+1位为1,则遍历查询子树中当前节点的右子节点。Further, the method of traversing the corresponding query subtree is as follows: set the comparison bit of the current node traversed in the query subtree to be n, if the n+1th bit of the key value of the new node is 0, then traverse the current node in the query subtree The left child node of the node, if the n+1th bit of the key value of the new node is 1, traverse the right child node of the current node in the query subtree.
进一步的,确定该新节点的插入位置的方法为:Further, the method for determining the insertion position of the new node is:
a)若L等于当前节点的比较位以及该新节点的比较位,且当前节点为不含有CIDR块信息的内部节点,则将该新节点替换该内部节点;a) If L is equal to the comparison bit of the current node and the comparison bit of the new node, and the current node is an internal node that does not contain CIDR block information, replace the internal node with the new node;
b)若L等于当前节点的比较位且L小于该新节点的比较位,则将该新节点作为当前节点的一个子节点,若该新节点的CIDR块的二进制串第L+1位为0,则作为当前节点的左子节点,若第L+1位为1,则作为当前节点的右子节点;b) If L is equal to the comparison bit of the current node and L is smaller than the comparison bit of the new node, then the new node will be regarded as a child node of the current node, if the L+1th bit of the binary string of the CIDR block of the new node is 0 , as the left child node of the current node, if the L+1th bit is 1, it is used as the right child node of the current node;
c)若L等于该新节点的比较位且L小于当前节点的比较位,则将该新节点作为当前节点的父节点,若当前节点CIDR块的二进制串的第L+1位为0,则作为该新节点的左子树,若第L+1位为1,则作为该新节点的右子树;c) If L is equal to the comparison bit of the new node and L is smaller than the comparison bit of the current node, then the new node is taken as the parent node of the current node, if the L+1th bit of the binary string of the CIDR block of the current node is 0, then As the left subtree of the new node, if the L+1th bit is 1, it is used as the right subtree of the new node;
d)若L小于该新节点的比较位且L小于当前节点的比较位,则新建内部节点,设置其关键字为空、比较位为L,顶替当前节点的位置,若该新节点CIDR块的二进制串第L+1位为0,则将该新节点作为该新建内部节点的左子节点,当前节点及其子树作为该新建内部节点的右子树,若该新节点CIDR块的二进制串第L+1位为1,则将该新节点作为该新建内部节点的右子节点,当前节点及其子树作为该新建内部节点的左子树。d) If L is less than the comparison bit of the new node and L is less than the comparison bit of the current node, create a new internal node, set its keyword to be empty, and set the comparison bit to L to replace the position of the current node. If the new node’s CIDR block If bit L+1 of the binary string is 0, then the new node is taken as the left child node of the newly created internal node, and the current node and its subtree are taken as the right subtree of the newly created internal node. If the binary string of the CIDR block of the new node If the L+1th bit is 1, the new node is used as the right child node of the newly created internal node, and the current node and its subtree are used as the left subtree of the newly created internal node.
进一步的,所述配置文件的建立方法为:Further, the establishment method of the configuration file is:
41)设置归属信息记录格式,归属信息记录由相应的IP CIDR块字段及若干归属信息字段组成,格式如:IP CIDR信息(xxx.xxx.xxx.xxx/xx,由子网地址和网络前缀长度两部分组成),国家/地区信息,城市信息,机构信息,AS信息,经度,纬度信息等;其中IP CIDR字段值不可为空的,其他字段值可以为空;41) Set the format of the attribution information record. The attribution information record is composed of the corresponding IP CIDR block field and several attribution information fields. The format is such as: IP CIDR information (xxx.xxx.xxx.xxx/xx, consisting of subnet address and network prefix length part), country/region information, city information, organization information, AS information, longitude, latitude information, etc.; the IP CIDR field value cannot be empty, and other field values can be empty;
42)创建归属信息,首先根据IP地址归属记录的字段格式,从IP地址归属信息库里取出需要的字段(如果IP地址归属信息库里没有相关字段,可以自定义),并组织成一条记录;其次创建自定义的IP CIDR地址归属信息记录(其IP CIDR块在IP地址库里不存在);42) To create attribution information, first, according to the field format of the IP address attribution record, take out the required fields from the IP address attribution information database (if there is no relevant field in the IP address attribution information database, you can customize it), and organize it into a record; Secondly, create a custom IP CIDR address attribution information record (its IP CIDR block does not exist in the IP address library);
43)将42)中所述的IP地址归属信息记录保存于配置文件,生成所述配置文件,其中每条记录占据一行;配置文件一般是以文本文件的方式保存IP地址归属信息记录。43) Save the IP address attribution information record described in 42) in a configuration file, and generate the configuration file, wherein each record occupies one line; the configuration file generally saves the IP address attribution information record in the form of a text file.
进一步的,所述配置文件中,不同归属信息的IP CIDR块允许包含相同的IP地址。Further, in the configuration file, IP CIDR blocks of different attribution information are allowed to contain the same IP address.
进一步的,更新所述查询树的方法为:Further, the method for updating the query tree is:
61)读取归属信息更新配置文件中的CIDR记录,以CIDR地址块作为键值,以其网络前缀长度作为比较位来创建新节点a;如果更新操作为插入,则进行步骤62);若为删除,则进行步骤63;61) Read the CIDR record in the attribution information update configuration file, use the CIDR address block as the key value, and use its network prefix length as the comparison bit to create a new node a; if the update operation is insertion, proceed to step 62); if it is delete, proceed to step 63;
62)根据节点a中的IP地址类别,选择相应查询子树的头节点,执行步骤22)和23),将该新节点a及其归属信息插入到该查询子树中;62) According to the IP address category in node a, select the head node of the corresponding query subtree, perform steps 22) and 23), and insert the new node a and its attribution information into the query subtree;
63)根据节点a中的IP地址类别,选择相应查询子树的头节点,执行步骤22),定位到待删除CIDR节点在该查询子树中的节点CIDR,如果该节点CIDR与待删除CIDR一致,则进行步骤64),否则返回出错信息;63) According to the IP address category in node a, select the head node of the corresponding query subtree, perform step 22), locate the node CIDR of the CIDR node to be deleted in the query subtree, if the node CIDR is consistent with the CIDR to be deleted , proceed to step 64), otherwise return an error message;
64)根据规则(i)-(k),从该查询子树中删除相应位置的CIDR块信息,并调整查询树;64) According to the rules (i)-(k), delete the CIDR block information at the corresponding position from the query subtree, and adjust the query tree;
(i)如果该查询子树中待删除节点为叶子节点,则删除整个节点信息,若该叶子节点为其父节点的左子节点,则将其父节点左子节点标记为空,反之亦然;(i) If the node to be deleted in the query subtree is a leaf node, delete the entire node information, if the leaf node is the left child node of its parent node, mark the left child node of its parent node as empty, and vice versa ;
(j)如果该查询子树中待删除节点为内部节点且只有一个子节点,则删除该内部节点及其归属信息,并用其子节点代替其在树中的位置;(j) If the node to be deleted in the query subtree is an internal node and has only one child node, then delete the internal node and its attribution information, and replace its position in the tree with its child node;
(k)如果该查询子树中待删除节点为内部节点且拥有两个子节点,则只删除该内部节点的CIDR信息,保留该内部节点及其比较位。(k) If the node to be deleted in the query subtree is an internal node and has two child nodes, only the CIDR information of the internal node is deleted, and the internal node and its comparison bits are retained.
一种IP地址归属信息快速查询方法,其步骤为:A method for quickly inquiring about IP address attribution information, the steps of which are:
71)根据待查询IP地址的类型在查询树中选择IPV4头节点或者IPV6头节点,从所选头节点开始深度优先方法遍历查询树,直到到达查询树的叶子节点为止,并在遍历过程中将查询树中所有含有CIDR块归属信息的节点压入设置的栈中;71) Select an IPV4 head node or an IPV6 head node in the query tree according to the type of IP address to be queried, and traverse the query tree in a depth-first manner from the selected head node until it reaches the leaf node of the query tree, and in the process of traversing the All nodes in the query tree containing CIDR block attribution information are pushed into the set stack;
72)遍历该栈中每一节点,查找所有与待查询IP地址匹配的节点,进行步骤73),若没有与待查询IP地址匹配的节点,则返回空值或者未找到;72) Traverse each node in the stack, find all nodes matching the IP address to be queried, and proceed to step 73), if there is no node matching the IP address to be queried, return a null value or not found;
73)判断IP地址归属信息配置状态,若配置了多归属信息,则返回栈中所有节点的归属信息,若只配置了唯一归属信息,则只返回栈顶节点的归属信息。73) Determine the configuration status of the IP address attribution information. If multi-homing information is configured, return the attribution information of all nodes in the stack. If only unique attribution information is configured, only return the attribution information of the top node in the stack.
进一步的,遍历查询树的方法为:设查询树中遍历到的当前节点的比较位为n,若待查询IP地址对应的二进制串第n+1位为0,则遍历当前节点的左子节点,若第n+1位为1,则遍历当前节点的右子节点。Further, the method of traversing the query tree is: set the comparison bit of the current node traversed in the query tree to be n, if the n+1th bit of the binary string corresponding to the IP address to be queried is 0, then traverse the left child node of the current node , if the n+1th bit is 1, then traverse the right child node of the current node.
进一步的,所述栈中的节点包括:遍历查询树过程中所有含有CIDR块归属信息的内部节点和最后到达的叶子节点。Further, the nodes in the stack include: all internal nodes containing CIDR block attribution information and the last arrived leaf node in the process of traversing the query tree.
根据本发明的实施例,本发明的技术特征有:According to embodiments of the present invention, technical characterictic of the present invention has:
1.根据本发明实施例,本发明支持自定义IP CIDR块地址归属信息并建立配置文件,首先设置归属信息记录格式,归属信息记录由相应的IP CIDR块字段及若干归属信息字段组成,格式如:IP CIDR信息(xxx.xxx.xxx.xxx/xx,由子网地址和网络前缀长度两部分组成),国家/地区信息,城市信息,机构信息,AS信息,经度,纬度信息等;其中IP CIDR字段值不可为空的,其他字段值可以为空;然后创建归属信息,首先根据IP地址归属记录的字段格式,从IP地址归属信息库里取出需要的字段(如果IP地址归属信息库里没有相关字段,可以自定义),并组织成一条记录;其次创建自定义的IP CIDR地址归属信息记录(其IP CIDR块在IP地址库里不存在);最后将所述的IP地址归属信息记录保存于配置文件,生成所述配置文件,其中每条记录占据一行;配置文件一般是以文本文件的方式保存IP地址归属信息记录。1. According to the embodiment of the present invention, the present invention supports self-defining IP CIDR block address attribution information and sets up configuration file, first sets attribution information record format, and attribution information record is made up of corresponding IP CIDR block field and some attribution information fields, and format is as follows : IP CIDR information (xxx.xxx.xxx.xxx/xx, composed of subnet address and network prefix length), country/region information, city information, organization information, AS information, longitude, latitude information, etc.; where IP CIDR Field values cannot be empty, and other field values can be empty; then create attribution information, firstly, according to the field format of the IP address attribution record, take out the required fields from the IP address attribution information database (if there is no relevant field in the IP address attribution information database) field, which can be customized), and organize it into a record; secondly, create a custom IP CIDR address attribution information record (its IP CIDR block does not exist in the IP address library); finally, save the IP address attribution information record in The configuration file is to generate the configuration file, wherein each record occupies one line; the configuration file generally saves the IP address attribution information record in the form of a text file.
2.本发明提出一种基于Patricia查询树思想的IP地址归属信息查询树,根据本发明一个实施例,本发明IP地址归属信息查询树以配置文件中记录的IP CIDR块地址二进制串作为关键词,CIDR块网络前缀长度作为比较位,并将配置文件中IP CIDR块对应的归属信息作为值域关联到相应节点上。根据实施例,本发明构造的IP地址归属信息查询树是特殊的Patricia查询树,其特点如下:2. The present invention proposes a kind of IP address attribution information query tree based on the Patricia query tree thought. According to one embodiment of the present invention, the IP address attribution information query tree of the present invention uses the IP CIDR block address binary string recorded in the configuration file as a keyword , the length of the CIDR block network prefix is used as a comparison bit, and the attribution information corresponding to the IP CIDR block in the configuration file is associated with the corresponding node as a value field. According to an embodiment, the IP address attribution information query tree constructed by the present invention is a special Patricia query tree, and its characteristics are as follows:
普通Patricia树的关键词的信息都保存在叶子节点(即外部节点),内部节点只记录比较位的位置以及存储左右子节点,而本发明中构造的IP地址归属信息查询树为了适应IP CIDR地址的特殊性,其内部节点也可以保存关键字信息。如在本发明的一个实施例中,存在如下的CIDR块地址A、B、C,其中B地址块和C地址块属于A地址块的子块,也即A地址块网络前缀与B、C地址块的网络前缀有共同的部分,因此在IP地址归属信息查询树中A作为B与C的父节点,A已不再是叶子节点了,A作为内部节点的同时也存储着关键字信息。The information of the keyword of common Patricia tree is all stored in leaf node (being external node), and internal node only records the position of comparison bit and stores left and right sub-nodes, and the IP address attribution information inquiry tree of structure among the present invention is in order to adapt to IP CIDR address The particularity of , its internal nodes can also store keyword information. As in one embodiment of the present invention, there are the following CIDR block addresses A, B, and C, where B address block and C address block belong to the sub-blocks of A address block, that is, the network prefix of A address block and the addresses of B and C The network prefix of the block has a common part, so in the IP address attribution information query tree, A is the parent node of B and C, and A is no longer a leaf node. As an internal node, A also stores keyword information.
3.根据本发明的一个实施例,本发明支持一个IP地址归属于一个或者多个CIDR块,具有一个或者多个归属信息,并能够在查询时返回查询树中与该IP地址匹配的所有CIDR块的归属信息。根据本发明实施例,在某些场景中(如网络监控),一个大机构中的某些主机或者子机构需要临时或长期的进行单独监控(例如流量的监控等),因此需要给这些主机或者子机构的IP地址配置相应的CIDR块及其归属信息,以便能够进行相关作业,这些IP地址不仅具有大机构的归属信息,也具有嵌套的自定义的小机构的归属信息。3. According to an embodiment of the present invention, the present invention supports that an IP address belongs to one or more CIDR blocks, has one or more attribution information, and can return all CIDRs that match the IP address in the query tree when querying The attribution information of the block. According to the embodiment of the present invention, in some scenarios (such as network monitoring), some hosts or sub-organizations in a large organization need temporary or long-term independent monitoring (such as traffic monitoring, etc.), so it is necessary to provide these hosts or The IP addresses of sub-organizations are configured with corresponding CIDR blocks and their attribution information so that related operations can be performed. These IP addresses not only have the attribution information of large organizations, but also have nested and customized attribution information of small organizations.
4.更进一步,根据本发明的实施例,本发明IP地址归属信息查询树还具有如下特征:本发明IP地址归属信息查询树含有两棵子树,分别存储IPV4CIDR地址归属信息和IPV6CIDR块地址归属信息。本发明的实施例中首先需要考虑IP地址归属信息查询树的时间复杂度,查找时间复杂度与树的深度有关,而查询树的深度主要与IP地址二进制串位数(IPV4具有32位,IPV6具有128位)和树中的节点记录数量(节点记录数量越多,树的深度越大)有关,因此为了提高查询效率,减少查询时间(特别是对于32位的IPV4地址),最好能将IPV4CIDR地址和IPV6CIDR地址分开构造查询树;其次需要考虑所构造的查询树的相关操作应该比较简化,例如能对外提供IP地址信息的统一查询接口,IP CIDR块的统一管理接口。因此本发明实施例中采用首先构造整体IP地址归属信息查询树,然后再分别针对IPV4和IPV6CIDR块地址信息构造相应查询树并作为整体查询树的两棵子树的方案,从而到达既提升查询效率,又简化查询接口和方便配置管理的目的。4. Further, according to an embodiment of the present invention, the IP address attribution information query tree of the present invention also has the following characteristics: the IP address attribution information query tree of the present invention contains two subtrees, storing IPV4CIDR address attribution information and IPV6CIDR block address attribution information respectively . In the embodiments of the present invention, at first need to consider the time complexity of the IP address attribution information query tree, the search time complexity is related to the depth of the tree, and the depth of the query tree is mainly related to the number of bits of the IP address binary string (IPV4 has 32 bits, IPV6 has 128 bits) is related to the number of node records in the tree (the more the number of node records, the greater the depth of the tree), so in order to improve query efficiency and reduce query time (especially for 32-bit IPV4 addresses), it is best to use The IPV4CIDR address and the IPV6CIDR address construct the query tree separately; secondly, it is necessary to consider that the related operations of the constructed query tree should be relatively simplified, such as a unified query interface that can provide external IP address information, and a unified management interface for IP CIDR blocks. Therefore adopt in the embodiment of the present invention at first to construct whole IP address attribution information query tree, then construct corresponding query tree respectively for IPV4 and IPV6CIDR block address information and as the scheme of two sub-trees of whole query tree, thereby reach to improve query efficiency, It also simplifies the query interface and facilitates configuration management.
5.本发明提出一种针对本发明IP地址归属信息查询树的查询树构造算法,根据本发明一个实施例,本发明中构造查询树的算法包括如下步骤:5. the present invention proposes a kind of query tree construction algorithm for the IP address attribution information query tree of the present invention, according to an embodiment of the present invention, the algorithm of constructing query tree among the present invention comprises the following steps:
第一步,初始化IP地址归属信息查询树及其对应的俩子树,分别为IPV4查询子树和IPv6查询子树。The first step is to initialize the IP address attribution information query tree and its corresponding two subtrees, which are respectively the IPV4 query subtree and the IPv6 query subtree.
第二步,若配置文件中IP CIDR归属信息记录读取完毕,转第六步;否则从配置文件中读取IP CIDR归属信息记录,以CIDR地址块作为键值,以其网络前缀长度作为比较位来创建新节点,若该CIDR块属于IPV4地址块则转(a);否则转(b)。In the second step, if the IP CIDR attribution information record in the configuration file has been read, go to step six; otherwise, read the IP CIDR attribution information record from the configuration file, use the CIDR address block as the key value, and use the network prefix length as the comparison bit to create a new node, if the CIDR block belongs to the IPV4 address block then turn to (a); otherwise turn to (b).
(a)若IPV4头节点为空,则以该新节点作为IPV4头节点,并将其归属信息关联到该节点,转第二步;否则选择IPV4头节点,转第三步。(a) If the IPV4 head node is empty, then use this new node as the IPV4 head node, and associate its attribution information with this node, and turn to the second step; otherwise, select the IPV4 head node, and turn to the third step.
(b)若IPV6头节点为空,则以该新节点作为IPV6头节点,并将其归属信息关联到该节点,转第二步;否则选择IPV6头节点,转第三步。(b) If the IPV6 head node is empty, then use this new node as the IPV6 head node, and associate its attribution information with this node, and turn to the second step; otherwise, select the IPV6 head node, and turn to the third step.
第三步,从头节点开始遍历对应的子树(IPV4或者IPV6),设查询树中遍历到的当前节点比较位为n,若待插入的新节点键值的第n+1位为0,则遍历查询树中当前节点左子节点,若第n+1位为1,则遍历查询树中当前节点的右子节点,直到遇到(c)中的任一条件为止,计算出查询树中遍历到的当前节点与待插入节点共同的网络前缀长度L,转第四步。The third step is to traverse the corresponding subtree (IPV4 or IPV6) from the head node, and set the comparison bit of the current node traversed in the query tree to be n, if the n+1th bit of the new node key value to be inserted is 0, then Traverse the left child node of the current node in the query tree, if the n+1th bit is 1, traverse the right child node of the current node in the query tree until any condition in (c) is encountered, and calculate the traversal in the query tree Find the common network prefix length L of the current node and the node to be inserted, and go to the fourth step.
(c)条件一:已经遍历到达查询树中叶节点;条件二:遍历到的当前节点为比较位大于待插入的新节点的比较位,且包含CIDR块信息的内部节点。(c) Condition 1: The leaf node in the query tree has been traversed; Condition 2: The current node traversed is an internal node whose comparison bit is greater than that of the new node to be inserted and contains CIDR block information.
第四步,在查询树中按照(d)中规则回退到满足插入新节点位置,转第五步。In the fourth step, in the query tree, follow the rule in (d) to fall back to the position where the new node is inserted, and go to the fifth step.
(d)若L大于树中当前节点的比较位,则回退到当前节点的父节点,并重新设置当前节点为其父节点(即将该父节点设置为当前节点),直到回退到L小于或者等于树中当前节点的比较位为止。(d) If L is greater than the comparison bit of the current node in the tree, roll back to the parent node of the current node, and reset the current node as its parent node (that is, set the parent node as the current node) until it rolls back to L less than Or equal to the comparison bit of the current node in the tree.
第五步,根据(e-h)中规则,将新节点插入到查询树中并根据情况调整查询树,并将其归属信息关联到该节点,转第二步。The fifth step is to insert a new node into the query tree according to the rules in (e-h), adjust the query tree according to the situation, and associate its attribution information to the node, and go to the second step.
(e)若满足L等于查询树中当前节点的比较位,且L等于待插入新节点的比较位,若当前节点为不含有CIDR块信息的内部节点,则将待插入新节点替换该内部节点,否则不处理(即,如果当前节点是含有CIDR块信息的内部节点,则说明该CIDR块信息已经存在不需要再次插入到树中)。(e) If it is satisfied that L is equal to the comparison bit of the current node in the query tree, and L is equal to the comparison bit of the new node to be inserted, if the current node is an internal node that does not contain CIDR block information, replace the internal node with the new node to be inserted , otherwise it is not processed (that is, if the current node is an internal node containing CIDR block information, it means that the CIDR block information already exists and does not need to be inserted into the tree again).
(f)若满足L等于查询树中当前节点的比较位且L小于待插入新节点的比较位,则将新节点作为树中当前节点的一个子节点插入到树中,若待插入新节点的CIDR块的二进制串的第L+1位为0,则作为当前节点的左子节点,若第L+1位为1,则作为当前节点的右子节点。(f) If it is satisfied that L is equal to the comparison bit of the current node in the query tree and L is less than the comparison bit of the new node to be inserted, the new node is inserted into the tree as a child node of the current node in the tree. If the L+1th bit of the binary string of the CIDR block is 0, it is used as the left child node of the current node, and if the L+1th bit is 1, it is used as the right child node of the current node.
(g)若满足L等于待插入新节点的比较位且L小于查询树中当前节点的比较位,则将新节点作为当前节点的父节点插入到树中(顶替当前节点在树中的位置),当前节点及其子树作为新节点的子树,若当前节点CIDR块的二进制串的第L+1位为0,则作为新节点的左子树,若第L+1位为1,则作为新节点的右子树。(g) If it is satisfied that L is equal to the comparison bit of the new node to be inserted and L is less than the comparison bit of the current node in the query tree, insert the new node into the tree as the parent node of the current node (replacing the position of the current node in the tree) , the current node and its subtree are used as the subtree of the new node. If the L+1th bit of the binary string of the CIDR block of the current node is 0, it is used as the left subtree of the new node. If the L+1th bit is 1, then as the right subtree of the new node.
(h)若满足L小于待插入新节点的比较位且L小于查询树中当前节点的比较位,则新建内部节点,设置其关键字为空,比较位为L,顶替当前节点在树中的位置,若待插入的新节点CIDR块的二进制串的第L+1位为0,则作为新建内部节点的左子节点,当前节点及其子树作为新建内部节点的右子树,若待插入的新节点CIDR块的二进制串的第L+1位为1,则作为新建内部节点的右子节点,当前节点及其子树作为新建内部节点的左子树。(h) If it is satisfied that L is less than the comparison bit of the new node to be inserted and L is less than the comparison bit of the current node in the query tree, create a new internal node, set its keyword to empty, and set its comparison bit to L to replace the current node in the tree position, if the L+1th bit of the binary string of the CIDR block of the new node to be inserted is 0, then it will be the left child node of the new internal node, and the current node and its subtree will be the right subtree of the new internal node. The L+1th bit of the binary string of the new node CIDR block is 1, then it is used as the right sub-node of the newly-built internal node, and the current node and its subtree are used as the left sub-tree of the newly-built internal node.
第六步,完成IP地址归属信息查询树构造。The sixth step is to complete the construction of the IP address attribution information query tree.
6.本发明提出一种针对本发明IP地址归属信息查询树的实时更新算法,能够及时的将新节点插入到查询树中,或者从树中删除节点,完成查询树的更新。根据本发明一个实施例,本发明中更新查询树的算法包括如下步骤:6. The present invention proposes a real-time update algorithm for the IP address attribution information query tree of the present invention, which can insert new nodes into the query tree in time, or delete nodes from the tree to complete the update of the query tree. According to one embodiment of the present invention, the algorithm for updating the query tree in the present invention includes the following steps:
第一步,若归属信息更新配置文件读取完毕,转第五步;否则从归属信息更新配置文件中读取一条CIDR归属信息记录,并判断更新操作,若为插入,转第二步;若为删除,转第三步。In the first step, if the attribution information update configuration file is read, go to step five; otherwise, read a CIDR attribution information record from the attribution information update configuration file, and judge the update operation, if it is insert, go to the second step; if For deletion, go to the third step.
第二步,根据读取的CIDR记录的IP地址类别,选择相应的头节点,以CIDR地址块作为键值,以其网络前缀长度作为比较位来创建新节点,执行构造IP地址归属查询树操作的第三、四、五步,将CIDR块记录对应的节点插入到树中;转第一步。In the second step, according to the IP address category of the read CIDR record, select the corresponding head node, use the CIDR address block as the key value, and use the network prefix length as the comparison bit to create a new node, and execute the operation of constructing the IP address attribution query tree The third, fourth, and fifth steps are to insert the corresponding node of the CIDR block record into the tree; go to the first step.
第三步,根据IP地址类别,选择相应的头节点,执行构造IP地址归属查询树的第三,四步操作,定位到待删除CIDR节点在该查询子树中的节点CIDR,比较树中节点CIDR与待删除CIDR是否一致,若一致,则转第四步,否则返回出错信息。The third step is to select the corresponding head node according to the IP address category, perform the third and fourth steps of constructing the IP address attribution query tree, locate the node CIDR of the CIDR node to be deleted in the query subtree, and compare the nodes in the tree Whether the CIDR is consistent with the CIDR to be deleted, if they are consistent, go to step 4, otherwise return an error message.
第四步,根据(i-k)中的规则,从查询树中相应位置删除给定的CIDR块信息,并根据情况调整查询树;转第一步。The fourth step is to delete the given CIDR block information from the corresponding position in the query tree according to the rules in (i-k), and adjust the query tree according to the situation; go to the first step.
(i)如果树中待删除节点为叶子节点,则删除整个节点信息(包括CIDR归属信息),若该叶子节点为其父节点的左子节点,将其父节点左子节点标记为空,反之亦然。(i) If the node to be deleted in the tree is a leaf node, then delete the entire node information (including CIDR attribution information), if the leaf node is the left child node of its parent node, mark the left child node of its parent node as empty, otherwise The same is true.
(j)如果树中待删除节点为内部节点且只有一个子节点,则删除整个节点信息(包括CIDR归属信息),并用其子节点代替其在树中的位置。(j) If the node to be deleted in the tree is an internal node and has only one child node, delete the entire node information (including CIDR attribution information), and replace its position in the tree with its child node.
(k)如果树中待删除节点为内部节点且拥有两个子节点,则只删除该节点的CIDR信息,保留该节点及其比较位,整个树结构不做调整。(k) If the node to be deleted in the tree is an internal node and has two child nodes, only the CIDR information of the node is deleted, and the node and its comparison bit are retained, and the entire tree structure is not adjusted.
第五步,完成IP地址归属信息查询树更新。The fifth step is to complete the update of the IP address attribution information query tree.
7.本发明提出一种针对本发明IP地址归属信息查询树的IP地址归属信息快速查询算法,根据本发明的一个实施例,本发明IP地址归属信息查询需要快速的找到第一个满足最长匹配的CIDR块,而满足最长匹配的CIDR块一般情况下都是位于某个叶子节点处或者位于靠近叶子节点的某个内部节点处,因此如何快速的到达这些节点关乎到查询速度,本发明设计的先寻叶再回溯的方法能够很好的解决这一问题,避免了遍历查询树时对相关节点逐次的匹配比较,使得整体的平均查询比较次数降低很多,查询速度得到很大提升。本发明快速查询算法包含如下步骤:7. The present invention proposes a fast IP address attribution information query algorithm for the IP address attribution information query tree of the present invention. According to an embodiment of the present invention, the IP address attribution information query of the present invention needs to quickly find the first one that satisfies the longest Matching CIDR blocks, and the CIDR blocks that satisfy the longest match are generally located at a certain leaf node or at an internal node close to the leaf node, so how to quickly reach these nodes is related to the query speed, the present invention The designed method of first finding leaves and then backtracking can solve this problem very well, avoiding the sequential matching and comparison of relevant nodes when traversing the query tree, so that the overall average query comparison times are greatly reduced, and the query speed is greatly improved. The fast query algorithm of the present invention comprises the following steps:
第一步,完成初始化工作,包括设置栈等。The first step is to complete the initialization work, including setting up the stack and so on.
第二步,根据待查询IP地址的类型在查询树中选择IPV4头节点或者IPV6头节点,从头节点开始深度优先方法遍历查询树;转第三步。The second step is to select an IPV4 head node or an IPV6 head node in the query tree according to the type of the IP address to be queried, and traverse the query tree in a depth-first manner from the head node; turn to the third step.
第三步,执行(l)中寻叶操作,直到到达查询树的叶子节点为止,并在寻叶遍历过程中将查询树中所有含有CIDR块归属信息的节点(包含所有内部节点和最后到达的叶子节点)压入第一步操作设置的栈中;转第四步。The third step is to perform the leaf-finding operation in (1) until the leaf node of the query tree is reached, and in the leaf-finding traversal process, all nodes containing CIDR block attribution information in the query tree (including all internal nodes and the last arrived leaf node) into the stack set by the first step operation; turn to the fourth step.
(l)设树中遍历到的当前节点的比较位为n,若待查询IP地址对应的二进制串的第n+1位为0,则遍历当前节点的左子节点,若第n+1位为1,则遍历当前节点的右子节点。(l) Let the comparison bit of the current node traversed in the tree be n, if the n+1th bit of the binary string corresponding to the IP address to be queried is 0, then traverse the left child node of the current node, if the n+1th bit If it is 1, it traverses the right child node of the current node.
第四步,遍历含有CIDR块地址归属信息节点的栈,直到栈为空或者栈顶节点与待查询IP地址匹配为止,若栈顶节点与待查询IP地址不匹配,则弹出栈顶节点(即,将没匹配的节点丢弃掉);转第五步。The fourth step is to traverse the stack containing the CIDR block address attribution information node until the stack is empty or the top node of the stack matches the IP address to be queried. If the top node of the stack does not match the IP address to be queried, the top node of the stack is popped (ie , discard the unmatched nodes); turn to step five.
第五步,判断栈的状态,若栈为空(即栈中所有节点都没匹配会出现空栈的情况),则返回空值或者未找到;若栈不为空,转第六步。The fifth step is to judge the state of the stack. If the stack is empty (that is, if all the nodes in the stack do not match, an empty stack will appear), return a null value or not found; if the stack is not empty, go to the sixth step.
第六步,判断IP地址归属信息配置状态,若配置了多归属信息,则返回栈中所有节点的归属信息,若只配置了唯一归属信息,则只返回栈顶节点的归属信息(由于栈顶节点是满足最长匹配的CIDR块,而且只要栈顶元素满足匹配,则栈中剩余节点都会满足匹配的)。The sixth step is to judge the configuration status of IP address attribution information. If multi-homing information is configured, the attribution information of all nodes in the stack will be returned. If only unique attribution information is configured, only the attribution information of the top node in the stack will be returned (due to The node is the CIDR block that satisfies the longest match, and as long as the top element of the stack satisfies the match, the rest of the nodes in the stack will also satisfy the match).
与现有技术相比,本发明的积极效果为:Compared with prior art, positive effect of the present invention is:
1.本发明中IP地址归属信息查询方法每次只需在主体系统(如网络监控系统,安全系统)启动时进行初始化,然后常驻内存,只有当发现相应的配置文件中有更新操作时,将重新更新整个树,将配置中删除的监控对象从树中删除,将配置中增加的监控对象插入到树中,相比数据库查询具有更高的效率。1. in the present invention, the IP address attribution information query method only needs to be initialized when the main body system (such as a network monitoring system, a security system) starts, and then resides in the internal memory. Only when it is found that there is an update operation in the corresponding configuration file, The entire tree will be updated again, the monitoring objects deleted in the configuration will be deleted from the tree, and the monitoring objects added in the configuration will be inserted into the tree, which is more efficient than database queries.
2.本发明中的IP CIDR归属信息的树索引方式能够有效的存储IP CIDR归属信息,且本发明中不同归属信息的IP CIDR块允许包含相同的IP地址,一个IP地址归属于一个或者多个CIDR块,具有一个或者多个归属信息,并能够在查询时返回查询树中与该IP地址匹配的所有CIDR块的归属信息,能够根据实时需求在线更新IP CIDR地址块的归属信息,相比较已有的Geo IP,QQ二进制地址库具有更高的灵活性。2. The tree index method of the IP CIDR attribution information in the present invention can effectively store the IP CIDR attribution information, and the IP CIDR blocks of different attribution information in the present invention are allowed to contain the same IP address, and one IP address belongs to one or more CIDR block has one or more attribution information, and can return the attribution information of all CIDR blocks matching the IP address in the query tree during query, and can update the attribution information of IP CIDR address blocks online according to real-time needs. Compared with existing Some Geo IP, QQ binary address library has higher flexibility.
3.本发明中IP地址快速查询算法的寻叶与回退步骤的时间复杂度与IP地址归属信息查询树的深度有关,时间复杂度最优为O(log N),最差为O(N)(对于IPV4地址N为32,IPV6地址N为128),由于这两个步骤只需要做位运算的比较操作,即使在最坏情况下查询速度也是很快,而且首先寻叶的操作实践证明可以使得整个查询中的比较次数期望值最小,提升平均查询速度,能够很好的满足运营商级别的网络流量监控系统毫秒级的实时性要求的应用;同时其空间复杂度为O(n)(n为CIDR块地址数量),以目前硬件所能提供的存储能力完全满足其要求。3. The time complexity of the leaf-seeking and fallback steps of the IP address fast query algorithm in the present invention is related to the depth of the IP address attribution information query tree, and the time complexity is optimally O(log N), and worst is O(N ) (for IPV4 address N is 32, and for IPV6 address N is 128), since these two steps only need to do comparison operations of bit operations, the query speed is very fast even in the worst case, and the practice of first finding leaves has proved that It can minimize the expected value of the number of comparisons in the entire query, increase the average query speed, and can well meet the real-time requirements of the operator-level network traffic monitoring system in milliseconds; at the same time, its space complexity is O(n)(n is the number of CIDR block addresses), and the storage capacity provided by the current hardware fully meets its requirements.
附图说明Description of drawings
附图1为本发明构造IP地址归属信息查询树的示例图;Accompanying drawing 1 is the example figure that the present invention constructs IP address attribution information inquiry tree;
附图2为本发明构造的用IPV4内网地址块实例化的IP查询树示意图;Accompanying drawing 2 is the IP query tree schematic diagram instantiated with the IPV4 intranet address block of structure of the present invention;
附图3为本发明构造IP地址归属信息查询树的算法流程图;Accompanying drawing 3 is the algorithm flowchart of the structure IP address attribution information inquiry tree of the present invention;
附图4为本发明附图2查询树进行更新操作后的IP查询树示意图;Accompanying drawing 4 is the schematic diagram of the IP query tree after the update operation of the query tree of accompanying drawing 2 of the present invention;
附图5为本发明IP地址归属信息查询树查找算法流程图。Accompanying drawing 5 is the flow chart of IP address attribution information query tree search algorithm of the present invention.
具体实施方式detailed description
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行完整的表述。包括IP地址归属信息查询树的构造、更新和IP地址归属信息查询算法。The technical solutions in the embodiments of the present invention will be fully described below in conjunction with the drawings in the embodiments of the present invention. Including the construction and update of the IP address attribution information query tree and the IP address attribution information query algorithm.
1.IP地址归属信息查询树构造包括两步:1. IP address attribution information query tree construction includes two steps:
首先,定义IP CIDR地址块归属信息,形成配置文件。First, define IP CIDR address block attribution information to form a configuration file.
第一步,结合实际应用中的要求,确定需要的归属信息记录格式,由CIDR块,国家名称等字段组成,其中CIDR块字段是不可缺少的字段,其他字段可以根据实际需求增减。The first step is to determine the required attribution information record format based on the requirements in practical applications, which consists of fields such as CIDR block and country name, among which the CIDR block field is an indispensable field, and other fields can be increased or decreased according to actual needs.
第二步,根据第一步确定的归属信息记录格式,从GeoIP csv等文件中抽取出需要的IPCIDR块以及归属信息字段,并补充GeoIP csv等文件中不存在的字段值,组织成归属信息记录;同时增加自定义的IP CIDR块(GeoIP中不存在)归属信息记录;In the second step, according to the attribution information record format determined in the first step, the required IPCIDR blocks and attribution information fields are extracted from GeoIP csv and other files, and field values that do not exist in GeoIP csv and other files are added to form attribution information records ;At the same time, add a custom IP CIDR block (does not exist in GeoIP) attribution information record;
第三步,将IP CIDR归属信息记录保存于配置文件中,如表1所示。The third step is to save the IP CIDR attribution information record in the configuration file, as shown in Table 1.
表1为本发明IP CIDR地址归属信息配置文件的示意:Table 1 is a schematic representation of the IP CIDR address attribution information configuration file of the present invention:
其次,构造IP地址归属信息查询树。Second, construct an IP address attribution information query tree.
如图1所示为本发明构造的IP地址归属信息查询树示意图,其中树根节点包含两个子节点,一个是IPV4头节点,IPV4的CIDR归属信息保存在以该节点为根的树中;另一个是IPV6头节点,IPV6的CIDR归属信息保存在以该节点为根的树中。As shown in Figure 1, it is the IP address attribution information query tree schematic diagram of the present invention structure, and wherein tree root node comprises two child nodes, and one is IPV4 head node, and the CIDR attribution information of IPV4 is stored in the tree taking this node as root; One is the IPV6 head node, and the CIDR attribution information of IPV6 is stored in a tree rooted at this node.
如图2所示为只有IPV4地址块的查询树示意图,为了方便说明查询树的构造,树中节点用IPV4内网地址块进行实例化。Figure 2 is a schematic diagram of a query tree with only IPV4 address blocks. In order to facilitate the description of the structure of the query tree, nodes in the tree are instantiated with IPV4 intranet address blocks.
如图3所示为本发明实施例IP地址归属信息查询树的构造算法流程图。以下将结合表1所示配置文件,图2以及图3,以构造图2中IPV4查询树为例,详细描述本发明实施例IP地址归属信息查询树的构造(IPV6树的构造和IPV4树构造过程是一样,以下不再做描述):FIG. 3 is a flowchart of an algorithm for constructing an IP address attribution information query tree according to an embodiment of the present invention. Below in conjunction with the configuration file shown in Table 1, Fig. 2 and Fig. 3, take the structure of IPV4 query tree in Fig. 2 as an example, describe in detail the structure of the IP address attribution information query tree in the embodiment of the present invention (the structure of the IPV6 tree and the structure of the IPV4 tree The process is the same and will not be described below):
配置文件中CIDR块依次为:192.168.10.0/23,192.168.12.0/23,192.168.8.0/21,192.168.4.0/22。The CIDR blocks in the configuration file are: 192.168.10.0/23, 192.168.12.0/23, 192.168.8.0/21, 192.168.4.0/22.
第一步,初始化IP地址归属信息查询树根节点,以及IPV4头节点。The first step is to initialize the root node of the IP address attribution information query tree and the IPV4 head node.
第二步,从配置文件中读取192.168.10.0/23块记录,以192.168.10.0作为键值,以23作为比较位,创建新节点,执行以下(a)中操作,并将其插入树中。The second step is to read the 192.168.10.0/23 block record from the configuration file, use 192.168.10.0 as the key value, and use 23 as the comparison bit to create a new node, perform the following operations in (a), and insert it into the tree .
(a)此时,IPV4头节点为空,以92.168.10.0/23节点作为IPV4头节点,并将其归属信息关联到该节点。(a) At this time, the IPV4 head node is empty, and the 92.168.10.0/23 node is used as the IPV4 head node, and its attribution information is associated with this node.
第三步,从配置文件中读取192.168.12.0/23块记录,以192.168.12.0作为键值,以23作为比较位,创建新节点,执行以下(b-e)中操作,将其插入到查询树中,并将其归属信息关联到该节点。The third step is to read the 192.168.12.0/23 block record from the configuration file, use 192.168.12.0 as the key value, and 23 as the comparison bit, create a new node, perform the following (b-e) operations, and insert it into the query tree , and associate its attribution information with this node.
(b)从第一步创建的头节点开始遍历对应的IPV4查询树,当前树中只有一个节点192.168.10.0/23,因此已经遍历到达IPV4查询树中叶节点,终止遍历,并计算出待插入节点与树中当前节点的共同网络前缀长度为21;由于树中只有一个节点,不再执行回退操作。(b) Start traversing the corresponding IPV4 query tree from the head node created in the first step. There is only one node 192.168.10.0/23 in the current tree, so it has traversed to reach the leaf node in the IPV4 query tree, terminate the traversal, and calculate the node to be inserted The common network prefix length with the current node in the tree is 21; since there is only one node in the tree, no fallback operation is performed.
(c)创建内部节点,设置其CIDR块地址为空,比较位为21,并作为192.168.10.0/23与192.168.12.0/23的父节点。(c) Create an internal node, set its CIDR block address to be empty, compare bit to 21, and serve as the parent node of 192.168.10.0/23 and 192.168.12.0/23.
(d)利用(c)中创建的内部节点的比较位计算可知,192.168.10.0/23作为该内部节点的左子节点,192.168.12.0/23作为其右子结点。(d) Using the comparison bit calculation of the internal node created in (c), it can be known that 192.168.10.0/23 is the left child node of the internal node, and 192.168.12.0/23 is its right child node.
(e)重新调整(c)中内部节点为IPV4查询树头节点。(e) Readjust the internal node in (c) to be the head node of the IPV4 query tree.
第四步,从配置文件中读取192.168.8.0/21块记录,以192.168.8.0作为键值,以21作为比较位,创建新节点,执行以下(f-h)中操作,将其插入查询树中,并将其归属信息关联到该节点。The fourth step is to read the 192.168.8.0/21 block record from the configuration file, use 192.168.8.0 as the key value, and 21 as the comparison bit, create a new node, perform the following (f-h) operations, and insert it into the query tree , and associate its attribution information to this node.
(f)从第三步中调整后的新头节点开始遍历对应的IPV4查询树,利用树中当前节点比较位计算可知,下一步选择遍历其左子树节点192.168.10.0/23,此时已经遍历到达IPV4查询树中叶节点,终止遍历,并计算出待插入节点与树中当前节点的共同网络前缀长度为21。(f) Start traversing the corresponding IPV4 query tree from the adjusted new head node in the third step, and use the current node comparison bit calculation in the tree to know that the next step is to choose to traverse its left subtree node 192.168.10.0/23, which is already The traversal reaches the leaf node in the IPV4 query tree, terminates the traversal, and calculates that the common network prefix length of the node to be inserted and the current node in the tree is 21.
(g)执行回退操作,根据(f)中计算出的共同网络前缀长度,回退到比较位为21的头节点。(g) Perform a rollback operation, and roll back to the head node whose comparison bit is 21 according to the common network prefix length calculated in (f).
(h)执行完(g)后回退到IPV4头节点处,该节点为内部节点,且该内部节点没有保存CIDR块地址信息,因此用192.168.8.0/21块地址节点代替树中当前节点。(h) Return to the IPV4 head node after executing (g), which is an internal node, and the internal node does not save the CIDR block address information, so replace the current node in the tree with the 192.168.8.0/21 block address node.
第五步,从配置文件中读取192.168.4.0/22块记录,以192.168.4.0作为键值,以22作为比较位,创建新节点,执行以下(i-m)中操作,并将其插入树中。The fifth step is to read the 192.168.4.0/22 block record from the configuration file, use 192.168.4.0 as the key value, and use 22 as the comparison bit, create a new node, perform the following (i-m) operations, and insert it into the tree .
(i)从第四步中调整后的新头节点192.168.8.0/21开始遍历对应的IPV4查询树,利用头节点比较位计算可知,下一步选择遍历其左子树节点192.168.10.0/23,此时已经遍历到达IPV4查询树中叶节点,终止遍历,并计算出待插入节点与树中当前节点的共同网络前缀长度为20。(i) From the new head node 192.168.8.0/21 adjusted in the fourth step, start traversing the corresponding IPV4 query tree, and use the head node comparison bit calculation to know that the next step selects to traverse its left subtree node 192.168.10.0/23, At this time, the traversal has reached the leaf node in the IPV4 query tree, the traversal is terminated, and the length of the common network prefix between the node to be inserted and the current node in the tree is calculated to be 20.
(j)执行回退操作,根据(i)中计算出的共同网络前缀长度,回退到比较位为21的头节点。(j) Perform a rollback operation, and roll back to the head node whose comparison bit is 21 according to the common network prefix length calculated in (i).
(k)创建内部节点,设置其CIDR块地址为空,比较位为20,并作为192.168.8.0/21与192.168.4.0/22的父节点。(k) Create an internal node, set its CIDR block address to be empty, compare bit to 20, and serve as the parent node of 192.168.8.0/21 and 192.168.4.0/22.
(l)利用(k)中创建的内部节点的比较位计算可知,192.168.4.0/22作为该内部节点的左子节点,192.168.8.0/21作为其右子节点。(l) Using the comparison bit calculation of the internal node created in (k), it can be seen that 192.168.4.0/22 is the left child node of the internal node, and 192.168.8.0/21 is the right child node.
(m)重新调整(k)中内部节点为IPV4查询树头节点。(m) Readjust the internal node in (k) to be the head node of the IPV4 query tree.
第六步,完成IPV4地址归属信息查询树构造。The sixth step is to complete the construction of the IPV4 address attribution information query tree.
2.IP地址归属信息查询树更新包括新增CIDR块信息,删除已有的CIDR块信息,新增操作跟构造树时插入一个新节点相同,因此以下不再做详细描述了;删除操作只需找到树中包含指定CIDR的节点,然后删除该节点的CIDR信息,并根据情况调整查询树。2. The IP address attribution information query tree update includes adding new CIDR block information and deleting existing CIDR block information. The new operation is the same as inserting a new node when constructing the tree, so the following will not be described in detail; Find the node that contains the specified CIDR in the tree, then delete the CIDR information of the node, and adjust the query tree according to the situation.
如图4为删除图2中192.168.8.0/21块地址后的查询树示意图,以下将结合图2、图4,以删除图2查询树中192.168.8.0/21地址块为例,详细描述本发明实施例IPV4地址归属信息查询树的删除CIDR的更新操作:Figure 4 is a schematic diagram of the query tree after deleting the address block 192.168.8.0/21 in Figure 2. The following will combine Figure 2 and Figure 4 to delete the 192.168.8.0/21 address block in the query tree in Figure 2 as an example to describe this in detail. Invention embodiment IPV4 address attribution information query tree deletion CIDR update operation:
第一步,从更新树配置文件读取192.168.8.0/21块记录,并构造新节点。The first step is to read the 192.168.8.0/21 block record from the update tree configuration file and construct a new node.
第二步,从图2中IPV4头节点开始遍历整个查询树,利用树中当前节点比较位计算可知,下一步选择遍历节点192.168.8.0/21,然后再遍历192.168.10.0/23,此时已经遍历到达IPV4查询树中叶节点,终止遍历,计算出待删除节点与树中当前节点的共同网络前缀长度为21。The second step is to traverse the entire query tree from the IPV4 head node in Figure 2, and use the current node comparison bit calculation in the tree to know that the next step is to traverse the node 192.168.8.0/21, and then traverse 192.168.10.0/23. The traversal reaches the leaf node in the IPV4 query tree, terminates the traversal, and calculates that the common network prefix length of the node to be deleted and the current node in the tree is 21.
第三步,执行回退操作,根据第二步中计算出的共同网络前缀长度,回退到比较位为21的内部节点192.168.8.0/21;比较发现当前内部节点其CIDR块也为192.168.8.0/21,因此可以正确删除,执行删除操作。The third step is to perform a rollback operation. According to the common network prefix length calculated in the second step, roll back to the internal node 192.168.8.0/21 whose comparison bit is 21; the comparison finds that the CIDR block of the current internal node is also 192.168. 8.0/21, so it can be deleted correctly, perform the delete operation.
第四步,根据查询树的结构,查询树中当前节点192.168.8.0/21虽然为内部节点,但具有两个子节点,因此删除192.168.8.0/21块信息后无需调整树结构,因此只需从树中当前节点删除其CIDR块信息,并设置其比较位仍然为21即可。In the fourth step, according to the structure of the query tree, although the current node 192.168.8.0/21 in the query tree is an internal node, it has two child nodes, so there is no need to adjust the tree structure after deleting the 192.168.8.0/21 block information, so you only need to start from The current node in the tree deletes its CIDR block information and sets its comparison bit to 21.
第五步,完成查询树的更新,并更新配置文件。The fifth step is to complete the update of the query tree and update the configuration file.
3.IP地址归属信息查询树查询算法3. IP address attribution information query tree query algorithm
如图5所示为本发明IP地址归属信息查询树查找算法流程图,以下将结合图2中的查询树与图5查询树查找流程图,以查询192.168.10.1为例,详细描述本发明实施例IP地址归属信息查询过程:As shown in Figure 5, it is a flow chart of the IP address attribution information query tree search algorithm of the present invention. The following will combine the query tree in Figure 2 and the query tree search flow chart in Figure 5, taking the query 192.168.10.1 as an example to describe the implementation of the present invention in detail Example IP address attribution information query process:
第一步,完成初始化栈等。The first step is to complete the initialization stack and so on.
第二步,从图2中IPV4头节点开始遍历整个查询树,利用树中当前节点比较位计算可知,下一步选择遍历节点192.168.8.0/21,然后再遍历192.168.10.0/23,此时已经遍历到达IPV4查询树中叶节点,终止遍历;并在寻叶遍历过程中将遇到的CIDR信息192.168.8.0/21和192.168.10.0/23依次压入第一步操作设置的栈中。The second step is to traverse the entire query tree from the IPV4 head node in Figure 2, and use the current node comparison bit calculation in the tree to know that the next step is to traverse the node 192.168.8.0/21, and then traverse 192.168.10.0/23. When the traversal reaches the leaf node in the IPV4 query tree, the traversal is terminated; and the CIDR information 192.168.8.0/21 and 192.168.10.0/23 encountered during the leaf-seeking traversal process are sequentially pushed into the stack set by the first step operation.
第三步,遍历第二步中保存CIDR块地址信息的栈,首先取出栈顶元素192.168.10.0/23,并比较192.168.10.0与192.168.10.1的前23位,其结果为相同,故查询到192.168.10.1属于192.168.10.0/23块地址。The third step is to traverse the stack that saves the CIDR block address information in the second step, first take out the top element of the stack 192.168.10.0/23, and compare the first 23 bits of 192.168.10.0 and 192.168.10.1, the result is the same, so query 192.168.10.1 belongs to the 192.168.10.0/23 block address.
第四步,判断IP地址归属信息配置状态,若配置了多归属信息,则返回栈中192.168.8.0/21和192.168.10.0/23的归属信息,若只配置了唯一归属信息,则只返回栈顶节点192.168.10.0/23的归属信息。The fourth step is to judge the configuration status of IP address attribution information. If multi-homing information is configured, the attribution information of 192.168.8.0/21 and 192.168.10.0/23 in the stack will be returned. If only unique attribution information is configured, only the attribution information will be returned to the stack Ownership information of the top node 192.168.10.0/23.
Claims (9)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201310581441.0A CN103561133B (en) | 2013-11-19 | 2013-11-19 | A kind of IP address attribution information index method and method for quickly querying |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201310581441.0A CN103561133B (en) | 2013-11-19 | 2013-11-19 | A kind of IP address attribution information index method and method for quickly querying |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN103561133A CN103561133A (en) | 2014-02-05 |
| CN103561133B true CN103561133B (en) | 2016-08-24 |
Family
ID=50015283
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201310581441.0A Expired - Fee Related CN103561133B (en) | 2013-11-19 | 2013-11-19 | A kind of IP address attribution information index method and method for quickly querying |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN103561133B (en) |
Families Citing this family (23)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN103902715B (en) * | 2014-04-03 | 2017-12-22 | 北京国双科技有限公司 | IP range lookup method and apparatus |
| US9692727B2 (en) * | 2014-12-02 | 2017-06-27 | Nicira, Inc. | Context-aware distributed firewall |
| US10075411B2 (en) | 2015-01-07 | 2018-09-11 | Sony Corporation | Method and system for processing a geographical internet protocol (IP) lookup request |
| CN105025013B (en) * | 2015-06-12 | 2018-04-10 | 国家计算机网络与信息安全管理中心 | The method for building up of dynamic IP Matching Model based on priority Trie trees |
| CN105357334B (en) * | 2015-11-21 | 2019-03-01 | 广州咨元信息科技有限公司 | A kind of storage of the address IPV6 and method for quickly querying based on the division of the address IPV6 |
| CN105512229B (en) * | 2015-11-30 | 2019-02-22 | 北京奇艺世纪科技有限公司 | A kind of storage, querying method and the device of the regional information of IP address |
| CN105528463B (en) * | 2016-01-21 | 2018-12-14 | 北京奇艺世纪科技有限公司 | A kind of the index data loading method and device of search engine |
| CN106649464B (en) * | 2016-09-26 | 2019-08-30 | 深圳市数字城市工程研究中心 | Method and device for constructing a Chinese address tree |
| CN106777163B (en) * | 2016-12-20 | 2020-05-26 | 携程旅游网络技术(上海)有限公司 | Method and system for querying IP address based on red-black tree |
| CN107169054A (en) * | 2017-04-26 | 2017-09-15 | 四川长虹电器股份有限公司 | Ip indexing means based on prefix forest |
| CN107807976B (en) * | 2017-10-25 | 2021-01-12 | 世纪龙信息网络有限责任公司 | IP home location query method and device |
| CN108875006B (en) * | 2018-06-15 | 2021-03-30 | 泰康保险集团股份有限公司 | Method and device for determining IP address region |
| CN109151088A (en) * | 2018-08-20 | 2019-01-04 | 下代互联网重大应用技术(北京)工程研究中心有限公司 | The statistical method of IPv6 access user's geographical distribution ranking based on Http log |
| CN109802959A (en) * | 2019-01-07 | 2019-05-24 | 烽火通信科技股份有限公司 | Internet protocol selection method and system under double stack environment |
| CN111310076B (en) * | 2020-02-25 | 2023-10-03 | 同盾控股有限公司 | Geographic position query method, geographic position query device, geographic position query medium and electronic equipment |
| CN112737830B (en) * | 2020-12-25 | 2022-07-29 | 杭州迪普科技股份有限公司 | Method and device for calibrating detection target information reported by mechanism |
| CN114978563B (en) * | 2021-02-26 | 2024-05-24 | 中国移动通信集团广东有限公司 | Method and device for blocking IP address |
| CN114443707A (en) * | 2021-12-27 | 2022-05-06 | 天翼云科技有限公司 | Address query method and device, electronic equipment and storage medium |
| CN115237916A (en) * | 2022-07-26 | 2022-10-25 | 天翼云科技有限公司 | Method and device for retrieving address and electronic equipment |
| CN115941645B (en) * | 2022-10-13 | 2025-07-22 | 平安银行股份有限公司 | Query method and device for IP (Internet protocol) home of user, electronic equipment and storage medium |
| CN115955341A (en) * | 2022-12-19 | 2023-04-11 | 北京天融信网络安全技术有限公司 | Data processing method and device based on IP address range |
| CN115858542B (en) * | 2023-03-03 | 2023-06-13 | 神州灵云(北京)科技有限公司 | GeoIPv6 tree index method, system and electronic equipment |
| CN116668399B (en) * | 2023-05-09 | 2025-09-16 | 中国联合网络通信集团有限公司 | IP address query method, device and storage medium |
Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN1489849A (en) * | 2001-01-30 | 2004-04-14 | ŵ�������ܱ�Ե·������˾ | Method and apparatus for triple content addressable memory (TCAM) table management |
| CN1507229A (en) * | 2002-12-10 | 2004-06-23 | ����ͨѶ�ɷ�����˾ | Routing table organization and lookup method |
| CN103051543A (en) * | 2012-11-01 | 2013-04-17 | 广州微仕科信息技术有限公司 | Route prefix processing, lookup, adding and deleting method |
-
2013
- 2013-11-19 CN CN201310581441.0A patent/CN103561133B/en not_active Expired - Fee Related
Patent Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN1489849A (en) * | 2001-01-30 | 2004-04-14 | ŵ�������ܱ�Ե·������˾ | Method and apparatus for triple content addressable memory (TCAM) table management |
| CN1507229A (en) * | 2002-12-10 | 2004-06-23 | ����ͨѶ�ɷ�����˾ | Routing table organization and lookup method |
| CN103051543A (en) * | 2012-11-01 | 2013-04-17 | 广州微仕科信息技术有限公司 | Route prefix processing, lookup, adding and deleting method |
Non-Patent Citations (2)
| Title |
|---|
| IPv6路由器快速路径查找算法;华伟臣;《中国优秀硕士论文电子期刊网》;20070315;全文 * |
| 基于前缀值的IPv6路由查找算法研究;赵国锋;《中国优秀硕士论文电子期刊网》;20081015;全文 * |
Also Published As
| Publication number | Publication date |
|---|---|
| CN103561133A (en) | 2014-02-05 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN103561133B (en) | A kind of IP address attribution information index method and method for quickly querying | |
| CN103703467B (en) | Method and device for storing data | |
| US8744770B2 (en) | Path oracles for spatial networks | |
| CN102346747B (en) | Method for searching parameters in data model | |
| CN102521334A (en) | Data storage and query method based on classification characteristics and balanced binary tree | |
| CN101388030A (en) | Database and database processing methods | |
| CN112256821B (en) | Chinese address completion method, device, equipment and storage medium | |
| CN102148746A (en) | Message classification method and system | |
| CN110928882B (en) | Memory database indexing method and system based on improved red black tree | |
| CN107330094B (en) | Bloom filter tree structure and key-value pair storage method for dynamically storing key-value pairs | |
| US20080270352A1 (en) | Modifying entry names in directory server | |
| WO2022241813A1 (en) | Graph database construction method and apparatus based on graph compression, and related component | |
| CN100496019C (en) | A Method for Rapid Search and Update of IPv6 Routing Table | |
| CN108197313A (en) | The dictionary index method of space optimization is realized by 16 Trie trees | |
| CN102193983A (en) | Relation path-based node data filtering method of graphic database | |
| CN100397816C (en) | Method for classifying received data packets in network equipment | |
| CN104780101B (en) | Content center network Forwarding plane fib table structure and its search method | |
| CN101256579A (en) | A method of database range query data organization | |
| CN116126864A (en) | Index construction method, data query method and related equipment | |
| CN106202102A (en) | Batch data querying method and device | |
| CN110413711A (en) | A kind of variance data acquisition methods and its storage medium | |
| CN111641729A (en) | Inter-domain path identification prefix conflict detection and decomposition method based on prefix tree | |
| CN115834340A (en) | Rule storage method and device, electronic equipment and storage medium | |
| CN115086221A (en) | Message processing method, device, forwarding equipment and storage medium | |
| CN108959584A (en) | A kind of method and device of the processing diagram data based on community structure |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| C06 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| C14 | Grant of patent or utility model | ||
| GR01 | Patent grant | ||
| 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: 20160824 Termination date: 20191119 |