## 4 Performance Analysis of QoS Metrics
### Evaluation of PDR for the Transmission Power Level (\(P_{\text{Trans}}\)) and Energy Consumption
#### 4.1.2 Energy Consumption and Network Life at Different P\({}_{\text{Trans}}\) Levels
 } & \multirow{2}{*}{ \begin{tabular}{c} **Consumption** \\ **(μ)** \\ \end{tabular}  } & \multirow{2}{*}{\ \begin{tabular}{c} **Consumption** \\ **(μ)** \\ \end{tabular}  } & \multirow{2}{*}{ \begin{tabular}{c} **Sumption** \\ **(μ)** \\ \end{tabular}  } & \multirow{2}{*}{The energy consumption for each stage of the transmission is calculated with Equation (3) where \(I\) is the average current consumption, \(Rsh\) is the shunt resistor of 9 \(\Omega\) across which the XBee module is connected, and \(T\) is the duration of that stage. \[\text{Energy Consumption}=I^{2}R_{sh}T \tag{3}\]  
From Tables 5 and 6, we can see that for both the encrypted and unencrypted communication, the energy consumption is highest with a transmission power level of 5 dBm and the lowest with 1 dBm. As encrypted communication performs functions, such as encrypting the data before transmission and decrypting the data after reception, it consumes more energy for all the transmission levels in comparison with unencrypted communication. However, provided the security that the AES encryption provides to the communication, this increased energy consumption for the encryption is considerable and is recommended for most indoor and outdoor IoT applications. The energy consumption is highest in the data reception stage, which is followed by the radio standby stage for all the mentioned cases. One of the interesting facts of both encrypted and unencrypted communication is that the difference of the total energy consumption between a 1 and 3 dBm P\({}_{\text{Trans}}\) level is very little in comparison with the energy consumption difference between 3 and 5 dBm. In fact, with encrypted communication, this difference of energy consumption between P\({}_{\text{Trans}}\) levels of 1 and 3 dBm is almost inconsiderable. On the contrary, if PDR for different P\({}_{\text{Trans}}\) levels is analyzed, it is noticeable that PDR improved significantly from 1 to 3 dBm. As with 1 dBm, at 40 m, the PDR drops drastically to 75% and 50%, respectively, for outdoor and indoor environments; it is beyond consideration. With 3 dBm, the PDR is 100% up to a transmission distance of 35 and 30 m, respectively, for outdoor and indoor environments. Moreover, this drops to 96% and 86% for outdoor and indoor environments, respectively, at a transmission distance of 40 m, which is decent for most IoT applications. As with very little increase of energy consumption from 1 to 3 dBm, the PDR improves radically, the 3 dBm transmission power level is recommended by authors for network optimization. To improve the PDR further with a 5 dBm P\({}_{\text{Trans}}\) level, the energy consumption increase will significantly decrease the overall network life dramatically. Thus, 3 dBm is chosen for the rest of the study and analysis. The impact of the transmission power level on the network lifetime would be much more obvious by analyzing the network lifetime of the considered XBee S2C module. The network lifetime of any node can be calculated from the current consumption and duration of each stage of data transmission, which is presented in Tables 5 and 6. For calculating the network lifetime of any node, we formulated Equations (4)-(7) where \(T_{active}\) is the total duration, \(I_{active}\) is the total consumed current during the transmission of a single packet. The XBee module is configured to go to sleep immediately after the data transmission and wake-up after the predefined sleep time for the next transmission. The duration between two consecutive data transmissions is sleep time, which is configured by the user. The total number of transmissions in any given time depends on this user-defined sleep time, which is denoted by \(T_{slap}\). The current consumption during \(T_{slap}\) is minimum, which is 0.6 mA for the XBee S2C module and is presented by \(I_{slap}\) in Equation (6). The total lifetime of a node is calculated by Equation (7) and is presented with \(T_{lifetime}\) where \(B_{capacity}\) is the capacity of the DC source of the node in mAh [53].