• No results found

II. Sensor Data Faults Detection

4. Fault Detection Based on Spatial Correlation

4.5. Protocol Design

In this section, we present how the fault detection technique is incorporated into ex- isting WSN data collection protocols, especially how the computation is distributed among nodes. Details of real world implementation in TinyOS are presented as well. A sequence diagram showing the whole life cycle of the proposed solution is listed in Figure 4.6. The whole data collection procedure starts with a learning phase, in which the objective is to learn the spatial model (discussed in Section 4.3.2),

Chapter 4. Fault Detection Based on Spatial Correlation

Figure 4.6.: An overview of the message passing sequence.

which later will be used for both the verifier selection test and fault detection in the operational phase. More specifically, after being reached by their sink, the relevant source nodes broadcast its sensor readings to its one-hop distance neighbours as learning data. After receiving the learning data, each potential verifier node learns the corresponding spatial model via the formula presented in Theorem 4.1 or 4.2. At the end of the phase, i.e. after a predefined amount of learning data is sent by the source node, each potential verifier tests itself whether it is an eligible verifier node via the test listed in Theorem 4.3. The test result, if positive, is sent back to the corresponding source node. Upon this point, each source node and its corresponding eligible verifier nodes have established their source-verification relationships, and the eligible verifiers have also learnt the spatial models for its corresponding source nodes. Note that we differentiate source node and verifier node here only for the sake of illustration; however, each sensor can serves as both source and verifier node at the same time. Algorithm 4.3 summarises the steps involved in the learning phase. The operational phase, in which the actual data collection takes place, is ensued after the learning phase. In group validation scenario, each sampled data entry, before sending back to the sink, will be verified sequentially by its corresponding verifiers via the test discussed in Theorem 4.4. This is achieved via a simple routing protocol maintained by the source node. The source node inserts a FIFO queue of verifier addresses in the order of the desired verification sequence into the original data message, as shown in List 4.1. The verifier node whose address matches the

Algorithm 4.3 Learning spatial model Input: msg: received learning data message

1: if Packet.src(msg)∈Nbr then .If the source node is within one hop dis-

tance 2: eimsg.sensorDatalocalData

3: toUpdate← dataValidate(ei) .Apply Theorem 4.4 with α=αupdatefor

robust learning with prior 4: if !toUpdate then

5: discard ei

6: else

7: n++

8: update corresponding parameters via Theorem 4.1 or 4.2. 9: end if

10: end if

11: if n== LearningDataSize then .Learning phase finishes

12: verifier node test via Theorem 4.3 13: if test is positive then

14: notify source node .Notify the source node if test is positive

15: else

16: discard corresponding model .Delete the model parameters to save

space 17: end if

18: end if

destination verifies the contained data. Note that, according to our group voting mechanism (4.21), the data under validation does not need to go through all the checks, as it is only classified as faulty if all its verifiers give the same positive result. Therefore, based on the verification result, the current verifier can sets the message destination either to the next verifier in the queue, or the sink, if the test result is negative, i.e. not faulty. The data message will finally be delivered to the sink by an ordinary WSN routing protocol, like the collection tree protocol [77]. To make the local model adaptive, the verifiers who have verified the data also need to update its local spatial model according to Equation (4.22). To give each verifier equal chance to update their local models and, more importantly, to balance the work load among verifiers, it is advisable for the source node to change the verifier sequence queue from time to time by rotating the queue or even shuffle the sequence. The data validation procedure is summarised in Algorithm 4.4.

Figure 4.7 shows an example of WSN deployment which features the proposed data validation technique. There are two source nodes, S1 and S2; each with its

Chapter 4. Fault Detection Based on Spatial Correlation t y p e d e f n x _ s t r u c t V r f R a d i o M s g { n x _ u i n t 1 6 _ t s o u r c e I d; /* N o d e id of s o u r c e m o t e . */ n x _ u i n t 1 6 _ t c o u n t; /* E p o c h c o u n t */ n x _ u i n t 8 _ t q I n d e x; /* F r o n t of the vrf q u e u e */ n x _ u i n t 8 _ t q S i z e; /* The s i z e of the q u e u e */ n x _ u i n t 1 6 _ t v r f Q u e u e[M A X Q S i z e]; /* V e r i f i e r a d d r s Q u e u e */ n x _ u i n t 1 6 _ t v o l t a g e; n x _ u i n t 1 6 _ t s e n s o r D a t a; /* S e n s o r d a t a f r o m s o u r c e */ n x _ u i n t 8 _ t v r f R s t; /* A B o o l e a n f l a g s the vrf r e s u l t so far */ } V r f R a d i o M s g _ t;

Listing 4.1: Verification message layout

Algorithm 4.4 Data validation at a verifier node Input: msg: a radio message ofVrfRadioMsg_t received

Output: Check the contained data and forward the msgaccordingly

1: if Packet.isForMe(msg) then

2: (isFault, toUpdate)← dataValidate(msg.sensorData)

. Data test via Theorem 4.4

3: if toUpdate==true then

4: updateModel(msg.sensorData) . Model update using Equation (4.22)

5: end if

6: msg.qIndexmsg.qIndex+ 1

7: if isFault ==true&& msg.qIndex<msg.qSizethen

. If it is a fault, forward to the next ver-

ifier

8: Packet.destination(msg) ←msg.vrfQueue[msg.qIndex]

9: Packet.send(msg)

10: else . Else flip the flag and send to the sink

11: msg.vrfRstfalse

12: Packet.destination(msg) ←root

13: Packet.send(msg)

14: end if 15: end if

Figure 4.7.: A WSN deployment with spatial fault detection

both source node and verifier node for S1 in this case. We use hollow arrows to

represent the message passing for local data validation; while the regular arrows are used to mark message relay to the sink. In this round, source node S2 sets

its verification sequence as [V3, V4, V5]. However, the group validation mechanism

finalises its decision before reachingV5; therefore, the verified data is enroute to the

sink directly.