Method and device for determining shortest path length and nonvolatile storage medium

By constructing a directed graph in the wireless sensor network and using the Dijkstra and BFS algorithms to determine the shortest path, the problem of low path search efficiency in the sensor network is solved and the effect of quickly finding the shortest path is achieved.

CN118764934AInactive Publication Date: 2024-10-11CHINA TELECOM CORP LTD

Patent Information

Application Number
CN202410749890.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-11
Publication Date
2024-10-11
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In large-scale wireless sensor networks, due to limited node energy and storage resources, the search rate and efficiency are relatively low.

Method used

By constructing a directed graph and determining the shortest path lengths between the source node to the target node and the target node to the end point through the first and second preset algorithms, combined with the Dijkstra and BFS algorithms, the routing protocol is optimized to improve search efficiency.

Benefits of technology

It can quickly find the shortest path in large-scale networks, reduce the amount of calculation, improve the search rate and efficiency, and solve the problem of low efficiency of path search in sensor networks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118764934A_ABST
    Figure CN118764934A_ABST
Patent Text Reader

Abstract

The invention discloses a shortest path length determination method and device and a nonvolatile storage medium. The method comprises the steps that a directed graph composed of a plurality of routers is constructed, the length of a first path between a source node and a target node in the directed graph is determined through a first preset algorithm, and the target node is any node except the source node and an end point in the directed graph; the first path length is the path length corresponding to the shortest path from the source node to the target node; a second preset algorithm is adopted to determine the second path length between the target node and the end point in the directed graph, and the second path length is the path length corresponding to the shortest path between the target node and the end point; and determining the shortest path length corresponding to the directed graph based on the first path length and the second path length. According to the method and the device, the technical problem of relatively low search rate and efficiency on a large-scale network caused by limitation of node energy and storage resources of the existing sensor network is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of dynamic route planning, and in particular, to a method and device for determining the shortest path length and a non-volatile storage medium. Background Art

[0002] Wireless sensor networks are composed of a large number of micro sensor nodes, which have the characteristics of information perception, information processing and wireless communication, and have a very broad application prospect. The analysis and design of wireless sensor routing protocols is one of the core links in wireless sensor self-organizing networks, and the main task of routing protocols is to establish routes between aggregation nodes and sensor nodes, and the established routes can reliably transmit and forward data packets. However, because the energy and storage resources of sensor network nodes are limited, and considering the reduction of state information storage and routing protocol optimization, such as the existing wireless ad hoc network on-demand distance vector routing protocol (Ad hoc On-Demand Distance Vector Routing, AODV), the AODV routing protocol is studied based on the trust mechanism to obtain the trust-aware on-demand distance vector routing (TAODV) routing protocol. The Dijkstra algorithm is usually used to improve the TAODV routing protocol. The Dijkstra algorithm can improve the shortcomings of the trust mechanism, enhance the optimization of the search process, and speed up the search speed of the most promising path, but it needs to traverse all points, the calculation is large, and the search rate and efficiency are relatively low on large-scale networks.

[0003] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention

[0004] The embodiments of the present application provide a method, device and non-volatile storage medium for determining the shortest path length, so as to at least solve the technical problem of low search rate and efficiency on large-scale networks due to the limitation of energy and storage resources of existing sensor network nodes.

[0005] According to one aspect of an embodiment of the present application, a method for determining the shortest path length is provided, including: constructing a directed graph consisting of multiple routers, wherein each router is a node in the directed graph; using a first preset algorithm to determine a first path length between a source node and a target node in the directed graph, wherein the target node is any node in the directed graph except the source node and the end point, and the first path length is a path length corresponding to the shortest path between the source node and the target node; using a second preset algorithm to determine a second path length between the target node and the end point in the directed graph, wherein the second path length is a path length corresponding to the shortest path between the target node and the end point; based on the first path length and the second path length, determining the shortest path length corresponding to the directed graph.

[0006] In some embodiments of the present application, a first preset algorithm is used to determine a first path length between a source node and a target node in a directed graph, including: determining the shortest path node between the source node and each other node in the directed graph, and determining the weights between adjacent nodes in the shortest path node from the directed graph; reading the corresponding sum of weights from the source node to the target node in the order of the shortest path nodes to obtain the first path length.

[0007] In some embodiments of the present application, determining the shortest path node between a source node and each other node in a directed graph includes: determining a set of paths from the source node to a first node in the directed graph, wherein the first node is any node in the directed graph except the source node; determining a target path from the path set, wherein the target path is used to represent the shortest path between the source node and the first node; and determining the nodes in the target path as shortest path nodes.

[0008] In some embodiments of the present application, a second preset algorithm is used to determine the second path length between a target node and an end point in a directed graph, including: determining the shortest path between a source node and a target node as a first path; determining the nodes other than the source node and the target node passed through in the first path as a first node set; deleting the first node set from the directed graph to obtain a second node set; and determining the second path length between the target node and the end point from the second node set using a second preset algorithm.

[0009] In some embodiments of the present application, a second preset algorithm is used to determine the second path length between the target node and the end point from the second node set, including: step 1: establishing a preset array for storing whether the node has been traversed; step 2: adding the target node to the preset queue, and marking the state of the target node in the preset array as traversed; step 3: determining whether the target node is the end point; step 4: if the target node is not the end point, adding the second node adjacent to the target node in the directed graph to the preset queue, and marking the state of the second node in the preset array as traversed, wherein the second node is the node with the smallest distance among the nodes adjacent to the target node; step 5: determining whether the second node is the end point; step 6: if the second node is not the end point, updating the node adjacent to the second node in the directed graph and outside the preset queue to the second node and adding it to the preset queue, and marking the state of the updated second node in the preset array as traversed; step 7: repeating steps 5-6 until the traversal stops at the end point of the second node, and determining the preset queue as the second path; step 8: determining the sum of the weights of the adjacent nodes in the directed graph in the second path as the second path length.

[0010] In some embodiments of the present application, based on the first path length and the second path length, determining the shortest path length corresponding to the directed graph includes: determining a weight coefficient corresponding to the second path length; and determining the shortest path length based on the first path length, the weight coefficient and the second path length.

[0011] In some embodiments of the present application, a third node that receives a message is obtained, and a destination node of the message is obtained; it is determined whether the third node and the destination node are in a directed graph; when the third node and the destination node are both in the directed graph, and the third node is different from the destination node, the shortest path between the source node and the end point in the directed graph is determined; the target shortest path from the third node to the destination node is determined from the shortest path; and the message is forwarded according to the target shortest path.

[0012] According to another aspect of an embodiment of the present application, a device for determining the shortest path length is also provided, including: a construction module, used to construct a directed graph composed of multiple routers, wherein each router is a node in the directed graph; a first determination module, used to determine a first path length between a source node and a target node in the directed graph using a first preset algorithm, wherein the target node is any node in the directed graph except the source node and the end point, and the first path length is the path length corresponding to the shortest path between the source node and the target node; a second determination module, used to determine a second path length between the target node and the end point in the directed graph using a second preset algorithm, wherein the second path length is the path length corresponding to the shortest path between the target node and the end point; and a third determination module, used to determine the shortest path length corresponding to the directed graph based on the first path length and the second path length.

[0013] According to another aspect of an embodiment of the present application, a non-volatile storage medium is provided, in which a program is stored, wherein when the program is running, the device where the non-volatile storage medium is located is controlled to execute the above-mentioned method for determining the shortest path length.

[0014] According to another aspect of an embodiment of the present application, an electronic device is further provided, including: a memory and a processor, the processor being configured to run a program stored in the memory, wherein the method for determining the shortest path length is executed when the program is run.

[0015] According to another aspect of an embodiment of the present application, a computer program product is also provided, including computer instructions, which implement the above-mentioned method for determining the shortest path length when executed by a processor.

[0016] In an embodiment of the present application, a directed graph consisting of a plurality of routers is constructed, wherein each router is a node in the directed graph; a first preset algorithm is used to determine a first path length between a source node and a target node in the directed graph, wherein the target node is any node in the directed graph except the source node and the end point, and the first path length is a path length corresponding to the shortest path between the source node and the target node; a second preset algorithm is used to determine a second path length between the target node and the end point in the directed graph, wherein the second path length is a path length corresponding to the shortest path between the target node and the end point; based on the first path length and the second path length, the shortest path length corresponding to the directed graph is determined, thereby achieving the purpose of dividing from the target node, and respectively calculating the optimal shortest path distances from the source node to the target node and from the target node to the end point through the first preset algorithm and the second preset algorithm, thereby achieving the technical effect of obtaining the shortest path length of the entire path through the first preset algorithm and the second preset algorithm, thereby solving the technical problem of low search rate and efficiency on large-scale networks due to the limitation of energy and storage resources of existing sensor network nodes. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0018] Figure 1 It is a hardware structure block diagram of a computer terminal for implementing a method for determining the shortest path length provided in an embodiment of the present application;

[0019] Figure 2 It is a flowchart of a method for determining the shortest path length provided in an embodiment of the present application;

[0020] Figure 3 It is a scene diagram of the implementation of the Dijkstra algorithm of a method for determining the shortest path length provided in an embodiment of the present application;

[0021] Figure 4 It is a simple directed schematic diagram of a method for determining the shortest path length provided in an embodiment of the present application;

[0022] Figure 5 It is an improved RREQ message format diagram of a method for determining the shortest path length provided in an embodiment of the present application;

[0023] Figure 6 It is an improved RREP message format diagram of a method for determining the shortest path length provided in an embodiment of the present application;

[0024] Figure 7 It is a comparison diagram of normalized routing costs of TAODV and D-TAODV according to a method for determining the shortest path length provided in an embodiment of the present application;

[0025] Figure 8 This is a comparison diagram of the minimum number of hops of TAODV and D-TAODV according to a method for determining the shortest path length provided in an embodiment of the present application;

[0026] Fig. 9 is a comparison diagram of the optimal paths of TAODV and D-TAODV according to a method for determining the shortest path length provided in an embodiment of the present application;

[0027] Fig.10 It is a schematic diagram of a device for determining the shortest path length provided according to an embodiment of the present application. DETAILED DESCRIPTION

[0028] In order to enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this application.

[0029] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0030] In order to better understand the embodiments of the present application, the technical terms involved in the embodiments of the present application are explained as follows:

[0031] Ad hoc On-Demand Distance Vector Routing (AODV) is a distance vector-based routing protocol that uses the idea of ​​on-demand routing. The features of the AODV protocol include: the AODV protocol only establishes routes when needed, instead of periodically updating the routing table like the traditional distance vector protocol. This on-demand routing method can reduce the number of routing requests and reduce network overhead; the AODV protocol uses a routing maintenance mechanism. When the network topology changes, the nodes will notify each other and update the routing information in time to maintain the stability of the network; the AODV protocol supports multi-path routing. When the main path fails, it can quickly switch to the backup path to improve the reliability and robustness of the network; the AODV protocol uses broadcasting to transmit routing requests and routing replies, so it can quickly establish routes; in general, the AODV protocol is efficient, flexible, and reliable, and is suitable for dynamically changing environments in wireless self-organizing networks.

[0032] Trust-aware on-demand distance vector routing (TAODV): is a trust-aware routing protocol based on distance vector routing. The TAODV protocol adds a trust mechanism to the AODV protocol to improve the security and reliability of the network. The TAODV protocol considers the trust values ​​between nodes in the routing selection process, so that nodes in the network can select reliable routing paths according to their trust values. Nodes will exchange trust values ​​with each other and update their trust tables based on the received trust values ​​to select the most reliable routing path. By introducing the trust mechanism, the TAODV protocol can effectively resist attacks from malicious nodes and improve the security and reliability of the network. The TAODV protocol can also optimize the routing selection process, reduce routing overhead in the network, and improve network performance. In general, the TAODV routing protocol is a trust-aware routing protocol that can improve the security, reliability and performance of wireless ad hoc networks.

[0033] Breadth-First Search (BFS) is a search algorithm used in graph or tree data structures. In the BFS algorithm, starting from the starting node, all its adjacent nodes are traversed in sequence, and then the adjacent nodes of these adjacent nodes are traversed in sequence, and so on, until the target node is found or all nodes are traversed. The BFS algorithm is usually implemented using a queue, by adding the starting node to the queue, then taking out the nodes from the queue in sequence, and adding all its adjacent nodes to the queue until the queue is empty or the target node is found; the characteristic of the BFS algorithm is that it can find the shortest path from the starting node to the target node, because it traverses according to the distance of the nodes; however, the space complexity of the BFS algorithm is high because it needs to store all the nodes that have been visited. In general, the BFS algorithm is suitable for solving problems such as the shortest path, but in some cases, the space complexity may be too high.

[0034] Dijkstra's algorithm is an algorithm for solving the single-source shortest path problem in a graph. The algorithm finds the shortest path from the starting point to all other nodes by gradually expanding the set of known shortest paths. The basic idea of ​​Dijkstra's algorithm is to start from the starting point and gradually expand the set of known shortest paths until all nodes are included. In each step, the unvisited node closest to the starting point is selected as the intermediate node, and the shortest path distance from the starting point to the node is updated. By repeating this process until all nodes are visited, the shortest path from the starting point to all other nodes can be obtained. In sparse graphs, priority queues can be used to optimize the algorithm. Dijkstra's algorithm can be applied to directed and undirected graphs, and is applicable to cases where the weights of edges are non-negative.

[0035] A heuristic function is a function that evaluates the quality of a state node in a search algorithm. It is usually used to guide the search algorithm to select the next node in the search space to continue the search. The heuristic function evaluates the quality of the node by estimating the distance or expected cost from the current state node to the target node, so as to move towards the optimal solution as much as possible during the search process.

[0036] In the related art, because the energy and storage resources of sensor network nodes are limited, there is a problem of low search rate and efficiency on large-scale networks caused by the limited energy and storage resources of existing sensor network nodes. In order to solve this problem, the embodiments of the present application provide relevant solutions, which are described in detail below.

[0037] According to an embodiment of the present application, a method embodiment of a method for determining the shortest path length is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0038] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 FIG. 1 shows a hardware structure block diagram of a computer terminal for implementing a method for determining the shortest path length. Figure 1 As shown, the computer terminal 10 may include one or more (102a, 102b, ..., 102n are used to illustrate) processors 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data, and a transmission module 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply and / or a camera. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.

[0039] It should be noted that the one or more processors 102 and / or other data processing circuits described above may generally be referred to herein as "data processing circuits". The data processing circuits may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuit may be a single independent processing module, or may be incorporated in whole or in part into any of the other components in the computer terminal 10. As described in the embodiments of the present application, the data processing circuit acts as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).

[0040] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the method for determining the shortest path length in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, the method for determining the shortest path length described above is realized. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the computer terminal 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0041] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the computer terminal 10. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0042] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computer terminal 10 (or mobile device).

[0043] In the above operating environment, the embodiment of the present application provides a method for determining the shortest path length. Figure 2 is a flow chart of a method for determining the shortest path length provided in an embodiment of the present application, such as Figure 2 As shown, the method comprises the following steps:

[0044] Step S202, constructing a directed graph consisting of a plurality of routers, wherein each router is a node in the directed graph;

[0045] In the technical solution provided in step S202, the directed graph composed of multiple routers can be a weighted directed graph with n nodes, where n is a positive integer greater than 0. The directed graph can be used as a network model. The network model parameters include the following three types: normalized routing overhead, minimum hop count and shortest path. The first preset algorithm and the second preset algorithm are used to solve the above network model parameters. Normalized routing overhead refers to the number of control message packets required for each DATA data packet to be sent, wherein each hop of the routing packet is considered to be a new control message packet, reflecting the congestion level and routing efficiency of the network, and is used to measure the cost required to reach the target node. Its value is the sum of all link overheads in a path between two points, and the minimum path overhead is the optimal path to reach the target point, and the optimal path is the shortest path; the minimum hop count refers to the minimum number of routing hops required from the source node to the destination. The hop count represents the sum of the number of source nodes to the destination node, but the minimum hop count is the number of hops experienced in this process. The shortest path refers to the shortest distance from the source node to the destination. The path is the entire segment from the source node to the target node and from the target node to the end point. The routing request and routing response are performed by the first preset algorithm and the second preset algorithm to improve the TAODV routing protocol.

[0046] It should be noted that there are many ways to select the first preset algorithm and the second preset algorithm. For example, the first preset algorithm can be the Dijkstra algorithm, and the second preset algorithm can be the BFS algorithm. The Dijkstra algorithm can improve the shortcomings of the trust mechanism, enhance the optimization of the search process, and speed up the search speed of the most likely path, but it needs to traverse all nodes, and the amount of calculation is large. It can quickly give the shortest path, but it can only provide one shortest path for each target point and cannot provide other alternative shortest paths. Since Dijkstra expands outward layer by layer, the search range is very large and the time will be relatively slow, but the accuracy is high, and it can ensure that the obtained path is definitely the shortest. At this time, combined with the BFS algorithm, the BFS algorithm is much faster than the Dijkstra algorithm because it uses a heuristic function (heuristic function) to quickly guide the target node. When expanding adjacent nodes, it expands according to the nodes with the smallest cost and the smallest distance, and the amount of calculation is small. On the basis of searching the entire network, the optimal solution of the path search distance is kept within a finite small range. The Dijkstra algorithm is an algorithm close to the source node, and the BFS algorithm is an algorithm close to the end point. Therefore, the two algorithms are combined to implement the technical solution in this application.

[0047] Step S204, using a first preset algorithm to determine a first path length between a source node and a target node in a directed graph, wherein the target node is any node in the directed graph except the source node and the end point, and the first path length is a path length corresponding to the shortest path between the source node and the target node.

[0048] In the technical solution provided in step S204, there are multiple ways to use the first preset algorithm to determine the first path length between the source node and the target node in the directed graph. For example, it can be determined in the following ways: determine the shortest path node between the source node and each other node in the directed graph, and determine the weights between adjacent nodes in the shortest path node from the directed graph; read the corresponding weights and sums from the source node to the target node in the order of the shortest path nodes to obtain the first path length.

[0049] The shortest path nodes between the source node and other nodes in the directed graph can be determined in the following manner: determine a set of paths from the source node to the first node in the directed graph, where the first node is any node in the directed graph except the source node; determine a target path from the path set, where the target path is used to represent the shortest path between the source node and the first node; and determine the nodes in the target path as shortest path nodes.

[0050] The following is a specific embodiment:

[0051] The first preset algorithm can be the Dijkstra algorithm. According to the Dijkstra algorithm and the network model, a shortest path tree from each node to other nodes is constructed. At the same time, several shortest paths from the source node to the target node are saved according to the weights between the nodes, and the number of routing hops of the shortest path from the source node to the target node is obtained. The shortest paths from the source node to other nodes are saved in array A, and the nodes on the shortest path from the source node to the target node are saved in set B. Introduce d(n), d(n) refers to the actual distance traveled from the source node to the target node, that is, the length of the first path, and n refers to the location of the target node.

[0052] For example, the specific process of constructing the shortest path tree from each node to other nodes is:

[0053] Step 1: Given a weighted directed graph with M nodes, where M is a positive integer greater than 0, first set an array A to store the shortest paths from the source node to other nodes, introduce d(n), which is initially empty, and pass array A to d(n);

[0054] Step 2: Under the condition of setting the initial set B, the distance from the source node to the source node is 0, and the distance between the source node and other connected nodes is set to the corresponding weight, and the distance of nodes without direct connection is set to infinity;

[0055] Step 3: Select the node with the smallest distance value (i.e. weight) from the source node and add this node to set B. Gradually update the distance value from the source node. If the sum of the distance value from the source node to this node and the distance value from this node to other nodes is less than the distance value from the source node directly to other nodes, then select the sum of the distance value from the source node to this node and the distance value from this node to other nodes, otherwise do not make any changes.

[0056] Step 4: Repeat the above process until all the nodes in the graph are included in set B. At this time, the algorithm ends and the shortest path tree is obtained.

[0057] Step S206, using a second preset algorithm to determine a second path length between the target node and the end point in the directed graph, wherein the second path length is a path length corresponding to the shortest path between the target node and the end point.

[0058] In the technical solution provided in step S206, there are many methods for determining the second path length between the target node and the end point in the directed graph using the second preset algorithm. For example, the following method can be used to determine the shortest path between the source node and the target node as the first path; determine the nodes other than the source node and the target node passed through in the first path as the first node set; delete the first node set from the directed graph to obtain the second node set; and determine the second path length between the target node and the end point from the second node set using the second preset algorithm.

[0059] It should be noted that in the above steps, the second path length between the target node and the end point can be determined from the second node set using the second preset algorithm by the following method:

[0060] Step 1: Establish a preset array for storing whether a node has been traversed; Step 2: Add the target node to the preset queue, and mark the state of the target node in the preset array as traversed; Step 3: Determine whether the target node is an end point; Step 4: If the target node is not an end point, add the second node adjacent to the target node in the directed graph to the preset queue, and mark the state of the second node in the preset array as traversed, wherein the second node is the node with the smallest distance among the nodes adjacent to the target node; Step 5: Determine whether the second node is an end point; Step 6: If the second node is not an end point, update the node adjacent to the second node in the directed graph and outside the preset queue to the second node and add it to the preset queue, and mark the state of the updated second node in the preset array as traversed; Step 7: Repeat steps 5-6 until the traversal stops at the end point of the second node, and the preset queue is determined as the second path; Step 8: The sum of the weights of the adjacent nodes in the second path in the directed graph is determined as the second path length.

[0061] The following is a specific embodiment of the above method:

[0062] The second preset algorithm may be a BFS algorithm, which uses a heuristic function h(n) to quickly guide the end point. The formula of the heuristic function is f(n)=h(n), where n represents the target node and h(n) represents the estimated distance of the best path from node n to the end point, i.e., the second path length obtained by the second preset algorithm. The implementation steps of the algorithm are as follows:

[0063] Step 1: First, create an array visit[] (i.e., the preset array mentioned above) to determine whether the node at the position has been traversed and a queue q (i.e., the preset queue mentioned above) to queue the unvisited nodes. Introduce the heuristic function h(n). Since the breadth-first search algorithm ignores the edge weight value, a weight coefficient w(n) is added here, and the original function h(n) is updated to h(n)*w(n).

[0064] Step 2: Initialize the array visit[] and clear the queue q;

[0065] Step 3: Enqueue the target node and set the point in the visit[] array to 1, which means it has been visited;

[0066] Step 4: while(!q.empty()){……}, i.e., determine whether the queue q is empty, perform a search operation, take out the head element and add the node with the smallest distance adjacent to the target node (i.e. the second node mentioned above) into the queue, and determine whether the node is the end point; if it is the end point, return the result (for example, the shortest time or the shortest path); if it is not the end point, continue to visit the nodes adjacent to the second node, add the node with the smallest distance among the adjacent nodes that can be walked into the queue, and update the array visit[]; repeat the above steps until the end point is visited.

[0067] Step S208: determining the shortest path length corresponding to the directed graph based on the first path length and the second path length.

[0068] In the technical solution provided in step S208, there are multiple ways to determine the shortest path length corresponding to the directed graph based on the first path length and the second path length, for example, determining the weight coefficient corresponding to the second path length; determining the shortest path length based on the first path length, the weight coefficient and the second path length.

[0069] For example, the shortest path length can be determined by the following formula:

[0070] F(n)=d(n)+h(n)*w(n)

[0071] F(n) is the shortest path length, d(n) is the first path length, h(n) is the second path length, and w(n) is a preset weight coefficient.

[0072] Based on the above steps S202-S208, a third node for receiving the message and a destination node for obtaining the message can also be obtained; whether the third node and the destination node are in a directed graph is determined; when the third node and the destination node are both in the directed graph, and the third node is different from the destination node, the shortest path between the source node and the end point in the directed graph is determined; the target shortest path from the third node to the destination node is determined from the shortest path; and the message is forwarded according to the target shortest path to realize message forwarding.

[0073] Figure 3 is a simple directed schematic diagram of a method for determining the shortest path length provided in an embodiment of the present application, such as Figure 3 As shown, the directed graph can be used as a network model, and each node in the directed graph can be used as a router. Figure 3 The simple directed graph shown contains 4 nodes, namely V1-V4. The nodes where there are paths have weights, namely distances. The distance from V1 to V3 is 3, the distance from V3 to V2 is 7, the distance from V3 to V4 is 1, the distance from V4 to V1 is 6, and the distance from V2 to V1 is 2.

[0074] Figure 4 is a scene diagram of the implementation of the Dijkstra algorithm according to a method for determining the shortest path length provided in an embodiment of the present application, Figure 4 is based on Figure 3 The implementation scenario diagram of Dijkstra algorithm for directed graph shown in the figure, Figure 4 Including preset sets, when the initial set B conditions are set, the distance from the source node to the source node is 0, and the distance between the source node and the nodes connected to it is set to the corresponding weight, and the distance between the nodes without direct connection is set to infinity. Select the node with the smallest distance value from the source node and add this node to set B. Figure 5 In the example, the source node is V1. The distance value from the source node is gradually updated. If the sum of the distance value from the source node to this node and the distance value from this node to other nodes is less than the distance value from the source node to other nodes directly, the sum of the distance value from the source node to this node and the distance value from this node to other nodes is selected. Otherwise, no change is made. The above process is repeated until all the nodes in the graph are collected in set B. At this time, the algorithm ends and the shortest path tree is obtained.

[0075] Specifically, when performing the first iteration, V1 is added to set B; when performing the second iteration, the distance from V1 to V3 is 3, and V3 is added to set B; when performing the third iteration, the distance from V3 to V2 is 7, and the distance from V3 to V4 is 1, and the distance V3 to V4 with a shorter distance is selected, and V4 is added to set B; when performing the fourth iteration, V2 is added to set B to complete the traversal.

[0076] Figure 5 is an improved RREQ message format diagram of a method for determining the shortest path length provided in an embodiment of the present application, such as Figure 5 As shown, the improved RREQ message format includes a routing request information flag, an optimal routing set, a destination node address, a destination node serial number, a source node address, and a source node serial number, wherein the destination node is the target node. Based on the above message, the routing request process can be completed, specifically:

[0077] The node receives a message, namely a route request packet (RREQ message); it queries the routing table, which is generated autonomously through communication between nodes in the network according to the protocol, and identifies the optimal path set A (i.e. Figure 2 Whether the node exists in the array A described in the figure; if not, the RREQ message is discarded; if it exists, a secondary resolution is required to observe whether the node route already exists and whether it is valid; when the target node route not only exists but is also valid, it is necessary to set the optimal path set A and the sequence number of the destination node, increase the number of hops in the sequence itself, and finally send the RREQ message information.

[0078] Figure 6 This is an improved RREP message format diagram of a method for determining the shortest path length provided in an embodiment of the present application, such as Figure 6 As shown, the improved RREP message format includes the optimal route set, the destination node address, the destination node serial number, the source node address, the source node serial number, and the time, wherein the destination node is the target node. Based on the above message, the routing response process can be completed, specifically:

[0079] The route request message RREQ is received by the node; the routing table is updated in time, the route response RREP message information is set, and this information is sent to the source node location; when the node receives the RREP message, it needs to make a judgment: whether the node is included in the optimal path set A (i.e. Figure 2 In the array A described in ; when the judgment is established, continue to work to determine whether the routing table has a reverse route to the source node; when the routing table has a reverse route to the source node, the RREP message is forwarded to the source node and a reverse route is established; when the judgment is not established, only the reverse route establishment work is performed.

[0080] Above Figure 5-6 In the routing request and routing response stages, the routing request table and routing response table of the TAODV routing protocol are used as the basis. The optimal path set is added based on the TAODV routing protocol RREQ message and RREP message. The optimal path set is the shortest path set between the source node and the destination node. The algorithm of the improved D-TAODV routing protocol has a small amount of calculation and can find the shortest distance point, avoiding the shortcomings of the Dijkstra and BFS algorithms.

[0081] In order to effectively evaluate the performance of the D-TAODV routing protocol, simulation software is used to conduct comparative experiments on the TAODV routing protocol and the D-TAODV routing protocol in terms of normalized routing cost, minimum hop count and shortest path, so as to find a shortest path. Specifically, for a given routing node, the TAODV routing protocol without the Dijkstra algorithm and the D-TAODV routing protocol with the Dijkstra algorithm are simulated in turn, and the normalized routing cost comparison chart, minimum hop count comparison chart and shortest path comparison chart between the two are obtained, namely Figure 7-9 .

[0082] Figure 7 TAODV and D-TAODV are normalized routing cost comparison diagrams according to a method for determining the shortest path length provided in an embodiment of the present application, such as Figure 7 As shown in the figure, the normalized routing cost comparison chart is obtained by simulating the TAODV routing protocol without the Dijkstra algorithm and the D-TAODV routing protocol with the Dijkstra algorithm. When the number of routing nodes is the same, the normalized routing cost of the D-TAODV routing protocol is generally smaller than that of the TAODV routing protocol; when the number of routing nodes of TAODV increases from 10 to 20, the routing cost tends to decrease; the reason is that in this node number range, the network energy consumption of the dynamic mode of the Dijkstra algorithm is smaller, and the Dijkstra algorithm has a relatively good advantage; when the number of routing nodes is less than 100, the normalized routing cost of the D-TAODV routing protocol is significantly smaller than that of the TAODV routing protocol, and the maximum difference can be nearly 0.43. The reason for this phenomenon is that TAODV has a certain degree of randomness when selecting paths, which may lead to an increase in the transmission energy consumption of nodes in the network, thereby increasing the routing overhead. The D-TAODV routing protocol is different from it. It uses the Dijkstra algorithm and combines it with the BFS algorithm, considering the possible location of the result, and thoroughly searches the entire network, reducing the routing overhead. As the number of nodes increases, the gap between the two gradually parallels, and the D-TAODV routing protocol reaches a balance state, which is 26.6% lower than TAODV.

[0083] Figure 8 TAODV and D-TAODV are compared in the minimum number of hops according to a method for determining the shortest path length provided in an embodiment of the present application. Figure 8 As shown in the figure, based on the same number of routing nodes, the minimum hop count of the D-TAODV routing protocol is basically smaller than that of the TAODV routing protocol. As the number of nodes increases, the gap between the two gradually becomes parallel. The reason is that the minimum hop count method adopted by the TAODV routing protocol is based on the trust mechanism. The hop count selection between nodes will be selected according to the calculation formula of the trust value, and the nodes with high trust values ​​will be selected for the hop count. However, the formula is artificially set and has a certain subjectivity. The D-TAODV routing protocol uses the Dijkstra algorithm and combines the BFS algorithm. It searches for the shortest path from the source node to the target node in the wireless sensor network through a multi-hop relay method. At the same time, it combines the best priority search, considers the possible location of the result, and searches the network, which can reduce the minimum hop count to a certain extent. Compared with the two, the D-TAODV routing protocol has more advantages, which is reduced by 13.6% compared with TAODV.

[0084] Fig. 9 TAODV and D-TAODV are optimal path comparison diagrams according to a method for determining the shortest path length provided in an embodiment of the present application, such as Fig. 9 As shown in the figure, under the same number of routing nodes, the optimal path of the D-TAODV routing protocol is generally smaller than that of the TAODV routing protocol. As the number of nodes exceeds 100, the gap between the optimal path of the D-TAODV routing protocol and the optimal path of the TAODV routing protocol becomes increasingly obvious. The reason is that the overhead of the D-TAODV routing protocol is smaller than that of the TAODV routing protocol. At the same time, the D-TAODV routing protocol uses the Dijkstra algorithm to improve the deficiencies of the trust mechanism, strengthen the search process, accelerate the search for the optimal path, and reduce the energy consumption of path optimization. The distance between the path search and the optimal solution is maintained at a limited and small range, reducing the burden of path selection, thereby reducing the length of the optimal path, which is 2.7% lower than that of TAODV.

[0085] Fig.10 is a schematic diagram of a device for determining the shortest path length provided in an embodiment of the present application, such as Fig.10 As shown, including:

[0086] A construction module 1002 is used to construct a directed graph consisting of multiple routers, wherein each router is a node in the directed graph;

[0087] A first determination module 1004 is used to determine a first path length between a source node and a target node in a directed graph using a first preset algorithm, wherein the target node is any node in the directed graph except the source node and the end point, and the first path length is a path length corresponding to the shortest path between the source node and the target node;

[0088] A second determination module 1006 is used to determine a second path length between a target node and an end point in the directed graph by using a second preset algorithm, wherein the second path length is a path length corresponding to the shortest path between the target node and the end point;

[0089] The third determining module 1008 is configured to determine the shortest path length corresponding to the directed graph based on the first path length and the second path length.

[0090] It should be noted that the various modules in the above-mentioned shortest path length determination device can be program modules (for example, a set of program instructions that implement a certain specific function) or hardware modules. For the latter, it can be expressed in the following forms, but is not limited to this: the expression form of each of the above-mentioned modules is a processor, or the functions of each of the above-mentioned modules are implemented by a processor.

[0091] in addition, Fig.10 The shortest path length determination device shown is used to perform Figure 2 A method for determining the shortest path length is shown, so Figure 2 The relevant explanations in also apply to the device for determining the shortest path length, and will not be repeated here.

[0092] The embodiment of the present application also provides a non-volatile storage medium, the non-volatile storage medium includes a stored program, wherein when the program is running, the device where the non-volatile storage medium is located is controlled to execute the above method for determining the shortest path length. For example, a directed graph consisting of multiple routers is constructed, wherein each router is a node in the directed graph; a first preset algorithm is used to determine the first path length between the source node and the target node in the directed graph, wherein the target node is any node in the directed graph except the source node and the end point, and the first path length is the path length corresponding to the shortest path between the source node and the target node; a second preset algorithm is used to determine the second path length between the target node and the end point in the directed graph, wherein the second path length is the path length corresponding to the shortest path between the target node and the end point; based on the first path length and the second path length, the shortest path length corresponding to the directed graph is determined.

[0093] The embodiment of the present application also provides an electronic device, the electronic device includes a processor, the processor is used to run a program, wherein the above method for determining the shortest path length is executed when the program is running. For example, a directed graph consisting of multiple routers is constructed, wherein each router is a node in the directed graph; a first preset algorithm is used to determine the first path length between the source node and the target node in the directed graph, wherein the target node is any node in the directed graph except the source node and the end point, and the first path length is the path length corresponding to the shortest path between the source node and the target node; a second preset algorithm is used to determine the second path length between the target node and the end point in the directed graph, wherein the second path length is the path length corresponding to the shortest path between the target node and the end point; based on the first path length and the second path length, the shortest path length corresponding to the directed graph is determined.

[0094] According to another aspect of the embodiment of the present application, a computer program product is also provided, including a computer program, which implements the above method for determining the shortest path length when executed by a processor. For example, a directed graph consisting of multiple routers is constructed, wherein each router is a node in the directed graph; a first preset algorithm is used to determine the first path length between the source node and the target node in the directed graph, wherein the target node is any node in the directed graph except the source node and the end point, and the first path length is the path length corresponding to the shortest path between the source node and the target node; a second preset algorithm is used to determine the second path length between the target node and the end point in the directed graph, wherein the second path length is the path length corresponding to the shortest path between the target node and the end point; based on the first path length and the second path length, the shortest path length corresponding to the directed graph is determined.

[0095] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.

[0096] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0097] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0098] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0099] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the relevant technology or all or part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk, etc. Various media that can store program codes.

[0100] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A method for determining the shortest path length, characterized in that: include: Constructing a directed graph consisting of a plurality of routers, wherein each router is a node in the directed graph; Determine a first path length between a source node and a target node in the directed graph using a first preset algorithm, wherein the target node is any node in the directed graph except the source node and the end point, and the first path length is a path length corresponding to the shortest path between the source node and the target node; Determine a second path length between the target node and the end point in the directed graph using a second preset algorithm, wherein the second path length is a path length corresponding to the shortest path between the target node and the end point; Based on the first path length and the second path length, a shortest path length corresponding to the directed graph is determined.

2. The method according to claim 1, characterized in that Determining a first path length between a source node and a target node in the directed graph using a first preset algorithm includes: Determine the shortest path node from the source node to each other node in the directed graph, and determine the weights between adjacent nodes in the shortest path node from the directed graph; The corresponding sums of weights from the source node to the target node are read in sequence according to the order of the shortest path nodes to obtain the first path length.

3. The method according to claim 2, characterized in that Determining the shortest path node between the source node and each other node in the directed graph includes: Determine a path set from the source node to a first node in the directed graph, wherein the first node is any node in the directed graph except the source node; Determine a target path from the path set, wherein the target path is used to represent the shortest path from the source node to the first node; A node in the target path is determined as the shortest path node.

4. The method according to claim 1, characterized in that: Determining a second path length between the target node and the end point in the directed graph using a second preset algorithm includes: Determine the shortest path from the source node to the target node as a first path; Determine nodes other than the source node and the target node passed through in the first path as a first node set; Deleting the first node set from the directed graph to obtain a second node set; The second preset algorithm is used to determine a second path length between the target node and the end point from the second node set.

5. The method according to claim 4, characterized in that Determining a second path length between the target node and the end point from the second node set using the second preset algorithm includes: Step 1: Create a preset array for storing whether a node has been traversed; Step 2: Add the target node to a preset queue, and mark the state of the target node in the preset array as traversed; Step 3: Determine whether the target node is the end point; Step 4: When the target node is not the end point, add a second node adjacent to the target node in the directed graph to the preset queue, and mark the state of the second node in the preset array as traversed, wherein the second node is the node with the smallest distance among the nodes adjacent to the target node; Step 5: Determine whether the second node is the end point; Step 6: When the second node is not the end point, the node in the directed graph that is adjacent to the second node and outside the preset queue is updated to be a second node and added to the preset queue, and the state of the updated second node in the preset array is marked as traversed; Step 7: Repeat steps 5-6 until the traversal reaches the end point of the second node, and then stop traversing and determine the preset queue as the second path; Step 8: Determine the sum of weights of adjacent nodes in the second path in the directed graph as the second path length.

6. The method according to claim 1, characterized in that Determining the shortest path length corresponding to the directed graph based on the first path length and the second path length includes: Determining a weight coefficient corresponding to the second path length; The shortest path length is determined according to the first path length, the weight coefficient and the second path length.

7. The method according to claim 1, characterized in that The method further comprises: Acquire a third node that receives the message, and acquire a destination node of the message; Determining whether the third node and the destination node are in the directed graph; In a case where the third node and the destination node are both in the directed graph, and the third node is different from the destination node, determining the shortest path from the source node to the destination node in the directed graph; Determine a target shortest path from the third node to the destination node from the shortest paths; The message is forwarded according to the target shortest path.

8. A device for determining the shortest path length, characterized in that: include: A construction module, used to construct a directed graph consisting of a plurality of routers, wherein each router is a node in the directed graph; A first determination module, configured to determine a first path length between a source node and a target node in the directed graph by using a first preset algorithm, wherein the target node is any node in the directed graph except the source node and the end point, and the first path length is a path length corresponding to the shortest path between the source node and the target node; A second determination module, configured to determine a second path length between the target node and the end point in the directed graph by using a second preset algorithm, wherein the second path length is a path length corresponding to the shortest path between the target node and the end point; The third determination module is used to determine the shortest path length corresponding to the directed graph based on the first path length and the second path length.

9. A non-volatile storage medium, characterized in that: The non-volatile storage medium stores a program, wherein when the program is executed, the device where the non-volatile storage medium is located is controlled to execute the method for determining the shortest path length according to any one of claims 1 to 7.

10. An electronic device, characterized in that: include: A memory and a processor, wherein the processor is used to run a program stored in the memory, wherein the program executes the method for determining the shortest path length as described in any one of claims 1 to 7 when running.

11. A computer program product comprising computer instructions, characterized in that: When the computer instructions are executed by a processor, the method for determining the shortest path length described in any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Energy-saving deployment method of building internet of things network model

    CN103200616A

  • Routing determination method and routing determination device based on unordered node constraint, and storage medium

    CN109412954A

  • Segmented routing path calculation method and device and computer storage medium

    CN110557337A

  • Method and device for determining the length of a shortest path in a network

    US20090040931A1

  • Distribution of segment identifiers in network functions virtualization and software defined network environments

    US20170054626A1

Cited By

  • Communication optimization method and device based on position of lamp post of street lamp

    CN119363651A