Disclosure of Invention
The present invention is directed to provide a neighbor discovery method based on the greatest common divisor of cycle lengths, for solving the problem of neighbor node discovery in a mobile ad hoc network, in view of the above-mentioned deficiencies of the prior art.
The idea of realizing the purpose of the invention is that when the maximum common factor of the basic period time length of any two nodes is equal to the time length of the monitoring channel after the node broadcasts the beacon minus the time length of the node broadcasting the beacon plus one, the lower bound of obtaining delay is found in the worst case; when the basic periods of the two nodes are the same, the super period is used for realizing mutual discovery and reaching the lower bound of the discovery delay under the worst condition; in short, no matter the basic cycle durations of the two nodes are equal or unequal, the lower bound of the worst discovery delay can be obtained, and the durations in the basic cycle duration set can be in units of time of nanoseconds (ns), microseconds (μ s), milliseconds (ms) and seconds(s), and can also be in units of time slots; when the time slot is used as a unit, the time length in the basic period time length set can be a prime number or a composite number.
The specific steps for realizing the purpose of the invention are as follows:
(1) acquiring a basic cycle time length set:
(1a) all nodes given by the user preselect the minimum value and the maximum value of the basic period duration to form a basic periodAlternative set of epoch Length set Lmin,Lmin+1,…,Lmax-1,LmaxIn which L isminIndicating the minimum value, L, of the duration of a preselected basic period of all nodes given by the usermaxRepresenting the maximum value, L, of the duration of a preselected basic period of all nodes given by the userminAnd LmaxThe unit of (d) may be one of a nanosecond (ns), microsecond (μ s), millisecond (ms), and second(s) time unit;
(1b) setting the basic period duration set as an empty set;
(1c) randomly selecting a time length from the alternative set, and removing the selected time length from the alternative set;
(1d) judging whether the selected duration meets the constraint condition, if so, executing the step (1e), otherwise, executing the step (1 f);
(1e) adding the selected duration to a set of base cycle durations;
(1f) judging whether all the time lengths in the alternative set are selected, if so, obtaining the basic period time length sets of all the nodes and then executing the step (2), otherwise, executing the step (1 c);
(2) setting the basic period duration and the super period duration of each node:
(2a) selecting an unselected node from the mobile ad hoc network;
(2b) according to | u-lkThe absolute value of the difference between each time length in the basic period time length set and the pre-selection basic period time length of the node selected by the user is calculated through an equation, wherein u represents the pre-selection basic period time length of the node selected by the user, and lkRepresenting the kth duration in the basic cycle duration set, k being 1,2, …, n, n representing the total number of durations in the basic cycle duration set;
(2c) selecting the time length with the minimum absolute value as a basic period time length of the selected node;
(2d) calculating a super-cycle time length of the selected node according to a super-cycle time length formula;
(3) setting the working mode of each node:
(3a) selecting an unselected node from the mobile ad hoc network;
(3b) from the power-on time of a selected node, taking the time length of every other basic cycle as a basic cycle, taking l/(omega-tau +1) basic cycles as a super cycle, wherein the selected node has a plurality of super cycles, wherein l represents the time length of the basic cycle of the selected node, omega represents the time length of listening to channel broadcast after the selected node broadcasts a beacon in the basic cycle, and tau represents the time length of broadcasting a beacon by the selected node, if the time length of (omega-tau +1) is taken as a time slot, the basic cycle l comprises l/(omega-tau +1) time slots, and the number of the time slots can be prime number or composite number.
(3c) In each super-period of the selected node, a basic period is randomly selected as a special basic period, and in the special basic period, the selected node monitors the channel broadcast after broadcasting a beacon
In other fundamental periods, the selected node listens for the channel broadcast ω after broadcasting a beacon, wherein,
indicating a rounding-up operation, l indicating a base period duration of the selected node, and ω indicating a duration of listening to a channel broadcast after the selected node broadcasts a beacon in the base period;
(4) the node discovers its neighbor nodes:
(4a) after receiving the beacon broadcast by the neighbor node, any node sends back a beacon to the neighbor node, and the receiving node and the neighbor node complete mutual discovery.
Compared with the prior art, the invention has the advantages that:
firstly, because the invention acquires the basic cycle time length set of all nodes, each time length in the set can take nanosecond (ns), microsecond (mus), millisecond (ms) or second(s) as a unit, and can also take a time slot as a unit, the invention overcomes the problem that the prior art needs to work according to the time slot and has small applicable scene, and the invention has the advantages of working according to the time slot, working according to the non-time slot and having large applicable scene.
Secondly, because the invention acquires the basic cycle time length set of all the nodes, the time slot number contained in each time length in the set can be a prime number or a composite number, and the invention overcomes the problems that the time slot number contained in the time length in the prior art must be a prime number and the basic cycle time length of the nodes which can be set by the nodes is small, so that the invention has the advantages that the time slot number contained in the basic cycle time length can be a prime number or a composite number, and the basic cycle time length of the nodes which can be set by the nodes is large.
Thirdly, because each time length in the basic period time length set of all the nodes meets the constraint condition, all the nodes can obtain the lower bound of the discovery delay under the worst condition, and the problems that the prior art needs to know the duty ratio of the neighbor nodes to optimize the node parameters and reduce the average discovery delay of the nodes are solved, so that the method has the advantages that the node parameters can be optimized and the average discovery delay of the nodes is short without knowing the duty ratio of the neighbor nodes.
Detailed Description
The invention is further described below with reference to the accompanying drawings. Specifically, the neighbor discovery method adopted by the present invention is referred to as Circle method.
The specific steps of the present invention will be further described with reference to fig. 1.
Step 1, acquiring a basic cycle duration set.
Suppose the user sets the minimum and maximum values of all node pre-selected base cycle durations to be 101 and 1001, respectively, resulting in a candidate set of base cycle durations of {101,102, …,1000,1001 }.
Substituting the minimum and maximum values of all node preselection basic cycle duration set by a user into the following formula to respectively obtain the maximum and minimum values of the duty ratio,
wherein DC represents the duty ratio of the node, tau represents the time length of the node broadcasting the beacon, omega represents the time length of monitoring the channel after the node broadcasting the beacon, delta represents the time length from the radio frequency being turned on to the beacon being actually sent out when the node broadcasts the beacon,
indicating a rounding down operation, l indicates a maximum or minimum value of the preselected base period duration,
indicating a rounding up operation.
The time length tau of the node broadcasting beacon is set to be 1, the time length omega of the node monitoring channel after the node broadcasting beacon is set to be 4, the time length delta from the radio frequency starting to the actual sending of the beacon when the node broadcasts the beacon is set to be 3, the minimum value of the time length of the preselection basic cycle set by the user is 101, and the maximum value is 1001. Substituting the minimum value and the maximum value of the preselection basic cycle time length set by the user into the formula to obtain that the duty ratio corresponding to the minimum preselection basic cycle time length 101 is approximately equal to 10%, and the duty ratio corresponding to the maximum preselection basic cycle time length 1001 is approximately equal to 1%.
The set of base cycle durations is set to an empty set.
Randomly selecting one time length from the alternative set, sequentially comparing the selected time length with all the time lengths in the basic period time length set, and adding the selected time length meeting the constraint condition into the basic period time length set.
Since the specific operation procedure for constructing the basic period duration set in a random manner is difficult to describe, the following description will be made by way of example.
The randomly chosen duration from the candidate set is always the minimum duration in the candidate set. The time length tau of the node broadcasting the beacon is set to be 1, the time length omega of the node listening to the channel after the beacon is broadcast is set to be 4, and omega-tau +1 is set to be 4. And (4) taking out 101 from the alternative set, and deleting 101 from the alternative set because 101 cannot be divided by 4 and 101 does not meet the constraint condition. Similarly, 102 and 103 are taken out from the candidate set, and since the two values cannot be divided by 4, the condition is not satisfied, and 102 and 103 are deleted from the candidate set. The next candidate set is 104, since 104 can be divided by 4 and the base cycle duration set is an empty set, 104 is taken from the candidate set and added to the base cycle duration set, which is {104}, and 104 is deleted from the candidate set. Similarly, 105,106 and 107 are removed from the alternative set. The next duration taken from the candidate set is 108, since gcd (108,104) ═ 4,108 is added to the base cycle duration set, which is {104,108 }; 108 are removed from the alternative set. Similarly, 109,110 and 111 are removed from the candidate set. The next time duration to fetch from the candidate set is 112, although 112 can be divided by 4, gcd (112,104) ≠ 8, so 112 does not satisfy the condition; and remove 112 from the alternative set. By analogy, 48 time lengths are finally added into the basic period time length set, namely the basic period time length set is {104,108,116,124,140,148,164,172,188,212,236,244,268,284,292,316,332,356,388,404,412,428,436,452,484,508,524,548,556,596,604,628,652,668,692,716,724,764,772,788,796,844,892,908,916,932,956,964 }.
The randomly chosen duration from the candidate set is always the maximum duration in the candidate set. The time length tau of the node broadcasting the beacon is set to be 1, the time length omega of the node listening to the channel after the beacon is broadcast is set to be 4, and omega-tau +1 is set to be 4. 1001 is taken out from the candidate set, and 1001 cannot be divided by 4, so that the condition is not satisfied, and 1001 is deleted from the candidate set. The next candidate set is 1000 in duration, and since 1000 can be divided by 4 and the basic cycle duration set is an empty set, 1000 is taken from the candidate set and added to the basic cycle duration set, the basic cycle duration set is {1000}, and 1000 is deleted from the candidate set. 999, 998 and 997 are taken out of the candidate set, and since the three values cannot be divided by 4, the condition is not satisfied, and 999, 998 and 997 are deleted from the candidate set. The next time duration taken from the candidate set is 996, since 996 is divisible by 4 and gcd (996,1000) is 4, 996 is added to the base cycle duration set, which is {1000,996}, and 996 is removed from the candidate set. 995, 994 and 993 are taken from the alternative set, and since the three values cannot be evenly divided by 4, the condition is not satisfied, and 995, 994 and 993 are deleted from the alternative set. The next time duration to be taken out from the candidate set is 992, and although 992 can be divided by 4, gcd (992,1000) ≠ 8, so 992 does not satisfy the condition, and 992 is deleted from the candidate set. By analogy, 47 time lengths are finally added into the basic period time length set, namely the basic period time length set is {1000,996,988,964,956,932,916,908,892,868,844,796,788,772,764,748,724,716,692,668,652,628,604,596,556,548,524,508,452,436,428,412,404,388,356,316,292,284,268,244,236,212,188,172,164,148,116 }.
Step 2: and setting the basic period duration and the super period duration of each node.
Optionally selecting an unselected node, setting the time length tau of the node broadcasting the beacon to be 1, setting the time length omega of the node listening to the channel after the node broadcasting the beacon to be 4, setting the time length delta from the radio frequency being turned on to the beacon being actually sent out to be 3 when the node broadcasts a beacon, and setting the time length of a preselected basic period given to the node by a user to be 198. The preselected base period duration 198 corresponds to a duty cycle of approximately 5%, which may be calculated as follows:
wherein DC represents the duty cycle of the selected node, τ represents the duration of the selected node sending a beacon, ω represents the duration of listening to the channel after the selected node sends a beacon, δ represents the duration from when the radio frequency is turned on until the beacon is actually sent out when the selected node sends a beacon,
indicating a rounding down operation, l indicates a preselected base period duration for the selected node,
the indicated rounding up operation.
Assuming that the base cycle duration set established in search order from small to large, i.e., the base cycle duration set is {104,108,116,124,140,148,164,172,188,212,236,244,268,284,292,316,332,356,388,404,412,428,436,452,484,508,524,548,556,596,604,628,652,668,692,716,724,764,772,788,796,844,892,908,916,932,956,964}, the absolute value of the difference between 188 and 198 is smallest in the base cycle duration set, the base cycle duration of the selected node is set to 188.
Optionally selecting two nodes, respectively assuming a node i and a node j, if the basic cycle time lengths of the node i and the node j are not equal, then there is a gcd (l)i,lj) The worst discovery delay of the node j is found by the node i, and the worst discovery delay of the node j is found by the node i is within the lower bound of the discovery delay:
wherein liRepresents the base cycle duration, l, of node ijThe basic cycle time length of the node j is shown, omega is the time length of monitoring a channel after the node sends a beacon, tau is the time length of sending one beacon by the node, omega of the node i is equal to omega of the node j, and tau of the node i is equal to tau of the node j.
Calculating the super-cycle length of the selected node according to a super-cycle time formula:
HL=l×l/(ω-τ+1)
wherein HL represents the super-cycle duration of the selected node, l represents the basic cycle duration of the selected node, ω represents the duration of listening to the channel broadcast after the selected node broadcasts a beacon in the basic cycle, and τ represents the duration of broadcasting a beacon by the selected node. Setting the time length tau of the node broadcasting the beacon to be 1, setting the time length omega of the node listening to the channel after the node broadcasting the beacon to be 4, and setting the time length of the basic cycle of the selected node to be 188, wherein the length of the super cycle of the node is 8836.
And step 3: the operation mode of each node is set.
The mode of operation of the node of the present invention is further described with reference to fig. 2. Wherein, fig. 2(a) is a schematic diagram of a node operating mode when a parameter is not determined, fig. 2(b) is a schematic diagram of a node operating mode when a parameter is determined, a black area in fig. 2 represents a time length for broadcasting a beacon by a node, a gray area represents a time length for listening to a channel after broadcasting a beacon by a node, a blank area represents a time length for the node to be in a sleeping state, a grid area represents a time length from when a radio frequency is turned on to when a beacon is actually sent out when a node broadcasts a beacon, and a sum of the time lengths of the black area, the gray area and the grid area is a time length for the node to be in an operating state, and a duty ratio formula of each node can:
wherein DC represents the duty cycle of the selected node, τ represents the duration of sending a beacon by the selected node, ω represents the duration of listening to the channel after sending the beacon by the selected node, δ represents the duration from the radio frequency being on until the beacon is actually sent when the selected node sends a beacon, l represents the fundamental period duration of the selected node,
the indicated rounding up operation.
Optionally selecting an unselected node, setting the time length tau of the node broadcasting the beacon to be 1, setting the time length omega of the node listening to the channel after the node broadcasting the beacon to be 4, setting the time length delta from the radio frequency being turned on to the beacon being actually sent out when the node broadcasts a beacon to be 3, setting the basic work cycle time length of the selected node to be 188, and setting the overcycle time length of the selected node to be 8836.
In each super-period of the selected nodes, a basic period is randomly selected as a special basic period. The embodiment of the invention selects the first basic period as the special basic period. As shown in fig. 2(b), in this basic period, the selected node listens for 94 time units after broadcasting a beacon, and in other basic periods, the selected node listens for 4 time units after broadcasting a beacon.
Optionally selecting two nodes, respectively assuming a node i and a node j, wherein the basic cycle time length of the node i is l
iThe basic cycle duration of node j is l
j. If the fundamental period durations of node i and node j are equal, i.e./
i=l
jThe worst case discovery delay for node i to discover node j is the length of one super-cycle of node i, i.e. the
The worst case discovery delay for a node j to discover a node i is the length of one super-cycle of the node j, i.e.
Due to l
i=l
jTherefore, the discovery delay of the node i in the worst case of discovering the node j, and the discovery delay of the node j in the worst case of discovering the node i all obtain the lower bound of the discovery delay:
wherein liRepresents the base cycle duration, l, of node ijThe basic cycle time length of the node j is shown, omega is the time length of monitoring a channel after the node sends a beacon, tau is the time length of sending one beacon by the node, omega of the node i is equal to omega of the node j, and tau of the node i is equal to tau of the node j.
And 4, step 4: the node discovers its neighbor nodes.
After receiving the beacon broadcast by the neighbor node, any node sends back a beacon to the neighbor node, and the receiving node and the neighbor node complete mutual discovery.
In the above step, if the duration of (ω - τ +1) is taken as a timeslot, where ω represents the duration of listening to the channel broadcast after the selected node broadcasts a beacon in the fundamental period, τ represents the duration of broadcasting a beacon by the selected node, and the operation mode is kept unchanged, the Circle can operate in a timeslot mode, and the number of timeslots included in the fundamental period may be a composite number, which increases the number of selectable duty cycles.
In the embodiment of the invention, the Circle neighbor discovery scheme and the existing neighbor discovery schemes such as Disco, U-Connect, Hello-S and Nihao are respectively applied under the same laboratory environment, and the discovery delays of different neighbor discovery schemes are recorded so as to compare the performances of the schemes. Specifically, we implement all the above neighbor discovery schemes based on the UPMA framework in TinyOS 2.1.2, and test all the schemes on two TelosB nodes, both of which operate in duty cycle mode. For Disco, U-Connect and Hello, the slot length is set to 10ms, specifically the length of the Hello-S active slot is set to 14 ms; a beacon is broadcast at both the beginning and end of the time slot. For Nihao, the slot length is set to 10ms, with a beacon broadcast at the beginning of each fundamental period. For Circle, the time length for listening to the channel after the node sends the beacon is set to 4 ms. The duration for which the TelosB node broadcasts a beacon is 1 ms. For Nihao and Circle, when a node broadcasts a beacon, the time length from the radio frequency starting to the actual sending of the beacon is 3 ms; for Disco, U-Connect, and Hello, the duration from when the radio frequency is turned on until the beacon is actually sent out is 2 ms.
To establish the same comparison reference, { d }A,dB,tA,tBAs an input to an embodiment of the present invention, wherein dAAnd dBDuty cycles, t, of two TelosB nodes, respectivelyAAnd tBRespectively, local points in time when two TelosB nodes come into communication range with each other, dAAnd dBValues are taken from a set of { 1%, 2%, …, 10% }, duty ratios of two TelosB nodes form a pair of duty ratios, and the logarithm of the duty ratio combination is 55. For each pair of duty cycles, 100 examples were used for testing, at which point the two TelosB nodes entered communication range with each otherAt random, the data for each example was recorded and counted.
The node discovery delay of Circle and the node discovery delays of the five prior methods employed by the present invention are further described with reference to fig. 3.
Five existing methods are Disco, U-Connect, Hello-S and NiHao, respectively.
The abscissa in fig. 3 represents the neighbor node discovery delay, and the ordinate represents the neighbor node discovery ratio. The unmarked curve in fig. 3 represents the relationship between the neighbor node discovery ratio of Disco and the neighbor node discovery time, the curve marked with "×" represents the relationship between the neighbor node discovery ratio of U-Connect and the neighbor node discovery time, the curve marked with "×" represents the relationship between the neighbor node discovery ratio of Hello and the neighbor node discovery time, the curve marked with "+" represents the relationship between the neighbor node discovery ratio of Hello _ S and the neighbor node discovery time, the curve marked with "Δ" represents the relationship between the neighbor node discovery ratio of NiHao and the neighbor node discovery time, and the curve marked with "o" represents the relationship between the neighbor node discovery ratio of Circle and the neighbor node discovery time.
As can be seen from FIG. 3, the neighbor node discovery delays of Circle, Disco, U-Connect, Hello-S and Nihao are 16S, 28S, 29S, 30S, 32S and 85S respectively for the six methods when the neighbor node discovery ratio is 90%. When the neighbor node discovery ratio is 100%, the worst-case neighbor node discovery delays of the six methods are 330s, 791s, 581s, 816s, 712s and 354s, respectively, and the time required by the Circle for the same discovery ratio of the six methods and the worst-case neighbor node discovery delay are the shortest.
The average discovery delay for different duty cycles for the six methods in the embodiment of the present invention is further described with reference to fig. 4. Fig. 4(a) is a schematic diagram of an average discovery delay of Disco under various duty cycles, fig. 4(b) is a schematic diagram of an average discovery delay of U-Connect under various duty cycles, fig. 4(c) is a schematic diagram of an average discovery delay of Hello under various duty cycles, fig. 4(d) is a schematic diagram of an average discovery delay of Hello-S under various duty cycles, fig. 4(e) is a schematic diagram of an average discovery delay of NiHao under various duty cycles, and fig. 4(f) is a schematic diagram of an average discovery delay of Circle adopted by the present invention under various duty cycles.
As can be seen from FIG. 4, in Circle, Disco, U-Connect, Hello-S and Nihao, when the duty cycles of both nodes are 1%, the average discovery delay of Circle and Nihao is shorter than that of the other four methods. When the duty cycle of the node is at other values, the average discovery delay of Circle is shorter than that of Nihao. In general, Circle's performance in terms of average discovery delay is the best of the six methods.
The average discovery delay for the asymmetric and symmetric duty cycle cases of the present invention is further described with reference to fig. 5. The abscissa in fig. 5 represents the duty ratio of the node, and the ordinate represents the average discovery delay of the neighbor node.
Fig. 5(a) is a schematic diagram of the average discovery delay in the case of the asymmetric duty cycle of the present invention, and fig. 5(b) is a schematic diagram of the average discovery delay in the case of the symmetric duty cycle of the present invention. In fig. 5, histograms marked by oblique lines represent a graph of the node duty ratio and the node average discovery delay relationship of Disco, histograms marked by a horizontal bar grid represent a graph of the node duty ratio and the node average discovery delay relationship of U-Connect, histograms marked by a vertical grid are a graph of the node duty ratio and the node average discovery delay relationship of Hello, histograms marked by an oblique grid are a graph of the node duty ratio and the node average discovery delay relationship of Hello _ S, histograms marked by white are a graph of the node duty ratio and the node average discovery delay relationship of NiHao, and histograms marked by black are a graph of the node duty ratio and the node average discovery delay relationship of Circle.
As can be seen from fig. 5, Circle, Disco, U-Connect, Hello-S, and Nihao shorten the neighbor discovery delay by 42%, 57%, and 37%, respectively, when the duty ratios are (1%, 5%), (1%, 10%), and (5%, 10%), respectively, and in the asymmetric case, Circle is the shortest of the average discovery delays of the six methods. Under the condition of symmetrical duty ratio, the Circle is the shortest in neighbor node discovery delay among six methods, and therefore the performance of the Circle adopted by the method in the aspect of average discovery delay is better than that of the other five methods.
The foregoing embodiments are merely illustrative of the principles and effects of the present invention, and are not to be construed as limiting the invention. Any person skilled in the art can modify or change the above-described embodiments without departing from the spirit and scope of the present invention. Accordingly, it is intended that all equivalent modifications or changes which can be made by those skilled in the art without departing from the spirit and technical spirit of the present invention be covered by the claims of the present invention.