Method for synchronizing network time of low-consumption wireless sensor
Technical field
The invention belongs to the wireless sensor network technology field, relate to the transmission method of wireless sensor network time synchronized message, specifically is a kind of method for synchronizing network time of low-consumption wireless sensor.
Background technology
Wireless sensor network is exactly to form by being deployed in cheap microsensor nodes a large amount of in the monitored area, the network system of the self-organizing of a multi-hop that forms by communication, its objective is some specific physical quantity in perception collaboratively and the collection network overlay area, and the information of being gathered handled, send to the observer then.
For the application of most of wireless sensor networks, unified time is being played the part of a vital role.Depend on the application of time synchronized and the every aspect that agreement is present in wireless sensor network.The realization of time synchronization protocol had both depended on the transmission feature of wireless sensor network, had supported the communication and the upper layer application of wireless sensor network simultaneously again, was a vital part in the wireless sensor network.
The time synchronized of sensor network can adopt two kinds of methods, one. and be equipped with the GPS module for each node,, make node time consistent, reach synchronous with the standard time to obtain precise time; Two. utilize network communication mode, swap time, information made the whole network keep unified time, reached synchronous.Because cost height, the energy consumption of GPS equipment are big, can not all be equipped with the GPS module for each node, therefore have only a spot of node can be equipped with the GPS module, other node then adopts the way of synchronization message swap time to reach the whole network time synchronized.
It is a variety of to utilize the method for network service synchronization message swap time to have between node, and wherein inundation airtime synchronous protocol is fairly simple a kind of method.The principle of this method is: each in network synchronization node adopts the mode of broadcasting to send its local zone time packing then.The time delay in each stage in the message transmission is carried out careful analysis and set up distributed model, the node that receives message is eliminated the influence that time delay causes according to the distributed model of being set up, adopt the method for linear regression to estimate time migration and the time drift of node, utilize the estimated value correcting local time with respect to length of a game.
Each node in this method hypothesis sensor network has unique identify label number, just ID number.A root node is arranged in the whole network, and root node is the node of ID minimum, also is the synchronisation source of choosing.Inundation airtime synchronous protocol adopts hierarchical structure, and root node belongs to 0 grade, and the node in the root node broadcast domain belongs to 1 grade of node, and by that analogy, the node of rank i is synchronized to the node that rank is i-1.The periodic airtime message of all nodes is received the time message of i-1 level node when i level node, reach synchronously after, generate new time message, broadcast away then.Successively, time synchronized reaches the time synchronized of the whole network at last from the low node of rank of the high node diffusion of rank.
Fig. 1 shows the structure of synchronous time message bag of inundation airtime.Comprise lead code Preamble, sync byte SYNC, data segment Data and CRC check sign indicating number four parts, data segment wherein comprises time beacon timeStamp, root node identification number rootID and three parts of sequence number seqNum again.Among Fig. 1, inundation airtime synchronous protocol utilizes the root node identification number rootID in the time synchronized message bag to carry out root node and selects, and can guarantee to select root node again under the situation that root node lost efficacy; The node that receives time synchronized message uses the sequence number seqNum in the message bag to judge whether the time synchronized message that receives is up-to-date.
In the inundation airtime synchronous protocol, all synchronization nodes all can the airtime synchronization message.Characteristics of wireless sensor network are that node density is big, answer this, a node will be received the time message of a lot of node broadcasts on every side, have only a meeting to be used in these message, other message then is redundancy message, these redundancy messages not only can be wasted the energy of node, but also can cause the network service collision, reduce network communication quality.
Summary of the invention
The objective of the invention is to avoid the deficiencies in the prior art, and propose a kind of method for synchronizing network time of low-consumption wireless sensor, can reduce the traffic volume of redundancy message in the time synchronized effectively, reach the purpose that reduces the time synchronized energy consumption.
For achieving the above object, the present invention proposes the notion of downstream site degree, and the method for the downstream site degree of adding up each node is provided.Utilize the downstream site degree to choose part of nodes transmitting time synchronization message in the network, other node is passive reception message, not transmitting time synchronization message.
Concrete grammar of the present invention comprises network presynchronization, active node selection, selects three processes again, and described network presynchronization process is mainly finished node hierarchy, time synchronized and statistics downstream site degree; Node in the network is divided into active node and passive node, and described active node is for after reaching synchronously with length of a game, the node of can generation time synchronization message bag also broadcasting away; Described passive node is can only the time of reception synchronization message, and node that can not airtime synchronization message bag; It is to utilize the downstream site degree to choose the node of the transmitting time synchronization message bag in the network that described active node is selected; The downstream site degree of node is the number that the downstream site of contacting directly is arranged with this node; Described selection course again is to occur in time synchronization process that active node lost efficacy or the energy of all active node can not satisfy airtime synchronization message or root node again and lost efficacy the time, selects active node again.
The method according to this invention, described node hierarchy is in time synchronization process, sensor node is divided into different ranks and write down node the level alias; Add up the downstream site degree on this basis: the initial value that makes the downstream site degree of a node is 0, and in a synchronizing cycle, the node that is in the i level is received the time synchronized message that certain node of i+1 level sends, and just its downstream site degree is added 1.
The method according to this invention, described active node selects to follow following rule: through all after dates of several time synchronized, within the specific limits, have only the node of downstream site degree maximum can send synchronization message, these nodes are exactly active node; Described passive node selects to follow following rule:
A) the downstream site degree is a not transmitting time synchronization message of 0 node, and then this node is passive node;
B) if the downstream site degree of node less than the downstream site degree of other brother of node that receives, node is the transmitting time synchronization message not, then this node is passive node.
The method according to this invention, the selection course again of active node is handled by following three kinds of modes:
(1) certain active node lost efficacy, and after the passive node of peer is confirmed, by passive node transmitting time synchronization message bag, through several synchronizing cycles, selected active node again;
(2) energy of all active node can not satisfy the airtime synchronization message again, is confirmed by root node, and initiates the selection again of the whole network;
(3) root node lost efficacy, and was initiated to select by new root node again, need carry out network presynchronization and active node again and select.
The message bag of passing time synchronization message of the present invention increases level alias levelNum and downstream site degree NLND among its data segment Data, wherein the level alias is used to transmit the class information of node, and this levelNum is necessary, and NLND is optional.
With respect to traditional inundation airtime synchronous protocol, the present invention mainly contains following several advantage:
(1) the present invention utilizes the downstream site degree to choose active node and passive node.In time synchronization process, owing to have only active node transmitting time synchronization message, passive node only needs time of reception synchronization message bag.Each node is all wanted the transmitting time synchronization message in traditional inundation airtime synchronous protocol, the present invention can effectively reduce the quantity of the node of transmitting time message in the network, reduced the Internet traffic in the synchronizing process, redundancy message in the time synchronized significantly reduces, network conflict also decreases, and has prolonged the work period of sensor network;
(2) in the network presynchronization process of the present invention, node hierarchy and statistics downstream site degree follow time synchronized to carry out.Active node selection course is again guaranteed maybe can not bear under the situation of time synchronized message transmission in the active node inefficacy, selects active node again.Can improve the stability of method for synchronizing network time of low-consumption wireless sensor operation so greatly.
Description of drawings
Accompanying drawing 1 is the structural representation of inundation airtime synchronization message bag
Accompanying drawing 2 is structural representations of low-consumption wireless sensor network time synchronization message bag of the present invention
Accompanying drawing 3 is one-level node of the present invention view before and after active node is selected
Embodiment
What Fig. 2 showed is the structure of the time synchronized message bag of low energy consumption method for synchronizing time, comprise lead code Preamble, sync byte SYNC, data segment Data and CRC check sign indicating number four parts, data segment wherein comprises time beacon timeStamp, root node identification number rootID, sequence number seqNum, node level alias levelNum and five parts of node downstream site degree NLND again.Have more two data than inundation airtime synchronization packets shown in Figure 1, what wherein levelNum carried is the class information of node, and these data are necessary, follow time synchronized all the time.The data that NLND carries are downstream site degree of node, and these data are optionally, only in have the initiative node selection course or again during selection course of time synchronized, just can carry these data in the time synchronized message bag.
Method for synchronizing network time of low-consumption wireless sensor is divided into three parts: network presynchronization process, active node selection course, selection course again.
(1) network presynchronization process
Time synchronized has mainly been finished 3 tasks in this process: node hierarchy, time synchronized and statistics downstream site degree.When carrying out time synchronized, sensor network also is accompanied by classification and these two processes of statistics downstream site degree.
Suppose that in the whole sensor network lifecycle, the communication distance of node is changeless, the emission radius of each node is identical.Classification and statistics downstream site degree and time synchronized are carried out simultaneously, any influence can not arranged to the convergence of time synchronized.After root node is determined, the beginning classification process, the regulation root node is 0 grade of node, is begun by root node synchronously.Root node airtime synchronization message bag comprises the significant datas such as level alias (levelNum=0) and time beacon of root node in this message bag.After node around the root node received this message bag, the evaluation time skew was adjusted local zone time according to time migration, then the level alias that extracts in the message bag was added 1, as the level alias of oneself.Around root node, can directly receive the node of the time message bag of root node transmission like this, its grade alias is 1.After these nodes and root node are synchronous, and through T=0.5T+T
RandAfter, produce new time beacon, with the level alias together packaging broadcast go out.T
RandValue is for (0,0.5T) the equally distributed random number between, the value of T are according to the transmission rate decision of node, and purpose is in order to reduce the network collision.Continue synchronously and classification for subsequent node, its process is, after certain node received that rank of living in is the time message bag that sends of node of i, if this node also is not provided with grade alias or level alias greater than i+1, the level alias of this node was set to i+1 so; Otherwise keep original grade of alias constant.Along with time synchronized, classification also is diffused into whole network from root node.
Through all after dates of several time synchronized, each node in the network has all had a level alias.After the level alias of node is determined in the network,, just can not carry out the classification process of sensor network again if root node does not change.After root node was reselected, the grade of node also will be repartitioned.
After time synchronized is carried out a period of time, the time of the node of network is tending towards synchronous, the rank of node is determined, just begin to add up downstream site degree NLND, this process is carried out in time synchronously together, and the downstream site degree of certain node is defined as: with this node the number of the downstream site of contacting directly is arranged.
The statistical method of downstream site degree is: the initial value that makes the downstream site degree of node in the network is 0, in a synchronizing cycle, if be in the time synchronized message that the node of i level receives that certain node of i+1 level sends, so just its downstream site degree is added 1 (NLND=NLND+1), like this, at all after dates of a time synchronized, each node in the network can count the quantity of downstream site in the own broadcast coverage, just downstream site degree.
(2) active node selection course
The present invention utilizes two data of downstream site degree NLND of node level alias levelNum in the message bag shown in Figure 2 and node to carry out active node and selects.The purpose of this process is some node transmitting time synchronization message bag of choosing in the network, and other node is passive reception message, does not initiatively send message.For this reason, following definition is arranged:
Active node---in the sensor network, after node and length of a game reach synchronously, can generation time synchronization message bag and broadcast away, such node is called active node;
Passive node---in the sensor network, node can only the time of reception synchronization message, and can not airtime synchronization message bag, and such node is called passive node.
Reach time synchronized at the whole network, after each node all obtains the downstream site degree of oneself,, carry out node and select in the next time synchronized cycle.The method that node is selected is to utilize the downstream site degree to judge: when subordinate's node degree is 0, represent that this node does not have downstream site, synchronization message bag of outside airtime of such node, do not have node yet and utilize this time synchronized message bag, therefore, this node only needs passive time of reception synchronization message bag, does not need initiatively to send message, and such node just is set to passive node; When node reaches synchronously and downstream site degree when being not 0, node is with the transmission of packing together of time beacon, node level alias and downstream site degree.After other brother of node receives this time synchronized message bag, downstream site degree of oneself and the downstream site degree in the message bag are compared, if the downstream site degree of node is less than the downstream site degree in the message bag, this node just is provided as passive node so, stops transmitting time synchronization message bag.Through all after dates of several time synchronized, within the specific limits, have only the node of downstream site degree maximum can send synchronization message like this, these nodes are exactly active node.
Shown in Figure 3 is the state of one-level node before and after active node is selected, and what wherein concentric circles was represented is the residing level of node, and the point of black is represented root node.What left figure represented is the communications status of node in the presynchronization process, and in this process, each node all needs the transmitting time synchronization message, and statistics downstream site degree.The downstream site degree that this node of digitized representation on dark some next door is added up among the figure; Right figure expression be state after first order node is selected through node, the active node in the first order that wherein dark some expression is selected, hollow dots is represented passive node.And the active node selection is not also carried out in the second level, and its all node is the transmitting time synchronization message still.
In Fig. 2, though the message bag of low energy consumption method for synchronizing time has more two data,, after the active node selection, the number of nodes of transmitting time synchronization message bag reduces, and from overall consideration, the TOCOM total communication amount has also reduced.Can effectively reduce the traffic, communication contention aware and the network overhead of time synchronized like this, save energy.
(3) selection course again
In service at sensor network following three kinds of situations can occur and influences the time synchronized of network: the first, certain active node lost efficacy in the running of network, will have influence on a part of time synchronized of sensor network; The second, the energy charge of active node is relatively large, after operation a period of time, and can not hold time the again transmission of synchronization message bag of active node, this situation can have influence on the time synchronized of whole network.Three, root node lost efficacy, and this situation also can have influence on the time synchronized of whole network.
For first kind of situation, can carry out the selection of active node in the part of network again, selection course is initiated by the brother of node of failure node.When certain passive node of peer does not receive time of node broadcasts of any and own same levels during message, this passive node just thinks that certain active node lost efficacy, at this moment passive node becomes active node, transmitting time synchronization message bag, through several synchronizing cycles, select active node again.
For second kind of situation, active node is selected to be initiated by root node again, and this process is identical with the method for above-mentioned " active node selection course ", and its difference is that the active node of having selected in the past will not be re-used as active node.
For the third situation, active node is selected to be initiated by root node equally again, but this process need carries out " network presynchronization " and " active node selection " process again.