A shortest path routing search method, system, device and storage medium
By judging and clearing the hop count of devices in the same data center in the breadth-first traversal algorithm, the network routing path is optimized, which solves the problem of shortest path calculation deviation caused by devices in the same data center in traditional methods, and realizes fast and accurate network topology map construction and resource optimization.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA COMM SERVICE APPL & SOLUTION TECH CO LTD
- Filing Date
- 2023-08-15
- Publication Date
- 2026-07-07
Smart Images

Figure CN117014366B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of network system management technology, specifically relating to a shortest path routing search method, system, device, and storage medium. Background Technology
[0002] A device topology diagram is a graphical representation of the devices and their connections in a network. It can be used for device routing topology management and fault location. Traditional methods for constructing device topology diagrams rely heavily on manual work, which is inefficient and prone to errors. Currently, the industry uses corresponding device routing algorithms, such as breadth-first search (BFS), to perform route searches in network systems. BFS is a graph search algorithm used to traverse or search graph or tree data structures. It is suitable for searching shortest paths, state-space searches, and constructing directed graphs. In general, BFS is a widely used traversal search algorithm for graphs and trees, its core idea being the use of queues to achieve breadth-first traversal. However, currently, this algorithm uses connections between devices in the same data center in the hop count calculation during node label processing, increasing the hop count for devices in the same data center and the breadth of the shortest path search, leading to inaccuracies in the shortest path calculation results. Summary of the Invention
[0003] The purpose of this invention is to provide a shortest path routing search method, system, device, and storage medium to solve the aforementioned problems existing in the prior art.
[0004] To achieve the above objectives, the present invention adopts the following technical solution:
[0005] Firstly, a shortest path routing search method is provided, including:
[0006] Obtain the adjacency table and the same-datacenter device table of the target network, and obtain the routing search instruction for the target network. The routing search instruction includes a given initial node and terminal node. The adjacency table contains the adjacency relationships of each node in the target network. The same-datacenter device table contains several data centers, the same-datacenter devices in each data center, and the nodes corresponding to each same-datacenter device.
[0007] Starting from the initial node, the target network is traversed and searched using a breadth-first traversal algorithm based on the adjacency table until the terminal node is reached, thus obtaining the traversal search result.
[0008] Construct a network topology graph based on the search results and determine all paths from the initial node to the terminal node in the network topology graph;
[0009] Calculate the initial hop count for each path from the initial node to the terminal node;
[0010] Determine whether there are nodes corresponding to devices in the same data center in each path based on the equipment table in the same data center.
[0011] When it is determined that there are nodes corresponding to the same equipment in the same data center in the corresponding path, the hop count between the nodes corresponding to the same equipment in the same data center is cleared to zero, and the optimized hop count of the path is recalculated. When it is determined that there are no nodes corresponding to the same equipment in the same data center in the corresponding path, the initial hop count of the path is used as its optimized hop count.
[0012] The path with the fewest hops is selected as the shortest path.
[0013] In one possible design, starting from the initial node, a breadth-first search algorithm is used to perform a route search on the target network based on the adjacency table until the terminal node is reached, obtaining the search results, including:
[0014] Starting from the initial node, add the initial node to the traversal queue and mark the initial node as visited;
[0015] Determine the adjacent nodes of the initial node from the adjacency table, and treat each of the initial node's adjacent nodes as first-level adjacent nodes. Add each first-level adjacent node to the traversal queue in turn, and mark each first-level adjacent node as visited, thus determining the connection relationship between the initial node and each first-level adjacent node.
[0016] Determine the unvisited adjacent nodes of each first-level adjacent node from the adjacency table, and use the unvisited adjacent nodes of each first-level adjacent node as second-level adjacent nodes. Add each second-level adjacent node to the traversal queue in turn, and mark each second-level adjacent node as visited, and determine the connection relationship between each first-level adjacent node and each second-level adjacent node.
[0017] The process is iterated in this manner until the terminal node is reached, resulting in a traversal search result. The traversal search result includes a traversal queue and the connection relationships between corresponding nodes in the traversal queue.
[0018] In one possible design, the step of constructing a network topology graph based on the traversal search results and determining all paths from the initial node to the terminal node in the network topology graph includes: constructing a network topology graph based on the traversal queue and the connection relationships between the corresponding nodes in the traversal queue, and determining all paths from the initial node to the terminal node in the network topology graph.
[0019] In one possible design, calculating the initial hop count for each path from the initial node to the terminal node includes: calculating the number of nodes traversed in each path from the initial node to the terminal node, and using the number of traversed nodes as the hop count for the corresponding path.
[0020] In one possible design, determining whether there are nodes corresponding to devices in the same data center in each path based on the same data center equipment table includes: comparing each node corresponding to a device in the same data center in the same data center equipment table with each node in the corresponding path to determine whether there are nodes corresponding to devices in the same data center in each path.
[0021] In one possible design, the method further includes: marking the nodes corresponding to the equipment in the same data center in the shortest path, and storing and displaying the marked shortest path as the routing search result.
[0022] Secondly, a shortest path routing search system is provided, comprising an acquisition unit, a traversal unit, a determination unit, a calculation unit, a judgment unit, an optimization unit, and an execution unit, wherein:
[0023] The acquisition unit is used to acquire the adjacency table and the same-room device table of the target network, and to acquire the route search instruction for the target network. The route search instruction includes a given initial node and terminal node. The adjacency table includes the adjacency relationship of each node in the target network. The same-room device table includes several computer rooms, the same-room devices in each computer room, and the nodes corresponding to each same-room device.
[0024] The traversal unit is used to traverse the target network from the initial node, according to the adjacency table, using the breadth-first traversal algorithm, until the terminal node is reached, and obtain the traversal search result.
[0025] The determining unit is used to construct a network topology graph based on the traversal search results and determine all paths from the initial node to the terminal node in the network topology graph;
[0026] The calculation unit is used to calculate the initial hop count for each path from the initial node to the terminal node;
[0027] The judgment unit is used to determine whether there are nodes corresponding to devices in the same data center in each path based on the same data center equipment table.
[0028] The optimization unit is used to reset the hop count between nodes corresponding to the same equipment in the same data center to zero and recalculate the optimized hop count of the path when it is determined that there are nodes corresponding to the same equipment in the same data center in the corresponding path; and to use the initial hop count of the path as its optimized hop count when it is determined that there are no nodes corresponding to the same equipment in the same data center in the corresponding path.
[0029] The execution unit is used to select the path with the fewest optimized hops as the shortest path, and to store and display the shortest path.
[0030] Thirdly, a shortest path routing search device is provided, including:
[0031] Memory, used to store instructions;
[0032] A processor is configured to read instructions stored in the memory and execute the method described in any one of the first aspects above, according to the instructions.
[0033] Fourthly, a computer-readable storage medium is provided, on which instructions are stored, which, when executed on a computer, cause the computer to perform any of the methods described in the first aspect. A computer program product containing instructions is also provided, which, when executed on a computer, cause the computer to perform any of the methods described in the first aspect.
[0034] Beneficial Effects: This invention employs a breadth-first search algorithm to traverse and search the target network, obtaining the search results and constructing a network topology graph. It then determines all paths from the initial node to the terminal node, calculates the initial hop count for each path, and checks if any nodes corresponding to devices in the same data center exist along each path. If so, the hop count between these nodes is reset to zero; otherwise, the original hop count is maintained. This process is repeated to obtain the optimized hop count for each path, and the path with the smallest optimized hop count is selected as the shortest path. This invention, based on a breadth-first search algorithm for network routing search and network topology graph construction, can construct network topology graphs in real-time, automatically, quickly, and accurately, improving network system management efficiency. It is suitable for networks with a large number of devices and complex interconnections. By ignoring the number of routing nodes between devices in the same data center and optimizing network routing paths to select the shortest path, this invention better reflects the actual characteristics of the network system, saves fiber optic cable resources within the same data center, achieves better economic and social benefits, and realizes the digital transformation of network resource management. Attached Figure Description
[0035] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0036] Figure 1 This is a schematic diagram of the steps in the method of Embodiment 1 of the present invention;
[0037] Figure 2 This is a schematic diagram of the network topology constructed in Example 1 of the present invention;
[0038] Figure 3 This is a schematic diagram of the equipment path in the computer room as exemplified in Embodiment 1 of the present invention;
[0039] Figure 4This is a schematic diagram of the system configuration in Embodiment 2 of the present invention;
[0040] Figure 5 This is a schematic diagram of the device configuration in Embodiment 3 of the present invention. Detailed Implementation
[0041] It should be noted that the descriptions of these embodiments are intended to aid in understanding the invention and do not constitute a limitation thereof. The specific structural and functional details disclosed herein are merely for describing exemplary embodiments of the invention. However, the invention may be embodied in many alternative forms and should not be construed as being limited to the embodiments described herein.
[0042] It should be understood that, unless otherwise explicitly specified and limited, the term "connection" should be interpreted broadly. For example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium; it can be a connection within two components. Those skilled in the art can understand the specific meaning of the above terms in the embodiments according to the specific circumstances.
[0043] Specific details are provided in the following description to provide a complete understanding of the exemplary embodiments. However, those skilled in the art will understand that the exemplary embodiments can be implemented without these specific details. For example, the system may be shown in block diagrams to avoid obscuring the example with unnecessary details. In other embodiments, well-known processes, structures, and techniques may be shown without non-essential details to avoid obscuring the embodiments.
[0044] Example 1:
[0045] This embodiment provides a shortest path route search method, which can be applied to corresponding route search servers, such as... Figure 1 As shown, the method includes the following steps:
[0046] S1. Obtain the adjacency table and the same-room device table of the target network, and obtain the routing search instruction for the target network. The routing search instruction includes a given initial node and terminal node. The adjacency table includes the adjacency relationship of each node in the target network. The same-room device table includes several computer rooms, the same-room devices in each computer room, and the nodes corresponding to each same-room device.
[0047] S2. Starting from the initial node, use the breadth-first traversal algorithm to traverse and search the target network according to the adjacency table until the terminal node is reached, and obtain the traversal search result. In specific implementation, starting from the initial node, the initial node is added to the traversal queue and marked as visited. The adjacent nodes of the initial node are determined from the adjacency table, and these adjacent nodes are designated as first-level adjacent nodes. Each first-level adjacent node is then added to the traversal queue and marked as visited, thus determining the connection relationship between the initial node and each first-level adjacent node. The unvisited adjacent nodes of each first-level adjacent node are determined from the adjacency table, and these unvisited adjacent nodes are designated as second-level adjacent nodes. Each second-level adjacent node is then added to the traversal queue and marked as visited, thus determining the connection relationship between each first-level adjacent node and each second-level adjacent node. This process is iterated until the terminal node is reached, yielding the traversal search result. The traversal search result includes the traversal queue and the connection relationships between the corresponding nodes in the traversal queue.
[0048] For example, such as Figure 2 As shown, the traversal search process starts from the initial node 0. From the adjacency table, the three adjacent nodes of node 0 are found to be nodes 2, 1, and 5. Nodes 0, 2, 1, and 5 are sequentially added to the traversal queue and marked as visited, thus determining the connection relationship between node 0 and nodes 2, 1, and 5. Then, the traversal search begins from node 2. Based on the adjacency table, its unvisited adjacent nodes are determined to be nodes 3 and 4. Nodes 3 and 4 are sequentially added to the traversal queue and marked as visited, thus determining the connection relationship between node 2 and nodes 3 and 4. Then… The process involves traversing and searching node 1. According to the adjacency table, its adjacent nodes are 0 and 2, both of which have been visited, meaning there are no unvisited adjacent nodes. Next, the process involves traversing and searching node 5. Its adjacent nodes are 0 and 3, and again, there are no unvisited adjacent nodes. The connection between node 5 and node 3 is then determined. The process continues with node 3. According to the adjacency table, its adjacent nodes are 2, 5, and 4, and there are no unvisited adjacent nodes. The connection between node 3 and node 4 is then determined. Finally, the process reaches node 4, and the traversal and search of node 4 is stopped when node 4 becomes the terminal node.
[0049] S3. Construct a network topology graph based on the traversal search results, and determine all paths from the initial node to the terminal node in the network topology graph. Specifically, the network topology graph is constructed based on the traversal queue and the connection relationships between corresponding nodes in the traversal queue, and all paths from the initial node to the terminal node in the network topology graph are determined. For example, the constructed network topology graph is as follows: Figure 2As shown, all paths from the initial node 0 to the terminal node 4 in the network topology graph are 0-2-4, 0-2-3-4, 0-1-2-3-4, and 0-5-3-4.
[0050] S4. Calculate the initial hop count for each path from the initial node to the terminal node. In practice, calculate the number of nodes traversed from the initial node to the terminal node in each path, and use this number as the hop count for the corresponding path. For example, in the above path, the initial hop count for 0-2-4 is 3, the initial hop count for 0-2-3-4 is 4, the initial hop count for 0-1-2-3-4 is 5, and the initial hop count for 0-5-3-4 is 3.
[0051] S5. Determine whether there are nodes corresponding to devices in the same data center in each path based on the same data center equipment table. In practice, the nodes corresponding to each device in the same data center in the same data center equipment table are compared with the nodes in the corresponding paths to determine whether there are nodes corresponding to devices in the same data center in each path. For example, if there are two devices in the same data center in the same data center equipment table, and their corresponding nodes are node 3 and node 4 respectively, then it is determined that there are nodes corresponding to devices in the same data center in paths 0-2-3-4, 0-1-2-3-4, and 0-5-3-4.
[0052] S6. When it is determined that there are nodes corresponding to equipment in the same data center in the corresponding path, the hop count between the corresponding nodes of the equipment in the same data center is reset to zero, and the optimized hop count of the path is recalculated. When it is determined that there are no nodes corresponding to equipment in the same data center in the corresponding path, the initial hop count of the path is used as its optimized hop count. For example, as follows... Figure 3 As shown, there are two paths from the node of device 1 to the node of device 5: device 1--device 2-1--device 2-2--device 5 and device 1--device 3--device 4--device 5. The initial hop count of device 1--device 2-1--device 2-2--device 5 is 4, and the initial hop count of device 1--device 3--device 4--device 5 is also 4. Devices 2-1 and 2-2 are devices in the same data center in data center 2. The hop count between their corresponding nodes is reset to zero. Therefore, the optimized hop count of device 1--device 2-1--device 2-2--device 5 is 3. There are no devices in the same data center in device 1--device 3--device 4--device 5, so its initial hop count of 4 is used as its optimized hop count. The optimized hop counts of the two paths are 3 and 4, respectively.
[0053] S7. Select the path with the fewest hops as the shortest path. In practice, the path with the fewest hops will be selected as the shortest path. Nodes corresponding to devices in the same data center will be marked on the shortest path, and the marked shortest path will be stored and displayed as the routing search results.
[0054] This embodiment uses a breadth-first search algorithm for network routing and topology construction. It can build network topology maps in real-time, automatically, quickly, and accurately, improving network system management efficiency. It is suitable for networks with a large number of devices and complex interconnections. By ignoring the number of routing nodes between devices within the same data center, it optimizes network routing paths and selects the shortest path. This better reflects the actual characteristics of the network system, saves fiber optic cable resources within the same data center, and achieves better economic and social benefits, realizing the digital transformation of network resource management.
[0055] Example 2:
[0056] This embodiment provides a shortest path routing search system, such as Figure 4 As shown, it includes an acquisition unit, a traversal unit, a determination unit, a calculation unit, a judgment unit, an optimization unit, and an execution unit, wherein:
[0057] The acquisition unit is used to acquire the adjacency table and the same-room device table of the target network, and to acquire the route search instruction for the target network. The route search instruction includes a given initial node and terminal node. The adjacency table includes the adjacency relationship of each node in the target network. The same-room device table includes several computer rooms, the same-room devices in each computer room, and the nodes corresponding to each same-room device.
[0058] The traversal unit is used to traverse the target network from the initial node, according to the adjacency table, using the breadth-first traversal algorithm, until the terminal node is reached, and obtain the traversal search result.
[0059] The determining unit is used to construct a network topology graph based on the traversal search results and determine all paths from the initial node to the terminal node in the network topology graph;
[0060] The calculation unit is used to calculate the initial hop count for each path from the initial node to the terminal node;
[0061] The judgment unit is used to determine whether there are nodes corresponding to devices in the same data center in each path based on the same data center equipment table.
[0062] The optimization unit is used to reset the hop count between nodes corresponding to the same equipment in the same data center to zero and recalculate the optimized hop count of the path when it is determined that there are nodes corresponding to the same equipment in the same data center in the corresponding path; and to use the initial hop count of the path as its optimized hop count when it is determined that there are no nodes corresponding to the same equipment in the same data center in the corresponding path.
[0063] The execution unit is used to select the path with the fewest optimized hops as the shortest path, and to store and display the shortest path.
[0064] Example 3:
[0065] This embodiment provides a shortest path routing search device, such as... Figure 5 As shown, at the hardware level, it includes:
[0066] The data interface is used to establish data communication between the processor and external data terminals;
[0067] Memory, used to store instructions;
[0068] The processor is used to read instructions stored in the memory and execute the shortest path routing search method in Embodiment 1 according to the instructions.
[0069] Optionally, the device also includes an internal bus. The processor, memory, and data interface can be interconnected via the internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, or an EISA (Extended Industry Standard Architecture) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc.
[0070] The memory may include, but is not limited to, random access memory (RAM), read-only memory (ROM), flash memory, first-in-first-out (FIFO) memory, and / or first-in-last-out (FILO) memory. The processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be 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.
[0071] Example 4:
[0072] This embodiment provides a computer-readable storage medium storing instructions that, when executed on a computer, cause the computer to perform the shortest path routing search method in Embodiment 1. The computer-readable storage medium refers to a data storage medium, which may include, but is not limited to, floppy disks, optical disks, hard disks, flash memory, USB flash drives, and / or Memory Sticks. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable systems.
[0073] This embodiment also provides a computer program product containing instructions that, when executed on a computer, cause the computer to perform the shortest path routing search method in Embodiment 1. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable system.
[0074] Finally, it should be noted that the above description is merely a preferred 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 shortest path routing search method, characterized in that, include: Obtain the adjacency table and the same-datacenter device table of the target network, and obtain the routing search instruction for the target network. The routing search instruction includes a given initial node and terminal node. The adjacency table contains the adjacency relationships of each node in the target network. The same-datacenter device table contains several data centers, the same-datacenter devices in each data center, and the nodes corresponding to each same-datacenter device. Starting from the initial node, the target network is traversed and searched using a breadth-first traversal algorithm based on the adjacency table until the terminal node is reached, thus obtaining the traversal search result. Construct a network topology graph based on the search results and determine all paths from the initial node to the terminal node in the network topology graph; Calculate the initial hop count for each path from the initial node to the terminal node; Determine whether there are nodes corresponding to devices in the same data center in each path based on the equipment table in the same data center. When it is determined that there are nodes corresponding to the same equipment in the same data center in the corresponding path, the hop count between the nodes corresponding to the same equipment in the same data center is cleared to zero, and the optimized hop count of the path is recalculated. When it is determined that there are no nodes corresponding to the same equipment in the same data center in the corresponding path, the initial hop count of the path is used as its optimized hop count. The path with the fewest hops is selected as the shortest path.
2. The shortest path routing search method according to claim 1, characterized in that, Starting from the initial node, a breadth-first traversal algorithm is used to perform a route search on the target network based on the adjacency table until the terminal node is reached. The traversal search results include: Starting from the initial node, add the initial node to the traversal queue and mark the initial node as visited; Determine the adjacent nodes of the initial node from the adjacency table, and treat each of the initial node's adjacent nodes as first-level adjacent nodes. Add each first-level adjacent node to the traversal queue in turn, and mark each first-level adjacent node as visited, thus determining the connection relationship between the initial node and each first-level adjacent node. Determine the unvisited adjacent nodes of each first-level adjacent node from the adjacency table, and use the unvisited adjacent nodes of each first-level adjacent node as second-level adjacent nodes. Add each second-level adjacent node to the traversal queue in turn, and mark each second-level adjacent node as visited, and determine the connection relationship between each first-level adjacent node and each second-level adjacent node. The process is iterated in this manner until the terminal node is reached, resulting in a traversal search result. The traversal search result includes a traversal queue and the connection relationships between corresponding nodes in the traversal queue.
3. The shortest path routing search method according to claim 2, characterized in that, The step of constructing a network topology graph based on the traversal search results and determining all paths from the initial node to the terminal node in the network topology graph includes: constructing a network topology graph based on the traversal queue and the connection relationships between the corresponding nodes in the traversal queue, and determining all paths from the initial node to the terminal node in the network topology graph.
4. The shortest path routing search method according to claim 1, characterized in that, The calculation of the initial hop count for each path from the initial node to the terminal node includes: calculating the number of nodes traversed in each path from the initial node to the terminal node, and using the number of traversed nodes as the hop count for the corresponding path.
5. The shortest path routing search method according to claim 1, characterized in that, The step of determining whether there are nodes corresponding to devices in the same data center in each path based on the same data center equipment table includes: comparing each node corresponding to each device in the same data center equipment table with each node in the corresponding path to determine whether there are nodes corresponding to devices in the same data center in each path.
6. The shortest path routing search method according to claim 1, characterized in that, The method further includes: marking the nodes corresponding to the equipment in the same data center in the shortest path, and storing and displaying the marked shortest path as the routing search results.
7. A shortest path routing search system, characterized in that, It includes an acquisition unit, a traversal unit, a determination unit, a calculation unit, a judgment unit, an optimization unit, and an execution unit, wherein: The acquisition unit is used to acquire the adjacency table and the same-room device table of the target network, and to acquire the route search instruction for the target network. The route search instruction includes a given initial node and terminal node. The adjacency table includes the adjacency relationship of each node in the target network. The same-room device table includes several computer rooms, the same-room devices in each computer room, and the nodes corresponding to each same-room device. The traversal unit is used to traverse the target network from the initial node, according to the adjacency table, using the breadth-first traversal algorithm, until the terminal node is reached, and obtain the traversal search result. The determining unit is used to construct a network topology graph based on the traversal search results and determine all paths from the initial node to the terminal node in the network topology graph; The calculation unit is used to calculate the initial hop count for each path from the initial node to the terminal node; The judgment unit is used to determine whether there are nodes corresponding to devices in the same data center in each path based on the same data center equipment table. The optimization unit is used to reset the hop count between nodes corresponding to the same equipment in the same data center to zero and recalculate the optimized hop count of the path when it is determined that there are nodes corresponding to the same equipment in the same data center in the corresponding path; and to use the initial hop count of the path as its optimized hop count when it is determined that there are no nodes corresponding to the same equipment in the same data center in the corresponding path. The execution unit is used to select the path with the fewest optimized hops as the shortest path, and to store and display the shortest path.
8. A shortest path routing search device, characterized in that, include: Memory, used to store instructions; A processor is configured to read instructions stored in the memory and execute the shortest path routing search method according to any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions that, when executed on a computer, cause the computer to perform the shortest path routing search method according to any one of claims 1-6.