## 5 Sensor-Stream Reduction  
Finally, the third aspect of our data-centric strategy considers the sensor-stream reduction algorithm (\(\mathbf{\Psi}\)). The objective of this reduction is to try to meet deadlines from real-time applications while keeping data fidelity (accuracy). The proposed sensor-stream reduction is motivated by the problem stated in Section 2. and evaluated in processing phase of project design described in Section 3. The in-network (data-centric) reduction algorithm is integrated into a shortest-path routing tree. In this case, the routing tree is built, based on application requirements, from the sink (root) to the sources nodes by using a flooding strategy. In this flooding, \(h_{dst}\) and \(t_{dst}\) values are delivered to every sensor node. Once the routing tree is built, the source node can send \(\mathbf{V}\) towards the sink. At this moment, relay nodes receive \(\{\mathbf{V}^{1}\ldots\mathbf{V}^{n_{f}}\}\) in some packets (fragments) and forward them to another relay node until the sink is reached. In this forward process, when a relay node receives \(\mathbf{V}^{1}\), it checks the stream reduction criterion, in our case if \(gap>0\) (Equation 5). If the criterion is satisfied \(\mathbf{V}^{1}\) is stored and the node waits to receive and store \(\{\mathbf{V}^{2}\ldots\mathbf{V}^{n_{f}}\}\). Otherwise, all fragments are forwarded. It is important highlighted that this forwarding is in routing layer, considering the sensor radio, certainly, the fragments are queued until the sender radio turns able. Based on the _real-time information_, \(|\mathbf{V}^{\prime}|\) is computed through Equation 6. When all fragments arrive, the \(\mathbf{\Psi}\) reduction is enabled. This forwarding process is shown in Algorithm 1. ```
Data: \(\mathbf{V}^{j}\) - fragment stream received
1 begin
2 \"Get from \(\mathbf{V}^{j}\) the fragments information\" if\(j=1\)then
3 \"\(gap\) is computed through equations (2-4)\" if\(gap>0\)then
4 \"Enable \(\mathbf{V}\) storage\" \(|\mathbf{V}^{\prime}|=p_{s}\,\left(1+\frac{h_{src}\,h_{dst}\,(d_{l}-t_{dst}) }{h_{dst}\,t_{src}+h_{src}\,t_{dst}}\right)-1\) {Equation 6}
5 end if
6 end if
7 ifStorage is enabledthen
8 \"Store \(\mathbf{V}^{j}\)\" if\(j=n_{f}\)then
9 \(\mathbf{V}^{\prime}\leftarrow\) \"Compute \(\mathbf{\Psi}\) on \(\mathbf{V}\) with \(|\mathbf{V}^{\prime}|\) size\" \"Send \(\mathbf{V}^{\prime}\)\"
10 end if
11 end if
12
13 else
14 \"Forward \(\mathbf{V}^{j}\)\"
15 end if
16
17 end if
18
19 end for
```  
**Algorithm 1**Pseudo-code of reduction decision. When the reduction is able, a histogram of \(\mathbf{V}\) is built (line 13 of Algorithm 1). We consider a simple histogram, all elements sensed are between \([0;1]\) and we have \(10\) equals histogram classes. To obtain such a sample, we choose the central elements of each histogram class, respecting the sample size \(|\mathbf{V}^{\prime}|\) and the class frequencies of the histogram. Thus, the resulting sample will be represented by the same histogram. Meanwhile, considering the sensor-stream reduction algorithm presented by [PERSON] _et al._[40], the sample elements are randomly chosen in each histogram class instead of considering the central elements. The reduction algorithms, used here, and their operations are depicted in Figure 3. The random sampling (a), we have a \"stream in \(\mathbf{V}\)\" with \(100\) elements, \(|\mathbf{V}^{\prime}|\to 50\%\) of \(\mathbf{V}\) is randomly chosen (this choice is performed in each histogram class), and then a \"stream out \(\mathbf{V}^{\prime\prime}\)\" is generated with \(|\mathbf{V}^{\prime}|=50\). The central sampling (b), we have again a \"stream in \(\mathbf{V}\)\" with \(100\) elements, \(|\mathbf{V}^{\prime}|\to 50\%\) of \(\mathbf{V}\) is choice considering the central histogram classes elements, and then a \"stream out \(\mathbf{V}^{\prime\prime}\)\" is generated with \(|\mathbf{V}^{\prime}|=50\). In order to identify both algorithms, in simulation study (Section 6.