## 3 Multi-MAF: A Hybrid Adaptive Algorithm for Routing in WSNs
### Reactive Component: SID  
On demand algorithms, such as AODV [17] and Push Diffusion [13], define another common approach for routing in ad hoc and sensor networks. In this strategy, the network may remain inactive until the communication process is triggered by sensors whose data is ready to be sent. This is the natural choice for event-driven scenarios in which communication may be triggered by an event detection. Obviously, the advantage of this approach is clearer in situations in which no management or control traffic is required, and periodical wake-up schemes, such as STEM [23] and B-MAC [24], can be used to save more resources while no event is being detected. In this work, we propose a simple reactive algorithm, called SID (Source-Initiated Dissemination). SID is similar to the Push Diffusion [13]. However, SID allows source nodes to flood their data (e.g., when an event is detected) as long as a route is not available, and not only periodically as Push Diffusion proposes. These features make SID more reactive in the presence of network dynamics, but more sensitive in scenarios with intensive traffic. The SID protocol is decribed as follows:  
* A source node that detects an event broadcasts the sensed data, its identification, and a timestamp to all neighbors [Figure 3(a)]. * Whenever a node receives the data sent by another node, it stores its data identification (source node identification and timestamp) and the sender's identification. Eventually the node receives that packet from all neighbors, however, it will store and forward only the first packet. The amount of memory required by the algorithm is proportional to the network size. Other criteria for path formation may be considered, just as mentioned in the EF-Tree description. Figure 2: EF-Tree algorithm. * Similarly, data will arrive at the sink node from all neighbors. Then, the sink will send a control message requesting the data to be sent by the node from which it first received the data. This message identifies the data to be sent. This process is executed periodically by the sink while data is received. * When a node receives this control message (data request), it repeats the process and identifies which node should send that data. This process is repeated until the source nodes are reached, as shown in Figure 3(b). * Once a source node receives the control message requesting its data, it will update its own table so it will send further data packets to the node that first requested it. Thus, data is disseminated through the path where the sink's requisition message arrived [Figure 3(c)], which might be the fastest path in symmetric channels. * In order to allow the network to adjust to eventual topological changes (due to failures, mobility, or node inclusion), requisition messages are periodically sent by the sink towards the sources while data is being received. Once a node (source or relay) stops receiving requisition messages, due to any topological change, the node restarts to send or forward data by broadcast. Thus, if any path exists, data will reach the sink again and it will restart the requisition process. * Once the events disappear, data traffic stop and, consequently, the sink node stops sending requisition messages to source nodes. In the absence of periodic requisition messages for a specific piece of data, the table entries expire and the network becomes inactive again. Comparative Cost Analysis for EF-Tree and SID  
In order to prove the situations in which each algorithm is preferable, we present a comparative cost analysis regarding energy consumption, which is the basis for the Multi-MAF adaptive model. When a path is formed by SID and EF-Tree algorithms, we have an approximated energy cost (in Joules) of data dissemination given by:  
\[Cdata=Pt\cdot Sd\cdot Nh+Pr\cdot Sd\cdot Nh\cdot Nn \tag{1}\]  
representing the cost of data transmission by one source and routers, and the cost of signal reception by neighbors. _Pt_ and _Pr_ are transmission and reception power consumptions, respectively, in Joules/byte.