## 4 SENSED-SG Design and Protocols
### SENSED-SG Network Layer  
In our integral WSN-based system, the SENSED-SG network layer is in charge of providing message forwarding, and in particular, accomplishing the routing tasks. Basically, this layer enables nodes out of the sink node's range to deliver their messages to this node by means of a routing protocol. The design of a routing protocol must be based on the features of its target networks [59]; in line with this, engineering a routing protocol for a Smart Grid involves not only overcoming the challenges imposed by this environment (high electromagnetic interferences, lack of inexhaustible energy sources, _etc._) but also exploiting some beneficial features of it, such as the absence of nodes' mobility (power assets are installed in fixed emplacements) and the robustness of the wireless network topology (although WSN nodes may fail, the probability of such event is relatively low [21]). Bearing in mind these features, challenges and benefits, our proposed routing protocol is designed according to the following directions:  
* To minimize the number of messages sent and, therefore, to reduce power consumption, instead of making use of a proactive approach, nodes will explore a route to a given destination only when required, following, to this aim, a reactive approach. Unlike proactive routing protocols, reactive solutions are mainly used in larger networks (as those used in Smart Grids) where it is not necessary to maintain an up-to-date routing table in each node with all the possible destinations (as required in proactive protocols). The construction of this routing table implies a higher routing overhead (a great amount of messages are needed to be sent) and a notable increase in memory resources. Under these premises and as starting point, we have employed the [PERSON]'s reactive implementation of the AODV (_Ad hoc_ On-Demand Distance Vector) algorithm for the TinyOS operating system [60]. * In agreement with the effort made in reducing the number of network messages, we take advantage of the aforementioned robustness of the wireless topology: we assume that once the network topology is generated, few changes will take place in the near future. Therefore, when a node receives a route request from a neighbor, instead of re-broadcasting it (as it happens in most cases in the traditional AODV), if that node knows how to answer that request, it will directly send the reply message to its neighbor, sharply reducing the number of route request messages. This is even more significant when the routing protocol is built on top of a MAC layer specifically designed for unicast delivering. Note that route requests are messages broadcast to all possible nodes in coverage range, and therefore, these messages cannot benefit the phase-lock mechanism; resulting in a higher power consumption and a reduction in the network throughput. * Unlike traditional routing protocols that only consider the hop count to select the best route for a message, our proposal goes beyond, including the link quality indication (LQI) as a reliable method for assessing the quality of the link and the interference level. The use of the LQI has been selected as the preferred metric to estimate the goodness of a specific link over the traditional Received Signal Strength Indicator (RSSI) in a WSN [61]. This is all the more true when a WSN operates in a hostile environment as it occurs in a Smart Grid. The SG is full of electromagnetic interferences that can produce higher values of RSSI in certain links, which in turn would trick nodes into choosing non-optimal paths. Therefore, the hop count together with the LQI will be used to estimate the best route for a message to follow. Like most routing protocols, our approach depends on broadcasting packets to nodes in the coverage area to obtain important routing information. However, when combined with duty-cycling techniques (in which nodes are sleeping most of the time), broadcast messages are not usually heard by neighbors.