Disclosure of Invention
Aiming at the condition that local clocks of all nodes in a wireless sensor network are inconsistent due to crystal oscillator errors, operating environment and other factors, the invention aims to provide a Cognitive global clock Synchronization method of the wireless sensor network and application of the Cognitive global clock Synchronization method in a multi-hop network.
In order to achieve the above purpose, the idea of the invention is as follows:
and performing synchronous operation on the sensor nodes by adopting a cognitive global clock synchronization protocol. Firstly, selecting a sensor node with the highest energy in a network as a main node, selecting a node with the second highest energy as an expected main node, synchronizing the main node and the expected main node through a transmitter-receiver (S-R) model, and synchronizing the expected main node and other sub-nodes through a receiver-receiver (R-R) model to complete the global clock synchronization operation of the network. The synchronization process incorporates a recognizable transition mechanism: when the energy of the main node is lower than that of the expected main node, the expected main node replaces the expected main node to continuously work, the reliability of the network is guaranteed, and the wireless sensor network can still continuously run under the condition that the main node fails.
According to the conception, the invention adopts the following technical scheme:
a method for cognizably synchronizing global clocks of a wireless sensor network comprises the following specific steps:
step 1: the wireless sensor nodes are arranged in a descending order by taking the initial energy value as an ordering object, the node with the highest initial energy value is selected as a main node M, and the node with the next highest initial energy value is selected as an expected main node N;
step 2: master node M is at TMBroadcasting the synchronization information to the nodes within the broadcasting range at any time, and expecting the main node N to be at TNThe broadcast information is received at the moment, and other child nodes C are at TCBroadcast information from the master node M is received all the time, and all the nodes are ready to start global synchronization;
and step 3: it is desirable that the master node N first performs synchronization with the master node M: expect master node N to be at T1Sending a synchronization request to a master node M at a moment, wherein the master node M is at T2After receiving the synchronization request at time T3Feeding back an ACK signal to the expected main node N at any moment, wherein the ACK signal comprises T of the main node M2And T3Information; expect master node N to be at T4The ACK signal is received at the moment, and the self and the ACK signals are calculatedClock offset (N, M) between master nodes M and updating their local clocks;
and 4, step 4: it is desirable for the master node N to share offsets (N, M) and T with other nodes CNValue, node C compares the time T at which it receives the broadcastCAnd shared TNAnd offset (N, M), and calculates its own clock offsets offset (C, M) and offset (C, N) to update its local clock;
and 5: each time of information transmission, the node sending the information estimates the consumed energy and updates the energy value of the node;
step 6: after clock synchronization is completed, each node sends an information packet to a master node M, wherein the information packet comprises a node ID, an updated initial node clock value and a synchronized node clock energy value; the master node M constructs and updates a sensor node information table for the whole network according to the information packets;
and 7: after the master node M receives the clock information of all the nodes in the network, the master node M judges whether the energy of the master node M is lower than that of the node N: if yes, the roles of the main node M and the expected main node N are exchanged, the expected main node N is selected as the main node M of the next synchronization period, the original main node M is used as the expected main node N of the next period, whether the new expected main node N is the node with the highest energy value in the network is judged, and if not, other nodes are selected again as the new expected main nodes;
and 8: to this end, a synchronization cycle is completed, and if the next synchronization cycle is to be entered, a loop is started from step 2.
In the multi-hop network, the realization of the cognitive global clock synchronization method of the wireless sensor network needs to be added to the selection of intermediate nodes in each broadcast area; in the first broadcast area, the implementation steps of the method are executed according to the steps; in the second broadcast area, the method needs to select the node farthest from the master node in the first broadcast area as the intermediate node, and regard it as the expected master node in the second broadcast area, and then start to execute the clock synchronization in the second broadcast area from step 4; in the third broadcast area, the node farthest from the intermediate node in the second broadcast area is selected as a new intermediate node, and the synchronization is completed according to the steps.
Compared with the prior art, the invention has the beneficial effects that:
by combining the advantages and the disadvantages of a sender-receiver (S-R) model and a receiver-receiver (R-R) model, the CGCSP algorithm is provided to complete global clock synchronization operation on the wireless sensor network, so that the wireless sensor network achieves global synchronization, and the clock synchronization operation has high precision, low energy consumption and higher reliability. The method is applicable to multi-hop networks.
Detailed Description
Embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
As shown in fig. 1, the clock synchronization process of the cognitive global clock synchronization method of the wireless sensor network can be divided into two main stages: the first phase is the synchronization between the master node M and the desired master node N; the second phase is when synchronization between the master node N and the other child nodes C is desired.
In the first phase, the clock synchronization employs a transmitter-receiver (S-R) mode, similar to the TPSN scheme, as shown in fig. 2. Wherein, T1Indicating the local time of the master node M when it broadcasts a message to the desired master node N. T is2Indicating that the local time of the master node N is expected when the master node N is expected to receive a message from the master node M. T is3Indicating that the local time of the master node N is expected when the master node N is expected to send an ACK message to the master node M. T is4Indicating when master node M receivesThe local time of the master node M when an ACK message from the master node N is expected. In the first stage, when synchronization starts, the master node M broadcasts a synchronization start signal to all nodes within a broadcast range, expects the master node N to receive the message, and through message exchange with the master node M, calculates a clock offset between itself and the master node, and shares the information to other nodes. The clock offset (N, M) between the desired master node N and master node M is calculated by:
it is expected that the master node N updates its local clock by the following formulaNThe value of (c):
clockN=clockN-offset(N,M) (2)
in the second phase, where synchronization of the master node N with the other nodes C is desired, a receiver-receiver (R-R) model is employed, similar to the RBS scheme, as shown in fig. 3. At this stage, when the master node M broadcasts a synchronization message to all nodes in the network, node C also receives the broadcast message. By comparing the clock offset information shared by the node C and the expected master node N to the node C, the node C calculates the clock offset with the master node M according to the following formula, and updates the local clock of the node C, so that the node C and the master node M are synchronized:
offset(C,M)=offset(C,N)+offset(N,M) (3)
offset(C,N)=TC-TN(4)
wherein, TCIndicating the local clock value, T, at which node C receives the broadcast message of master node MNIndicating the local clock value at which the master node N is expected to receive the broadcast message from the master node M.
Combining the two stages results in a comprehensive CGCSP clock synchronization process, as shown in fig. 4.
Considering the energy consumption in the clock synchronization process of the CGCSP, the more synchronization messages exchanged between nodes, the longer the synchronization time spent, the more energy consumed by the sensor nodes, and the less efficient the clock synchronization. In general, the following equation may be used to represent the power consumption of free-space radio signal transmission:
wherein p istDenotes the transmission power, prDenotes a received power, d denotes a distance between a transmitting end and a receiving end, and c denotes a path loss coefficient. Due to factors such as diffraction signal attenuation, reflection and scattering of walls, the wireless signal is greatly interfered by the environment, and the path loss is generally large. Therefore, for the wireless sensor networks WSNs, the energy consumption of the clock synchronization algorithm can be roughly estimated according to the energy consumption of the message exchange in the synchronization process. According to a minimum transmission energy consumption model in a typical planar topology control algorithm, the energy consumption of a wireless sensor node is mainly related to message bytes and paths, and the protocol estimates the energy consumption of each time the wireless sensor node sends a synchronous message by using the following formula:
Et=2·Eelec·k+Eamp·k·dc(6)
wherein E istRepresenting the energy consumption of the node sending the message, k being the message word length, EelecRepresenting node electronics energy consumption, EampRepresenting the transmitter amplifier power consumption of the node and d refers to the distance between the transmitting node and the receiving node. And c is a path loss coefficient which is generally between 2 and 5, in practical situations, the path loss is generally 2, and the path loss is generally 4 when the outdoor environment is in use.
To sum up, a method for cognizably synchronizing global clocks of a wireless sensor network comprises the following specific steps:
step 1: the wireless sensor nodes are arranged in a descending order by taking the initial energy value as an ordering object, the node with the highest initial energy value is selected as a main node M, and the node with the next highest initial energy value is selected as an expected main node N;
step 2: master node M is at TMBroadcasting the synchronization information to the nodes within the broadcasting range at any time, and expecting the main node N to be at TNThe broadcast information is received at the moment, and other child nodes C are at TCThe broadcast message from the master node M is also received at that time, and each node is ready to startGlobal synchronization;
and step 3: it is desirable that the master node N first performs synchronization with the master node M: expect master node N to be at T1Sending a synchronization request to a master node M at a moment, wherein the master node M is at T2After receiving the synchronization request at time T3Feeding back an ACK signal to the expected main node N at any moment, wherein the ACK signal comprises T of the main node M2And T3Information; expect master node N to be at T4Receiving the ACK signal at the moment, calculating the clock offset (N, M) between the ACK signal and the master node M through equations (1) and (2), and updating the local clock of the ACK signal;
and 4, step 4: it is desirable for the master node N to share offsets (N, M) and T with other nodes CNValue, node C compares the time T at which it receives the broadcastCAnd shared TNAnd offset (N, M), and calculates its own clock offsets offset (C, M) and offset (C, N) by equations (3) and (4) to update its local clock;
and 5: for each information transmission, the node sending the information estimates the consumed energy according to the formula (6) and updates the energy value of the node;
step 6: after clock synchronization is completed, each node sends an information packet to a master node M, wherein the information packet comprises a node ID, an updated initial node clock value and a synchronized node clock energy value; the master node M constructs and updates a sensor node information table for the whole network according to the information packets;
and 7: after the master node M receives the clock information of all the nodes in the network, the master node M judges whether the energy of the master node M is lower than that of the node N: if yes, the roles of the main node M and the expected main node N are exchanged, the expected main node N is selected as the main node M of the next synchronization period, the original main node M is used as the expected main node N of the next period, whether the new expected main node N is the node with the highest energy value in the network is judged, and if not, other nodes are selected again as the new expected main nodes;
and 8: to this end, a synchronization cycle is completed, and if the next synchronization cycle is to be entered, a loop is started from step 2.
In the multi-hop network, the realization of the cognitive global clock synchronization method of the wireless sensor network needs to be added to the selection of intermediate nodes in each broadcast area; in the first broadcast area, the implementation steps of the method are executed according to the steps; in the second broadcast area, the method needs to select the node farthest from the master node in the first broadcast area as the intermediate node, and regard it as the expected master node in the second broadcast area, and then start to execute the clock synchronization in the second broadcast area from step 4; in the third broadcast area, the node farthest from the intermediate node in the second broadcast area is selected as a new intermediate node, and the synchronization is completed according to the steps.