Detailed Description
The technical solution of the present invention will be explained below with reference to the accompanying drawings.
In order to make the technical solution of the present invention clearer, some commonly used terms in the present invention are first defined:
define 1 search ant data frame: and sending a frame of data by the gateway node, wherein the frame of data is used for searching a path from the gateway node to the target node.
Definition 2 search ant lifetime: and searching the maximum value of the times that the ant data frame can be forwarded by the communication node.
Define 3 pheromone global update data frame: and sending a frame of data by the gateway node for pheromone updating of the optimal path.
Define 4 pheromone local update data frame: and one frame of data sent by the gateway node is used for updating the pheromone of the path from the gateway node to the next node.
Define 5 hops: hop count refers to the number of times an ant data frame is forwarded from the concentrator node to the target meter node.
The tasks of the gateway are as follows: the system is responsible for initiating a networking command for a certain target node, initiating a search ant data frame, finding an optimal communication path, initiating an iterative optimal pheromone update data frame, judging a convergence condition and updating a routing table.
Tasks of the respective nodes: judging the type of the data frame, selecting the next communication node according to the calculated probability, processing various data frames and the like.
As shown in fig. 1, the present invention provides a routing method for a power line carrier communication network, which may include the following steps:
s1, acquiring an initial path from a gateway node to a destination node in the power line carrier communication network, and acquiring the initial pheromone concentration of the initial path;
in practical applications, the gateway node may be a concentrator, and the destination node may be a target meter. At present, the downlink communication of a domestic and foreign centralized meter reading system, namely the communication between a concentrator and an electric meter, mostly adopts a power line carrier communication mode.
In order to obtain the initial path, a communication table of each node in the power line carrier communication network can be obtained; the communication table is used for storing address information of nodes which directly communicate with the nodes in the power line carrier communication network; and searching communication nodes in the power line carrier communication network according to the communication table to obtain a plurality of initial paths.
The communication table of a node is used for storing address information of nodes which can directly communicate with the node in a communication network, and the address information is put into the node in the form of a table for convenience of query, and is called the communication information table of the node, or simply called the communication table. The initialization of the communication information table is the process of each node in the network acquiring the address information of other nodes capable of communicating with the node.
Due to the communication of the power lineThe channel is shared, so collision of information may result when multiple nodes communicate with a gateway node simultaneously. In order to avoid the situation, the invention adopts a communication channel time division multiplexing mode, namely only one node can send data in the same time period. The specific scheme is as follows: when the main node sends an address information acquisition instruction to the slave nodes in a broadcast mode, the slave nodes receive the instruction at the same time, the slave nodes receiving the instruction make corresponding time delay according to the unique address number of the slave nodes, and then confirmation information is returned. Let the basic unit of delay be Deltat, assume node tiHas an address number of QiThen the delay time t of the nodeiComprises the following steps:
ti=Δt·Qi;
the node which needs to acquire the communication table at this time is a master node, and the node which directly communicates with the master node is a slave node.
The communication information table of each node is initialized by adopting a token passing mode, the token information adopts an independent token data frame, and the node obtaining the token carries out the initialization of the communication information table of the node. The communication node information table initiates the token passing process as shown in fig. 2.
For the destination node, the communication table of each node and the minimum hop count principle can be used as constraint conditions, N paths from the gateway node to the destination node are randomly generated, and the paths are used as initial paths.
After the initial paths are obtained, the fitness of each initial path can be calculated; selecting a path with the maximum fitness value, disconnecting the selected initial path from the same node, exchanging the path from the disconnected position to the target node, and recombining to obtain two new paths; acquiring the serial numbers of the nodes passed by the crossed initial paths, and interchanging the serial numbers of any two nodes; and acquiring the initial pheromone concentration of the initial path after the position interchange.
In one embodiment, the fitness may be calculated according to the following formula:
wherein, f (x) is the fitness, and g (x) is a preset objective function, i.e. the hop count from the gateway node to the destination node in the dynamic routing path.
When a path switch is performed, a first probability of the path switch may be set. Preferably, the first probability may be set according to:
in the formula (f)maxIs the largest of said fitness, favgIs the average value of the fitness of each path, f' is the greater of the fitness of the two paths undergoing exchange, pc1And pc2Is a preset value, pcIs the first probability.
When the numbers are interchanged, a second probability of the number interchange may be set. Preferably, the second probability may be set according to the following manner:
in the formula (f)maxIs the largest of said fitness, favgIs the average value of the fitness of each path, f' is the greater of the fitness of the two paths undergoing exchange, pm1And pm2Is a preset value, pmIs the second probability.
The optimized path can be screened out from the initial path according to the above mode, and the current iteration number n is judgedGIf n isG>NGThen the optimized communication paths are recorded and the initial pheromone concentration of the screened optimized paths is calculated. Wherein N isGIs a preset number of iterations. Assuming that the initial pheromone on each path is a given constant τ1The concentration of pheromone on the optimized path is higher than tau1The specific formula of the constant is as follows:
τ0=τ1+τ2;
in the formula, τ1Given a pheromone constant, τ0To optimize the pheromone concentration on the pathway, τ2To optimize the corresponding equivalent pheromone concentration of the path.
S2, sending a plurality of search ant data frames from the gateway node to the destination node, and performing a local pheromone concentration update operation on each search ant data frame; wherein the local pheromone concentration updating operation is to update, according to the initial pheromone concentration, the local pheromone concentration of each intermediate path through which the search ant data frame passes, the intermediate path being a path between two adjacent nodes on a path from the gateway node to the destination node;
the gateway node initiates a search ant data frame. The data frame may include the communication address of the destination node, routing area, and search ant lifetime. And the routing area is used for recording the address information of all communication nodes passed by the ants before reaching the destination node. When the ant data frame is searched for reaching one node, the next accessed node is selected according to the node communication table, and the pheromone concentration of the path is immediately updated. Specifically, a path transfer rule may be obtained; after the ant search data frame reaches the current node, selecting a next accessed node according to the path transfer rule by using a preset path transfer probability; calculating the local pheromone concentration of a path from the current node to the next visited node according to the following formula:
wherein, tauij=(1-ξ)τij+ξτ0;
In the formula, τijIs the concentration of pheromones on the path (i, j), i is the current node, j is the next node visited, ξ is the local update volatility factor, τ0Is the initial pheromone concentration, τminAnd τmaxIs a preset constant.
In one embodiment, the path transition probabilities may be set as follows:
in the formula,for the path transition probability from node i to node j, τijFor pheromone concentration on path (i, j), α is the information heuristic, β is the desired heuristic, ηijFor heuristic information on path (i, j), k denotes the number of the search ant data frame, and l is the set of all nodes in direct communication with node i. On this basis, the path transfer rule is as follows:
in the formula, q0Q is a random number between 0 and 1, η, a state transition factorilFor heuristic information on path (i, l), α is the information heuristic, β is the desired heuristic, τilIs the pheromone concentration on the path (i, l), i is the number of the current node, j is the number of the next visited node, and l is the set of all nodes in direct communication with node i. argmax { [ tau ]il]α[ηil]βDenotes [ tau ]il]α[ηil]βTaking the value of l at the maximum value. When q is less than or equal to q0Then, selecting a path according to a priori rule; when q > q0When it is in accordance withAnd (5) carrying out path search according to the probability.
In the process of searching ant data frames from the gateway node to the destination node, the operation is performed for each section of the intermediate path until the destination node is reached. Because the search ant data frame contains the address of the destination node, when a node receives the search ant data frame, the address in the data frame can be extracted, the address of the node is compared with the address carried in the search ant data frame, if the address of the node is the same as the address carried in the search ant data frame, the node can be judged to be the destination node, the ant search is completed, and the ant search data confirmation information is returned to the gateway.
And S3, selecting an optimal path from the gateway node to the target node according to the local pheromone concentration, updating the global pheromone concentration, respectively using the optimal path and the global pheromone concentration as an initial path and an initial pheromone concentration for iteration until a preset convergence condition is met, and selecting the optimal path obtained by iteration as a route from the gateway to the target node.
When all ants in one iteration are searched, the gateway initiates an pheromone updating data frame to the optimal routing line, the updated pheromone is updated and returns a confirmation data frame to be forwarded along the path until the data frame is received by the gateway, the next iteration is started, and the iteration is continuously repeated until a convergence condition or an iteration maximum value is reached. And after the optimal routing line is converged, storing the optimal routing information into the gateway. Specifically, the convergence condition may be an iteration number determination condition, that is, it is determined whether the algorithm reaches the maximum iteration number, and if the optimal path output before the maximum iteration number is reached is not changed, the path is recorded as the optimal path from the gateway node to the destination node, and the optimal path is stored in a routing table for gateway node communication.
After the optimal path is obtained, the global pheromone concentration of the optimal path can be updated according to the following modes:
τij=(1-ρ)τij+ρΔτij;
wherein,
in the formula,. DELTA.tauijIs the pheromone increment on path (i, j), τijIs the pheromone concentration on the path (i, j), ρ is the pheromone volatility factor, Q is a constant, LZSFor the optimal path length of each iteration, i is the number of the current node, and j is the number of the next visited node.
The invention has the following advantages:
(1) under the condition that the connection relation between the gateway node and the destination node is not known, the traditional mode of manually specifying the relay cannot meet the actual requirement. The routing algorithm can identify the unknown communication network through quick search, and find out the optimal communication routing path from the gateway node to the destination node.
(2) In a low-voltage power line carrier communication network, users often invest and quit, so that the logic topology structure of the communication network is changed at any moment. The routing algorithm adapts to the change and can quickly find out the optimal communication routing path from the gateway node to the destination node.
(3) The low-voltage power line has the characteristics of high noise, high attenuation, multiple loads and the like, a communication channel is easily influenced by the factors, and the algorithm has stronger survivability by carrying out networking on the whole communication network again when some communication nodes are damaged.
The technical features of the embodiments described above may be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the embodiments described above are not described, but should be considered as being within the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present invention, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the inventive concept, which falls within the scope of the present invention. Therefore, the protection scope of the present patent shall be subject to the appended claims.