## 5 Analysis of the Solution and Simulation
### Analytical and Validation Study
Along with Avrora, the TOSSIM simulator is employed in our work to emulate different propagation environments and noise patterns. The choice of TOSSIM is twofold, firstly it simulates the same code that is uploaded into WSN devices, easing and empowering the debugging process; and lastly it enables the definition of propagation and noise parameters, allowing us to accurately study very specific environments. As explained in the previous section, every node switches from the sleep state to the awake state and then returns to sleep periodically. The duration of both states is denoted as **AP** for the awake period, and **SP** for the sleep period. A sender will strive to send its messages in the forthcoming receiver's AP. One of the consequences of the duty cycle is that the shorter the receiver's AP, the fewer attempts the sender will have to get its messages delivered. This situation is depicted in Figure 6 where the red crosses represent message losses due to interferences or collisions. The first relation between design parameters and metrics can therefore be identified: reducing the Active Period will also decrease the number of potential attempts that the sender does for delivering its messages. Consequently, the likelihood of message loss will increase. Defining _P(L)_ as the probability of message loss and \(N\) as the number of attempts, the PRR can be expressed by Equation (1):  
\[PRR=1-P(L)^{N} \tag{1}\]  
The Figure 7a illustrates the value of PRR for different scenarios. As expected, in this figure, we can observe how the PRR increases as the AP grows. This phenomenon is also confirmed by means of TOSSIM simulations (Figure 7b). To this aim the following simulation configuration is set:  
* **Topology:** Two nodes in coverage range. * **Propagation environment:** These two nodes are deployed in three different scenarios. The first one is characterized by very harsh radio propagation conditions (Harsh environment--average probability of packet loss: 0.25). The second environment is defined by its moderately hard propagation conditions (Mild Environment--average likelihood of packet loss: 0.13). And finally the last scenario represents a favorable environment where the average likelihood of  
Figure 6: Figure of our proposed MAC layer. packet loss is around 0.05 (Good Environment). These probabilities of packet lost have been selected as a result of a previous study conducted to characterize different SG propagation environments and are implemented in the simulator by tuning different design parameters of the log-distance path model (path loss exponent, shadowing standard deviation, power decay, _etc._). This model has been widely substantiated and validated in multiple WSN-based approaches applied to SG [64, 65] and therefore, it has been selected as the propagation model for every simulation carried out in this work. * **Message size:** The length of the message is 15 bytes. Due to the CSMA/CA mechanism (total transmission time, ACK waiting time and backoff among others) and hardware limitations (clock frequency of the transceiver and processing unit) nodes can carry out one attempt of transmission each 11 milliseconds; therefore, the Active Period grows in increments of 11 ms to minimize the time the radio is ON--in both figures AP varies from 11 ms to 110 ms (maximum value computed that corresponds to 10 attempts of retransmission). It can be observed that extending the AP from 11 ms to 33 ms (from 1 attempt to 6), the PRR increases up to a 49% in very harsh scenarios. Therefore, more attempts mean a higher probability that messages reach the destination. This is especially important in the Smart Grid, where nodes are expected to be deployed in very noisy and unsteady environments. Then, in the interest of enhancing the network's reliability, the AP should be extended until guaranteeing a significant value of PRR.