Skip to main content
. 2018 Sep 24;18(10):3221. doi: 10.3390/s18103221
Algorithm 1 The CS-DDSG algorithm
Input:
 The probability of selecting source nodes: P1;
 The probability of forwarding: P2;
 The number of measurements: M;
Output:
 Measurement vector: y;
 Measurement matrix: Φ;
Stage 1:
1: for i = 1:N
2: S(i).id = [i];
3: S(i).data = xi;
4: end for
Stage 2:
5: Nodes select themselves with the probability p1 and broadcast their packets;
6: N2 = 0;
7: for i = 1:N·p1
8: for j = 1:N
9: if node i receives the broadcasting data from node j
10: S(j).id = [j,i];
11: S(j).data = xj + xi;
12: N2 = N2 + 1;
13: end if
14: end for
15: end for
Stage 3:
16: The receiving nodes in Stage 2 forward their update packets with probability p2.
17: N3 = N2p2;
18: for loop = 1:max
19: if N3 ≤ 1
20: break
21: end if
22: if node j forwards its packets
23: for i = 1: N
24: if node i has not received a packet and hears node j
25: S(i).id = [i,j];
26: S(i).data = xi + xj;
27: N3 = N3 + 1;
28: end if
29: end for
30: end if
31: The reception nodes in the stage 3 forwarding their packets with probability p2.
32: end for
Stage 4:
33: The mobile sink queries M nodes to generate Φ and Y .
34: Φ = zeros (M, N)
35: if node ik are queried
36: Ωk = S(ik).id;
37: Φ(k, Ωk) = 1;
38: end if
39: Return Φ and Y.