## 5 Analysis of the Solution and Simulation  
### Analytical and Validation Study  
A theoretical study using analytical expressions and simulation tools allow us to conduct experiments using a system model before deploying the real devices on the field. This study results in a better understanding of the _design parameters_, determining their appropriate ranges and enhancing the use of available resources. The goal is to achieve a suitable performance of SENSED-SG for its subsequent real-operation in a Smart Grid. Consequently, in order to assess diverse figures of merit, we have, on the one hand, derived their most appropriate mathematical equations that can be applied to a Smart Grid and, on the other hand, implemented our proposal in two simulation scenarios. Furthermore, using these figures of merit as the metrics of interest, we have compared our proposal with a ZigBee approach to demonstrate its feasibility. The chosen metrics are the following ones:  
* **Packet Reception Rate (PRR)**: The ratio between the number of received messages and the total amount of messages sent (for an arbitrary pair of sender/receiver nodes). It gives an idea of how well the network performs in term of losses. * **End-to-end delay**: The time elapsed between when a message is generated and it reaches the receiver and gets processed. This metric is especially relevant for scenarios characterized by hard real-time constraints where the \"freshness\" of the information is crucial. * **Energy Consumption**: The total energy consumed by nodes after a given period of time. Since nodes are not equipped with inexhaustible power supplies, this metric is of tremendous importance to extend nodes' lifetimes, and therefore, the network lifetime of the WSN deployed. Although there is a notable amount of _design parameters_ capable of affecting these three metrics in some way, this work is focused on the effects of varying (i) the awake and sleep periods of the duty cycle and (ii) the sensing and reporting frequencies. The duty cycle configuration has a direct impact on all three metrics whereas the reporting and sensing frequencies basically influences the total energy consumed per node. The reason for choosing these parameters instead of any others is twofold: firstly, their higher impact on the metrics compared to others (e.g., the CSMA backoff or the periodicity of route discarding in AODV). And secondly and more important, all of the chosen ones can be adjusted and tweaked at real-time to adapt the network to the dynamics of the Smart Grid. To this end, two approaches will be considered: (i) a mathematical characterization that quantifies the effects of the design parameters on the figures of merit selected. This is done to obtain the analytical expressions that help to calculate the network behavior in future deployments. And (ii) a set of simulations of the network for representative environments is also carried out to _verify and validate_ those _numerical expressions_. In this respect, one of the inherent problems that arises in computer-oriented network simulators is the lack of fine-grained simulation of the nodes behavior at hardware level (in particular, the radio interface and microcontroller specific behaviors). These limitations are not generally taken into account by widespread simulators and play an important role in the global behavior of the system. The problem is aggravated when these simulators ignore a specific node's hardware constraints like memory or computational processing limitations. To relieve this problem, instead oftraditional computer-oriented simulators (like ns-2 or Omnet++), embedded-systems-oriented simulators (such as Avrora and TOSSIM) will be employed. Regarding the simulation frameworks, Avrora [63] is a cycle-accurate instruction-level sensor network simulator capable of measuring detailed time-critical phenomena like the power consumption of each node operating in the WSN. This is the main reason why it is specifically used for providing an in-depth knowledge of WSN devices' consumption profiles.