2.5 Applications to wireless sensor networks
3.1.2 The second self-stabilizing MDS algorithm
In [83], Xu et al. presented a self-stabilizing algorithm for the MDS problem using unique identifiers under the synchronous daemon. The stabilization time is O(n). Like Hedetniemi’s algorithm, every node has two variables: a Boolean variable and a pointer. A node will point (i) to the unique IN neighbor, (ii) to itself if it has no IN neighbor, or (iii) to null if it has more than one IN neighbor. A node will enter the MDS if it has no IN neighbor and it has the smallest identifier within its closed neighborhood. A node will leave the MDS under the same condition as in Hedetniemi’s algorithm.
3.1.3 The first linear-move self-stabilizing MDS algorithm assum-ing the distributed daemon
In [75], Turau proposed a linear-time self-stabilizing algorithm (we call it Turau3n) for the MIS problem with the unique identifier assumption. Every node has a variable that may have one of three different values: IN (in the set), OUT (out of the set), or WAIT (an OUT node with no IN neighbor, waiting to join the set). So, Turau3n runs as follows: an OUT node that has no neighbor in the MIS will first change its variable to WAIT. After doing so, the node
CHAPTER 3. SELF-STABILIZING MDS ALGORITHMS 3.1. PREVIOUS RESULTS
may change its variable to IN if it has no WAIT neighbor with a lower identifier. Also, an IN node may leave the MIS and change its variable to OUT if it has an IN neighbor. Algorithm Turau3n is self-stabilizing under an unfair distributed daemon and stabilizes after at most 3n moves with an MIS. Turau3n is shown in Algorithm 2.
Algorithm 2 Turau3n
1: if v.state = OUT∧ ¬inNeighbor(v)
then v.state := WAIT; // wait for change
2: if v.state = WAIT∧ inNeighbor(v)
then v.state := OUT; // stop waiting
3: if v.state = WAIT∧ ¬inNeighbor(v) ∧ ¬waitNeighborW ithLowerId(v)
then v.state := IN; // enter I
4: if v.state = IN∧ inNeighbor(v)
then v.state := OUT; // leave I
Based on Turau3n, Turau extended the rules to design the first self-stabilizing MDS algorithm and we call it Turau9n. Each node has two variables. The first three-valued variable state is defined as the one in Turau3n. The second variable is a pointer variable called dependent. An IN node changes dependent to null. An OUT node changes dependent to null if there is more than one IN neighbor, or to the only one IN neighbor. The entering rule is the same as in Turau3n. Besides, the leaving rule is modified by adding the precondition
“there is no neighbor pointing to it”. Turau proved that Algorithm Turau9n is self-stabilizing under an unfair distributed daemon and stabilizes after at most 9n moves with an MDS.
The detail of Turau9n is shown in Algorithm 3.
CHAPTER 3. SELF-STABILIZING MDS ALGORITHMS 3.1. PREVIOUS RESULTS
dependentN eighbors(v) ≡ ∃w ∈ N(v) : w.dependent = v;
rules
1: if v.state = OUT∧ ¬inNeighbor(v)
then v.state := WAIT; // wait for change
2: if v.state = WAIT∧ inNeighbor(v)
then v.state := OUT; // stop waiting
3: if v.state = WAIT∧ ¬inNeighbor(v) ∧ ¬waitNeighborW ithLowerId(v)
then v.state := IN; v.dependent := null; // enter D 4: if v.state = IN∧ inNeighbor(v) ∧ ¬dependentNeighbors(v)
then v.state := OUT; // leave D
5: if v.state = IN∧ v.dependent ̸= null
then v.dependent := null; // modify the pointer
6: if v.state = OUT∧ uniqueInNeighbor(w, v) ∧ v.dependent ̸= w
then v.dependent := w; // modify the pointer
7: if v.state = OUT∧ moreT hanOneInNeighbor(v) ∧ v.dependent ̸= null
then v.dependent := null; // modify the pointer
3.1.4 The second linear-move self-stabilizing MDS algorithm
In [30], Goddard et al. proposed a 5n-move algorithm (we call it Goddard5n) for the MDS problem with nodes having locally distinct identifiers under an unfair distributed daemon.
When Algorithm Goddard5n stabilizes, the set S = {i : x(i) = 1} is an MDS of the given distributed system. In detail, each node maintains a Boolean variable x and a three-valued variable c. The value x(i) = 1 indicates that i ∈ S, while x(i) = 0 indicates that i ̸∈ S.
The counter c(i) counts the number of IN neighbors: c(i) = 0 indicates that i has no IN neighbor, c(i) = 1 means that i has exactly one IN neighbor, and c(i) = 2 means that i has
CHAPTER 3. SELF-STABILIZING MDS ALGORITHMS 3.2. A (4N − 2)-MOVE MDS ALGORITHM
at least two IN neighbors. The value of c(i) is rectified only when x(i) = 0 and is ignored if x(i) = 1. A node is allowed to join S if it has no IN neighbor and its counter evaluates 0 and it has no lower identifier neighbor having c = 0. On the other hand, a node is allowed to leave the MDS if it has an IN neighbor and the counters of all OUT neighbors evaluate to 2, which means that they all have more than one IN neighbor. Algorithm Goddard5n is shown in Algorithm 4.
Algorithm 4 Goddard5n variables
flag x(i)∈ {0, 1}; // S ={i : x(i) = 1}
integer c(i) ∈ {0, 1, 2}; // counter of N (i)∩ S
rules
D1: if c(i) incorrect ∧(x(i) = 0)
then correct c(i); // rectify counter
D2: if (|N(i) ∩ S| = 0) ∧ (x(i) = 0) ∧ (c(i) = 0) ∧ (̸ ∃j ∈ N(i) : j < i, c(j) = 0)
then x(i) := 1; // enter S
D3: if (|N(i) ∩ S| > 0) ∧ (x(i) = 1) ∧ (∀j ∈ N(i)\S : c(j) = 2)
then x(i) := 0 and make sure c(i) is correct; // leave S
In [30], Goddard et al. showed that Algorithm Goddard5n stabilizes in at most 5n moves under the distributed daemon and it stabilizes in at most 4n + 1 time-steps under the synchronous daemon. Although the publication time of [30] is in 2008 which is later then [75] in 2007, I personally suggest that this paper gives birth to the first linear-time self-stabilizing MDS algorithm since it is received in May 2006, and there is a two month gap before Turau submitted for publication of [75] in July 2006.
3.2 A (4n
− 2)-move MDS algorithm
The purpose of this section is to present our main result: Well4n, a (4n− 2)-move self-stabilizing algorithm for the MDS problem under an unfair distributed daemon. Algorithm
CHAPTER 3. SELF-STABILIZING MDS ALGORITHMS 3.2. A (4N − 2)-MOVE MDS ALGORITHM
Well4n uses four states, which are defined by the four-valued variable state. The range of values of state is: IN, OUT1, OUT2, and WAIT. A node with state = IN will be referred to as an IN node. Let S ={v : v.state = IN}; i.e., S is the set of IN nodes. Nodes with state = OUT1 or OUT2 or WAIT will be referred to as an OUT node.
The values of state have the following meanings. The value IN indicates that the node is in the MDS. The value OUT1 means that the node is not in the MDS and it has a unique IN neighbor. The value OUT2 indicates that the node is not in the MDS and it has at least one IN neighbor. The value WAIT means that the node is not in the MDS and it does not have any IN neighbors. For the MDS problem, a legitimate state means: the distributed system reaches the desired global property that the configuration conforms to MDS. To make it precise, in our self-stabilizing MDS algorithm, a legitimate configuration is: the set of IN nodes form an MDS, and every OUT node with state = OUT1 has a unique IN neighbor, state = OUT2 has at least one IN neighbor, and state = WAIT has no IN neighbor. Notice that a legitimate configuration will not contain any WAIT node.
To formally define the rules of Well4n, the following predicates defined for each node v are needed:
• noBtNbr(v) ≢ ∃ w ∈N(v) : w.state=WAIT ∧ w.id<v.id.
• noDpNbr(v) ≢ ∃ w ∈N(v) : w.state = OUT1.
We now explain the meaning of noBtN br and noDpN br and the idea of using local distinct identifier to break symmetry assuming the distributed daemon. When two or more neighboring nodes want to enter the MDS simultaneously, our algorithm chooses the one with the smaller (smallest) id. According to this, if v is an OUT node and has a neighbor w such that w.state = WAIT and w.id < v.id, then w is called a better neighbor of v. The predicate noBtN br indicates that v has no better neighbor. Also, if v is an IN node and has a neighbor w with w.state = OUT1, then w is called a dependent neighbor of v since w
CHAPTER 3. SELF-STABILIZING MDS ALGORITHMS 3.3. CORRECTNESS AND CONVERGENCE
depends on its unique neighbor in the MDS (the neighbor is v). The predicate noDpN br indicates that v has no dependent neighbor.
For convenience, we introduce
• InNbr(v) = |{u ∈ N(v) | u.state = IN}|.
In the algorithm Well4n, each node executes the six rules shown in Algorithm 5. The state diagram of Well4n is given in Figure 3.1.
Algorithm 5 Well4n
then v.state := OUT1; // rectify the counter
R5: if (v.state = OUT1 ∨ v.state = WAIT) ∧ InNbr(v) > 1
then v.state := OUT2; // rectify the counter
R6: if (v.state = OUT1 ∨ v.state = OUT2) ∧ InNbr(v) = 0
then v.state := WAIT; // rectify the counter
3.3 Correctness and convergence
We now prove the correctness of Well4n.
CHAPTER 3. SELF-STABILIZING MDS ALGORITHMS 3.3. CORRECTNESS AND CONVERGENCE
Figure 3.1: The state diagram of Well4n.
Lemma 3.3.1. In any configuration in which no node is privileged, (a) the number of IN neighbors of every OUT node consistent with its state, and (b) the set S is a minimal dominating set for G.
Proof. For (a), it is easy to check that if the state of an OUT node is inconsistent with the description on the number of its IN neighbors, then a rule can be enabled for this node.
For (b), suppose to the contrary that S is not a minimal dominating set for G. Then either (i) S is not a dominating set or (ii) S is a dominating set but not minimal. First consider (i). Since S is not a dominating set, there exists at least one node u /∈ S which has no IN neighbor; let S′ be the set of all such nodes. Since rule R6 is not enabled, every node in S′ has state = WAIT. Let u0 be the node in S′ with minimum id. Then u0 satisfies all the constraints of rule R1. Hence rule R1 is enabled and this contradicts to the assumption that no node is privileged.
Next consider (ii). Since S is a dominating set but not minimal, there must exist at least one node u∈ S such that S\{u} is also a dominating set for G. Then |N(u) ∩ S| ≥ 1 and for all u′ in N (u)\S, we have |N(u′)∩ S| ≥ 2. Thus, every node u′ in N (u)\S has InN br(u′) > 1. Hence, every node u′ in N (u)\S must have u′.state = OUT2; otherwise rule R5 is enabled on u′. Consequently, node u has noDpN br(u) = true and either InN br(u) = 1 (if|N(u) ∩ S| = 1) or InNbr(u) > 1 (if |N(u) ∩ S| > 1). Hence, either rule R2 or rule R3 is
CHAPTER 3. SELF-STABILIZING MDS ALGORITHMS 3.3. CORRECTNESS AND CONVERGENCE
enabled on node u, which is a contradiction.
Note that when the algorithm terminates, there is no node with state = WAIT. Since R6 is not enabled, any OUT node without an IN neighbor must have state = WAIT. Hence to prove that there is no node with state = WAIT, it suffices to prove that S is a minimal dominating set of G.
We now show that Well4n converges in a finite time. In particular, we show that the num-ber of moves of Well4n is at most 4n− 2. Let k be a nonnegative integer and ⟨r1, r2, . . . , rk⟩ be a sequence of rules (ri’s are not necessarily distinct). The sequence ⟨r1, r2, . . . , rk⟩ is called a move sequence if a node can execute rule r1, then rule r2, . . ., then rule rk. The following two lemmas show that in any possible move sequence of a specific node, rule R1 and rule R6 appear at most once when a distributed system run Well4n for a time period without any external intervention.
Lemma 3.3.2. If a node executes rule R1, then it will not execute any other rule. Conse-quently, if a node enters the set S, then it will never leave S.
Proof. Let v be a node which executes rule R1. Then v.state has been set to IN and thereafter v enters S. By the precondition of rule R1, v has no IN neighbor and no better neighbor;
therefore no neighbor of v enters S at the same time when v enters S. Thus, no node in N (v) that enters S and therefore InN br = 0. After executing rule R1, v.state is IN and the possible rule that v can execute is either rule R2 or rule R3. Rule R2 is impossible since it requires InN br(v) = 1; similarly rule R3 is also impossible since it requires InN br(v) > 1.
Therefore, v will not execute any other rule. The second statement of this lemma now follows.
Lemma 3.3.3. A node can execute rule R6 at most once, or equivalently, a node can set its state to WAIT at most once.
CHAPTER 3. SELF-STABILIZING MDS ALGORITHMS 3.3. CORRECTNESS AND CONVERGENCE
Proof. Let v be a node which executes rule R6 once. By the precondition of rule R6, v has no IN neighbor when executing rule R6. After executing rule R6, v.state is set to WAIT and the possible rules that v can execute is rule R1 or rule R4 or rule R5. If v executes rule R1, then by Lemma 3.3.2, v will not execute any other rule and we have this lemma. If v executes rule R4 or R5, then InN br(v) = 1 or InN br(v) > 1 must be true before rule R4 or R5 is enabled, meaning that v has a neighbor (say, u) which has executed rule R1; by Lemma 3.3.2 again, u will never leave S. Therefore it is impossible to have InN br(v) = 0, which means that v cannot execute rule R6 again.
In the next, we firstly claim that the length of a move sequence of any node in G is at most 4. If this is true, then the total number of moves among all nodes in G is at most 4n.
Furthermore, we improve the upper bound to 4n− 2 and show that this bound is tight.
Theorem 3.3.4. The proposed algorithm Well4n is self-stabilizing under an unfair dis-tributed daemon and it stabilizes after at most 4n− 2 moves with a minimal dominating set, where n is the number of nodes. Moreover, the bound 4n− 2 is tight.
Proof. By Lemma 3.3.1, the algorithm Well4n is correct. To prove that Well4n stabilizes after at most 4n− 2 moves, we first prove that it stabilizes after at most 4n moves, from which we conclude that Well4n has the convergence property. To do this, it suffices to show that any move sequence of a node is of length at most 4 under an unfair distributed daemon.
Let v be an arbitrary node in G. By Lemma 3.3.3, v can execute rule R6 at most once.
Thus, there are two cases: v never executes R6 and v executes R6 once.
First consider the case that v never executes rule R6. Then v.state never changes to WAIT. Thus, the move sequence of v is either ⟨R1⟩ or ⟨R2,R5⟩ or ⟨R4,R5⟩. It follows that any move sequence of v is of length at most 2.
Now consider the case that v executes rule R6 once. In this case, regard a move sequence of v as the concatenation of a prefix and a suffix. By Lemma 3.3.2, the prefix of any move
CHAPTER 3. SELF-STABILIZING MDS ALGORITHMS 3.3. CORRECTNESS AND CONVERGENCE
sequence of v cannot contain rule R1 since if v executes rule R1 then v will not execute any other rule, including rule R6. Hence, the possible prefix of any move sequence of v is either
⟨R2,R6⟩ or ⟨R3,R6⟩ or ⟨R4,R6⟩ or ⟨R5,R6⟩. After v executes rule R6, v.state changes to WAIT. Thus, the possible suffix of any move sequence of v is either ⟨R6,R1⟩ or ⟨R6,R4,R5⟩
or ⟨R6,R5⟩. Concatenating the prefix and suffix, we conclude that any move sequence of v is of length at most 4.
From the above, Well4n stabilizes after at most 4n moves with a minimal dominating set. We now prove that the bound can be strengthen to 4n−2. The cases of n = 1 and n = 2 are trivial. Suppose n≥ 3 and one of the nodes makes 4 moves; by the above argument, this node has two neighbors executing rule R1. Thus, at least two nodes in G make less than 4 moves and the upper bound can be strengthen to 4n− 2.
We now give an example to show that the upper bound 4n− 2 is tight. Consider the complete bipartite graph K2,n−2, where n ≥ 3. Let the two nodes in the partite set of cardinality two have the maximum and the minimum identifiers among the n nodes. If initially all nodes are in state IN, then there is a way that all the rest of the nodes executes
⟨R3,R6,R4,R5⟩ but nodes with the maximum and minimum identifiers execute ⟨R3,R6,R1⟩.
All together 4n− 2 moves are made.
Note that our algorithm Well4n will be equivalent to Goddard5n if rule R4 is modified as follows:
R4’: if (v.state = OUT2 ∨ v.state = WAIT) ∧ InNbr(v) = 1 then v.state := OUT1;
The idea of state OUT1 is to lock the unique IN neighbor. If node v change its state from OUT1 to OUT2, there exists a neighbor u of v entering the set S. By Lemma 3.3.2, u will never leave S. Hence, u will dominate v thereafter. Suppose then another IN neighbor w of v wants to leave S, and somehow it really does. If u becomes the only one IN neighbor of
CHAPTER 3. SELF-STABILIZING MDS ALGORITHMS 3.4. SIMULATIONS AND COMPARISONS
v, then there is no need for v to change its state back to OUT1 since neighbor u will never leave S. Hence the modification we made is reasonable and it can shorten the longest move sequence from ⟨R5,R4,R5,R4,R5⟩ to ⟨R3,R6,R4,R5⟩.
3.4 Simulations and comparisons
Theoretically, we have proven that: in the worst case, Well4n makes the smallest number of moves to stabilize among Well4n, Goddard5n, and Turau9n. However, the average behaviors of these algorithms are not known. This section presents simulations and comparisons of these three algorithms. Notice that we implement the original version of Turau9n since the modified version is incorrect (we explain the reason at the end of this section).
Simulation environments are conducted as follows and we calculate the mean and the standard deviation. We regard the distributed system as a wireless sensor network, where the transmission range of each node is the same. Thus the communication graph of the distributed system is a unit disk graph (UDG). Notice that our simulations only consider UDGs and the underlying graph may not be connected. We consider UDGs since they are the most commonly used models for wireless sensor networks (of course, other classes of graphs can be considered). In our simulations, the transmission range R of all of the nodes is set to from 15m to 45m with a step of 5m (m means meter). For each R, each algorithm is run 1000 times and each time 100 nodes are randomly placed in a square of size 200m × 200m (again, m means meter). The resultant average node degrees are 1.64 (when R = 15), 2.84, 4.35, 6.12, 8.17, 10.40, and 12.86 (when R = 45). In each simulation, we randomly assign each node an initial state and each state of the node is equally likely to happen. In particular, in Goddard5n, each node has four possible states: x(i) = 0∧ c(i) = 0, x(i) = 0∧ c(i) = 1, x(i) = 0 ∧ c(i) = 2, and x(i) = 1.
Recall that a move is called a membership move if its execution makes an IN node
CHAPTER 3. SELF-STABILIZING MDS ALGORITHMS 3.4. SIMULATIONS AND COMPARISONS
changes to an OUT node and vise versa, i.e., if the node executes rule R1, R2, or R3. In each simulation, every node independently computes the next state then summons the distributed daemon. The daemon then chooses a nonempty subset of nodes to make moves. The simulation continues until no node is privileged.
Figures 3.2 and 3.3 show the comparisons of the three algorithms. Figure 3.2 depicts the average number of “moves” with regard to the transmission ranges. In our simulations, Well4n always made fewer moves than Goddard5n and Turau9n. Figure 3.3 illustrates the average number of “membership moves” in terms of the transmission ranges. In our simulations, Goddard5n and Well4n make fewer membership moves than Turau9n. The simulation results show that if the average number of “moves” is considered, then Well4n outperforms Goddard5n; if the average number of “membership moves” is considered, then Goddard5n outperforms Well4n.
Figure 3.2: The average number of moves made by Well4n, Goddard5n, and Turau9n with regard to the transmission ranges, where the vertical line segments denote the standard deviations.
Before ending this section, we would like to point out an error in the modified Turau9n, which is called modified AMDS in [75]. Turau claimed (in page 93 in [75]) that rule 4 can
CHAPTER 3. SELF-STABILIZING MDS ALGORITHMS 3.4. SIMULATIONS AND COMPARISONS
Transmission ranges
Number of membership moves
0 10 20 30 40 50 60 70
15 20 25 30 35 40 45
Well4n Goddard5n Turau9n
Figure 3.3: The average number of membership moves made by Well4n, Goddard5n, and Turau9n in terms of the transmission ranges, where the vertical line segments denote the standard deviations.
be changed by replacing the predicate inN eighbor with inN eighborW ithLowerId so that the total number of moves can be further reduced. We now show that Turau’s claim is incorrect and should be eliminated. Suppose the replacement is done and the resultant rule is called rule 4′. Let G be a path of three nodes v1, v2, v3 and edges v1v2, v2v3; suppose the initial configuration is: v1, v2 are IN nodes with dependent = Λ and v3 is an OUT node with dependent = v2. Suppose vi.id is i. Since{v1, v2} is not an MDS, modified AMDS must make a move. It is not difficult to verify that no rule can be enabled by modifiedAMDS.
Chapter 4
The stableness of MDS algorithms
A node in a distributed system has limited information about the whole system. Usually, a node can only access the information of nodes in its 1-neighborhood. Let k be a positive
A node in a distributed system has limited information about the whole system. Usually, a node can only access the information of nodes in its 1-neighborhood. Let k be a positive