Route query method and device, electronic equipment, storage medium and program product

CN121664724BActive Publication Date: 2026-10-23BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202511910001.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-12-17
Publication Date
2026-10-23
Estimated Expiration
2045-12-17

AI Technical Summary

Technical Problem

[0003]本申请提供了一种路由查询方法、装置、电子设备、存储介质及程序产品,以解决用于路由表查找的存储器难以支持大规模路由表的查找问题

Benefits of technology

[0009]本申请实施例提供的路由查询方法,基于预设存储空间大小对第一路由表中路由条目对应的第一路由区间进行层级划分,得到第一路由树。其中,预设存储空间大小与用于路由表查找的存储器有关。因此,能够将路由条目对应的第一路由区间拆分成多个层级进行分别存储,从而确保各个路由条目对应的第一路由区间在各个层级所要占用的存储空间大小不超过预设存储空间大小,以满足存储器的存储要求。由此,在通过第一路由树查询与第一网络地址相匹配的目标路由区间时,每一层级需要查询的内容均满足存储器的存储要求,即便在存储器的存储容量受限的情况下,也可以支持大规模路由表的查找。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121664724B_ABST
    Figure CN121664724B_ABST
Patent Text Reader

Abstract

The application relates to the computer technical field and discloses a routing query method and device, electronic equipment, a storage medium and a program product. The method comprises the following steps: acquiring a first network address; querying a target routing interval matched with the first network address in a first routing tree; wherein the first routing tree is obtained by hierarchically dividing first routing intervals corresponding to routing entries in a first routing table based on a preset storage space size; the preset storage space size is related to a memory used for routing table lookup; leaf nodes of the first routing tree correspond to the routing entries in the first routing table; and a target routing entry is determined based on the target routing interval and a mapping relationship between the first routing interval and the routing entries in the first routing table. The application can solve the problem that the memory used for routing table lookup is difficult to support the lookup of a large-scale routing table.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, specifically to routing query methods, devices, electronic devices, storage media, and program products. Background Technology

[0002] In large-scale public cloud networks, gateway devices, as critical nodes for communication between tenant networks and external networks, need to maintain massive numbers of routing entries to support core capabilities such as multi-tenant isolation, cross-region access, and elastic scaling. However, with the growth in the number of tenants, the expansion of business scale, and the increasing complexity of network architecture, routing tables grow exponentially. The storage capacity of the gateway device's memory used for routing table lookups is limited, making it difficult to support large-scale routing table lookups. Summary of the Invention

[0003] This application provides a routing lookup method, apparatus, electronic device, storage medium, and program product to solve the problem that memory used for routing table lookup is difficult to support large-scale routing table lookups.

[0004] Firstly, this application provides a route lookup method, including: Obtain the first network address; Query the target routing interval in the first routing tree that matches the first network address; wherein, the first routing tree is obtained by hierarchically dividing the first routing interval corresponding to the routing entry in the first routing table based on a preset storage space size; the preset storage space size is related to the memory used for routing table lookup; the leaf nodes of the first routing tree correspond to the routing entries in the first routing table; Based on the target routing interval and the mapping relationship between the first routing interval and the routing entries in the first routing table, the target routing entry is determined.

[0005] Secondly, this application provides a routing query apparatus, comprising: The address acquisition module is used to obtain the first network address; The interval query module is used to query the target routing interval in the first routing tree that matches the first network address; wherein, the first routing tree is obtained by hierarchically dividing the first routing interval corresponding to the routing entries in the first routing table based on a preset storage space size; the preset storage space size is related to the memory used for routing table lookup; the leaf nodes of the first routing tree correspond to the routing entries in the first routing table; The entry analysis module is used to determine the target route entry based on the target route interval and the mapping relationship between the first route interval and the route entries in the first route table.

[0006] Thirdly, this application provides an electronic device, including: a memory and a processor, which are communicatively connected to each other. The memory stores computer instructions, and the processor executes the computer instructions to perform the routing query method of the first aspect or any corresponding embodiment described above.

[0007] Fourthly, this application provides a computer-readable storage medium storing computer instructions for causing a computer to execute the routing query method of the first aspect or any corresponding embodiment described above.

[0008] Fifthly, this application provides a computer program product, including computer instructions for causing a computer to execute the routing query method described in the first aspect or any corresponding embodiment thereof.

[0009] The routing query method provided in this application hierarchically divides the first routing intervals corresponding to routing entries in a first routing table into a first routing tree based on a preset storage space size. The preset storage space size is related to the memory used for routing table lookups. Therefore, the first routing intervals corresponding to routing entries can be split into multiple levels for separate storage, ensuring that the storage space occupied by the first routing intervals corresponding to each routing entry at each level does not exceed the preset storage space size, thus meeting the storage requirements of the memory. Consequently, when querying a target routing interval matching a first network address through the first routing tree, the content queried at each level meets the storage requirements of the memory, supporting large-scale routing table lookups even when memory storage capacity is limited.

[0010] The beneficial effects of routing query devices, electronic devices, storage media, and program products correspond to the beneficial effects of routing query methods, and will not be elaborated here. Attached Figure Description

[0011] To more clearly illustrate the technical solutions in the specific embodiments of this application or the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0012] Figure 1 This is a schematic diagram illustrating an application scenario according to an embodiment of this application; Figure 2 This is a schematic diagram of the first type of routing query method according to an embodiment of this application; Figure 3This is a flowchart illustrating the method for determining the first routing tree according to an embodiment of this application; Figure 4 This is a schematic diagram illustrating the separation of routing sections according to an embodiment of this application; Figure 5 This is a schematic diagram of adjacent routing intervals according to an embodiment of this application. Figure 6 This is a schematic diagram of overlapping routing intervals according to an embodiment of this application; Figure 7 This is a first schematic diagram of a first routing tree according to an embodiment of this application; Figure 8 This is a second schematic diagram of a first routing tree according to an embodiment of this application; Figure 9 This is a third schematic diagram of the first routing tree according to the embodiments of this application; Figure 10 This is a schematic diagram of a second flowchart of the routing query method according to an embodiment of this application; Figure 11 This is a structural block diagram of a routing query device according to an embodiment of this application; Figure 12 This is a schematic diagram of the hardware structure of an electronic device according to an embodiment of this application. Detailed Implementation

[0013] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0014] It is understood that before using the technical solutions disclosed in the various embodiments of this application, users should be informed of the types, scope of use, and usage scenarios of the personal information involved in this application in an appropriate manner in accordance with relevant laws and regulations, and user authorization should be obtained.

[0015] For example, upon receiving a user's active request, a prompt message is sent to the user to explicitly inform them that the requested operation will require the acquisition and use of the user's personal information. This allows the user to independently choose whether to provide personal information to the software or hardware, such as the electronic device, application, server, or storage medium performing the operations of this application's technical solution, based on the prompt message.

[0016] As an optional but non-limiting implementation, in response to a user's active request, sending a prompt message to the user can be done via a pop-up window, where the prompt message can be presented in text format. Furthermore, the pop-up window can also include a selection control allowing the user to choose "agree" or "disagree" to provide personal information to the electronic device.

[0017] It is understood that the above notification and user authorization process are merely illustrative and do not constitute a limitation on the implementation of this application. Other methods that comply with relevant laws and regulations may also be applied to the implementation of this application.

[0018] It is understood that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and related provisions.

[0019] The terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this application, "multiple" means two or more, unless otherwise explicitly specified.

[0020] As one optional application scenario in the embodiments of this application, such as Figure 1 As shown, the routing query system includes at least one terminal device and at least one server. Figure 1 The system is illustrated in the example, which includes a computer 101, a mobile terminal 102, and a server 103, and terminal devices such as the computer 101 and the mobile terminal 102 are connected to the server 103 through a network 120.

[0021] The terminal device can be a smartphone, tablet, laptop, PDA, desktop computer, game console, smart TV, smart wearable device, in-vehicle terminal, VR (Virtual Reality) device, AR (Augmented Reality) device, etc. Server 103 can be a standalone physical server, a server cluster, a distributed system, or a cloud server providing cloud services. Network 120 can be a wired or wireless network, examples of which include, but are not limited to, the Internet, corporate intranet, local area network, wide area network, mobile communication network, and combinations thereof. Network 120 is equipped with a gateway device. The terminal device can send data packets to the gateway device. The memory (such as TCAM) in the gateway device used for routing table lookup looks up the routing table based on the network address carried in the data packet, determines the routing entry matching the network address, and forwards the data packet to the server 103 corresponding to that network address according to the routing entry.

[0022] It should be noted that, Figure 1 This is merely an example of an application scenario and does not limit the scope of protection of this application.

[0023] In large-scale public cloud networks, gateway devices (also known as hardware gateways) serve as critical nodes for communication between tenant networks and external networks. They need to maintain massive numbers of routing entries to support core capabilities such as multi-tenant isolation, cross-region access, and elastic scaling. Currently, with the influence of Virtual Private Cloud (VPC) subnetting, container network overlay tunneling, and hybrid cloud cross-connectivity, the growth in the number of tenants, the expansion of business scale, and the increasing complexity of network architecture have caused routing tables to grow exponentially.

[0024] However, due to the limited storage capacity of the tri-state content-addressable memory (TCAM) and other memories used by gateway devices for looking up routing tables, the size of the routing table has become a key bottleneck restricting the performance of gateway devices. In particular, the cost pressure brought about by the high cost of TCAM and other memories further exacerbates this contradiction.

[0025] To address the requirement of gateway devices to implement Longest Prefix Match (LPM) for large-scale routing tables, the following three solutions are mainly adopted in related technologies: The first type is a collaborative architecture of TCAM and Static Random-Access Memory (SRAM): This combination of TCAM for quickly matching network prefixes of routing entries in the routing table and SRAM for storing routing details can support approximately 200,000 to 400,000 IPv4 routing entries. However, in IPv6 scenarios, due to limitations in address length and storage efficiency, the capacity is compressed to less than 100,000 entries, which is insufficient to meet the needs of ultra-large-scale networks.

[0026] The second method is segment-based routing entry filtering: by utilizing the hierarchical inclusion relationship of routing segments (such as the coverage characteristics of supernets and subnets), redundant routing entries in the routing table are filtered and merged, which can reduce the size of routing entries by about 50% and improve storage utilization without sacrificing forwarding accuracy. However, when handling route changes, it is necessary to consider the issue of ensuring the sequence number of routing entries, and the efficiency of routing entry distribution is low.

[0027] The third method is traffic scheduling isolation at the account level: through the coordinated scheduling of gateway devices and software routers, traffic of specific accounts is guided to the software layer for processing, while the corresponding routing entries for that account are not issued in the gateway device, thereby reducing the storage pressure on the routing table of the gateway device and realizing elastic allocation of resources.

[0028] However, the above three methods still face the following problems: First, there's the bottleneck of hardware storage resources: Traditional gateway devices rely on TCAMs to store routing tables. However, the storage cost per bit of TCAM is more than 30 times that of SRAM, and its capacity is limited by hardware specifications. Typically, the storage capacity of a single TCAM chip is in the tens of thousands to hundreds of thousands of routing entries. When the number of routing entries exceeds the hardware limit, it is necessary to expand the capacity by cascading TCAMs, which increases the cost of routing table lookups, latency, and power consumption, and makes it difficult to meet the "millisecond-level" elastic scheduling requirements of public clouds.

[0029] Second, routing updates are inefficient: Public cloud tenants frequently perform operations such as subnet creation, subnet deletion, elastic network address (e.g., IP address) binding, elastic network address unbinding, and cross-regional leased line switching, requiring real-time synchronization of the routing table. In hardware-based routing table update mechanisms, under scenarios with a large number of routing entries, a single routing table update can take up to seconds, far exceeding the business tolerance threshold and potentially causing traffic interruptions or routing black holes.

[0030] Therefore, given the limited storage capacity of memory used for routing table lookups, how to support large-scale routing table lookups has become an urgent problem to be solved.

[0031] According to an embodiment of this application, a routing query method embodiment is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.

[0032] This embodiment provides a routing lookup method that can be used in a gateway device, which has a memory, such as SRAM, for routing table lookup. Figure 2 This is a flowchart of a routing query method according to an embodiment of this application, such as... Figure 2 As shown, the process includes the following steps: Step S201: Obtain the first network address.

[0033] In practical applications, a gateway device can receive data packets sent by terminal devices and obtain a first network address based on the destination address carried in the data packet. This first network address is an Internet Protocol (IP) address.

[0034] Step S202: Query the target routing interval in the first routing tree that matches the first network address; wherein, the first routing tree is obtained by hierarchically dividing the first routing interval corresponding to the routing entry in the first routing table based on a preset storage space size; the preset storage space size is related to the memory used for routing table lookup; the leaf nodes of the first routing tree correspond to the first routing entries in the first routing table.

[0035] Optionally, the preset storage space size is related to the storage capacity of the memory, specifically the storage capacity of the memory's storage units. The storage unit of the memory is a cache line. That is, the storage capacity of a single cache line is used as the preset storage space size.

[0036] Optionally, the memory is SRAM, consisting of one or more SRAM chips. Alternatively, the memory can be a tri-state content-addressable memory, which can be determined based on the memory actually used by the gateway device for routing table lookups.

[0037] It should be noted that after hierarchically dividing the first routing intervals corresponding to the routing entries in the first routing table, at least one level of sub-intervals is obtained for each routing entry. The first routing tree includes nodes at at least one level, and the nodes in the first routing tree correspond one-to-one with the aforementioned sub-intervals. The address of the root node of the first routing tree is the query address of the first routing table.

[0038] In practical applications, since the query address of the first routing table is the address of the root node of the first routing tree, when the gateway device performs a route query through the query address of the first routing table, it can access the first routing tree through the query address, and query the sub-intervals that match the first network address in the hierarchical order of the sub-intervals in the first routing tree, until the leaf node of the first routing tree is found, and obtain the target routing interval that matches the first network address.

[0039] Understandably, the routing interval from the root node to the leaf node that matches the first network address is the target routing interval.

[0040] Step S203: Determine the target route entry based on the target route interval and the mapping relationship between the first route interval and the route entries in the first route table.

[0041] In practical applications, the control plane sends the routing entries in the first routing table to the gateway device. The process of the control plane sending the routing entries in the first routing table is the process of generating the first routing tree. Each leaf node in the first routing tree represents a routing interval, and each routing interval maps to a routing entry.

[0042] It is worth noting that if the first network address is obtained based on the destination address carried in the received data packet, the routing lookup method of this application further includes: forwarding the data packet to the first network address through the target routing entry.

[0043] The routing query method provided in this embodiment hierarchically divides the first routing intervals corresponding to routing entries in the first routing table into a first routing tree based on a preset storage space size. The preset storage space size is related to the memory used for routing table lookups. Therefore, the first routing intervals corresponding to routing entries can be split into multiple levels for separate storage, ensuring that the storage space occupied by the first routing intervals corresponding to each routing entry at each level does not exceed the preset storage space size, thus meeting the storage requirements of the memory. Consequently, when querying a target routing interval matching a first network address through the first routing tree, the content queried at each level meets the storage requirements of the memory, supporting large-scale routing table lookups even when memory storage capacity is limited.

[0044] This embodiment provides a route query method, such as Figure 3 As shown, the first routing tree was obtained in the following way: Step S301: Obtain the first routing table.

[0045] Optionally, the target storage object stores one or more routing tables (such as a first routing table). When the routing tables stored in the target storage object change, such as when a new routing table (i.e., the first routing table) is stored, the target storage object distributes the first routing table to the gateway device via a remote procedure call protocol (such as gRPC). Alternatively, the gateway device can also actively retrieve the first routing table from the target storage object; this is not limited here.

[0046] Step S302: Perform interval routing processing based on the routing entries in the first routing table to obtain the mapping relationship between the first routing interval and the routing entries in the first routing table.

[0047] In practical applications, a first routing interval is generated for all routing entries in the first routing table. This first routing interval is determined by the start and end addresses of the routing entries. All routing addresses within the first routing interval can be matched by the corresponding routing entries. Specifically, routing entries include network prefixes, and the first routing interval of a routing entry can be determined based on its network prefix.

[0048] Furthermore, if the first routing intervals corresponding to different routing entries overlap, the overlapping routing intervals are merged, and the overlapping routing intervals are pointed to the routing entry corresponding to the first routing interval with the longest prefix length. Conversely, the non-overlapping routing intervals are pointed to the routing entry corresponding to the first routing interval with the shortest prefix length. It should be noted that overlapping first routing intervals here only include the case where one first routing interval is contained within another. For example, two first routing intervals may have overlapping start addresses, but the end address of one first routing interval may be located within the other.

[0049] It is worth noting that in the above mapping relationship, the first route interval corresponding to each route entry is different.

[0050] Step S303: Based on the preset storage space size, the first routing interval corresponding to the routing entry in the first routing table is hierarchically divided to obtain at least one level of sub-intervals of the routing entry in the first routing table; wherein the storage space size used to store the sub-intervals of the same level corresponding to the same routing entry does not exceed the preset storage space size.

[0051] Specifically, the bit range for each routing entry at each level is determined based on a preset storage space size. According to the bit range for each level, the first routing interval corresponding to each routing entry is hierarchically divided, resulting in at least one sub-interval for each routing entry at each level. The sub-intervals of the first routing interval at each level are represented by the bit range of the first routing interval at the corresponding level. For example, the sub-interval at the first level corresponds to the bit range of the first routing interval (0, a1). The sub-interval at the second level corresponds to the bit range of the first routing interval (a1, a1+a2). The sub-interval at the third level corresponds to the bit range of the first routing interval (a1+a2, a1+a2+a3). If the first routing interval uses IPv4, then the total bit range of the first routing interval is 32, a1+a2+a3=32.

[0052] In practical applications, based on a general algorithm with a preset storage space size and bit depth, the number of bits corresponding to each level of the first routing interval for each routing entry is calculated when constructing the first routing tree, to obtain the optimal bit array for partitioning. The first routing interval corresponding to the routing entry in the first routing table is then hierarchically divided according to the bit array, resulting in at least one level of sub-intervals for each routing entry in the first routing table. The number of bits in each level of sub-region is consistent with the number of bits corresponding to that level in the bit array.

[0053] Step S304: Using sub-intervals as nodes, construct the first routing tree according to the hierarchical relationship of the sub-intervals.

[0054] Specifically, the data within the bit range corresponding to the sub-interval is used as the key of the node, and the node is inserted into the corresponding level of the initial routing tree until the leaf nodes of the initial routing tree are mapped to the corresponding routing entries, thus obtaining the first routing tree. Here, the mapping of a leaf node to a corresponding routing entry means that the routing interval formed by the path from the root node to the leaf node is consistent with the first routing interval of the corresponding routing entry.

[0055] Furthermore, the first routing tree is written into the gateway device, such as into the memory of the gateway device used for routing table lookup, so that the gateway device can perform routing queries based on the first routing tree.

[0056] The routing query method provided in this embodiment limits the storage space size for storing sub-intervals at the same level corresponding to the same routing entry to no more than a preset storage space size. Therefore, it can ensure that when the memory searches for routing entries according to levels, the storage space size of the sub-regions searched at each level meets the storage requirements of the memory, further ensuring the effective query of routing entries.

[0057] In some optional implementations, step S302 above, which involves performing interval routing processing based on routing entries in the first routing table to obtain the mapping relationship between the first routing interval and routing entries in the first routing table, includes: Step a1: Determine the first routing interval corresponding to the routing entry in the first routing table.

[0058] Specifically, the routing entries in the first routing table include network prefixes. The first routing interval of a routing entry is determined based on its network prefix.

[0059] It's worth noting that a routing entry is essentially a routing range consisting of a start address and an end address. For example, [start, end), where start is the start address and end is the end address. All routing addresses within this routing range can be matched by the routing entry. For instance, the routing entry 10.0.0.0 / 8 (i.e., the network prefix of the routing entry) corresponds to the routing range [0x0A000000, 0x0B000000]. If a network address is greater than or equal to 0x0A000000 and less than 0x0B000000, it can be matched by this routing entry.

[0060] Step a2: If the first routing interval corresponding to the first routing entry in the first routing table contains the first routing interval corresponding to the second routing entry, then based on the routing intervals in the first routing interval corresponding to the first routing entry that do not overlap with the first routing interval corresponding to the second routing entry, update the first routing interval corresponding to the first routing entry to obtain the mapping relationship between the first routing interval and the routing entry in the first routing table.

[0061] In this context, the first route interval corresponding to the second route entry remains unchanged. That is, based on the updated first route interval corresponding to the first route entry, and based on the first route intervals corresponding to other route entries (including the second route entry) in the first routing table, a mapping relationship is constructed between the first route interval and the route entries in the first routing table.

[0062] It is worth noting that the starting address of the first routing interval corresponding to the first routing entry is the same as that of the first routing interval corresponding to the second routing entry, and the ending address of the first routing interval corresponding to the second routing entry is located in the first routing interval corresponding to the first routing entry.

[0063] The routing query method provided in this embodiment updates the first routing interval corresponding to the first routing entry if the first routing interval corresponding to the first routing entry in the first routing table includes the first routing interval corresponding to the second routing entry. This update is based on the non-overlapping routing intervals within the first routing interval corresponding to the first routing entry that are not identical to the first routing interval corresponding to the second routing entry. Therefore, it ensures that different first routing intervals correspond to only one routing entry, avoiding the situation where one first routing interval corresponds to multiple routing entries, thus ensuring the accuracy of the routing query.

[0064] In some optional implementations, the first routing table contains a default route entry. The routing query method of this application further includes: obtaining the first routing interval corresponding to the default route entry based on routing intervals other than those corresponding to non-default route entries in the first routing table, within a preset routing interval. The preset routing interval includes the first routing intervals corresponding to all route entries. Optionally, the preset routing interval is [0x0, 0xffffffff].

[0065] It is worth noting that the relationship between the route intervals after expanding the route entries of multiple legitimate Classless Inter-Domain Routing (CIDR) routes may fall into three categories: The first type is interval separation. For example... Figure 4 As shown, taking route entries 10.0.1.0 / 24 and 192.168.10.0 / 24 as examples, the first routing interval corresponding to route entry 10.0.1.0 / 24 is [0x0A000100, 0x0A000200), and the first routing interval corresponding to route entry 192.168.10.0 / 24 is [0xC0A80A00, 0xC0A80B00). In this case, the first routing interval [0x0A000100, 0x0A000200) matches route entry 10.0.1.0 / 24, the first routing interval [0xC0A80A00, 0xC0A80B00) matches route entry 192.168.10.0 / 24, and the remaining routing intervals match the default route entry (also known as the default route).

[0066] The second type is adjacent intervals. For example... Figure 5 As shown, taking route entries 192.168.0.0 / 24 and 192.168.1.0 / 24 as examples, the first route interval corresponding to route entry 192.168.0.0 / 24 is [0xC0A80000, 0xC0A80100), and the first route interval corresponding to route entry 192.168.1.0 / 24 is [0xC0A80100, 0xC0A80200). In this case, the first route interval [0xC0A80000, 0xC0A80100) matches route entry 192.168.0.0 / 24, the first route interval [0xC0A80100, 0xC0A80200) matches route entry 192.168.1.0 / 24, and the remaining route intervals match the default route entry.

[0067] The third type is interval inclusion. For example... Figure 6As shown, taking route entries 192.168.0.0 / 16 and 192.168.0.0 / 24 as examples, the first route interval corresponding to route entry 192.168.0.0 / 16 is [0xC0A80000, 0xC0A90000), and the first route interval corresponding to route entry 192.168.0.0 / 24 is [0xC0A80000, 0xC0A80100). In this case, the first route interval [0xC0A80000, 0xC0A80100) matches route entry 192.168.0.0 / 24, the first route interval [0xC0A80100, 0xC0A90000) matches route entry 192.168.0.0 / 16, and the remaining route intervals match the default route entry.

[0068] It is worth noting that, see Figures 4-6 Assuming the first routing table contains n routing entries, each entry, after being expanded into a routing interval, corresponds to two points (i.e., a start address and an end address). If these two points fall within the preset routing interval [0x0, 0xffffffff], a maximum of 2n+1 routing intervals can be formed. Any routing address within a routing interval can potentially match at most the same routing entry in the first routing table. Therefore, constructing the first routing table can be transformed into splitting all routing entries in the first routing table into multiple routing intervals (i.e., the aforementioned first routing intervals) within the preset routing intervals, and finding the longest mask-matching routing entry for each routing interval.

[0069] In some optional implementations, step S303 above, which involves hierarchically dividing the first routing interval corresponding to the routing entry in the first routing table based on a preset storage space size to obtain at least one level of sub-intervals for the routing entries in the first routing table, includes: Step b1: Obtain the first prefix length of the first route interval corresponding to the route entry in the first routing table.

[0070] The first prefix length is the number of bits in the network prefix of the first routing interval. For example, 4 bits, 16 bits, 32 bits, etc.

[0071] For example, taking route entry 192.168.10.0 / 24 as an example, the length of the first prefix corresponding to 192.168.10.0 / 24 is 24.

[0072] Step b2: Determine the second prefix length from the first prefix length based on the preset storage space size.

[0073] It is worth noting that the storage units (such as cache lines) used for routing table lookups in gateway devices are typically 64 bytes, which is often insufficient to store the first routing interval corresponding to all routing entries within a single storage unit. Therefore, it is necessary to determine the second prefix length based on the first prefix length of the first routing interval according to the preset storage space size, so that the storage space for storing the data of the second prefix length of the first routing interval can meet the preset storage space size.

[0074] Step b3: Divide the first routing interval corresponding to the routing entry in the first routing table based on the second prefix length to obtain the first-level sub-interval of the routing entry in the first routing table.

[0075] Specifically, the bit range corresponding to the first level is determined based on the second prefix length. The first routing interval corresponding to the routing entry is then divided according to the bit range corresponding to the first level, resulting in sub-intervals for the first level of the routing entry.

[0076] For example, if the second prefix length is 16 bits, then the first 16 bits of the data in the first routing interval corresponding to the routing entry represent the sub-interval of the first level of the routing entry.

[0077] Step b4: Divide the first level sub-interval of the routing entry in the first routing table based on the preset storage space size to obtain the next level sub-interval of the routing entry in the first routing table.

[0078] Specifically, based on the preset storage space size and the bit range of the routing entry excluding the first level, the bit range corresponding to the next level is determined. Based on the bit range corresponding to the next level, the sub-intervals of the first level of the routing entry are divided to obtain the sub-intervals of the next level of the routing entry. That is, the sub-intervals of the next level of the routing entry are represented by the data in the bit range corresponding to the first routing interval of the routing entry in the next level. If the sub-intervals from the first level of the routing entry to the current last level cannot represent the first routing interval of the routing entry, step b4 is returned to execute until the sub-intervals from the first level of the routing entry to the current last level can represent the first routing interval of the routing entry.

[0079] For example, assuming the second prefix length is 16 bits, the first level sub-interval of the routing entry is the first 16 bits of the first routing interval corresponding to the routing entry. Assuming the prefix length corresponding to the second level is 8 bits, the second level sub-interval of the routing entry is the 16th to 24th bits of the first routing interval corresponding to the routing entry.

[0080] The routing lookup method provided in this embodiment addresses the limitation of storage capacity in a single storage unit of the memory used for routing table lookup in the gateway device, making it difficult to store the first routing interval corresponding to all routing entries within a single storage unit. Therefore, this embodiment determines a second prefix length based on a preset storage space size within the first prefix length of the first routing interval corresponding to the routing entry, and hierarchically divides the first routing interval corresponding to the routing entry according to the second prefix length, thereby ensuring that the storage unit of the memory supports single sub-interval lookups.

[0081] In some optional implementations, the routing query method of this application further includes: Step c1: If the storage space used to store the first routing intervals corresponding to all routing entries in the first routing table does not exceed the preset storage space size, then the first routing intervals corresponding to the routing entries in the first routing table are used as nodes to construct the first routing tree.

[0082] The storage space size used to store the first routing interval corresponding to all routing entries in the first routing table refers to the storage space size used to store the bit data of the first routing interval corresponding to all routing entries.

[0083] Step c2: If the storage space used to store the first route interval corresponding to all route entries in the first routing table exceeds the preset storage space size, then the step of determining the second prefix length based on the preset storage space size in the first prefix length is executed.

[0084] Specifically, steps c1 and c2 are executed before step b2. That is, step b2 is executed only if the storage space used to store the first routing interval corresponding to all routing entries in the first routing table exceeds the preset storage space size.

[0085] The routing query method provided in this embodiment only performs the step of hierarchically dividing the first routing interval when the storage space used to store the first routing interval corresponding to all routing entries in the first routing table exceeds a preset storage space size. Therefore, it can avoid splitting the first routing interval too much, thereby reducing the number of bits consumed by the first routing interval at the first level.

[0086] In some optional implementations, determining the second prefix length based on the preset storage space size in step b2 above includes: Step b21: Obtain the number of route entries in the first routing table.

[0087] Step b22: Based on the length and quantity of the first prefix, determine the storage space size corresponding to the routing interval for storing all routing entries in the first routing table.

[0088] For example, assuming the number of routing entries is 3 and the first prefix length is 4 bits, the storage space size corresponding to the first prefix length of the 3 routing entries is determined based on the storage space size of the 4-bit first routing entries.

[0089] Step b23: If the storage space size corresponding to the first prefix length does not exceed the preset storage space size, then the first prefix length is used as the candidate prefix length.

[0090] For example, if the storage space size corresponding to 4 bits does not exceed the preset storage space size, then 4 bits are used as the candidate prefix length.

[0091] Step b24: Determine the second prefix length from the candidate prefix lengths.

[0092] Among them, the second prefix length is the largest second prefix length among the candidate prefix lengths.

[0093] For example, assuming that the first prefix length of the first route interval corresponding to all route entries includes 4 bits, 16 bits, and 32 bits, if the storage space size corresponding to the 16-bit length exceeds the preset storage space size, and if the storage space size corresponding to the 4-bit length does not exceed the preset storage space size, then the 4-bit length is used as the second prefix length.

[0094] The routing query method provided in this embodiment selects a first prefix length whose storage space size does not exceed a preset storage space size as a candidate prefix length. Therefore, it can ensure that the gateway device supports routing matching between the first network address and all sub-intervals of the first level.

[0095] In some optional implementations, step S304 above includes: Step d1: Sort the sub-intervals at the same level based on the size relationship of the routing addresses corresponding to the sub-intervals.

[0096] Step d2: Using sub-intervals as nodes, construct the first routing tree according to the hierarchical relationship of the sub-intervals and the sorting results of sub-intervals at the same level.

[0097] For example, see Figure 7 , Figure 7The diagram shows the eight sub-intervals of the first level, and the eight sub-intervals are sorted according to the size relationship of the routing addresses of the sub-intervals. When performing a routing query using the first routing tree, if the first network address matches the key children[t] (such as the starting address of the sub-interval) of the leaf node of the first routing tree, it is equivalent to the first network address being within the sub-interval [children[t], children[t+1]).

[0098] The routing query method provided in this embodiment constructs a first routing tree according to the hierarchical relationship of sub-intervals and the sorting results of sub-intervals at the same level. Therefore, it can facilitate the quick search for the target routing interval that matches the first network address.

[0099] For example, Virtual Private Clouds (VPCs) typically use three private network segments: 10.0.0.0 / 8, 172.16.0.0 / 12, and 192.168.0.0 / 16. Since the storage capacity of a memory unit (such as SRAM) is typically around 64 bytes, it is often difficult to store the data of the first routing interval for all routing entries within a single storage unit. Therefore, each level can be used to represent a certain range of bits for the data in the first routing interval, with multiple levels covering the bit count of the first routing interval. For instance, after expanding a single VPC route into multiple first routing intervals, the different data values ​​for the first 16 bits are usually not too numerous. Therefore, in most cases, the first level can be set to 16 bits, and the following two levels to 8 bits each. If the sub-intervals calculated using this bit count are too numerous, the bit count consumed by the current level can be further reduced until the data of the leaf nodes of the routing entries is within a preset storage space size.

[0100] See Figure 8 Assuming the total number of bits in the first routing interval corresponding to a routing entry is 32, then each level represents the bit data of the first routing interval [31:0]. The bit array calculated by the bit-counting algorithm is [a1, a2, a3], where each member represents the number of bits consumed in constructing the corresponding level of the first routing tree. For example, the root node of the first routing tree is root. The first level sub-interval under the root node is generated by the bit count of the boundary points of all sub-intervals (0, a1), the second level sub-interval is generated by the bit count of the boundary points of all sub-intervals (a1, a1 + a2), and the third level sub-interval is generated by the bit count of the boundary points of all sub-intervals (a1 + a2, a1 + a2 + a3). a1 + a2 + a3 = 32, where 32 is the total number of bits occupied by the first routing interval.

[0101] Assuming the first level represents [31:0] bits, since the routing address of a is less than the routing address of b, b is less than the routing address of c, d is less than the routing address of e, e is less than the routing address of f, and f is less than the routing address of g, the sub-intervals of the first level are represented by the following data: a[31:31-a1], b[31:31 - a1], c[31:31 - a1], d[31:31 - a1], e[31:31 - a1], f[31:31 - a1], g[31:31 - a1]. Since the data in a[31:31 - a1], b[31:31 - a1], and c[31:31 - a1] of the first routing interval is consistent, therefore, in Figure 8 In this context, a[31:31 - a1] is used to represent the data in the first routing interval within a[31:31 - a1], b[31:31 - a1], and c[31:31 - a1]. Since the data in the first routing interval within d[31:31 - a1] and e[31:31 - a1] are identical, therefore, in Figure 8 In this context, d[31:31 - a1] is used to represent the data in the first routing interval within d[31:31 - a1] and e[31:31 - a1]. Since the data in the first routing interval within f[31:31 - a1] and g[31:31 - a1] are identical, therefore, in Figure 8 In this context, f[31:31 - a1] is used to represent the data in the first routing interval in f[31:31 - a1] and g[31:31 - a1]. Thus, the first level of the first routing tree has the following different sub-intervals a[31:31 - a1], d[31:31 - a1], and f[31:31 - a1].

[0102] By splitting the sub-intervals of the first level, we can obtain the following: Figure 9The sub-intervals are shown below. For example, the second-level sub-intervals of a[31:31 -a1] include: a[31 - a1 - 1:31 - a1 - a2], b[31 - a1 - 1:31 - a1 -a2], c[31 - a1 - 1:31 - a1 - a2], the sub-intervals of d[31:31 - a1] are d[31 - a1 - 1:31 - a1 - a2], e[31 - a1 - 1:31 - a1 - a2], and the sub-intervals of f[31:31 - a1] are f[31 - a1 - 1:31 - a1 - a2], g[31 - a1 - 1:31 - a1 - a2]. The first routing tree is constructed layer by layer down to the leaf nodes, and the routing entries corresponding to each leaf node are stored.

[0103] In some optional implementations, the first routing tree includes at least one level of sub-intervals obtained by hierarchically dividing the first routing intervals corresponding to the routing entries in the first routing table. Step S202 includes: performing a binary search on the first network address and each level of sub-interval according to the hierarchical order of the sub-intervals in the first routing tree to obtain the target routing interval that matches the first network address.

[0104] Specifically, starting from the root node of the first routing tree, the bit range corresponding to each level is obtained to determine the sub-interval of the routing entry at each level. A binary search is used to find the first sub-interval in each level where the first network address is less than or equal to the routing address corresponding to the sub-area. Within the first sub-interval, the second sub-interval with the largest routing address range is determined. This search is continued layer by layer until the leaf node of the first routing tree is found. The routing interval formed by all the second sub-intervals from the root node to the leaf node is taken as the target routing interval matching the first network address.

[0105] The routing query method provided in this embodiment performs a binary search on the first network address and the sub-intervals at each level to obtain the target routing interval that matches the first network address. Therefore, it can improve the efficiency of routing queries.

[0106] In some optional implementations, the routing query method of this application further includes: Step e1: In response to the update instruction for the first routing table, obtain the third routing entry that has been changed in the first routing table. The third routing entry includes at least one of the newly added routing entries and the deleted routing entries in the first routing table.

[0107] Step e2: Based on the preset storage space size and the routing interval corresponding to the third routing entry, adjust the second routing tree to obtain the third routing tree. The second routing tree has the same structure as the first routing tree.

[0108] Step e3: Adjust the query address of the first routing table from the address of the root node of the first routing tree to the address of the root node of the third routing tree.

[0109] Understandably, when adding or deleting a route entry in the first routing table, a second routing tree with the same structure as the first routing tree is recreated. Based on the preset storage space size and the routing range corresponding to the third route entry, the second routing tree is adjusted to obtain the third routing tree. When a lookup in the first routing table is needed, the query address of the first routing table is adjusted from the address of the root node of the first routing tree to the address of the root node of the third routing tree. Therefore, the adjustment of the routing tree corresponding to the first routing table can be avoided from affecting the routing lookup in the data plane, thus ensuring routing lookup performance.

[0110] In some optional implementations, the routing query method of this application further includes: in response to an update instruction for a fourth routing entry in a first routing table, determining an updated routing entry, wherein the routing entries in the first routing table include the fourth routing entry; and updating the mapping relationship based on the updated routing entry.

[0111] Understandably, when a route entry in the first routing table is updated, it is only necessary to update the mapping relationship between the first routing interval and the fourth route entry to the first routing interval and the updated route entry. Therefore, the update of route entries can be achieved quickly.

[0112] See Figure 10 Taking the routing table stored in the target storage object (such as the ETCD storage system) as an example, the core idea of ​​the routing query method in this application is as follows: First, when the routing table in the target storage object changes, the high-performance remote procedure call protocol (gRPC) sends the first routing table with changed data to the gateway device through the configuration distribution channel. The memory (such as SRAM) in the gateway device used for routing table lookup receives the first routing table and obtains the routing entries in the first routing table. Then, the SRAM splits the first routing table according to the Virtual Private Cloud (VPC) dimension, converting each routing entry in the first routing table into a corresponding first routing interval (i.e., IP interval) to determine the mapping relationship between the first routing interval and the routing entries in the first routing table. The bit range of the first routing interval of the routing entries in the first routing tree at each level is also determined. Based on this, according to the bit range of each level and the mapping relationship between the first routing interval and the routing entries in the first routing table, and combined with multi-bit compression technology, a tree-structured first routing tree is constructed, and the address of the root node of the first routing tree is used as the query address of the first routing table for routing lookup.

[0113] It should be noted that during the construction of the first routing tree, it is necessary to ensure that the member data of any node in the first routing tree (i.e., the sub-regions of the first routing interval) can be included in the memory space of a single storage unit (such as a cache line) of SRAM. Simultaneously, to improve the efficiency of route entry lookup, the control plane sorts the sub-intervals of the routing intervals in the first routing tree, ensuring the orderliness of sub-intervals corresponding to nodes at the same level. This allows the memory to efficiently perform binary search among the limited number of nodes in the first routing tree, improving route query efficiency. Furthermore, the routing query method of this application relies on SRAM memory to store route entries, not only overcoming the capacity limitations of storage devices such as TCAM used for routing table lookups, but also supporting a scale of millions of route entries, significantly improving routing update efficiency, enabling extremely fast routing tree updates, reducing update time, and effectively adapting to the high requirements of large-scale public cloud networks for routing table capacity and dynamism.

[0114] For another specific application example, a computer located in city A sends a data packet carrying a network request to a gateway device in the target network. The memory (such as SRAM) in the gateway device used for routing table lookup searches the first routing tree based on the first network address carried in the data packet (such as the network address of the server in city B), determines the target routing entry that matches the first network address, and forwards the data packet to the next-hop network address based on the target routing entry, so as to forward it to the server in city B.

[0115] Compared to related technologies, the routing query method in this application can split all routing tables of a public cloud VPC into multiple routing tables according to the VPC, controlling the size of a single routing table to remain within a certain range. Simultaneously, this application can convert each routing entry with the longest prefix match into a routing interval, and multiple routing entries in a single routing table are converted into multiple non-overlapping routing intervals, thus transforming the longest prefix match lookup into a routing interval lookup. Furthermore, this application employs multi-bit compression technology, controlling the size of a single routing table while ensuring the height of the generated routing tree remains within a certain range, with the bit data of routing entries at a single level stored in a single storage unit. In addition, this application sorts routing entries within sub-intervals at the same level on the control plane. Therefore, on the data plane, binary search of routing entries for network addresses can be implemented using fixed instructions, and the storage and retrieval of routing entries in the routing table can be achieved using only memory (such as SRAM). This allows support for routing tables of millions in scale while ensuring that the routing query performance of the data plane remains within linear speed range, and the incremental update time of the routing table on the control plane does not increase linearly with the growth of public cloud routing entries.

[0116] This embodiment also provides a routing query device for implementing the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that performs a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.

[0117] This embodiment provides a routing query device, such as Figure 11 As shown, it includes: Address acquisition module 1101 is used to acquire the first network address.

[0118] The interval query module 1102 is used to query the target routing interval in the first routing tree that matches the first network address; wherein, the first routing tree is obtained by hierarchically dividing the first routing interval corresponding to the routing entry in the first routing table based on a preset storage space size; the preset storage space size is related to the memory used for routing table lookup; the leaf nodes of the first routing tree correspond to the first routing entry in the first routing table.

[0119] The entry analysis module 1103 is used to determine the target route entry based on the target route interval and the mapping relationship between the first route interval and the route entries in the first routing table.

[0120] In some optional implementations, the interval query module 1102 includes: The interval query unit is used to perform a binary search on the first network address and the sub-intervals at each level according to the hierarchical order of the sub-intervals in the first routing tree, so as to obtain the target routing interval that matches the first network address.

[0121] In some optional embodiments, the routing query apparatus of this application further includes: The routing table retrieval module is used to retrieve the first routing table; The routing processing module is used to perform interval routing processing based on the routing entries in the first routing table, and to obtain the mapping relationship between the first routing interval and the routing entries in the first routing table; The hierarchical partitioning module is used to hierarchically partition the first routing interval corresponding to the routing entry in the first routing table based on a preset storage space size, so as to obtain at least one level of sub-intervals of the routing entry in the first routing table; wherein the storage space size used to store the sub-intervals of the same level corresponding to the same routing entry does not exceed the preset storage space size. The routing tree building module is used to construct the first routing tree based on the hierarchical relationship of sub-intervals, using sub-intervals as nodes.

[0122] In some alternative implementations, the routing processing module includes: The interval acquisition unit is used to determine the first routing interval corresponding to the routing entry in the first routing table; The routing processing unit is configured to update the first routing interval corresponding to the first routing entry based on the routing intervals in the first routing interval corresponding to the first routing entry that do not overlap with the first routing interval corresponding to the second routing entry if the first routing interval corresponding to the first routing entry in the first routing table contains the first routing interval corresponding to the second routing entry, so as to obtain the mapping relationship between the first routing interval and the routing entry in the first routing table.

[0123] In some optional implementations, the hierarchy partitioning module includes: The length acquisition unit is used to obtain the length of the first prefix of the first route interval corresponding to the route entry in the first routing table; The length analysis unit is used to determine the second prefix length from the first prefix length based on the preset storage space size; The first partitioning unit is used to partition the first routing interval corresponding to the routing entry in the first routing table based on the second prefix length, so as to obtain the first level of sub-interval of the routing entry in the first routing table; The second partitioning unit is used to partition the first level sub-interval of the routing entry in the first routing table based on the preset storage space size, so as to obtain the next level sub-interval of the routing entry in the first routing table.

[0124] In some optional embodiments, the routing query apparatus of this application further includes: The first construction module is used to construct a first routing tree by using the first routing interval corresponding to the routing entries in the first routing table as nodes if the storage space used to store the first routing interval corresponding to all routing entries in the first routing table does not exceed the preset storage space size. The second construction module is used to perform the step of determining the second prefix length based on the preset storage space size in the first prefix length if the storage space size used to store the first route interval corresponding to all route entries in the first routing table exceeds the preset storage space size.

[0125] In some alternative implementations, the length analysis unit includes: The quantity acquisition subunit is used to obtain the number of routing entries in the first routing table; The first analysis subunit is used to determine the storage space size corresponding to the routing interval for storing all routing entries in the first routing table, based on the first prefix length and quantity. The second analysis subunit is used to take the first prefix length as a candidate prefix length if the storage space size corresponding to the first prefix length does not exceed the preset storage space size. The third analysis subunit is used to determine the second prefix length from the candidate prefix lengths.

[0126] In some alternative implementations, the routing tree building module includes: The interval sorting unit is used to sort sub-intervals at the same level based on the size relationship of the routing addresses corresponding to the sub-intervals; The routing tree construction unit is used to construct the first routing tree by using sub-intervals as nodes, according to the hierarchical relationship of the sub-intervals and the sorting result of the sub-intervals at the same level.

[0127] In some optional embodiments, the routing query apparatus of this application further includes: The first response module is used to respond to an update command for the first routing table and obtain the third routing entries that have been changed in the first routing table. The third routing entries include at least one of newly added routing entries and deleted routing entries in the first routing table. The routing tree update module is used to adjust the second routing tree based on the preset storage space size and the routing interval corresponding to the third routing entry to obtain the third routing tree. The second routing tree has the same structure as the first routing tree. The address adjustment module is used to adjust the query address of the first routing table from the address of the root node of the first routing tree to the address of the root node of the third routing tree.

[0128] In some optional embodiments, the routing query apparatus of this application further includes: The second response module is used to respond to an update instruction for the fourth route entry in the first routing table and determine the updated route entry, wherein the route entries in the first routing table include the fourth route entry; The mapping update module is used to update the mapping relationship based on the updated routing entries.

[0129] The routing query apparatus provided in this application can execute the routing query method provided in any embodiment of this application, and has the corresponding functional modules and beneficial effects for executing the method. Further functional descriptions of the various modules and units described above are the same as those in the corresponding embodiments described above, and will not be repeated here.

[0130] Figure 12 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.

[0131] The following is a detailed reference. Figure 12The diagram illustrates a structural schematic suitable for implementing the electronic device described in the embodiments of this application. The electronic device may include a processor (e.g., a central processing unit, graphics processor, etc.) 1201, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 1202 or a program loaded from memory 1208 into random access memory (RAM) 1203. The RAM 1203 also stores various programs and data required for the operation of the electronic device. The processor 1201, ROM 1202, and RAM 1203 are interconnected via a bus 1204. An input / output (I / O) interface 1205 is also connected to the bus 1204.

[0132] Typically, the following devices can be connected to I / O interface 1205: input devices 1206 including, for example, a touchscreen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 1207 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; memory 1208 including, for example, magnetic tape, hard disk, etc.; and communication devices 1209. Communication device 1209 allows electronic devices to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 12 Electronic devices with various devices are shown, but it should be understood that it is not required to implement or have all of the devices shown, and more or fewer devices may be implemented or have instead.

[0133] Specifically, according to embodiments of this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication device 1209, or installed from memory 1208, or installed from ROM 1202. When the computer program is executed by processor 1201, it performs the functions defined in the routing query method of embodiments of this application.

[0134] Figure 12 The electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.

[0135] This application also provides a computer-readable storage medium. The methods described in this application can be implemented in hardware or firmware, or implemented as recordable on a storage medium, or implemented as computer code downloaded over a network and originally stored on a remote storage medium or a non-transitory machine-readable storage medium and then stored on a local storage medium. Thus, the methods described herein can be processed by software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium can be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; further, the storage medium can also include combinations of the above types of memory. It is understood that computers, processors, microprocessor controllers, or programmable hardware include storage components capable of storing or receiving software or computer code. When the software or computer code is accessed and executed by the computer, processor, or hardware, the routing query method shown in the above embodiments is implemented.

[0136] A portion of this application can be applied as a computer program product, such as computer program instructions, which, when executed by a computer, can invoke or provide the methods and / or technical solutions according to this application through the operation of the computer. Those skilled in the art will understand that the forms in which computer program instructions exist in a computer-readable medium include, but are not limited to, source files, executable files, installation package files, etc. Correspondingly, the ways in which computer program instructions are executed by a computer include, but are not limited to: the computer directly executing the instructions, or the computer compiling the instructions and then executing the corresponding compiled program, or the computer reading and executing the instructions, or the computer reading and installing the instructions and then executing the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to a computer.

[0137] Although embodiments of this application have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of this application, and all such modifications and variations fall within the scope defined by the appended claims.

Claims

1. A routing query method, characterized in that, include: Obtain the first network address; Query the target routing interval in the first routing tree that matches the first network address; wherein, the first routing tree is obtained by hierarchically dividing the first routing interval corresponding to the routing entry in the first routing table based on a preset storage space size; the preset storage space size is related to the memory used for routing table lookup; the leaf nodes of the first routing tree correspond to the routing entries in the first routing table; Based on the target routing interval and the mapping relationship between the first routing interval and the routing entries in the first routing table, the target routing entry is determined; The first routing tree is obtained by: acquiring the first routing table; performing interval routing processing based on the routing entries in the first routing table to obtain the mapping relationship between the first routing interval and the routing entries in the first routing table; dividing the first routing interval corresponding to the routing entries in the first routing table into hierarchical segments based on the preset storage space size to obtain at least one level of sub-intervals for the routing entries in the first routing table; wherein the storage space size used to store the sub-intervals of the same level corresponding to the same routing entry does not exceed the preset storage space size; and constructing the first routing tree according to the hierarchical relationship of the sub-intervals, using the sub-intervals as nodes.

2. The routing query method according to claim 1, characterized in that, The step of performing interval routing processing based on the routing entries in the first routing table to obtain the mapping relationship between the first routing interval and the routing entries in the first routing table includes: Determine the first routing interval corresponding to the routing entry in the first routing table; If the first routing interval corresponding to the first routing entry in the first routing table contains the first routing interval corresponding to the second routing entry, then based on the routing intervals in the first routing interval corresponding to the first routing entry that do not overlap with the first routing interval corresponding to the second routing entry, the first routing interval corresponding to the first routing entry is updated to obtain the mapping relationship between the first routing interval and the routing entry in the first routing table.

3. The routing query method according to claim 1, characterized in that, The step of hierarchically dividing the first routing interval corresponding to the routing entry in the first routing table based on the preset storage space size to obtain at least one level of sub-intervals for the routing entries in the first routing table includes: Obtain the first prefix length of the first route interval corresponding to the route entry in the first routing table; The second prefix length is determined from the first prefix length based on the preset storage space size; The first routing interval corresponding to the routing entry in the first routing table is divided based on the second prefix length to obtain the first-level sub-interval of the routing entry in the first routing table; Based on the preset storage space size, the first level of the routing entries in the first routing table is divided into sub-intervals to obtain the next level of the routing entries in the first routing table.

4. The routing query method according to claim 3, characterized in that, Also includes: If the storage space used to store the first routing interval corresponding to all routing entries in the first routing table does not exceed the preset storage space size, then the first routing tree is constructed using the first routing interval corresponding to the routing entries in the first routing table as nodes. If the storage space used to store the first routing interval corresponding to all routing entries in the first routing table exceeds the preset storage space size, then the step of determining the second prefix length based on the preset storage space size in the first prefix length is executed.

5. The routing query method according to claim 3, characterized in that, Determining the second prefix length based on the preset storage space size within the first prefix length includes: Get the number of route entries in the first routing table; Based on the first prefix length and the quantity, determine the storage space size corresponding to the routing interval for storing all routing entries in the first routing table with the first prefix length; If the storage space size corresponding to the first prefix length does not exceed the preset storage space size, then the first prefix length is taken as the candidate prefix length; The second prefix length is determined from the candidate prefix lengths.

6. The routing query method according to claim 1, characterized in that, The step of constructing the first routing tree using the sub-intervals as nodes and according to the hierarchical relationship of the sub-intervals includes: Based on the size relationship of the routing addresses corresponding to the sub-intervals, the sub-intervals at the same level are sorted. Using the sub-intervals as nodes, the first routing tree is constructed according to the hierarchical relationship of the sub-intervals and the sorting result of the sub-intervals at the same level.

7. The routing query method according to claim 1, characterized in that, The first routing tree includes at least one level of sub-intervals obtained by hierarchically dividing the first routing intervals corresponding to the routing entries in the first routing table; The query of the target route range in the first routing tree that matches the first network address includes: According to the hierarchical order of the sub-intervals in the first routing tree, a binary search is performed on the first network address and the sub-intervals at each level to obtain the target routing interval that matches the first network address.

8. The routing query method according to claim 1, characterized in that, Also includes: In response to an update instruction for the first routing table, a third routing entry that has been modified in the first routing table is obtained, the third routing entry including at least one of newly added routing entries and deleted routing entries in the first routing table; Based on the preset storage space size and the routing interval corresponding to the third routing entry, the second routing tree is adjusted to obtain the third routing tree, and the second routing tree has the same structure as the first routing tree; The query address of the first routing table is adjusted from the address of the root node of the first routing tree to the address of the root node of the third routing tree.

9. The routing query method according to claim 1, characterized in that, Also includes: In response to the update instruction for the fourth route entry in the first routing table, the updated route entry is determined; The mapping relationship is updated based on the updated routing entries.

10. A routing query device, characterized in that, include: The address acquisition module is used to obtain the first network address; The interval query module is used to query the target routing interval in the first routing tree that matches the first network address; wherein, the first routing tree is obtained by hierarchically dividing the first routing interval corresponding to the routing entries in the first routing table based on a preset storage space size; the preset storage space size is related to the memory used for routing table lookup; the leaf nodes of the first routing tree correspond to the routing entries in the first routing table; The entry analysis module is used to determine the target route entry based on the target route interval and the mapping relationship between the first route interval and the route entries in the first route table; The routing table acquisition module is used to acquire the first routing table; The routing processing module is used to perform interval routing processing based on the routing entries in the first routing table to obtain the mapping relationship between the first routing interval and the routing entries in the first routing table; The hierarchical partitioning module is used to hierarchically partition the first routing interval corresponding to the routing entry in the first routing table based on the preset storage space size, to obtain at least one level of sub-intervals of the routing entry in the first routing table; wherein the storage space size used to store the sub-intervals of the same level corresponding to the same routing entry does not exceed the preset storage space size; The routing tree construction module is used to construct the first routing tree according to the hierarchical relationship of the sub-intervals, using the sub-intervals as nodes.

11. An electronic device, characterized in that, include: A memory and a processor are communicatively connected, the memory stores computer instructions, and the processor executes the routing query method of any one of claims 1 to 9 by executing the computer instructions.

12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing a computer to perform the routing query method according to any one of claims 1 to 9.

13. A computer program product, characterized in that, Includes computer instructions for causing a computer to perform the routing query method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Route configuration method, longest mask matching method and application

    CN120639694A