Route comparison method and device, computer device and storage medium

By converting route addresses into integer ranges and using a range tree algorithm for comparison, the problem of time-consuming route comparison in cloud enterprise networks is solved, and efficient route conflict detection is achieved.

CN122268792APending Publication Date: 2026-06-23BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
Filing Date
2024-12-23
Publication Date
2026-06-23

AI Technical Summary

Technical Problem

In cloud enterprise networks, the routing comparison process has an O(n²) complexity, which leads to long processing times and affects user experience.

Method used

The address range of the route is converted into an integer interval and compared using an interval tree algorithm. The interval tree algorithm is used to quickly match the route intervals, reducing the time complexity to O(nlogn).

Benefits of technology

It improves the efficiency of route comparison, especially when there are a large number of routes, with a significant performance improvement and a speed increase of hundreds of times.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122268792A_ABST
    Figure CN122268792A_ABST
Patent Text Reader

Abstract

Embodiments of the present application relate to a routing comparison method and device, computer equipment and a storage medium, by obtaining a first route published by a cloud enterprise network, and obtaining a plurality of second routes already existing in the instance; converting the address range of the target address corresponding to the first route and each second route into an interval of integers to obtain a first interval corresponding to the first route and a second interval corresponding to each second route; comparing the first interval and the plurality of second intervals according to an interval tree algorithm to obtain a plurality of comparison results, the comparison results representing whether the first interval and each second interval overlap. Thus, the addresses of the routes to be compared can be converted into integer intervals and compared according to the interval tree algorithm, even when the number of routes is large, the comparison can be quickly performed, and the efficiency of the route comparison is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of cloud enterprise network technology, and in particular to a routing comparison method, apparatus, computer equipment and storage medium. Background Technology

[0002] The Cloud Enterprise Network (CEN) can be used to connect Virtual Private Clouds (VPCs) and Direct Connect (DCs) in different regions of a user, enabling interconnection. When an instance (VPC or DC) is added to CEN, the user can publish the routes under this instance to the Cloud Enterprise Network. This operation allows other instances under the Cloud Enterprise Network to learn this route, thereby achieving interconnection.

[0003] During the process of learning newly published routes, conflicts with local routes on the instance are inevitable. Therefore, it is necessary to compare the published routes with local routes to eliminate conflicting routes. For example, when a VPC receives n routes from CEN, and there are m existing routes within the VPC, the route comparison needs to be performed m*n times, which has an O(n²) complexity. When the number of routes is very large, the comparison takes a long time, thus affecting the return time of the Cloud Enterprise Network route publishing operation API and impacting the user experience. Therefore, how to improve the efficiency of route comparison has become an urgent problem to be solved. Summary of the Invention

[0004] In view of this, in order to solve the above-mentioned technical problems or some of the technical problems, embodiments of the present invention provide a routing comparison method, apparatus, computer device and storage medium.

[0005] In a first aspect, embodiments of the present invention provide a route comparison method, including:

[0006] Retrieve the first route published by the cloud enterprise network, and retrieve multiple second routes that already exist in the instance;

[0007] Convert the address range of the target address corresponding to the first route and each of the second routes into an integer range to obtain the first range corresponding to the first route and the second range corresponding to each of the second routes;

[0008] The first interval and multiple second intervals are compared using the interval tree algorithm to obtain multiple comparison results. The comparison results indicate whether there is any overlap between the first interval and each of the second intervals.

[0009] In one possible implementation, converting the address ranges of the target addresses corresponding to the first route and each of the second routes into integer ranges includes:

[0010] For the first route and each of the second routes, obtain the start address and the end address, with each route corresponding to one start address and one end address;

[0011] Convert each start address and each end address into their corresponding integer values;

[0012] The integer value of the starting address is used as the starting point of the interval, and the integer value of the ending address corresponding to the starting address is used as the ending point of the interval.

[0013] The interval generated by the first route is taken as the first interval, and each interval generated by the second route is taken as the second interval.

[0014] In one possible implementation, the integer value is determined in the following way:

[0015] Each start address and each end address are divided into four parts, A, B, C, and D, according to the address structure, and each start address and each end address are converted into integer values ​​using the following formula:

[0016] Integer value = A × (256) 3 )+B×(256 2 )+C×(256 1 )+D×(256 0 ).

[0017] In one possible implementation, the interval tree is generated in the following way:

[0018] Determine the root node of the interval tree from multiple second intervals;

[0019] The other second intervals are divided into left and right subtree nodes of the interval tree according to the size of the starting point, so that the starting point of each node in the interval tree is smaller than the starting point of its right subtree node and larger than the starting point of its left subtree node.

[0020] In one possible implementation, the comparison of the first interval and the plurality of second intervals according to the interval tree algorithm includes:

[0021] The node currently being compared with the first interval is determined as the target node, and the first target node to be compared is the root node;

[0022] The first interval is overlapped with the target node query interval to obtain a comparison result, which includes: full overlap, partial overlap, and no overlap.

[0023] When the comparison result is that all nodes overlap, the first interval is compared with the left subtree node and the right subtree node of the target node, respectively.

[0024] In one possible implementation, the comparison of the first interval and the plurality of second intervals according to the interval tree algorithm includes:

[0025] When the comparison result is partial overlap or non-overlap, and the starting point of the first interval is less than the starting point of the target node, the first interval is compared with the left subtree node of the target node;

[0026] When the comparison result is partially overlapping or not overlapping, and the end point of the first interval is greater than the end point of the target node, the first interval is compared with the right subtree node of the target node.

[0027] In one possible implementation, the method further includes:

[0028] When the first interval is completely consistent with the second interval corresponding to the target node, and the starting point of the target node is less than or equal to the ending point of the left subtree node, the first interval is compared with the left subtree node of the target node.

[0029] When the first interval is completely consistent with the second interval corresponding to the target node, and the end point of the target node is greater than or equal to the start point of the right subtree node, the first interval is compared with the right subtree node of the target node.

[0030] In a second aspect, embodiments of the present invention provide a routing comparison device, comprising:

[0031] The acquisition module is used to acquire the first route published by the cloud enterprise network, as well as multiple second routes that already exist in the instance;

[0032] The conversion module is used to convert the address range of the target address corresponding to the first route and each of the second routes into an integer interval, so as to obtain the first interval corresponding to the first route and the second interval corresponding to each of the second routes;

[0033] The comparison module is used to compare the first interval and multiple second intervals according to the interval tree algorithm to obtain multiple comparison results, wherein the comparison results indicate whether the first interval overlaps with each of the second intervals.

[0034] Thirdly, embodiments of the present invention provide a computer device, including: a processor and a memory, wherein the processor is configured to execute a routing comparison program stored in the memory to implement the routing comparison method described in any one of the first aspects above.

[0035] Fourthly, embodiments of the present invention provide a storage medium storing one or more programs, which can be executed by one or more processors to implement the routing comparison method described in any one of the first aspects.

[0036] The routing comparison scheme provided in this invention obtains a first route published by the cloud enterprise network and multiple existing second routes in the instance; converts the address ranges of the target addresses corresponding to the first route and each second route into integer intervals to obtain a first interval corresponding to the first route and a second interval corresponding to each second route; compares the first interval and the multiple second intervals according to an interval tree algorithm to obtain multiple comparison results, where each comparison result indicates whether there is overlap between the first interval and each second interval. Therefore, the addresses of the routes to be compared can be converted into integer intervals before comparison using the interval tree algorithm, enabling fast comparison even when the number of routes is large, thus improving the efficiency of routing comparison. Attached Figure Description

[0037] Figure 1 A flowchart illustrating a routing comparison method provided in an embodiment of the present invention;

[0038] Figure 2 A flowchart illustrating another route comparison method provided in an embodiment of the present invention;

[0039] Figure 3 This is a schematic diagram of the structure of a routing comparison device provided in an embodiment of the present invention;

[0040] Figure 4 A schematic diagram of the structure of a computer device provided in an embodiment of the present invention;

[0041] Figure 5 This is a schematic diagram of an interval tree structure provided in an embodiment of the present invention. Detailed Implementation

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

[0043] To facilitate understanding of the embodiments of the present invention, further explanations and descriptions will be provided below with reference to the accompanying drawings and specific embodiments. These embodiments do not constitute a limitation on the embodiments of the present invention.

[0044] Figure 1 This is a flowchart illustrating a routing comparison method provided in an embodiment of the present invention, as shown below. Figure 1 As shown, the method specifically includes:

[0045] S11. Obtain the first route published by the cloud enterprise network, and obtain multiple second routes that already exist in the instance.

[0046] The routing comparison method provided in this embodiment is applied to an instance in a Cloud Enterprise Network (CEN). The instance may include a Virtual Private Cloud (VPC) and a leased data center (DC). CEN is an enterprise network solution based on cloud computing technology. It connects different branches, offices, and data centers of an enterprise via the Internet, enabling rapid connection between VPCs in different regions and the customer's local network. A VPC is a service in a cloud computing environment that allows users to create isolated virtual networks on public cloud infrastructure. VPC provides a flexible way for users to configure and manage network resources according to their needs. DC access provides a method for quickly and securely connecting cloud servers and local data centers. Users can connect computing resources in multiple regions at once through a single physical leased line, achieving flexible and reliable hybrid cloud deployment. Specifically, the routing comparison method of this invention converts the addresses of the routes to be compared into integer ranges and then compares them using a range tree algorithm to obtain the comparison result.

[0047] In this embodiment, the first route is a route published to the instance by the cloud enterprise network. There can be one or more first routes. When there are multiple first routes, the route comparison method of this embodiment is executed for each first route. The cloud enterprise network will publish the newly added first route to different instances, so that the instances can compare the first route with their local multiple second routes to obtain a comparison result. The comparison result is used to determine whether the first route conflicts with the second routes, and thus determine whether the first route can be further distributed.

[0048] Specifically, the instance obtains the first route published by the current cloud enterprise network and the second route from the instance's local machine. Methods for obtaining the second route include, but are not limited to: using APIs or command-line tools provided by the cloud platform (such as AWS CLI, Azure CLI, GCP CLI) to retrieve the instance's routing table; querying the virtual machine's network configuration or using commands in the operating system (such as `ip route show`) to view routing information; and identifying the second route based on its destination, priority, and network interface information.

[0049] S12. Convert the address range of the target address corresponding to the first route and each second route into an integer interval to obtain the first interval corresponding to the first route and the second interval corresponding to each second route.

[0050] In this embodiment, for the first route and each second route, the start address and end address of its IP address are obtained respectively. The value in the start address is used to generate an integer value according to a preset calculation formula as the start point (left node of the interval) of the interval range corresponding to the route. The value in the end address is used to generate an integer value according to a preset calculation formula as the end point (right node of the interval) of the interval range corresponding to the route. The start point and end point of each route generate an interval, thus obtaining the first interval of the first route and the second interval of the second route.

[0051] S13. The first interval and multiple second intervals are compared according to the interval tree algorithm to obtain multiple comparison results. The comparison results indicate whether there is any overlap between the first interval and each second interval.

[0052] In this embodiment, an interval tree is a special type of balanced binary search tree that can efficiently store intervals. Assume the first interval is [A_start, A_end], and there are multiple second intervals [B_start, B_end]. We will use the interval tree to compare the first and second intervals, query whether they overlap, and obtain multiple comparison results.

[0053] First, insert all second intervals ([B_start,B_end]) into the interval tree, select one second interval as the root node, and generate left and right subtree nodes for the other second intervals based on the root node.

[0054] Furthermore, starting from the root node of the tree, the overlap between the current node and the first interval [A_start, A_end] is checked to obtain a comparison result for output. The overlap status can include: full overlap, partial overlap, and no overlap. Only the comparison results of partial overlap and full overlap can be output. Then, the left subtree nodes or right subtree nodes are recursively checked. The specific query route depends on the left and right endpoints of the current interval. After the query, multiple comparison results are obtained for output.

[0055] In one possible implementation, after the comparison result is output, the instance can determine whether the current first route should be sent based on the pre-set comparison result. If so, the first route will be sent; otherwise, it will not be sent (for example, if all second routes are non-overlapping, the route will be sent, or if route A partially overlaps with the first route, the route will be sent).

[0056] As an example, you can first configure the online runtime environment and dependency libraries:

[0057] Operating System: CentOS 7

[0058] Python version: 2.7.11

[0059] Python library sortedcontainers==2.4.0

[0060] Python library intervaltree == 3.1.0

[0061] Taking the first interval [4,11] and the second interval [10,15][5,10][1,5] as an example, the constructed interval tree is as follows: Figure 5 The diagram shown is a schematic diagram of an interval tree structure provided in an embodiment of the present invention.

[0062] ① Starting from the root node [5,10], determine if the root node overlaps with the query interval and record the comparison results.

[0063] ② Move to the left to [1,5]. This interval also overlaps with the query interval. Record the comparison result.

[0064] ③ Move to the right to [10,15], which also overlaps with the query interval, and record the comparison result.

[0065] ④ Since [0,3] and [12,20] do not overlap with [4,11], we can skip the overlap query and end the query.

[0066] Taking the first interval [0, 4] as an example, and the second interval [0, 3][1, 5] as an example:

[0067] ① Starting from the root node [5,10]: The query interval [0,4] does not overlap with [5,10] because the ending value of [0,4] is 4, which is less than the starting value of [5,10], 5. Therefore, move to the left.

[0068] ② Move to the left to [1,5]: This interval overlaps with [0,4], so record the comparison result of [1,5].

[0069] ③ Move to the left to [0,3]: This interval is completely within [0,4], and record the comparison result of [0,3].

[0070] ④ End of query: The nodes [10,15] and [12,20] on the right and the right subtree do not need to be checked, because their starting values ​​are greater than the ending value of the query interval.

[0071] Taking the first interval [21, 25] as an example:

[0072] ① Starting from the root node [5,10]: The query interval [21,25] does not overlap with [5,10].

[0073] ② Move to the right to [10,15]: There is still no overlap.

[0074] ③ Move to the right again to [12,20]: This interval also does not overlap with [21,25].

[0075] ④ Query ends: No intervals overlapping with [21,25] were found.

[0076] The route comparison method provided in this invention obtains a first route published by the cloud enterprise network and multiple existing second routes in the instance; converts the address ranges of the target addresses corresponding to the first route and each second route into integer intervals to obtain a first interval corresponding to the first route and a second interval corresponding to each second route; compares the first interval and multiple second intervals according to an interval tree algorithm to obtain multiple comparison results, where each comparison result indicates whether there is overlap between the first interval and each second interval. Therefore, the addresses of the routes to be compared can be converted into integer intervals before comparison using the interval tree algorithm, enabling fast comparison even when the number of routes is large, thus improving the efficiency of route comparison.

[0077] Figure 2 This is a flowchart illustrating another routing comparison method provided in an embodiment of the present invention, as shown below. Figure 2 As shown, the method specifically includes:

[0078] S21. Obtain the published first route and the multiple second routes that already exist in the instance. In this embodiment, it is similar to step S11, and can be referred to for details. Figure 1 For the sake of brevity, the relevant content will not be elaborated upon here.

[0079] S22. For the first route and each second route, obtain the start address and end address. Each route corresponds to a start address and an end address. Convert each start address and each end address into the corresponding integer value.

[0080] In this embodiment, the start address and end address refer to the two endpoints of the IP address range of the route, such as the network address and broadcast address in Classless Inter-Domain Routing (CIDR), a method for IP address allocation and routing. CIDR uses a forward slash followed by a number to represent the network prefix, such as the IP address 192.168.1.0 / 24. Here, " / 24" indicates that the network portion occupies 24 bits, and the remaining 8 bits are used for the host address.

[0081] The process of converting these addresses to integer values ​​is actually converting the IP address from the regular dotted decimal format (e.g., 192.168.1.0) to the corresponding 32-bit integer value, which helps to perform address comparison, routing calculation and other operations more efficiently.

[0082] An IP address is a 32-bit number, typically represented by 4 bytes (8 bits per byte), in the format A, B, C, D, where A, B, C, and D are numbers between 0 and 255. The value of each byte can be considered an integer within the range of 2 to the power of 8. For the IP address 192.168.1.0, then A = 192, B = 168, C = 1, and D = 0.

[0083] Converting an IP address to an integer includes:

[0084] Each start address and each end address are divided into four parts according to the address structure, namely A, B, C, and D, and each start address and each end address are converted into integer values ​​using the following formula:

[0085] Integer value = A × (256) 3 )+B×(256 2 )+C×(256 1 )+D×(256 0 ).

[0086] For a CIDR route (e.g., 192.168.1.0 / 24), the start and end addresses can be obtained using the following steps:

[0087] The starting address in CIDR notation is the network address, which is the result of a bitwise AND operation between the IP address and the subnet mask. The ending address is the broadcast address calculated from the subnet mask. For a / 24 subnet, the ending address is usually the last address of the network address, i.e., all bits of the host portion are set to 1. For example, for the IP address 192.168.1.0 / 24, the starting address is 192.168.1.0, and the ending address is 192.168.1.255. Converting to integers gives:

[0088] Starting address integer value = 3232235520

[0089] End address integer value = 3232235775

[0090] Since `cidr.broadcast` is None when the subnet mask is 32 or 31, this is a special subnet:

[0091] CIDR / 32 represents a single IP address. It is a precise address and does not have the concept of network and broadcast addresses. Therefore, for a / 32 subnet, the concept of a broadcast address does not apply, and broadcast will return None.

[0092] CIDR / 31 is typically used for point-to-point connections. This is because the / 31 subnet only has two IP addresses, one for host A and one for host B. To avoid wasting addresses, broadcast addresses are usually not used in this configuration, so broadcast will return None.

[0093] S23. Take the integer value of the starting address as the starting point of the interval, and take the integer value of the ending address corresponding to the starting address as the ending point of the interval; take the interval generated by the first route as the first interval, and take the interval generated by each second route as the second interval.

[0094] In this embodiment, the starting point of each interval is the integer value after IP address translation (the starting address of the route). The ending point of the interval is the integer value after IP address translation (e.g., broadcast address) (the ending address of the route). The interval generated by the IP address of the first route is designated as the first interval, and the interval generated by the IP address of the second route is designated as the second interval.

[0095] For example, if the first route is 192.168.1.0 / 24, the integer range of the first interval is: [3232235520, 3232235775].

[0096] S24. Determine the root node of the interval tree from multiple second intervals; divide the other second intervals into left and right subtree nodes of the interval tree according to the size of the starting point, so that the starting point of each node in the interval tree is smaller than the starting point of its right subtree node and larger than the starting point of its left subtree node.

[0097] In this embodiment, a suitable root node is selected from multiple second intervals. Typically, the root node is the median of the starting points of all intervals. This helps ensure the balance of the interval tree, thereby improving query efficiency. After selecting the root node, the other intervals will determine their positions in the interval tree based on their starting points. Specifically, the starting points of all second intervals can be obtained. All intervals are then sorted according to the size of their starting points. The median is selected as the root node (this can be achieved by selecting the middle element of the sorted intervals).

[0098] Furthermore, based on the selected root node, the remaining intervals are divided into left and right subtree nodes. Intervals smaller than the root node's starting point are placed in the left subtree as left subtree nodes. Intervals larger than the root node's starting point are placed in the right subtree as right subtree nodes. Each subtree continues to be constructed using the same method, recursively selecting the median as the subtree's root node and recursively assigning intervals to the left and right subtrees according to the size of the starting point. The steps are repeated for the left and right subtrees until all intervals are placed in the interval tree. When an interval overlaps with the first interval query, the overlap status can be determined by comparing the starting and ending points.

[0099] S25. Determine the node currently being compared with the first interval as the target node, and the first target node to be compared as the root node; overlap the first interval with the target node query interval to obtain the comparison result.

[0100] In this embodiment, the first interval is compared with the second interval corresponding to the node in the interval tree according to the interval tree algorithm. The comparison process is to query the overlap between the two intervals and take the result of the overlap query as the comparison result. The comparison result includes: full overlap, partial overlap and no overlap.

[0101] Specifically, starting with the root node as the first node to be compared, the current node being compared is determined as the target node. First, the root node of the first interval and the interval tree is set as the target node, and comparison with the root node begins. The comparison result has three possible outcomes:

[0102] The first approach: If the starting point of the first interval is less than the starting point of the target node, and the ending point of the first interval is greater than the ending point of the target node, the comparison result is determined to be a complete overlap, and the result is output. Simultaneously, the left and right subtree nodes of the target node are designated as two new target nodes, and comparisons are continued based on the first interval.

[0103] As an example, ['start']<=start and existing['end']>=end, the input CIDR needs to be within the overlapping interval to be determined as a subset, and not(existing['start']==start and existing['end']==end), the input CIDR cannot be exactly the same as the overlapping interval to be determined as a proper subset.

[0104] The second method: When either the start point or the end point of the first interval is within the second interval of the target node, the comparison result is determined to be partially overlapping. When neither the start point nor the end point is within the second interval of the target node, the comparison result is determined to be non-overlapping. When the comparison result is partially overlapping or non-overlapping, and the start point of the first interval is less than the start point of the target node, the first interval is compared with the left subtree node of the target node to obtain the comparison result for output. When the comparison result is partially overlapping or non-overlapping, and the end point of the first interval is greater than the end point of the target node, the first interval is compared with the right subtree node of the target node to obtain the comparison result for output.

[0105] The third scenario is when the starting and ending points of the first interval are completely consistent with the starting and ending points of the second interval corresponding to the target node (for example, determine whether the overlapping interval and CIDR are equal at both ends; if so, it means that there is complete consistency), and the starting point of the target node is less than or equal to the ending point of its left subtree node, it means that the target node and the left subtree node have an overlapping part. In this case, the first interval is compared with the left subtree node of the target node, and the comparison result is used for output.

[0106] When the start and end points of the first interval are exactly the same as the start and end points of the second interval corresponding to the target node, and the end point of the target node is greater than or equal to the start point of the right subtree node, it means that the target node and its right subtree node have an overlapping part. The first interval is compared with the right subtree node of the target node, and the comparison result is used for output.

[0107] The route comparison method provided in this embodiment of the invention determines the interval between the first route and the second route local to the instance, and compares them according to the interval tree algorithm to obtain the comparison result. It achieves significant optimization in terms of time complexity, number of library function calls, and comparison efficiency of the comparison function. The more routes there are, the more obvious the speed difference becomes. When the number of routes is greater than 100, the interval tree comparison can achieve a performance improvement of hundreds of times or more. The interval tree algorithm reduces the time complexity of n2 to O(nlogn), improving the speed and efficiency of route comparison.

[0108] Figure 3 This is a schematic diagram of the structure of a routing comparison device provided in an embodiment of the present invention, as shown below. Figure 3 As shown, the device specifically includes:

[0109] The acquisition module 31 is used to acquire the first route published by the cloud enterprise network and to acquire multiple second routes that already exist in the instance;

[0110] The conversion module 32 is used to convert the address range of the target address corresponding to the first route and each of the second routes into an integer interval, so as to obtain the first interval corresponding to the first route and the second interval corresponding to each of the second routes;

[0111] The comparison module 33 is used to compare the first interval and multiple second intervals according to the interval tree algorithm to obtain multiple comparison results, wherein the comparison results indicate whether the first interval overlaps with each of the second intervals.

[0112] In one possible implementation, the conversion module is specifically used to obtain a start address and an end address for the first route and each of the second routes, with each route corresponding to a start address and an end address;

[0113] Convert each start address and each end address into their corresponding integer values;

[0114] The integer value of the starting address is used as the starting point of the interval, and the integer value of the ending address corresponding to the starting address is used as the ending point of the interval.

[0115] The interval generated by the first route is taken as the first interval, and each interval generated by the second route is taken as the second interval.

[0116] In one possible implementation, the conversion module is specifically used to divide each of the start addresses and each of the end addresses into four parts, A, B, C, and D, according to the address structure, so as to convert each of the start addresses and each of the end addresses into integer values ​​using the following formula:

[0117] Integer value = A × (256) 3 )+B×(256 2 )+C×(256 1 )+D×(256 0 ).

[0118] In one possible implementation, the generation module 34 is used to determine the root node of the interval tree from a plurality of the second intervals;

[0119] The other second intervals are divided into left and right subtree nodes of the interval tree according to the size of the starting point, so that the starting point of each node in the interval tree is smaller than the starting point of its right subtree node and larger than the starting point of its left subtree node.

[0120] In one possible implementation, the comparison module is specifically used to determine that the node currently being compared with the first interval is the target node, and the first target node to be compared is the root node;

[0121] The first interval is overlapped with the target node query interval to obtain a comparison result, which includes: full overlap, partial overlap, and no overlap.

[0122] When the comparison result is that all nodes overlap, the first interval is compared with the left subtree node and the right subtree node of the target node, respectively.

[0123] In one possible implementation, the comparison module is specifically used to compare the first interval with the left subtree node of the target node when the comparison result is partially overlapping or not overlapping, and the starting point of the first interval is less than the starting point of the target node.

[0124] When the comparison result is partially overlapping or not overlapping, and the end point of the first interval is greater than the end point of the target node, the first interval is compared with the right subtree node of the target node.

[0125] In one possible implementation, the comparison module is further configured to compare the first interval with the left subtree node of the target node when the first interval is completely consistent with the second interval corresponding to the target node, and the starting point of the target node is less than or equal to the ending point of the left subtree node.

[0126] When the first interval is completely consistent with the second interval corresponding to the target node, and the end point of the target node is greater than or equal to the start point of the right subtree node, the first interval is compared with the right subtree node of the target node.

[0127] The routing comparison device provided in this embodiment can be as follows: Figure 3 The apparatus shown can perform, for example Figure 1-2 All steps of the routing comparison method are then implemented. Figure 1-2 For details on the technical effectiveness of the route comparison method shown, please refer to [link / reference]. Figure 1-2 The relevant descriptions are presented concisely and will not be elaborated upon here.

[0128] Figure 4 This is a schematic diagram of the structure of a computer device provided in an embodiment of the present invention. Figure 4 The computer device 400 shown includes at least one processor 401, a memory 402, at least one network interface 404, and other user interfaces 403. The various components in the computer device 400 are coupled together via a bus system 405. It is understood that the bus system 405 is used to implement communication between these components. In addition to a data bus, the bus system 405 also includes a power bus, a control bus, and a status signal bus. However, for clarity, ... Figure 4 The general designated all buses as Bus System 405.

[0129] The user interface 403 may include a display, keyboard, or clicking device (e.g., mouse, trackball, touchpad, or touchscreen).

[0130] It is understood that the memory 402 in the embodiments of the present invention can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced Synchronous DRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), and Direct Rambus RAM (DRRAM). The memory 402 described herein is intended to include, but is not limited to, these and any other suitable types of memory.

[0131] In some implementations, memory 402 stores elements, executable units or data structures, or subsets thereof, or extended sets thereof: operating system 4021 and application program 4022.

[0132] The operating system 4021 includes various system programs, such as the framework layer, core library layer, and driver layer, used to implement various basic business functions and handle hardware-based tasks. The application program 4022 includes various applications, such as a media player and a browser, used to implement various application functions. The program implementing the method of this embodiment can be included in the application program 4022.

[0133] In this embodiment of the invention, by calling the program or instructions stored in the memory 402, specifically the program or instructions stored in the application program 4022, the processor 401 executes the method steps provided in each method embodiment, including, for example:

[0134] Retrieve the first published route, and retrieve the multiple second routes that already exist in the instance;

[0135] Convert the address range of the target address corresponding to the first route and each of the second routes into an integer range to obtain the first range corresponding to the first route and the second range corresponding to each of the second routes;

[0136] The first interval and multiple second intervals are compared using the interval tree algorithm to obtain multiple comparison results. The comparison results indicate whether there is any overlap between the first interval and each of the second intervals.

[0137] In one possible implementation, for the first route and each of the second routes, a start address and an end address are obtained, with each route corresponding to a start address and an end address;

[0138] Convert each start address and each end address into their corresponding integer values;

[0139] The integer value of the starting address is used as the starting point of the interval, and the integer value of the ending address corresponding to the starting address is used as the ending point of the interval.

[0140] The interval generated by the first route is taken as the first interval, and each interval generated by the second route is taken as the second interval.

[0141] In one possible implementation, each start address and each end address are divided into four parts, A, B, C, and D, according to an address structure, so that each start address and each end address can be converted into an integer value using the following formula:

[0142] Integer value = A × (256) 3 )+B×(256 2 )+C×(256 1 )+D×(256 0 ).

[0143] In one possible implementation, the root node of the interval tree is determined from multiple second intervals;

[0144] The other second intervals are divided into left and right subtree nodes of the interval tree according to the size of the starting point, so that the starting point of each node in the interval tree is smaller than the starting point of its right subtree node and larger than the starting point of its left subtree node.

[0145] In one possible implementation, the node currently being compared with the first interval is determined as the target node, and the first target node to be compared is the root node;

[0146] The first interval is overlapped with the target node query interval to obtain a comparison result, which includes: full overlap, partial overlap, and no overlap.

[0147] When the comparison result is that all nodes overlap, the first interval is compared with the left subtree node and the right subtree node of the target node, respectively.

[0148] In one possible implementation, when the comparison result is partial overlap or non-overlap, and the starting point of the first interval is less than the starting point of the target node, the first interval is compared with the left subtree node of the target node.

[0149] When the comparison result is partially overlapping or not overlapping, and the end point of the first interval is greater than the end point of the target node, the first interval is compared with the right subtree node of the target node.

[0150] In one possible implementation, when the first interval is completely consistent with the second interval corresponding to the target node, and the starting point of the target node is less than or equal to the ending point of the left subtree node, the first interval is compared with the left subtree node of the target node.

[0151] When the first interval is completely consistent with the second interval corresponding to the target node, and the end point of the target node is greater than or equal to the start point of the right subtree node, the first interval is compared with the right subtree node of the target node.

[0152] The methods disclosed in the above embodiments of the present invention can be applied to processor 401, or implemented by processor 401. Processor 401 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the integrated logic circuit of the hardware in processor 401 or by instructions in the form of software. The processor 401 may be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of the present invention. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of the present invention can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software units in the decoding processor. The software units may be located in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. The storage medium is located in memory 402. Processor 401 reads the information in memory 402 and, in conjunction with its hardware, completes the steps of the above method.

[0153] It is understood that the embodiments described herein can be implemented in hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit can be implemented in one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described herein, or combinations thereof.

[0154] For software implementation, the techniques described herein can be implemented by units that perform the functions described herein. The software code can be stored in memory and executed by a processor. The memory can be implemented in the processor or external to the processor.

[0155] The computer device provided in this embodiment may be as follows: Figure 4 The computer device shown can perform, for example Figure 1-2 All steps of the routing comparison method are then implemented. Figure 1-2 For details on the technical effectiveness of the route comparison method shown, please refer to [link / reference]. Figure 1-2 The relevant descriptions are presented concisely and will not be elaborated upon here.

[0156] This invention also provides a storage medium (computer-readable storage medium). This storage medium stores one or more programs. The storage medium may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as read-only memory, flash memory, hard disk, or solid-state drive; the memory may also include combinations of the above types of memory.

[0157] One or more programs in the storage medium can be executed by one or more processors to implement the routing comparison method described above that is executed on the device side.

[0158] The processor is used to execute a route comparison program stored in memory to implement the following steps of a route comparison method executed on the device side:

[0159] Retrieve the first published route, and retrieve the multiple second routes that already exist in the instance;

[0160] Convert the address range of the target address corresponding to the first route and each of the second routes into an integer range to obtain the first range corresponding to the first route and the second range corresponding to each of the second routes;

[0161] The first interval and multiple second intervals are compared using the interval tree algorithm to obtain multiple comparison results. The comparison results indicate whether there is any overlap between the first interval and each of the second intervals.

[0162] In one possible implementation, for the first route and each of the second routes, a start address and an end address are obtained, with each route corresponding to a start address and an end address;

[0163] Convert each start address and each end address into their corresponding integer values;

[0164] The integer value of the starting address is used as the starting point of the interval, and the integer value of the ending address corresponding to the starting address is used as the ending point of the interval.

[0165] The interval generated by the first route is taken as the first interval, and each interval generated by the second route is taken as the second interval.

[0166] In one possible implementation, each start address and each end address are divided into four parts, A, B, C, and D, according to an address structure, so that each start address and each end address can be converted into an integer value using the following formula:

[0167] Integer value = A × (256) 3 )+B×(256 2 )+C×(256 1 )+D×(256 0 ).

[0168] In one possible implementation, the root node of the interval tree is determined from multiple second intervals;

[0169] The other second intervals are divided into left and right subtree nodes of the interval tree according to the size of the starting point, so that the starting point of each node in the interval tree is smaller than the starting point of its right subtree node and larger than the starting point of its left subtree node.

[0170] In one possible implementation, the node currently being compared with the first interval is determined as the target node, and the first target node to be compared is the root node;

[0171] The first interval is overlapped with the target node query interval to obtain a comparison result, which includes: full overlap, partial overlap, and no overlap.

[0172] When the comparison result is that all nodes overlap, the first interval is compared with the left subtree node and the right subtree node of the target node, respectively.

[0173] In one possible implementation, when the comparison result is partial overlap or non-overlap, and the starting point of the first interval is less than the starting point of the target node, the first interval is compared with the left subtree node of the target node.

[0174] When the comparison result is partially overlapping or not overlapping, and the end point of the first interval is greater than the end point of the target node, the first interval is compared with the right subtree node of the target node.

[0175] In one possible implementation, when the first interval is completely consistent with the second interval corresponding to the target node, and the starting point of the target node is less than or equal to the ending point of the left subtree node, the first interval is compared with the left subtree node of the target node.

[0176] When the first interval is completely consistent with the second interval corresponding to the target node, and the end point of the target node is greater than or equal to the start point of the right subtree node, the first interval is compared with the right subtree node of the target node.

[0177] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.

[0178] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented in hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.

[0179] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A routing comparison method, characterized in that, include: Retrieve the first published route, and retrieve the multiple second routes that already exist in the instance; Convert the address range of the target address corresponding to the first route and each of the second routes into an integer range to obtain the first range corresponding to the first route and the second range corresponding to each of the second routes; The first interval and multiple second intervals are compared using the interval tree algorithm to obtain multiple comparison results. The comparison results indicate whether there is any overlap between the first interval and each of the second intervals.

2. The method according to claim 1, characterized in that, The step of converting the address range of the target address corresponding to the first route and each of the second routes into an integer range includes: For the first route and each of the second routes, obtain the start address and the end address, with each route corresponding to one start address and one end address; Convert each start address and each end address into their corresponding integer values; The integer value of the starting address is used as the starting point of the interval, and the integer value of the ending address corresponding to the starting address is used as the ending point of the interval. The interval generated by the first route is taken as the first interval, and each interval generated by the second route is taken as the second interval.

3. The method according to claim 2, characterized in that, The integer value is determined in the following way: Each start address and each end address are divided into four parts, A, B, C, and D, according to the address structure, and each start address and each end address are converted into integer values ​​using the following formula: Integer value = A × (256) 3 )+B×(256 2 )+C×(256 1 )+D×(256 0 ).

4. The method according to claim 3, characterized in that, Interval trees are generated in the following way: Determine the root node of the interval tree from multiple second intervals; The other second intervals are divided into left and right subtree nodes of the interval tree according to the size of the starting point, so that the starting point of each node in the interval tree is smaller than the starting point of its right subtree node and larger than the starting point of its left subtree node.

5. The method according to claim 4, characterized in that, The comparison of the first interval and multiple second intervals according to the interval tree algorithm includes: The node currently being compared with the first interval is determined as the target node, and the first target node to be compared is the root node; The first interval is overlapped with the target node query interval to obtain a comparison result, which includes: full overlap, partial overlap, and no overlap. When the comparison result is that all nodes overlap, the first interval is compared with the left subtree node and the right subtree node of the target node, respectively.

6. The method according to claim 5, characterized in that, The comparison of the first interval and multiple second intervals according to the interval tree algorithm includes: When the comparison result is partial overlap or non-overlap, and the starting point of the first interval is less than the starting point of the target node, the first interval is compared with the left subtree node of the target node; When the comparison result is partially overlapping or not overlapping, and the end point of the first interval is greater than the end point of the target node, the first interval is compared with the right subtree node of the target node.

7. The method according to claim 6, characterized in that, The method further includes: When the first interval is completely consistent with the second interval corresponding to the target node, and the starting point of the target node is less than or equal to the ending point of the left subtree node, the first interval is compared with the left subtree node of the target node. When the first interval is completely consistent with the second interval corresponding to the target node, and the end point of the target node is greater than or equal to the start point of the right subtree node, the first interval is compared with the right subtree node of the target node.

8. A routing comparison device, characterized in that, include: The acquisition module is used to acquire the first route published by the cloud enterprise network, as well as multiple second routes that already exist in the instance; The conversion module is used to convert the address range of the target address corresponding to the first route and each of the second routes into an integer interval, so as to obtain the first interval corresponding to the first route and the second interval corresponding to each of the second routes; The comparison module is used to compare the first interval and multiple second intervals according to the interval tree algorithm to obtain multiple comparison results, wherein the comparison results indicate whether the first interval overlaps with each of the second intervals.

9. A computer device, characterized in that, include: A processor and a memory, the processor being configured to execute a route comparison program stored in the memory to implement the route comparison method according to any one of claims 1 to 7.

10. A storage medium, characterized in that, The storage medium stores one or more programs, which can be executed by one or more processors to implement the routing comparison method according to any one of claims 1 to 7.