# Energy-Saving Routing Protocols for Smart Cities
## 2 Materials and Methods
### Proposed Radio Power Adjustment (RPA) Routing Protocol for Energy Savings  
The proposed radio power adjustment (RPA) routing protocol is based on the DSR protocol, as DSR shows better overall performance, including the lowest energy consumption, as compared to DVR and AODV. The first step of the proposed RPA routing protocol is to provide a way for Cupcarbon to compute the Radio Signal Strength Indicator (RSSI) from the distance between two nodes according to the log-distance model. This model was chosen because it is independent of the transmission frequency and antenna gain. The log-distance path loss model can be obtained by [38]:  
\[\overline{PL}(d)=\overline{PL}(d_{0})+10n\log\left(\frac{d}{d_{0}}\right), \tag{8}\]  
where \(n\) corresponds to the path loss coefficient (the value of 3.3 was adopted in this work), \(d\) is the distance between the transmitter and the receiver, and \(d_{0}\) is the reference distance. The choice of the value of \(n\) was carried out by taking into account the experimental results obtained in [39]. In these experiments, two devices were used to exchange data using LoRa modulation in an urban environment while evaluating the packet delivery rate and RSSI as a function of the transmission distance. Then, the RSSI curves versus the distance were obtained and compared to the experimental data and the data from the log-distance model, with the value of \(n=3.3\) representing the best fit between the curves. The value of \(\overline{PL}(d_{0})\) represents the path loss for a direct line of sight with respect to the reference distance, and can be obtained by [38]:  
\[\overline{PL}(d_{0})=20 log\left(\frac{4\pi d_{0}}{\lambda}\right). \tag{9}\]  
In Equation (9), \(d_{0}\) is the reference distance and the parameter \(\lambda\) corresponds to the carrier wavelength. Equations (8) and (9) were programmed in CupCarbon. When any data are received, the distance between the transmitting and receiving nodes which are exchanging data is obtained through the computed RSSI function. The second step of the proposed RPA routing protocol is the definition of an equation that relates the computed RSSI value to the minimum \(P_{TX}\) necessary to maintain the communication link. To this end, simulations were performed in Cupcarbon varying the distance between two nodes. In this way, a node \(RX\) was kept fixed and a node \(TX\) was initially moved to a distance equal to the maximum range of 1.7 km; \(P_{TX}\), that is, the transmission power of node \(TX\), was set to the maximum value (20 dBm). Thus, the distance between the nodes was reducedin 50-meter intervals until the minimum distance of 1 m was reached, with the RSSI value calculated for each distance at these intervals. At the same time as the distance was being reduced, at each new displacement point \(P_{TX}\) was reduced in 5% intervals until a minimum value at which the communication link was not lost was reached. The results of this process were then imported into Octave software and an interpolation process was performed applying the _polyfit_ function. To assess which polynomial obtained a better approximation of the original data, the Root Mean Square Error (RMSE) was used as a criterion, resulting in the following mathematical expression being obtained:  
\[ \begin{split} P_{TX}(RSSI)=&-1.161169468381691\times 1 0^{-7}\cdot(RSSI)^{5}\\ &-4.870470506506291\times 10^{-5}\cdot(RSSI)^{4}\\ &-0.008114743288230\cdot(RSSI)^{3}\\ &-0.660852476932444\cdot(RSSI)^{2}\\ &-25.953469491107786\cdot RSSI\\ &-3.829454402717133\times 10^{2}\end{split}  \tag{10}\]  
Finally, this expression was inserted into the DSR protocol code to determine the appropriate \(P_{TX}\) for each RSSI value. To use the proposed RPA routing protocol, it is necessary to add a new column to the routing table that contains the value of \(P_{TX}\) for each destination, this value being initialized with 100% and automatically changed as the simulation is run.