A Clock Synchronization Method, Device, Equipment and Medium for Wireless Sensor Networks
By establishing a system model in a wireless sensor network and determining the general frequency and offset using a weighted average algorithm, the problem of insufficient clock synchronization accuracy is solved, and more efficient clock synchronization and energy consumption management is achieved.
Patent Information
- Application Number
- CN202211239808.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-11
- Publication Date
- 2025-06-10
- Estimated Expiration
- 2042-10-11
AI Technical Summary
The accuracy of clock synchronization in wireless sensor networks is insufficient, resulting in clock drift and message delay problems, and it is difficult for the prior art to make the best choice between high precision and energy consumption.
By establishing a system model of the target node, iteratively process the system model and weight matrix using the weighted averaging algorithm, determine the common frequency and offset of the wireless sensor network, and adjust the frequency and offset of the target node to achieve clock synchronization.
Improves the accuracy of clock synchronization in wireless sensor networks, reduces clock drift and message delay, while finding the best balance between energy consumption and accuracy.
Smart Images

Figure CN115580368B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of distributed systems, and particularly to a clock synchronization method, apparatus, device, and computer-readable storage medium for a wireless sensor network. Background Art
[0002] Since the emergence of computer networks and distributed systems, clock synchronization has attracted the strong interest of researchers. Clock synchronization is crucial for a wide range of communication protocols and applications. For example, modules such as data fusion, multiple access control (MAC) protocols, and node protocols all require the support of an accurate clock to operate correctly.
[0003] The purpose of clock synchronization is to ensure that all network nodes have the same concept of time. However, affected by the limited resources of network nodes and the imperfect hardware of network nodes, problems such as clock drift and message delay during node-to-node communication have emerged. At the same time, considering the limited resources of wireless nodes, the synchronization algorithm needs to make the best trade-off between high precision and energy consumption. Although the Network Time Protocol (NTP) is based on the high-precision synchronization technology of the Global Positioning System (GPS), these protocols are not applicable to wireless sensor networks (WSNs). The main reason is that the synchronization schemes in these protocols take precision as the primary goal. However, in WSNs, other factors such as energy consumption, scalability, robustness, convergence speed, and asymmetric link applications must also be considered.
[0004] In recent years, the clock synchronization problem in wireless sensor networks has received great attention and has evolved into a topic with considerable research interest. Clock synchronization schemes include one that enhances the accuracy of timestamps based on a time allocation scheme to achieve sub-nanosecond time transfer accuracy. However, this scheme brings changes in signal-to-noise ratio and channel change rate, resulting in a decrease in synchronization accuracy. Another scheme is to use Gaussian white noise for simulation and a Kalman filter for reduction to solve the errors introduced during the observation process and the frequency jitter caused by the instability of the slave clock oscillator. This method can establish a stable clock frequency model and reduce the impact of frequency jitter on the system. However, it only considers the clock frequency and ignores the clock offset.
[0005] It can be seen that how to improve the accuracy of clock synchronization in wireless sensor networks is a problem that needs to be solved by those skilled in the art. Summary of the Invention
[0006] The purpose of the embodiments of the present application is to provide a clock synchronization method, device, equipment, and computer-readable storage medium for a wireless sensor network, which can improve the accuracy of clock synchronization in the wireless sensor network.
[0007] To solve the above technical problems, the embodiments of the present application provide a clock synchronization method for a wireless sensor network, including:
[0008] Based on the clock parameters and measurement parameters of a target node, establish a system model of the target node; wherein, the system model is used to calculate the frequency and offset of the target node; the target node is any one of all nodes in the wireless sensor network;
[0009] Use the weighted average algorithm to perform iterative processing on the system model and the weight matrix corresponding to the wireless sensor network to determine the common frequency and common offset of the wireless sensor network;
[0010] Adjust the frequency and offset of the target node according to the common frequency and common offset.
[0011] Optionally, the establishing a system model of the target node based on the clock parameters and measurement parameters of the target node includes:
[0012] Using the initial clock frequency, clock initial offset, oscillator parameters of the target node itself, and the set sampling period and state noise included in the clock parameters of the target node, establish a state model corresponding to the frequency and offset of the target node;
[0013] Using the measurement matrix and measurement noise included in the measurement parameters, establish a measurement model of the target node;
[0014] Take the state model corresponding to the frequency and offset of the target node and the measurement model of the target node as the system model of the target node.
[0015] Optionally, the establishing a state model corresponding to the frequency and offset of the target node using the initial clock frequency, clock initial offset, oscillator parameters of the target node itself, and the set sampling period and state noise included in the clock parameters of the target node includes:
[0016] Call the clock Kalman state model to process the initial clock frequency, clock initial offset, oscillator parameters of the target node itself, and the set sampling period and state noise of the target node to obtain the state model of the frequency and offset of the target node; the calculation formula corresponding to the clock Kalman state model is:
[0017] X n (k) = Φ n X n(k - 1)+ω n (k)+b n ;
[0018] Wherein, X n (k)=[α n (k)β n (k)] T , α n (k)=α n (k - 1)+δ n (k), β n (k)=β n (k - 1)+τα n (k - 1)+τδ n (k)-τ,
[0019] α n (k) represents the clock frequency state of node n at the current time k, α n (k - 1) represents the clock frequency state of node n at the previous time k - 1, δ n (k) represents the state noise, β n (k) represents the clock offset state of node n at the current time k, β n (k - 1) represents the clock offset state of node n at the previous time k - 1, τ represents the sampling period, Φ n represents the state transition matrix, ω n (k) represents the general state noise.
[0020] Optionally, the use of the weighted average algorithm to iteratively process the system model and the weight matrix corresponding to the wireless sensor network to determine the general frequency and general offset of the wireless sensor network includes:
[0021] According to the weight matrix corresponding to the wireless sensor network and the state parameters corresponding to each node, determine the state change model between the target node and the adjacent nodes; wherein, the adjacent nodes are any node in the wireless sensor network other than the target node;
[0022] Use the weighted average algorithm to iteratively process the system model and the state change model to determine the general frequency and general offset of the wireless sensor network.
[0023] Optionally, the determining the state change model between the target node and the adjacent nodes according to the weight matrix corresponding to the wireless sensor network and the state parameters corresponding to each node includes:
[0024] The iterative average consensus algorithm formula is called to process the weight matrix corresponding to the wireless sensor network and the state parameters corresponding to each node to obtain the state change model of the target node and the adjacent nodes; the iterative average consensus algorithm formula is:
[0025]
[0026] Among them, x i (t+1) represents the state of node i at the next moment, w ij (t) represents the weights corresponding to nodes i and j, x j (t) represents the state of node j at the current moment, N i Represents the neighbor set of node i.
[0027] Optionally, with respect to a method for determining a weight matrix corresponding to the wireless sensor network, the method further includes:
[0028] Determining a node distance between any two nodes according to the signal strength between any two nodes in the wireless sensor network;
[0029] Based on the node distance between any two nodes, determine the weight value between any two nodes;
[0030] The weight values between any two nodes are summarized as a weight matrix corresponding to the wireless sensor network.
[0031] Optionally, determining the node distance between any two nodes according to the signal strength between any two nodes in the wireless sensor network includes:
[0032] Obtaining the signal strength between any two nodes in the wireless sensor network;
[0033] The corresponding relationship between signal strength and node distance is called to determine the node distance between any two nodes; the corresponding relationship between signal strength and node distance is:
[0034]
[0035] Where P(d) represents the signal strength received by the node when the distance is d, d 0 is the reference distance, P(d 0 ) indicates the distance d 0 The signal strength received by the node at the time, m represents the path attenuation index related to the environment, X m represents Gaussian noise with σ as standard deviation and mean 0.
[0036] The embodiment of the present application also provides a clock synchronization device for a wireless sensor network, including an establishing unit, a determining unit and an adjusting unit;
[0037] The establishing unit is configured to establish a system model of a target node based on the clock parameters and measurement parameters of the target node; wherein, the system model is used to calculate the frequency and offset of the target node; the target node is any one of all nodes in the wireless sensor network;
[0038] The determining unit is configured to use a weighted average algorithm to iteratively process the system model and the weight matrix corresponding to the wireless sensor network, so as to determine the common frequency and common offset of the wireless sensor network;
[0039] The adjusting unit is configured to adjust the frequency and offset of the target node according to the common frequency and common offset.
[0040] Optionally, the establishing unit includes a state model establishing subunit, a measurement model establishing subunit and an as subunit;
[0041] The state model establishing subunit is configured to establish a state model corresponding to the frequency and offset of the target node by using the initial clock frequency, clock initial offset, oscillator parameters of the target node itself, and the set sampling period and state noise included in the clock parameters of the target node;
[0042] The measurement model establishing subunit is configured to establish a measurement model of the target node by using the measurement matrix and measurement noise included in the measurement parameters;
[0043] The as subunit is configured to use the state model corresponding to the frequency and offset of the target node and the measurement model of the target node as the system model of the target node.
[0044] Optionally, the state model establishing subunit is configured to call a clock Kalman state model to process the initial clock frequency, clock initial offset, oscillator parameters of the target node itself, and the set sampling period and state noise of the target node, so as to obtain a state model of the frequency and offset of the target node; the calculation formula corresponding to the clock Kalman state model is:
[0045] X n (k)=Φ n X n (k - 1)+ω n (k)+b n ;
[0046] Wherein, X n (k)=[α n (k)β n (k)] T , α n (k)=αn (k - 1)+δ n (k), β n (k)=β n (k - 1)+τα n (k - 1)+τδ n (k)-τ,
[0047] α n (k) represents the clock frequency state of node n at the current time k, α n (k - 1) represents the clock frequency state of node n at the previous time k - 1, δ n (k) represents the state noise, β n (k) represents the clock offset state of node n at the current time k, β n (k - 1) represents the clock offset state of node n at the previous time k - 1, τ represents the sampling period, Φ n represents the state transition matrix, ω n (k) represents the general state noise.
[0048] Optionally, the determining unit includes a state change determining subunit and a general parameter determining subunit;
[0049] The state change determining subunit is configured to determine a state change model between a target node and an adjacent node according to the weight matrix corresponding to the wireless sensor network and the state parameters corresponding to each node; wherein, the adjacent node is any node in the wireless sensor network other than the target node;
[0050] The general parameter determining subunit is configured to perform iterative processing on the system model and the state change model by using a weighted average algorithm to determine the general frequency and general offset of the wireless sensor network.
[0051] Optionally, the state change determining subunit is configured to call the iterative average consensus algorithm formula to process the weight matrix corresponding to the wireless sensor network and the state parameters corresponding to each node to obtain a state change model between a target node and an adjacent node; the iterative average consensus algorithm formula is:
[0052]
[0053] wherein, x i (t + 1) represents the state of node i at the next time, w ij (t) represents the weight corresponding to node i and node j, x j (t) represents the state of node j at the current time, N i represents the neighbor set of node i.
[0054] Optionally, for the method of determining the weight matrix corresponding to the wireless sensor network, the device further includes a distance determination unit, a weight determination unit, and a summarization unit;
[0055] The distance determination unit is configured to determine the node distance between any two nodes according to the signal strength between any two nodes in the wireless sensor network;
[0056] The weight determination unit is configured to determine the weight value between any two nodes based on the node distance between any two nodes;
[0057] The summarization unit is configured to summarize the weight values between any two nodes as the weight matrix corresponding to the wireless sensor network.
[0058] Optionally, the distance determination unit is configured to obtain the signal strength between any two nodes in the wireless sensor network;
[0059] Call the corresponding relationship formula between the signal strength and the node distance to determine the node distance between any two nodes; the corresponding relationship formula between the signal strength and the node distance is:
[0060]
[0061] where P(d) represents the signal strength received by the node when the distance is d, d 0 is the reference distance, P(d 0 ) represents the signal strength received by the node when the distance is d 0 , m represents the path loss exponent related to the environment, and X m represents Gaussian noise with a mean of 0 and a standard deviation of σ.
[0062] An embodiment of the present application further provides an electronic device, including:
[0063] A memory for storing a computer program;
[0064] A processor for executing the computer program to implement the steps of the clock synchronization method for the wireless sensor network as described above.
[0065] An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the clock synchronization method for the wireless sensor network as described above are implemented.
[0066] As can be seen from the above technical solution, a system model of the target node is established based on the clock parameters and measurement parameters of the target node; wherein, the system model is used to calculate the frequency and offset of the target node; the target node is any one of all the nodes in the wireless sensor network. In order to achieve time synchronization of each node in the wireless sensor network, the weighted average algorithm can be used to iteratively process the system model and the weight matrix corresponding to the wireless sensor network to determine the common frequency and common offset of the wireless sensor network. According to the common frequency and common offset, the frequency and offset of the target node are adjusted. In this technical solution, through the weighted average method, each node in the wireless sensor network makes its frequency and offset in the network approach the recognized common frequency and common offset among nodes through continuous iteration, so as to make the network clock reach a higher-precision synchronization. And when constructing the system model, both the influence of frequency on clock synchronization and the influence of offset on clock synchronization are considered, improving the accuracy of clock synchronization in the wireless sensor network. BRIEF DESCRIPTION OF THE DRAWINGS
[0067] To more clearly illustrate the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0068] Figure 1 It is a flowchart of a clock synchronization method for a wireless sensor network provided by an embodiment of the present application;
[0069] Figure 2 It is a schematic diagram of the relationship between the local clock and the real time provided by an embodiment of the present application;
[0070] Figure 3 It is a schematic diagram of an actual clock synchronization message exchange mechanism provided by an embodiment of the present application;
[0071] Figure 4 It is a schematic diagram of the relationship change between the synchronization error and the number of iterations when three nodes in an embodiment of the present application undergo synchronous iteration;
[0072] Figure 5 It is a schematic diagram of the relationship change between the synchronization error and the number of iterations when three nodes in an embodiment of the present application undergo synchronous iteration under the condition of introducing weights;
[0073] Figure 6 It is a schematic diagram of the structure of a clock synchronization device for a wireless sensor network provided by an embodiment of the present application;
[0074] Figure 7Structural diagram of an electronic device provided by an embodiment of the present application. Detailed implementation manners
[0075] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0076] The terms "including" and "having" in the specification and claims of the present application, and any variations related to "including" and "having", are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the listed steps or units, but may include steps or units not listed.
[0077] To enable those skilled in the art to better understand the solution of the present application, the present application will be further described in detail below in conjunction with the accompanying drawings and specific implementation manners.
[0078] Next, a clock synchronization method for a wireless sensor network provided by an embodiment of the present application will be introduced in detail. Figure 1 Flowchart of a clock synchronization method for a wireless sensor network provided by an embodiment of the present application. The method includes:
[0079] S101: Based on the clock parameters and measurement parameters of the target node, establish a system model of the target node.
[0080] The wireless sensor network contains multiple nodes, and the processing methods for clock synchronization of each node are the same. In the embodiments of the present application, any one node in all the nodes of the wireless sensor network, that is, the target node, is taken as an example for illustration.
[0081] Among them, the system model is used to calculate the frequency and offset of the target node.
[0082] In the embodiments of the present application, in order to improve the accuracy of clock synchronization, two types of parameters affecting clock synchronization are fully considered: frequency and deviation.
[0083] Taking the target node as an example, in practical applications, the clock parameters of the target node may include the initial clock frequency of the target node, the initial clock offset, and the oscillator parameters of the target node itself. To implement the construction of the system model, the clock parameters may also include the set sampling period and state noise.
[0084] In a specific implementation, a state model corresponding to the frequency and offset of the target node can be established by using the initial clock frequency, clock initial offset, oscillator parameters of the target node itself, as well as the set sampling period and state noise included in the clock parameters of the target node.
[0085] To improve the stability of the state model, a measurement model of the target node can be established by using the measurement matrix and measurement noise included in the measurement parameters. The measurement model is used to filter the state model to ensure the stability of the state model. In the embodiments of the present application, the state model corresponding to the frequency and offset of the target node and the measurement model of the target node can be used as the system model of the target node.
[0086] A typical sensor clock consists of a stable quartz oscillator and a counter. The application reads and uses the software clock through an appropriate Application Programming Interface (API), which provides a local clock for each sensor.
[0087] The relationship between the local clock C(t) and the real-time t is as Figure 2 shown. The slope of the standard clock is 1 and the offset is 0; the slope of the fast clock is greater than 1 and there is an offset; the slope of the slow clock is less than 1 and there is an offset. This characteristic can establish an integral model of the clock, and its formula is as follows:
[0088]
[0089] Among them, α(τ) represents the clock frequency, θ 0 represents the clock initial offset, and τ represents time.
[0090] According to the characteristics of the node's own quartz oscillator, summarize its characteristic equation, and then obtain the formula of the local crystal oscillator model of the uncoupled (synchronized) node clock:
[0091]
[0092] Among them, φ n (t) represents the instantaneous phase (accumulator) of node n, f 0 represents the center frequency of the quartz oscillator, ξ n represents the normalized frequency, θ n0 represents the clock initial offset of node n, p n represents the quality parameter of the crystal oscillator of node n, and B(t) represents the standard Wiener process.
[0093] During the experimental stage, to prevent the sampling period from being too long and causing serious loss of useful signals, sampling is performed with a period of τ. At the same time, considering the uncertain factors in the specific environment, Gaussian white noise is introduced. Based on formulas (1) and (2), the recurrence formulas for the frequency and offset states of the node clock are established:
[0094]
[0095] Among them, α n (k) represents the clock frequency state of node n at the current moment k, and α n (k - 1) represents the clock frequency state of node n at the previous moment k - 1. δ n (k) represents the state noise, and β n (k) represents the clock offset state of node n at the current moment k. β n (k - 1) represents the clock offset state of node n at the previous moment k - 1. τ represents the sampling period.
[0096] The offset state equation of formula (3) is derived from the state equation of formula (1). The specific process is as follows:
[0097]
[0098] In the formula, α(l) can be obtained by substituting it into the clock frequency state equation to obtain the clock offset equation.
[0099] Let X n (k)=[α n (k)β n (k)] T . Based on this, formula (3) can be summarized into the clock Kalman state model shown in the following formula (4):
[0100] X n (k)=Φ n X n (k - 1)+ω n (k)+b n (4);
[0101] Among them, Φ n is the state transition matrix ω n (k) represents the general state noise
[0102] In practical applications, the sampling period and state noise can be set. After obtaining the initial clock frequency, initial clock offset, and oscillator parameters of the target node, the clock Kalman state model can be called to process the initial clock frequency, initial clock offset, oscillator parameters of the target node, and the set sampling period and state noise to obtain the state model of the frequency and offset of the target node. Among them, the calculation formula corresponding to the clock Kalman state model is Formula (4).
[0103] For the sake of convenience in description, the state model of the frequency and offset of the target node can be simply referred to as the state model.
[0104] In the embodiments of the present application, the state model and the measurement model are used as the system models of the target node. The measurement model can implement a filtering function to ensure the stability of the output result of the state model.
[0105] Some working environments of the sensor are special. It is impossible for people to measure the relevant parameters of some aspects of the sensor at any time, so the relevant data of the sensor clock cannot be directly obtained. However, according to the IEEE 1588 protocol, the state of the sensor clock can be indirectly obtained through the timestamps recorded by the slave node clock.
[0106] Due to the influence of the environment and itself, the clock frequencies and offsets of each node of the wireless sensor are different. The actual clock synchronization message exchange mechanism is as Figure 3 shown Figure 3 Taking the clocks of two nodes as an example, for the sake of convenience in distinction, the clock of one node can be called the master clock, and the clock of the other node can be called the slave clock. Correspondingly, the node to which the master clock belongs can be called the master node, and the node to which the slave clock belongs can be called the slave node. It should be noted that in the present application, the master node and the slave node are only used to distinguish two different nodes and are not subject to other functional limitations.
[0107] In practical applications, the synchronization process in the PTP protocol includes two stages: the offset measurement stage and the delay measurement stage. In the offset measurement stage, the master clock periodically sends synchronization messages to the slave clock. The slave clock receives the synchronization message at time T2 and records the timestamp. Immediately afterwards, the master clock packs the timestamp T1 of sending the synchronization message into the follow-up message and sends it to the slave clock. The slave clock receives and records the timestamp T1. In the delay measurement stage, the slave clock sends a delay request message to the master clock and records the timestamp T3 at this time. After receiving the delay request message, the master clock records the timestamp T4 at this time, then packs and sends a delay request response message to the slave clock, and the slave clock receives and records the timestamp T4.
[0108] Through Figure 3Establish a model based on the message exchange mechanism model and the recording of timestamps. The formula corresponding to the model is as follows:
[0109]
[0110] Among them, D ij is the fixed delay part between the master node i and the slave node j, and D 1 and D 2 are the random delay parts between the two nodes respectively. Since D 1 and D 2 represent the random delay between different node clocks to achieve the asymmetry of the communication link, so D 1 and D 2 are independent Gaussian variables that follow a Gaussian distribution with a mean of 0 and a variance of σ 2 .
[0111] Subtract the two formulas in formula (5), and we can get:
[0112] T j -T i = 2β j (k)-2β i (k)+V i (6);
[0113] Among them, T j = T 2 +T 3 ,T i = T 1 +T 4 ,V i = D 1 -D 2 ,β j (k) represents the clock offset state of the slave node j at the current moment, and β i (k) represents the clock offset state of the master node i at the current moment.
[0114] In formula (6), i represents the master node, and j represents the slave node. T i represents the master node clock, while T j represents the clock of the slave node communicating with the master node. Summarizing, the formula (7) of the clock Kalman measurement equation is as follows:
[0115] Z n (k)= H n (k)X n (k)+v n (k) (7);
[0116] Among them, Z n (k)= T jN -Ti , N = 1, 2, 3…, H n (k) represents the measurement matrix, v n (k) follows a measurement noise with a mean of zero and a covariance of R n = 2σ 2 I
[0117] In summary, the system model for obtaining the node clock parameters through the state model and the measurement model is as follows:
[0118]
[0119] Using this model, the parameters of any node clock in the network can be obtained. The parameters of the node clock can include the frequency and offset corresponding to the node.
[0120] Let the local clock of any node i in the network be τ i , and the local clock of its corresponding neighbor node j be τ j . Correspondingly, for node i, it can be expressed according to the following formula (9):
[0121]
[0122] where and represent the relative offset and frequency drift between node i and neighbor node j.
[0123] S102: Using the weighted average algorithm, perform iterative processing on the system model and the weight matrix corresponding to the wireless sensor network to determine the common frequency and common offset of the wireless sensor network.
[0124] In the embodiment of the present application, the state change model between the target node and the adjacent nodes can be determined according to the weight matrix corresponding to the wireless sensor network and the state parameters corresponding to each node. Among them, the adjacent node is any node in the wireless sensor network except the target node. Using the weighted average algorithm to perform iterative processing on the system model and the state change model can determine the common frequency and common offset of the wireless sensor network.
[0125] Considering that there will be nodes with relatively large clock parameter deviations in the wireless sensor network, in order to achieve balance among the nodes, a weight matrix is introduced in the embodiment of the present application.
[0126] Generally, a wireless sensor network can be modeled as an undirected graph g(t) = (v, ε(t)), consisting of a set of nodes v = {1, ···, n} and a set of edge sets indicating the available communication links, which means that node i and node j can communicate with each other reliably at time t. The symbol N i\(N(t)=\{j\in v|\{i,j\}\in\varepsilon(t),i\neq j\}\) represents the neighbor set of node \(i\in v\), and \(d\) i (t) represents its degree, that is, the number of its neighbors. Among them,
[0127] Assume that at any time \(t\), the undirected graph \(g(t)\) is connected, ensuring that every pair of nodes can exchange messages within \(g(t)\), that is, there is a path between any two different nodes in the network.
[0128] A weighted graph is a triple \(g(t)=(v,\varepsilon(t),w(t))\), where is a function that assigns a strictly positive real number \(w\) to each edge ij , which is called its weight.
[0129] In the specific implementation, the determination method of the weight matrix corresponding to the wireless sensor network can include: determining the node distance between any two nodes according to the signal strength between any two nodes in the wireless sensor network; determining the weight value between any two nodes based on the node distance between any two nodes; summarizing the weight values between any two nodes as the weight matrix corresponding to the wireless sensor network.
[0130] After obtaining the signal strength between any two nodes in the wireless sensor network, the corresponding relationship formula between the signal strength and the node distance can be called to determine the node distance between any two nodes; the corresponding relationship formula between the signal strength and the node distance is
[0131]
[0132] where \(P(d)\) represents the signal strength received by the node at a distance of \(d\), \(d\) 0 is the reference distance, \(P(d\) 0 ) represents the signal strength received by the node at a distance of \(d\) 0 when, \(m\) represents the path loss exponent related to the environment, and \(X\) m represents Gaussian noise with a standard deviation of \(\sigma\) and a mean of 0.
[0133] In the wireless sensor network, we can define the distributed consensus problem as: enabling each node in the network to reach a consensus or agreement on the common value of an interest quantity, so that all nodes in the network can cooperate in a coordinated manner.
[0134] One common type of consensus problem is the average consensus problem, where each node holds a value or measurement, and the goal is to use distributed linear iteration to calculate the average of all values in the network. In fact, the average algorithm adopts a completely distributed and simple mechanism. In each iteration, neighbor nodes exchange their local states (information) and update their states using a simple linear weighted average based on the received data.
[0135] To describe the average consensus algorithm, in the embodiments of this application, the average algorithm is carried out on a weighted graph g. In addition, some scalar values defining its state are associated with each node i ∈ v The goal of the average consensus algorithm is to calculate the average value recognized by nodes in a distributed manner
[0136] Assume that the state of each node i at time t is denoted as x i (t), and the state of the network is a vector, denoted as X(t) = [x 1 (t), ···, x n (t)] T . Therefore, the formula of the iterative average consensus algorithm at iteration t is as follows:
[0137]
[0138] Among them,
[0139] Among them, x i (t + 1) represents the state of node i at the next moment, w ij (t) represents the weight corresponding to node i and node j, x j (t) represents the state of node j at the current moment, N i represents the neighbor set of node i.
[0140] In a specific implementation, the formula of the iterative average consensus algorithm can be called to process the weight matrix corresponding to the wireless sensor network and the state parameters corresponding to each node, so as to obtain the state change model of the target node and adjacent nodes.
[0141] Or the iterative average consensus algorithm at iteration t can be expressed in the following form:
[0142] X(t + 1) = W(t)X(t) (11);
[0143] Among them, W(t) gives the weight matrix at iteration t.
[0144] If for all i and j, w ijIf (t)≥0, the square matrix W(t) is non - negative. If it is non - negative and the sum of the entries in each row is 1, it is a row - stochastic matrix. If W(t) is row - stochastic and g is connected, the iterative algorithm described by Equation (11) asymptotically solves the average consensus problem, that is:
[0145]
[0146] where 1 is a column vector with all components equal to 1.
[0147] This algorithm makes the parameters of each node in the wireless sensor network approach the recognized average value among nodes through continuous iteration by means of weighted averaging, so as to achieve a certain accuracy of network clock synchronization.
[0148] S103: Adjust the frequency and offset of the target node according to the common frequency and common offset.
[0149] After determining the common frequency and common offset, the frequency of the target node can be adjusted to approach the common frequency, and the offset of the target node can be adjusted to approach the common offset.
[0150] It should be noted that as time goes by, the common frequency and common offset will also change. According to the methods of S101 and S102 above, the current common frequency and common offset can be determined periodically or in real - time. Based on the current common frequency and common offset, the frequency and offset of the target node are adjusted.
[0151] In the embodiment of this application, MATLAB R2020a is used for simulation experiments.
[0152] In MATLAB, a model is built based on network and clock theory, and then the algorithm is updated into specific formulas. Among them, the specific parameters in the model are shown in Table 1. It should be noted that since the local clocks of nodes are independent of each other and do not interfere with each other, the parameter settings of different nodes should be considered separately and cannot be mechanically copied, and there should be a certain degree of randomness and difference.
[0153] Table 1
[0154]
[0155] On this basis, the Root Average Mean Squared Error (RAMSE) criterion is introduced. By calculating the root - mean - square error of the filtered results of the slave clock and the compensated slave clock and the filtered result of the master clock, the optimization result of this algorithm is made more intuitive, as shown in Equation (12) specifically:
[0156]
[0157] Select any three nodes from the network. The relationship between the synchronization error and the number of iterations during synchronous iteration of these three nodes is as Figure 4 shown. Without introducing weights, through Figure 4 it can be seen that when the number of synchronous iterations is about 50 times, the synchronization effect is achieved.
[0158] When weights are introduced, the change in the relationship between the synchronization error and the number of iterations during synchronous iteration of the three nodes is as Figure 5 shown. From Figure 5 it is not difficult to see that when the weights are changed, the node clocks achieve the synchronization effect at about 40 iterations.
[0159] This application performs an optimal estimation of the node clocks in the network through Kalman filtering, and then conducts a synchronization study on the node clocks through a weighted average algorithm. The network clock system optimized by the weighted average algorithm has faster convergence during the synchronization process compared to the unoptimized clock system, and also has a shorter number of iterations, which also means lower energy consumption, thus greatly improving the lifespan of the WSN.
[0160] It can be seen from the above technical solution that based on the clock parameters and measurement parameters of the target node, a system model of the target node is established; wherein, the system model is used to calculate the frequency and offset of the target node; the target node is any one of all the nodes in the wireless sensor network. In order to achieve time synchronization of each node in the wireless sensor network, a weighted average algorithm can be used to perform iterative processing on the system model and the weight matrix corresponding to the wireless sensor network to determine the common frequency and common offset of the wireless sensor network. According to the common frequency and common offset, the frequency and offset of the target node are adjusted. In this technical solution, through the weighted average method, each node in the wireless sensor network makes its frequency and offset in the network approach the recognized common frequency and common offset among nodes through continuous iterative methods, so as to make the network clock achieve a higher-precision synchronization. And when constructing the system model, both the influence of frequency on clock synchronization and the influence of offset on clock synchronization are considered, improving the accuracy of wireless sensor network clock synchronization.
[0161] Figure 6 This is a schematic structural diagram of a clock synchronization device for a wireless sensor network provided by an embodiment of this application, including a establishing unit 61, a determining unit 62, and an adjusting unit 63;
[0162] Establishment unit 61, configured to establish a system model of a target node based on the clock parameters and measurement parameters of the target node; wherein, the system model is used to calculate the frequency and offset of the target node; the target node is any one of all the nodes in the wireless sensor network;
[0163] Determination unit 62, configured to perform iterative processing on the system model and the weight matrix corresponding to the wireless sensor network by using a weighted average algorithm to determine the common frequency and common offset of the wireless sensor network;
[0164] Adjustment unit 63, configured to adjust the frequency and offset of the target node according to the common frequency and common offset.
[0165] Optionally, the establishment unit includes a state model establishment subunit, a measurement model establishment subunit, and an as subunit;
[0166] The state model establishment subunit is configured to establish a state model corresponding to the frequency and offset of the target node by using the initial clock frequency, clock initial offset, oscillator parameters of the target node itself, and the set sampling period and state noise included in the clock parameters of the target node;
[0167] The measurement model establishment subunit is configured to establish a measurement model of the target node by using the measurement matrix and measurement noise included in the measurement parameters;
[0168] The as subunit is configured to use the state model corresponding to the frequency and offset of the target node and the measurement model of the target node as the system model of the target node.
[0169] Optionally, the state model establishment subunit is configured to call a clock Kalman state model to process the initial clock frequency, clock initial offset, oscillator parameters of the target node itself, and the set sampling period and state noise of the target node to obtain a state model of the frequency and offset of the target node; the calculation formula corresponding to the clock Kalman state model is:
[0170] X n (k)=Φ n X n (k - 1)+ω n (k)+b n ;
[0171] Wherein, X n (k)=[α n (k)β n (k)] T , α n (k)=α n (k - 1)+δ n (k), β n (k)=β n(k - 1)+τα n (k - 1)+τδ n (k)-τ,
[0172] α n (k) represents the clock frequency state of node n at the current time k, α n (k - 1) represents the clock frequency state of node n at the previous time k - 1, δ n (k) represents the state noise, β n (k) represents the clock offset state of node n at the current time k, β n (k - 1) represents the clock offset state of node n at the previous time k - 1, τ represents the sampling period, Φ n represents the state transition matrix, ω n (k) represents the general state noise.
[0173] Optionally, the determination unit includes a state change determination subunit and a general parameter determination subunit;
[0174] The state change determination subunit is configured to determine a state change model between a target node and an adjacent node according to the weight matrix corresponding to the wireless sensor network and the state parameters corresponding to each node; wherein, the adjacent node is any node in the wireless sensor network other than the target node;
[0175] The general parameter determination subunit is configured to perform iterative processing on the system model and the state change model by using a weighted average algorithm to determine the general frequency and general offset of the wireless sensor network.
[0176] Optionally, the state change determination subunit is configured to call the iterative average consensus algorithm formula to process the weight matrix corresponding to the wireless sensor network and the state parameters corresponding to each node to obtain a state change model between the target node and the adjacent node; the iterative average consensus algorithm formula is:
[0177]
[0178] wherein, x i (t + 1) represents the state of node i at the next time, w ij (t) represents the weight corresponding to node i and node j, x j (t) represents the state of node j at the current time, N i represents the neighbor set of node i.
[0179] Optionally, for the determination method of the weight matrix corresponding to the wireless sensor network, the apparatus further includes a distance determination unit, a weight determination unit, and a summary unit;
[0180] A distance determination unit, configured to determine the node distance between any two nodes according to the signal strength between any two nodes in a wireless sensor network;
[0181] A weight determination unit, configured to determine the weight value between any two nodes based on the node distance between any two nodes;
[0182] An aggregation unit, configured to aggregate the weight values between any two nodes as the weight matrix corresponding to the wireless sensor network.
[0183] Optionally, the distance determination unit is configured to obtain the signal strength between any two nodes in the wireless sensor network;
[0184] Call the corresponding relationship formula between the signal strength and the node distance to determine the node distance between any two nodes; the corresponding relationship formula between the signal strength and the node distance is:
[0185]
[0186] where P(d) represents the signal strength received by the node when the distance is d, d 0 is the reference distance, P(d 0 ) represents the signal strength received by the node when the distance is d 0 , m represents the path loss exponent related to the environment, and X m represents Gaussian noise with a standard deviation of σ and a mean of 0.
[0187] Figure 6 For the description of the features in the corresponding embodiments, reference can be made to Figure 1 the relevant descriptions of the corresponding embodiments, which will not be elaborated here one by one.
[0188] It can be seen from the above technical solutions that a system model of the target node is established based on the clock parameters and measurement parameters of the target node; wherein, the system model is used to calculate the frequency and offset of the target node; the target node is any one of all the nodes in the wireless sensor network. In order to achieve time synchronization of each node in the wireless sensor network, the weighted average algorithm can be used to iteratively process the system model and the weight matrix corresponding to the wireless sensor network to determine the common frequency and common offset of the wireless sensor network. According to the common frequency and common offset, the frequency and offset of the target node are adjusted. In this technical solution, through the weighted average method, each node in the wireless sensor network makes its frequency and offset in the network approach the recognized common frequency and common offset among nodes through continuous iteration, so as to make the network clock reach a higher-precision synchronization. And when constructing the system model, both the influence of frequency on clock synchronization and the influence of offset on clock synchronization are considered, improving the accuracy of wireless sensor network clock synchronization.
[0189] Figure 7 The structural diagram of an electronic device provided by an embodiment of the present application is shown as Figure 7 follows. The electronic device includes: a memory 20 for storing a computer program;
[0190] a processor 21 for implementing the steps of the clock synchronization method of the wireless sensor network in the above embodiment when executing the computer program.
[0191] The electronic device provided in this embodiment may include, but is not limited to, a smart phone, a tablet computer, a notebook computer, a desktop computer, etc.
[0192] Among them, the processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 21 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 21 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the wake state, also known as the CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 21 may be integrated with a GPU (Graphics Processing Unit), and the GPU is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 21 may further include an AI (Artificial Intelligence) processor, and the AI processor is used to process computational operations related to machine learning.
[0193] The memory 20 may include one or more computer-readable storage media, which may be non-transitory. The memory 20 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices and flash storage devices. In this embodiment, the memory 20 is at least used to store the following computer program 201. After the computer program is loaded and executed by the processor 21, the relevant steps of the clock synchronization method of the wireless sensor network disclosed in any of the foregoing embodiments can be implemented. In addition, the resources stored in the memory 20 may also include an operating system 202, data 203, etc., and the storage method may be transient storage or permanent storage. Among them, the operating system 202 may include Windows, Unix, Linux, etc. The data 203 may include, but is not limited to, clock parameters, measurement parameters, etc.
[0194] In some embodiments, the electronic device may further include a display screen 22, an input / output interface 23, a communication interface 24, a power supply 25, and a communication bus 26.
[0195] Those skilled in the art can understand that Figure 7 the structure shown in does not constitute a limitation on the electronic device, and it may include more or fewer components than those shown in the figure.
[0196] It can be understood that if the clock synchronization method of the wireless sensor network in the above embodiments 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, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and executes all or part of the steps of the methods of the various embodiments of the present application. The foregoing storage medium includes: USB flash drive, mobile hard disk, read-only memory (ROM), random access memory (RAM), electrically erasable programmable ROM, register, hard disk, removable disk, CD-ROM, disk, or optical disc, etc., which can store program codes.
[0197] Based on this, the embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the clock synchronization method of the wireless sensor network as described above are implemented.
[0198] The above has introduced in detail a clock synchronization method, apparatus, device, and computer-readable storage medium for a wireless sensor network provided by the present application. The various embodiments in the specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. For the same or similar parts among the various embodiments, reference can be made to each other. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple. For the relevant parts, reference can be made to the description in the method part.
[0199] Those skilled in the art can further realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Skilled professionals can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present application.
[0200] The above has introduced in detail a clock synchronization method, apparatus, device, and computer-readable storage medium for a wireless sensor network provided by the present application. Specific examples are used herein to elaborate on the principles and implementation manners of the present invention. The description of the above embodiments is only used to help understand the method and its core idea of the present invention. It should be noted that for those of ordinary skill in the art in the technical field, without departing from the principles of the present invention, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the protection scope of the claims of the present application.
Claims
1. A clock synchronization method for a wireless sensor network, characterized in that, comprising: Based on the clock parameters and measurement parameters of a target node, establishing a system model of the target node; wherein, the system model is used to calculate the frequency and offset of the target node; the target node is any one of all nodes in the wireless sensor network; Using a weighted average algorithm to perform iterative processing on the system model and the weight matrix corresponding to the wireless sensor network to determine the common frequency and common offset of the wireless sensor network; Adjusting the frequency and offset of the target node according to the common frequency and common offset; The establishing a system model of the target node based on the clock parameters and measurement parameters of the target node includes: Using the initial clock frequency, clock initial offset, oscillator parameters of the target node itself, and set sampling period and state noise included in the clock parameters of the target node to establish a state model corresponding to the frequency and offset of the target node; Using the measurement matrix and measurement noise included in the measurement parameters to establish a measurement model of the target node; Taking the state model corresponding to the frequency and offset of the target node and the measurement model of the target node as the system model of the target node; Regarding the determination method of the weight matrix corresponding to the wireless sensor network, the method further includes: Determining the node distance between any two nodes according to the signal strength between any two nodes in the wireless sensor network; Based on the node distance between any two nodes, determining the weight value between any two nodes; Summarizing the weight values between any two nodes as the weight matrix corresponding to the wireless sensor network.
2. The clock synchronization method for a wireless sensor network according to claim 1, characterized in that, The establishing a state model corresponding to the frequency and offset of the target node using the initial clock frequency, clock initial offset, oscillator parameters of the target node itself, and set sampling period and state noise included in the clock parameters of the target node includes: Invoking a clock Kalman state model to process the initial clock frequency, clock initial offset, oscillator parameters of the target node itself, and set sampling period and state noise of the target node to obtain a state model of the frequency and offset of the target node; the calculation formula corresponding to the clock Kalman state model is: X n (k) = Φ n X n (k - 1)+ω n (k)+b n ; where X n (k) = [α n (k)β n (k)] T , α n (k) = α n (k - 1) + δ n (k), β n (k) = β n (k - 1) + τα n (k - 1) + τδ n (k) - τ, α n (k) represents the clock frequency state of node n at the current moment k, α n (k - 1) represents the clock frequency state of node n at the previous moment k - 1, δ n (k) represents the state noise, β n (k) represents the clock offset state of node n at the current moment k, β n (k - 1) represents the clock offset state of node n at the previous moment k - 1, τ represents the sampling period, Φ n represents the state transition matrix, ω n (k) represents the general state noise.
3. The clock synchronization method for a wireless sensor network according to claim 1, characterized in that, The using a weighted average algorithm to perform iterative processing on the system model and the weight matrix corresponding to the wireless sensor network to determine the common frequency and common offset of the wireless sensor network includes: Determining a state change model between the target node and adjacent nodes according to the weight matrix corresponding to the wireless sensor network and the state parameters corresponding to each node; wherein, the adjacent node is any one of the nodes in the wireless sensor network other than the target node; Using a weighted average algorithm to perform iterative processing on the system model and the state change model to determine the common frequency and common offset of the wireless sensor network.
4. The clock synchronization method for a wireless sensor network according to claim 3, wherein, the determining of the state change model between the target node and its adjacent nodes according to the weight matrix corresponding to the wireless sensor network and the state parameters corresponding to each node includes: invoking the iterative average consensus algorithm formula to process the weight matrix corresponding to the wireless sensor network and the state parameters corresponding to each node, so as to obtain the state change model between the target node and its adjacent nodes; the iterative average consensus algorithm formula is: where x i (t + 1) represents the state of node i at the next moment, and w ij (t) represents the weight corresponding to node i and node j, and x j (t) represents the state of node j at the current moment, and N i represents the neighbor set of node i.
5. A clock synchronization device for a wireless sensor network, wherein, it includes a establishing unit, a determining unit and an adjusting unit; the establishing unit is configured to establish a system model of the target node based on the clock parameters and measurement parameters of the target node; wherein, the system model is used to calculate the frequency and offset of the target node; the target node is any one of all nodes in the wireless sensor network; the determining unit is configured to use the weighted average algorithm to perform iterative processing on the system model and the weight matrix corresponding to the wireless sensor network, so as to determine the common frequency and common offset of the wireless sensor network; the adjusting unit is configured to adjust the frequency and offset of the target node according to the common frequency and common offset; the establishing unit includes a state model establishing subunit, a measurement model establishing subunit and an acting subunit; the state model establishing subunit is configured to establish a state model corresponding to the frequency and offset of the target node by using the clock parameters of the target node including the initial clock frequency, the initial clock offset, the oscillator parameters of the target node itself, and the set sampling period and state noise; the measurement model establishing subunit is configured to establish a measurement model of the target node by using the measurement parameters including the measurement matrix and measurement noise; the acting subunit is configured to use the state model corresponding to the frequency and offset of the target node and the measurement model of the target node as the system model of the target node; for the determining manner of the weight matrix corresponding to the wireless sensor network, the device further includes a distance determining unit, a weight determining unit and a summarizing unit; the distance determining unit is configured to determine the node distance between any two nodes in the wireless sensor network according to the signal strength between any two nodes; the weight determining unit is configured to determine the weight value between any two nodes based on the node distance between any two nodes; the summarizing unit is configured to summarize the weight values between any two nodes as the weight matrix corresponding to the wireless sensor network.
6. An electronic device, wherein, it includes: a memory for storing a computer program; a processor for executing the computer program to implement the steps of the clock synchronization method for the wireless sensor network according to any one of claims 1 to 4.
7. A computer-readable storage medium, wherein, A computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the clock synchronization method of the wireless sensor network according to any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Method for selecting PRC (primary reference clock) access network element in clock synchronization planning
CN105337681A
Hierarchical Ad Hoc network time synchronization method based on clustering algorithm
CN110278048A