A Distributed and Deterministic TDMA Algorithm for Write-All-With-Collision Model
aa r X i v : . [ c s . O S ] A ug A Distributed and Deterministic TDMA Algorithm forWrite-All-With-Collision Model ∗ Mahesh ArumugamCisco Systems, Inc.,San Jose, CA 95134Email: [email protected]
Abstract
Several self-stabilizing time division multiple access (TDMA) algorithms are proposed forsensor networks. In addition to providing a collision-free communication service, such algorithmsenable the transformation of programs written in abstract models considered in distributedcomputing literature into a model consistent with sensor networks, i.e., write all with collision(WAC) model. Existing TDMA slot assignment algorithms have one or more of the followingproperties: (i) compute slots using a randomized algorithm, (ii) assume that the topology isknown upfront, and/or (iii) assign slots sequentially. If these algorithms are used to transformabstract programs into programs in WAC model then the transformed programs are probabilis-tically correct, do not allow the addition of new nodes, and/or converge in a sequential fashion.In this paper, we propose a self-stabilizing deterministic TDMA algorithm where a sensor isaware of only its neighbors. We show that the slots are assigned to the sensors in a concur-rent fashion and starting from arbitrary initial states, the algorithm converges to states wherecollision-free communication among the sensors is restored. Moreover, this algorithm facilitatesthe transformation of abstract programs into programs in WAC model that are deterministicallycorrect.
Keywords: time division multiple access (TDMA), distance 2 coloring, self-stabilization, program transformation, write all with collision (WAC) model, sensornetworks ∗ Contact Information:Address: 170 W. Tasman Dr, San Jose, CA 95134Phone: +1-408-853-3547Fax: +1-408-527-9537URL: http://aumahesh.googlepages.com/ Introduction
One of the important concerns in programming distributed computing platforms is the model ofcomputation used to specify programs. Programs written for distributed computing platforms suchas sensor networks and embedded systems often have to deal with several low level challenges ofthe platform. In sensor networks, especially, one has to write programs that deal with issues suchas communication, message collision and race conditions among different processes. Therefore, tosimplify the programming, it is important to abstract such low level issues. In other words, theability to specify programs in an abstract model and later transform them into a concrete modelthat is appropriate to the platform is crucial.The problem of transformation of programs in an abstract model to programs in other modelsof computation has been studied extensively (e.g., [1–6]). These transformations cannot be appliedto obtain concrete programs for sensor networks as the model of computation in sensor networks is write all with collision (WAC) model. In WAC model, communication is local broadcast in nature.As a result, whenever a sensor executes an action , it writes the state of all its neighbors in oneatomic step. However, if two neighbors j and k of a sensor (say i ) try to execute their write actionsat the same time then, due to collision, state of i will remain unchanged. The actions of j and k may update the state of their other neighbors successfully. Existing transformations for WAC model.
Recently, several approaches have been proposedto transform programs written in abstract models considered in distributed computing literatureinto programs in WAC model [7–10]. Such transformation algorithms can be classified into twocategories: (a) randomized [7, 8] and (b) deterministic [9, 10].In [7], the authors propose a cached sensornet transform (CST) that allows one to correctlysimulate an abstract program in sensor networks. This transformation uses carrier sensor multipleaccess (CSMA) based MAC protocol to broadcast the state of a sensor and, hence, the transformedprogram is randomized. And, the algorithm in [9] uses time division multiple access (TDMA)to ensure that collisions do not occur during write actions. Specifically, in WAC model, eachsensor executes the enabled actions in the TDMA slots assigned to that sensor. And, the sensorwrites the state of all its neighbors in its TDMA slots. If the TDMA algorithm in [11], a self-stabilizing and deterministic algorithm designed for grid-based topologies, is used with [9] then thetransformed program in WAC model is self-stabilizing and deterministically correct for grid-basedtopologies. And, if randomized TDMA algorithms proposed in [8, 12] are used with [9] then thetransformed program is probabilistically correct. Finally, the algorithm in [10], a self-stabilizing anddeterministic TDMA algorithm for arbitrary topologies, allows one to transform abstract programsinto programs in WAC model that are deterministically correct for arbitrary topologies.In this paper, we are interested in stabilization preserving deterministic transformation forWAC model. As mentioned above, a self-stabilizing deterministic TDMA algorithm enables such atransformation. One of the drawbacks of existing self-stabilizing deterministic TDMA algorithms(e.g., [10]) is that the recovery is sequential. Specifically, in [10], whenever the network is perturbedto states where the TDMA slots are not collision-free, a distinguished sensor (e.g., base station)initiates a recovery process and each sensor recomputes its slots one by one. However, it is desirablethat the network self-stabilizes from such arbitrary states in a distributed and concurrent manner(without the assistance of distinguished sensors).
Contributions of the paper.
To redress this deficiency, in this paper, we propose a self-stabilizing deterministic TDMA algorithm that provides concurrent recovery. In this algorithm,whenever a sensor observes that the slots assigned to its neighbors are not collision-free, it initiatesa recovery. As a result, its neighbors recover to legitimate states (i.e., the slots are collision-free)and the network as a whole self-stabilizes concurrently. We show that the algorithm supportsaddition or removal of sensors in the network. While a removal of a sensor does not affect thenormal operation of the network, our algorithm ensures that the slots assigned to removed sensor1re reused. And, our algorithm supports controlled addition of new sensors in the network. Inaddition, we propose an extension to our algorithm that improves the bandwidth allocation of thesensors.
Organization of the paper.
The rest of the paper is organized as follows. In Section 2, weintroduce the models of computation considered in distributed computing platforms. We formallystate the problem definition of TDMA and identify the assumptions made in this paper. In Section3, we present our distributed TDMA slot assignment algorithm for WAC model. We show thatthe algorithm is self-stabilizing. Also, we discuss extensions that allow dynamic addition/removalof sensors, improve bandwidth allocation, and synchronize time. Then, in Section 4, we compareour algorithm with related work. Finally, in Section 5, we summarize our work and identify futureresearch directions.
In this section, we define the models of computation, formally state the problem, and discuss theassumptions made in this paper.
A computation model limits the variables that a program can read and write. Program actions aresplit into a set of processes (i.e., sensors). Each action is associated with one of the processes inthe program. We now define shared memory model and WAC model.
Shared memory model.
In this model, in one atomic step, a sensor can read its state as wellas the state of all its neighbors and write its own state.
Write all with collision (WAC) model.
In this model, each sensor consists of write actions(to be precise, write-all actions). In one atomic step, a sensor can update its own state and thestate of all its neighbors. However, if two or more sensors simultaneously try to update the state ofa sensor, say, k , then the state of k remains unchanged. Thus, WAC model captures the fact that amessage sent by a sensor is broadcast. But, if multiple messages are sent to a sensor simultaneouslythen, due to collision, it receives none. Distributed TDMA slot assignment.
TDMA is the problem of assigning communicationtime slots to each sensor. Two sensors j and k cannot transmit in the same slot if their communi-cation interferes with each other. In other words, j and k cannot transmit in the same slot if thecommunication distance between them is less than or equal to 2. To model this requirement, weconsider the sensor network as a graph G = ( V, E ) where V is the set of all sensors and E is thecommunication topology of the network. More precisely, if sensors u ∈ V and v ∈ V can communi-cate with each other then the edge ( u, v ) ∈ E . Finally, distance G ( u, v ) identifies the communicationdistance between u and v in G . The communication distance is the number of links in the shortestpath between the two sensors. Thus, the problem statement of TDMA is shown in Figure 1. Problem Statement: Distributed TDMA Slot Assignment
Consider the communication graph G = ( V, E ) ; Given a sensor j ∈ V , assign time slots to j such that the following condition is satisfied: k ∈ V ∧ k = j ∧ distance G ( j, k ) ≤ ⇒ slot .j ∩ slot .k = ∅ where slot .i identifies the slots assigned to sensor i . Figure 1: Problem statement of distributed TDMA slot assignment2 efinition 2.1 (TDMA frame) In TDMA, time is partitioned into fixed sized frames. EachTDMA frame is divided into fixed sized slots. In this paper, we ensure uniform bandwidth allocationamong sensors. Therefore, each sensor is assigned one slot in every TDMA frame. A sensor isallowed to transmit in the slots assigned to it.
Definition 2.2 (TDMA period) The length of the TDMA frame is called the TDMA period. Morespecifically, it is the interval between the slots assigned to a sensor in consecutive frames.
Distance 2 coloring.
The problem statement of TDMA is similar to the problem of distance 2coloring. Distance 2 coloring algorithm assigns colors to all the sensors in the network such that thecolors assigned to distance 2 neighborhood of a sensor are unique. The color assigned to a sensoridentifies the initial TDMA slot of that sensor. The sensor can compute its subsequent TDMAslots using TDMA period. Ideally, TDMA period P = ( d + 1), where d is the maximum degree ofthe network. (We refer the reader to [10] for a proof that the number of colors required to obtaindistance 2 coloring is at most d + 1.) Thus, Figure 2 states the problem definition of distance 2coloring. Problem Statement: Distance 2 Coloring
Consider the communication graph G = ( V, E ) ; Given a sensor j ∈ V , assign a color to j such that the following condition is satisfied: k ∈ V ∧ k = j ∧ distance G ( j, k ) ≤ ⇒ color .j = color .k where color .i identifies the color assigned to sensor i . Figure 2: Problem statement of distance 2 coloring
Self-stabilization.
An algorithm is self-stabilizing iff starting from an arbitrary state, it: (a)recovers to legitimate state and (b) upon recovery continues to be in legitimate states forever [13,14].Extending this definition, we have the problem statement of a self-stabilizing TDMA slot assignmentalgorithm as shown in Figure 3.
Problem Statement: Self-Stabilizing TDMA Slot Assignment
Consider the communication graph G = ( V, E ) ; A TDMA slot assignment algorithmis self-stabilizing iff starting from arbitrary initial states, the algorithm recovers to thefollowing state: j ∈ V ∧ k ∈ V ∧ k = j ∧ distance G ( j, k ) ≤ ⇒ slot .j ∩ slot .k = ∅ and continues to remain in this state forever. Figure 3: Problem statement of self-stabilizing TDMA slot assignment
In this paper, we do not assume the presence of a base station. In our algorithm, the sensors col-laborate among themselves to obtain distance 2 coloring and TDMA slot assignments. We assumethat each sensor knows the IDs of the sensors that it can communicate with. This assumption isreasonable since the sensors collaborate among their neighbors when an event occurs. We assumethat the maximum degree of the graph does not exceed a certain threshold, say d . This can beensured by having the deployment follow a certain geometric distribution or using a predeterminedtopology. Finally, we assume that the clocks of the sensors are synchronized. Later, in Section 3.5,we discuss how sensors can synchronize their clocks.3 TDMA Slot Assignment Algorithm
In this section, we present our distributed and deterministic TDMA algorithm. First, in Section3.1, we give the outline of the algorithm. Then, in Section 3.2, we present the algorithm in detail.Specifically, we discuss how the network self-stabilizes starting from arbitrary initial states to stateswhere the slots are assigned as identified in Figure 3. Subsequently, in Section 3.3, we illustrateour algorithm with an example. And, in Section 3.4, we discuss the convergence and scalabilityproperties of the algorithm. Finally, in Section 3.5, we discuss extensions to this algorithm.
Initially, the colors assigned to the sensors may be arbitrary. As a result, the communication amongthe sensors may not be collision-free. To achieve collision-free communication among the sensors, inthis algorithm, we adopt distributed reset (e.g., [15]) approach. More specifically, whenever collisionsare observed for a particular slot (i.e., color) for a threshold number of consecutive TDMA frames(say, at j ), the algorithm resets the colors of appropriate sensor(s) in the neighborhood of j . Inother words, a reset computation is used to update the colors assigned to the sensors such that thesensors in distance 2 neighborhood of j have unique colors and, thus, ensure that slots assigned tothem are collision-free at j .Towards this end, j schedules a reset computation in its current TDMA slots. It schedules thereset such that the following requirements are satisfied: (i) reset computations of others sensors inthe distance 2 neighborhood of j do not interfere with each other and (ii) when j initiates reset,the sensors in the distance 3 neighborhood of j have stopped transmitting. The first requirementensures that only one reset computation is active in a given neighborhood at any instant. Otherwise,simultaneous resets in a distance 2 neighborhood may result in collisions and/or sensors choosingconflicting colors. The second requirement ensures that the reset messages and update messagesare communicated in a collision-free manner.Whenever a sensor, say k , receives the reset message from j , first, it updates the color informationit maintains about its distance 1 and distance 2 neighbors. Next, it checks if it has to change thecolor in response to the reset. If k needs to update its color, it chooses a non-conflicting coloramong the sensors in its distance 2 neighborhood. And, subsequently, k broadcasts change colormessage in its newly computed slots.Now, whenever a sensor, say l , receives the change color message from k , first, it cancels anyscheduled reset computations. Subsequently, l updates the color information it maintains about itsdistance 1 and distance 2 neighbors. When j receives change color message , it sends restart message to signal its distance 3 neighborhood to restart application communication. Thus, the algorithmresets the neighborhood of j to deal with a collision at j . However, note that one reset computationmay not be sufficient to restore the state of the network. In this section, we discuss the algorithm in detail. This is a 5-step algorithm: (1) observe collisionand schedule reset computation, (2) send reset message, (3) update color, (4) notify color, and (5)restart communication. Now, we discuss each of these 5 steps. These steps may be repeated untilthe network self-stabilizes to legitimate states.
Step 1: Observe collision and schedule reset computation.
If a sensor, say j , observescollision at slot c x (i.e., color c x ) for a threshold number of consecutive frames then it schedules areset computation. Towards this end, first, j appends c x to collisions .j , the list of collision slotsit has observed so far. Also, it adds ( f c .j, c x ) to timestamp .j , where f c .j is the frame in which4 observed the collision at slot c x . If j observed a collision for the first time then j determinesthe slot in which it can send a reset message . Sensor j schedules a reset computation such thatrequirements identified in Section 3.1 are met. Requirement 1: Ensure only one active reset in the neighborhood.
To satisfy this requirement, j schedules the reset computation in TDMA frame f reset .j = f c .j + ID .j + D timeout , where ID .j is the ID of sensor j and D timeout is defined below. This ensures that if two sensors observe acollision simultaneously, then their resets are scheduled in unique frames. On the other hand, ifthe sensors observe a collision in different frames, it is possible that their resets are scheduled inthe same frame. However, before a sensor initiates a reset, requirement 2 ensures that the distance3 neighborhood has stopped. As a result, the sensor that observed a collision earlier will be ableto proceed with the reset without any collision. Requirement 2: Ensure distance 3 neighborhood has stopped.
Suppose j has scheduled reset in f reset .j . Before j initiates reset, it has to wait until its distance 3 neighborhood stops transmittingmessages. Towards this end, j stops transmitting for at least D timeout frames before it fires thereset. D timeout is the number of TDMA frames required for distance 3 neighborhood of j to stoptransmitting messages. Specifically, when j stops, its neighbors will notice that j has stopped. Asa result, distance 1 neighbors of j stop. Likewise, distance 2 and distance 3 neighbors of j stop.To prevent false positives, neighbor, say l ∈ N.j , stops only after it detects that j has stopped fora threshold number of consecutive frames, stoptimeout . Therefore, in order to ensure that distance3 neighborhood of a sensor has stopped, D timeout ≥ stoptimeout . Step 2: Send reset message.
Each sensor, say j , maintains the state of its distance 2neighborhood: nbrClr .j (contains the state of distance 1 neighbors of j ) and dist2Clr .j (containsthe state of distance 2 neighbors of j ). Each entry in nbrClr .j contains color assignment and thelast frame in which j or its neighbors received a message from the corresponding sensor. Likewise,each entry in dist2Clr .j contains color assignment and the last frame in which one of the neighborsof j received a message from the corresponding sensor. Initially, nbrClr .j contains arbitrary colorassignments that may not reflect the accurate state of all its distance 1 neighbors. And, dist2Clr .j may not reflect the actual distance 2 neighbors and their state. Notation.
We denote an entry in nbrClr .j as ( k, c k , f k ); this indicates that j last received amessage from k in frame f k and in slot (i.e., color) c k . Entries in dist2Clr .j are denoted similarly.Additionally, we use “-” to wildcard or ignore a field in an entry. For example, ( − , c x , − ) indicatesthat we are interested in entries that have the color c x . Additionally, we denote the current frameat j as f current .j .Sensor j initiates a reset in frame f reset .j only if it has not stopped transmitting in responseto another reset. From Step 1, we note that j sends the reset message to its distance 1 neighborsin a collision-free manner. The reset message format is shown in Figure 4. The message includesthe state of distance 1 neighbors that j knows currently, list of collisions and their timestamps, thesensor that should update its color in response to this reset, and the initiator of the reset (in thiscase, j ). Sensor j selects the sensor that should update its color based on IDs of the neighbors that j did not hear for a threshold number of consecutive frames. rm j . neighborState neighbor color lastReceived j color.j f current .j nbrClr .jrm j . collisionInfo collisions .jrm j . resetTimestamp timestamp .jrm j . sensorToChange l , where l ∈ N.j is the sensor with lowest ID for which j did not hear any thing for a threshold number of frames rm j . initiator j Figure 4: Reset message of j , rm j heorem 3.1 Reset computation initiated by any sensor executes in a collision-free manner.
Proof.
Suppose two reset computations execute simultaneously in a distance 2 neighborhood. Let k and l be two unique sensors that have initiated the reset such that distance G ( k, l ) ≤
2. Both k and l should have observed a collision in the same frame and scheduled resets to start at the sameframe. Otherwise, either one of them would have observed that that the neighbors have stoppedin response to a reset of the other and, hence, it would have stopped as well. Therefore, we have, f reset .k = f reset .l . In other words, f c .k + ID .k + D timeout = f c .l + ID .l + D timeout . Withoutloss of generality, assume that ID .k < ID .l . Now, we have f c .k > f c .l . More specifically, l observedthe collision before k did. This is a contradiction. Step 3: Update color, if necessary.
Whenever a sensor, say k , receives the reset message rm j , first, it cancels any scheduled reset. Next, it updates its neighbor state using the informationin rm j . Specifically, it updates nbrClr .k with the color information of the initiator of the reset j .And, it updates nbrClr .k and dist2Clr .k using the information in rm j about distance 1 neighbors of j . Towards this end, we proceed as shown in Figure 5. (Note that k updates an entry in nbrClr .k or dist2Clr .k only if the initiator j had received a message from the corresponding sensor mostrecently than that of k .) if ( j = rm j . initiator ∧ ( j, c j , − ) ∈ rm j . neighborState ) nbrClr .k = { nbrClr .k − ( j, − , − ) } ∪ ( j, c j , f current .k )if ( p ∈ N.j ∧ ( p, c p , f ) ∈ rm j . neighborState ∧ ( p, − , f ) ∈ nbrClr .k ∧ f < f ) nbrClr .k = { nbrClr .k − ( p, − , − ) } ∪ ( p, c p , f )else if ( p N.k ∧ ( p, c p , f ) ∈ rm j . neighborState ∧ ( p, − , f ) ∈ dist2Clr .k ∧ f < f ) dist2Clr .k = { dist2Clr .k − ( p, − , − ) } ∪ ( p, c p , f ) Figure 5: Updating nbrClr .k and dist2Clr .k of sensor k Sensor k then checks if it has to update its color. If k = rm j . sensorToChange then j requires k to update its color. Sensor k updates its color as shown in Figure 6. Specifically, if color .k is in rm j . collisionInfo , k chooses a color c from K (i.e., the set of all available colors) such that there isno collision in slot c at j and is unique among its distance 2 neighborhood. if ( k = rm j . sensorToChange ∧ color .k ∈ rm j . collisionInfo ) { potentialColors = { c | c ∈ K ∧ c rm j . collisionInfo ∧ ( − , c, − ) nbrClr .k ∧ ( − , c, − ) dist2Clr .k } color .k = min ( potentialColors ) } Figure 6: Updating color assignment of sensor k Step 4: Notify color. If k = rm j . sensorToChange , it sends change color message cm k to allits neighbors as shown in Figure 7 (regardless of whether it changed its color or not). Specifically, k sends its color information, nbrClr .k , and the initiator of the reset. Whenever a sensor receives change color message , first, it cancels any scheduled resets. Next, it updates its nbrClr and dist2Clr similar to the discussion shown in Figure 5. Specifically, if l receives cm k , it updates nbrClr .l with( k, c k , f current .l ), where ( k, c k , − ) ∈ cm k . neighborState . Similarly, l updates nbrClr .l and dist2Clr .l based on neighbor state information in cm k . cm k . neighborState neighbor color lastReceived k color.k f current .k nbrClr .kcm k . initiator j Figure 7: Change color message of k , cm k heorem 3.2 If a sensor updates its color in response to a reset then the change color messageof that sensor is communicated in a collision-free manner.
Proof.
Let j be the initiator of the reset. And, l ∈ N.j updates its color in response to thereset of j . When j initiates the reset ( rm j ), distance 3 neighbors of j have stopped transmitting.Therefore, when l sends change color message cm l , neighbors of l will receive it successfully. Hence,all neighbors of l will get the latest color assigned to l . Step 5: Restart communication.
Whenever j initiates a reset, it expects to receive a changecolor message from rm j . sensorToChange before its next allotted slot in f current .j + 1 frame. If j receives the change color message from the sensor that changed the color in response to resetof j , j cleans collisions .j and timestamp .j . Then, it signals its neighbors to restart applicationcommunication. Specifically, it sends restart message , sm j ; the format of sm j is the same as change color message as shown in Figure 7. Once a sensor receives sm j , it updates nbrClr and dist2Clr and starts application communication in its slots. Continuing in this fashion, the distance3 neighborhood of j restart their communication. Note that the restart operation updates thecolor assignment of l = rm j . sensorToChange at distance 2 neighborhood of l , potentially causingcollisions at some distance 2 neighbors of l . When a sensor hears a restart message or collision, itrestarts application communication.On the other hand, if l = rm j . sensorToChange did not send change color message (possibly,due to failure of l ) then j marks l as potentially failed . And, it cleans collisions .j and timestamp .j .Also, it sends the restart message as mentioned above. In future resets at j , j will not set l in rm j . sensorToChange . If l has indeed failed, the extension proposed in Section 3.5.1 will reclaimthe slots assigned to l . Otherwise, sensor j will remove l from the list of potentially failed sensorswhen j hears a message from l . Theorem 3.3
If a sensor changes its color in response to a reset, eventually, the distance 2 neigh-borhood of that sensor learn the state of the sensor.
Proof.
Suppose k ∈ N.j updates its color in response to a reset initiated by j . Distance 3neighborhood of j have stopped transmitting in response to the reset of j . Therefore, we canconclude that sensors in distance 2 neighborhood of k have stopped transmitting. Now, when k sends change color message cm k , distance 1 neighbors of k receive it successfully. When j sends restart message , some distance 2 neighbors of k are updated about the state of k . However, itis possible that when distance 1 neighbors of k forward this restart, collisions may prevent somedistance 2 neighbors of k to not receive the update. On the other hand, k will also witness thiscollision, and, as a result, schedules a reset computation in future frames. Hence, eventually, stateof k will be updated at all the sensors in its distance 2 neighborhood.We note that in this algorithm at most one neighbor is recovered in any reset. Therefore, if twoor more sensors are involved in a collision at j then j still observes collisions after reset. Subsequentresets at j or at other sensors will eventually restore collision-free communication at j . Thus, wehave Theorem 3.4
Eventually, the network self-stabilizes to the states where collision-free communica-tion among the sensors is restored.
In this section, we illustrate the TDMA slot assignment algorithm with an example. We considerthe topology shown in Figure 8(a). The color assignments of each sensor is specified along with the7D of the node. For example, 2(1) denotes that sensor 2 is assigned color 1. Initially, we assumethat f current = 0 at all sensors. Based on initial color assignments, we can note that every sensorobserves a collision. Sensors shown as filled circles denote that they have observed a collision.Figure 8: Illustration of the TDMA slot assignment algorithmAssuming that the sensors have observed the collision for a threshold number of times, theyschedule reset computation. Specifically, each sensor determines the frame in which it can send areset message. Each sensor, say j , determines the frame for reset as follows: f reset .j = f current + ID .j + f t , where f t = D timeout . Figure 8(b) shows the frames in which the sensors have scheduledthe reset computation.In this illustration, as shown in Figure 8(c), sensor 0 sets rm . sensorToChange = 1. As aresult, sensor 1 changes its color to 2. Then, it sends a change color message , cm (cf. Figure 8(d)).Once sensor 0 receives cm , it updates its state and sends restart message , sm (cf. Figure 8(e)).Once sensors 1 and 2 receive sm , they restart their communication. Continuing in this fashion,distance 3 neighborhood of sensor 0 restart communication. However, as we can observe fromFigure 8(f), message communication is still not collision free. Sensors then schedule subsequentreset computations and, finally, as shown in Figure 8(g), collision-free communication is restored.The convergence time for the network shown in Figure 8(a) is 4 f t +18 frames. If we had used theapproach proposed in [10], where a base station initiates slot revalidation then the whole network isstopped (in response to missing token circulation). By contrast, in our algorithm, only the sensorsin the distance 3 neighborhood of the initiator are stopped.8 .4 Convergence and Scalability As discussed in Section 3.2, at most one sensor is recovered at the initiator in any reset computation.Assuming no failure of sensors, if a sensor observes x collisions then, in the worst case, it takes x resets to recover its neighbors. Additionally, we also note that reset computations are scheduledbased on the IDs of the sensors in order to avoid interference among them. If two sensors that arenot in the distance 3 neighborhood of each other initiate a reset then it is possible that resets arescheduled far apart even though there is no interference among them.To improve the convergence and scalability of the algorithm, we can use the neighborhoodunique naming scheme proposed in [8] that assigns unique IDs for sensors within any distance 3neighborhood. This reduces the ID space of the network. Hence, two sensors not in the distance 3neighborhood of each other can schedule their reset computations close to each other. As a result,the convergence time of the algorithm is improved.Regarding scalability, first, we note that unlike [10], convergence can takes place in parallel ifthe initiators of resets are not in the distance 3 neighborhood of each other. And, since we adoptneighborhood unique naming scheme, the ID space of the network is small. Thus, integratingneighborhood unique naming scheme from [8] improves the convergence time and scalability of ouralgorithm. In this section, we discuss some extensions to our TDMA algorithm. First, in Section 3.5.1, weprovide an extension that allows the sensors to deal with failure of their neighbors. Then, in Section3.5.2, we present an approach to deal with addition of new sensors in the network. Subsequently,in Section 3.5.3, we present an optimization that that improves the bandwidth allocation of thesensors. Finally, in Section 3.5.4, we discuss how time synchronization can be achieved.
In our algorithm, whenever a sensor (say j ) hears a collision, it schedules a reset computation torestore collision-free communication. On the other hand, if j does not hear a message or observe acollision in a given slot, it could be because of the one of the following factors: (i) suppose k ∈ N.j is the neighbor that is assigned the corresponding color; k may be failed, (iii) k may have stoppedin response to a reset, or (iii) k does not have any data to send. If a sensor fails, the TDMA slotsassigned to other sensors are still collision-free and, hence, normal operation of the network is notaffected. However, the slots assigned to the failed sensors are wasted. In this section, we discussan approach to reclaim slots assigned to failed sensors.First, we introduce control message . Each sensor transmits a control message once in every T control frames. This message includes the color assignment of the sensor and its nbrClr . And, T control is determined when the network is deployed and is chosen based on how frequently thenetwork changes. If topology changes are common, a smaller T control lets the sensors to quicklylearn the state of their neighbors. On the other hand, a larger T control is more appropriate for anetwork that changes only occasionally.To reclaim the slots assigned to failed sensors, we proceed as follows. Sensor j concludes that k ∈ N.j has failed if f current .j − lastReceived k > T control , where ( k, − , lastReceived k ) ∈ nbrClr .j .Specifically, if j sees that it did not receive any message from k for more than T control frames, itconcludes that k has failed.When j concludes k has failed, it sets ( k, − , failed ) in nbrClr .j . And, sends control message , control j . Whenever a sensor receives control j such that ( k, − , failed ) ∈ control j . neighborState , itmarks k as failed. The active neighbors of j remove ( k, − , − ) from nbrClr or dist2Clr . This allows9he sensors to reuse the color assigned to k to other sensors (in case of dynamic addition of newsensors or during reset computations). However, if k has not failed, it announces its presences inits current TDMA slots by sending control k . When neighbors of k receive this message they updatetheir nbrClr . Subsequently, distance 2 neighbors of k also restore the state of k . In this section, we discuss an approach to dynamically add new sensors in the network. Thisapproach is similar to [10]. Suppose a sensor (say p ) is added to the network such that the maximumdegree of the network is not changed. Before p starts transmitting application messages, it listensto the message communication of its neighbors. To let p learn the colors used in its distance 2neighborhood, we extend our algorithm as follows.Sensor p waits for T control frames before it participates in the network. This allows p tolearn distance 1 and distance 2 neighbors and their color assignments (from control messages of itsneighbors). After T control , p chooses a color. Next, p announces its presence to its neighbors bysending a control message in its newly computed slot. When a sensor receives a control message from p , it adds p to its neighbor list and updates nbrClr . Subsequently, distance 2 neighbors of p also learn its presence and update their dist2Clr .Thus, this approach allows the addition of new sensors in a neighborhood such that it does notviolate the maximum degree assumption. However, if two or more sensors are added simultaneously,it is possible that they may choose the same color and, as a result, cause collisions. Since ouralgorithm is self-stabilizing, the network will eventually self-stabilize to states where the colorassignments are collision-free. In this section, we discuss an approach to improve the bandwidth allocation of the sensors. Thisapproach allows the sensors to reduce the TDMA period and, hence, get better bandwidth allo-cation. The basic intuition behind this extension is that if c x is the maximum color used in thenetwork, the ideal TDMA period should be c x + 1.In this approach, each sensor (say j ) maintains maxColor .j that denotes the maximum colorused in its distance 2 neighborhood. It also maintains controlMax .j that denotes the maximumcolor used in the network. Note that j may not yet have the accurate information about themaximum color used in the network.To improve the bandwidth allocation of the sensors, we extend the control message (discussed inSection 3.5.2) as shown in Figure 9. Any sensor in the network may decide to improve bandwidthallocation in the network. Let j decides to improve bandwidth allocation. It sends a control mes-sage , control j that includes control j . maxColorInfo =max( controlMax.j , maxColor .j ). Sensor j alsoindicates when the sensors can switch to new TDMA period, i.e., control j . switchOn = f switchOn .j ,where f switchOn .j ≥ f current .j + 2 T control . (We discuss why this is necessary later.) control j . maxColorInfo c = max ( controlMax .j, maxColor .j ), where maxColor .j is the maximum in { c x | ( − , c x , − ) ∈ nbrClr .j ∨ ( − , c x , − ) ∈ dist2Clr .j ∨ c x = color .j } control j . switchOn f switchOn .j Figure 9: Extending control message for improving bandwidth allocationWhenever k receives control j with maxColorInfo , k sets controlMax .k = max( controlMax .k , control j . maxColorInfo ). It also notes down the frame in which it can switch to the new TDMAperiod, i.e., f switchOn .k = max ( f switchOn .k, control j . switchOn ). Thus, continuing in this fashion,10ach sensor will eventually learn the maximum color used in the network, i.e., controlMax . And,each sensor also knows the ideal TDMA period (i.e., controlMax + 1).Once the sensors have learned the maximum color used in the network, they can update theirTDMA period. However, this operation should occur synchronously. In other words, all the sensorsshould update their TDMA period at the same time. Otherwise, collisions may occur. To addressthis issue, first, we note the following. If the TDMA slots assigned to the sensors are consistentthen all the sensors learn the maximum color used in the network in at most 2 T control frames,where T control is the period between two successive control messages (cf. Section 3.5.2). Since theinitiator of this operation includes the frame in which new TDMA period is effective, each sensorknows exactly when to switch. Thus, the TDMA period can be updated to reflect the ideal value.Additionally, a sensor can request for unused bandwidth in its distance 2 neighborhood usingthe approach proposed in [10] that negotiates with the neighbors to lease unused slots. In our algorithm, we assume that the sensors have identical clocks. In this section, we show howour algorithm can be extended to synchronize time across the network. Again, in this extension, weuse control message to synchronize time. Specifically, whenever a sensor (say j ) transmits controlmessage , control j , it includes the information shown in Figure 10. control j . timesynchInfo real time current frame wallClock .j f current .j Figure 10: Extending control message for time synchronizationSpecifically, the control message includes the real clock value at j and current frame at j . Basedon this information and the color assigned to j , a sensor determines start of the frame in wall-clocktime. Whenever a neighbor (say k ∈ N.j ) receives the control message, it updates wallClock .k with control j . timesynchInfo , if required. And, k determines the start of the frame and updates it framenumber and slot number accordingly.Continuing in this fashion, time synchronization is achieved in the network. In addition, in thecase where the TDMA slots are consistent, we can integrate synchronization algorithms proposedin the literature for sensor networks. For example, time synchronization services such as [16–18]could be integrated with our algorithm. These services synchronize the sensors to within a fewmicroseconds. We also expect that performance of the time synchronization service will improveas TDMA provides a collision-free communication medium. Related work that deals with self-stabilizing deterministic slot assignment algorithms include [10,11, 19, 20]. In [11], Kulkarni and Arumugam proposed self-stabilizing TDMA (SS-TDMA). In thisalgorithm, the topology of the network is known upfront and remains static. Also, a base stationis responsible for periodic diffusing computations that assign/revalidate the slots of the sensors.Unlike [11], in the proposed algorithm, the sensors are aware of only their neighbors and there isno designated sensor that is responsible for the slot assignment.In [10], Arumugam and Kulkarni proposed self-stabilizing deterministic TDMA algorithm.Again, this algorithm assumes the presence of the base station that is responsible for token circu-lation. And, the slots are assigned in sequential fashion. By contrast, the algorithm proposed inthis paper assigns slots in a concurrent fashion and no token circulation is required.In [19], Danturi et al proposed a self-stabilizing solution to dining philosophers problem where11 process cannot share the critical section (CS) with non-neighboring processes also. This problemhas application in distance-k coloring, where k is the distance up to which a process cannot shareCS. This algorithm requires each process p to maintain a tree rooted at itself that spans theprocesses with whom p cannot share CS using algorithms in the literature. However, the algorithmis written in shared memory model. On the other hand, the proposed algorithm can be used insensor networks directly and also allows one to transform abstract programs into programs in WACmodel.In [20], BitMAC is proposed for collision-free communication in sensor networks. One of theimportant assumptions in this paper is that when two messages collide the result is an OR operationbetween them. This algorithm is not self-stabilizing. Unlike [20], our algorithm is written for WACmodel and is self-stabilizing.Related work that deals with randomized algorithms for TDMA slot assignment include [8,12]. In [8], Herman and Tixeuil proposed a probabilistic fast clustering technique for TDMAslot assignment. In this algorithm, first, a maximal independent set that identifies the leaders iscomputed. These leaders are then responsible for distance 2 coloring. In [12], Busch et al proposeda randomized algorithm for slot assignment. The algorithm operates in two phases: (1) to computethe slots and (2) to determine the ideal TDMA period. Both these phases are self-stabilizing andcan be interleaved. Unlike [8, 12], our algorithm is deterministic.Several other TDMA algorithms are proposed in the literature (e.g., [21–24]). However, mostof these algorithms are not self-stabilizing and/or make assumptions that are not relevant to WACmodel or sensor networks. In this paper, we presented a self-stabilizing deterministic TDMA slot assignment algorithm forwrite all with collision (WAC) model. We showed that the algorithm allows sensors to concurrentlyrecover and self-stabilize starting from arbitrary states. Towards this end, we used distributed resetto restore the state of the network quickly. More specifically, whenever a sensor observes a collisionfor a threshold number of consecutive TDMA frames, it schedules a reset computation to recoverits distance 2 neighborhood. We showed that at most one reset operation executes in a distance 3neighborhood at any instant. And, we showed how the sensors recover in response to resets andreach legitimate states that satisfy the problem statement of TDMA.Additionally, as discussed in [9], our algorithm is applicable in transforming existing programsin shared memory model into programs in WAC model. This allows one to reuse existing solutionsin distributed computing for problems such as routing, data dissemination, synchronization, andleader election in the context of sensor networks. Thus, the algorithm proposed in this paper al-lows one to transform such solutions and evaluate them in sensor networks. As a result, we canrapidly prototype sensor network applications. (We refer the reader to [25] for examples of suchtransformations.) Moreover, this algorithm demonstrates the feasibility of a deterministic transfor-mation of a program in shared memory model into a program in WAC model while preserving theself-stabilization property of the original program.There are several possible future directions. While this algorithm demonstrates concurrentrecovery of TDMA slots and the recovery time is expected to be reasonable for typical deployments,one future direction is to extend this algorithm to provide faster convergence. Additionally, whileour experience in transformation of abstract programs to WAC model (cf. [25]) suggests that theefficiency of the program obtained by transformation is close to that of manually designed programs,another future direction is to quantify the efficiency of the transformed programs.12 eferences [1] G. Antonoiu and P. K. Srimani. Mutual exclusion between neighboring nodes in an arbitrary system graph tree thatstabilizes using read/write atomicity.
In Euro-par’99 Parallel Processing, Springer-Verlag , LNCS:1685:824–830, 1999.[2] M. Gouda and F. Haddix. The linear alternator.
In Proceedings of the Third Workshop on Self-stabilizing Systems , pages31–47, 1997.[3] M. Gouda and F. Haddix. The alternator.
In Proceedings of the Fourth Workshop on Self-stabilizing Systems , pages48–53, 1999.[4] K. Ioannidou. Transformations of self-stabilizing algorithms.
In Proceedings of the 16th International Conference onDistributed Computing (DISC), Springer-Verlag , LNCS:2508:103–117, October 2002.[5] H. Kakugawa and M. Yamashita. Self-stabilizing local mutual exclusion on networks in which process identifiers are notdistinct.
In Proceedings of the 21st Symposium on Reliable Distributed Systems (SRDS) , pages 202–211, 2002.[6] M. Nesterenko and A. Arora. Stabilization-preserving atomicity refinement.
Journal of Parallel and Distributed Computing ,62(5):766–791, 2002.[7] T. Herman. Models of self-stabilization and sensor networks.
Workshop on Distributed Computing , 2003.[8] T. Herman and S. Tixeuil. A distributed TDMA slot assignment algorithm for wireless sensor networks.
In Proceedingsof the Workshop on Algorithmic Aspects of Wireless Sensor Networks (AlgoSensors), Springer , LNCS:3121:45–58, 2004.[9] S. S. Kulkarni and M. Arumugam. Transformations for write-all-with-collision model.
Computer Communications , 2006.[10] M. Arumugam and S. S. Kulkarni. Self-stabilizing deterministic time division multiple access for sensor networks.
AIAAJournal of Aerospace Computing, Information, and Communication (JACIC) , 3:403–419, August 2006.[11] S. S. Kulkarni and M. Arumugam. SS-TDMA: A self-stabilizing mac for sensor networks. In
Sensor Network Operations .Wiley-IEEE Press, 2006.[12] C. Busch, M. M-Ismail, F. Sivrikaya, and B. Yener. Contention-free MAC protocols for wireless sensor networks.
InProceedings of the 18th Annual Conference on Distributed Computing (DISC) , 2004.[13] E. W. Dijkstra. Self-stabilizing systems in spite of distributed control.
Communications of the ACM , 17(11), 1974.[14] S. Dolev.
Self-Stabilization . The MIT Press, 2000.[15] A. Arora and M. Gouda. Distributed reset.
IEEE Transactions on Computers , 43(9):1026–1038, 1994.[16] S. Ganeriwal, R. Kumar, and M. Srivastava. Timing sync protocol for sensor networks.
In Proceedings of the InternationalConference on Embedded Networked Sensor Systems (SenSys) , November 2003.[17] T. Herman. NestArch: Prototype time synchronization service. NEST Challenge Architecture. Available at: , January 2003.[18] J. van Greunen and J. Rabaey. Lightweight time synchronization for sensor networks.
In Proceedings of the Workshop onWireless Sensor Networks and Applications (WSNA) , September 2003.[19] P. Danturi, M. Nesterenko, and S. Tixeuil. Self-stabilizing philosophers with generic conflicts.
In Proceedings of the EighthInternational Symposium on Stabilization, Safety, and Security of Distributed Systems , November 2006.[20] M. Ringwald and K. R¨omer. BitMAC: A deterministic, collision-free, and robust MAC protocol for sensor networks.
InProceedings of the European Workshop on Sensor Networks (EWSN) , 2005.[21] V. Claesson, H. L¨onn, and N. Suri. Efficient TDMA synchronization for distributed embedded systems.
In Proceedings ofthe 20th IEEE Symposium on Reliable Distributed Systems (SRDS) , pages 198–201, October 2001.[22] W. B. Heinzelman, A. P. Chandrakasan, and H. Balakrishnan. An application-specific protocol architecture for wirelessmicrosensor networks.
IEEE Transactions on Wireless Communications , 1(4):660–670, October 2002.[23] K. Sohrabi and G. J. Pottie. Performance of a novel self-organization protocol for wireless ad-hoc sensor networks.
InProceedings of the IEEE Vehicular Technology Conference , pages 1222–1226, 1999.[24] K. Arisha, M. Youssef, and M. Younis. Energy-aware TDMA-based MAC for sensor networks.
In Proceedings of the IEEEWorkshop on Integrated Management of Power Aware Communications, Computing and Networking (IMPACCT) , May2002.[25] Mahesh Arumugam.
Rapid prototyping and quick deployment of sensor networks . PhD thesis, Michigan State University,2006. Available at: ..