# Modeling the Energy Performance of LoRaWAN
## 4 Modeling LoRaWAN End-Device Current Consumption
### Unacknowledged Transmission
In order to determine the time needed to transmit a data message via the radio interface, \(T_{tx}\), we take into acount LoRaWAN procedures, LoRa modulation details and the corresponding regional parameters. \(T_{tx}\) can be expressed in terms of the time required to transmit both the preamble and the physical message, denoted \(T_{preamble}\) and \(T_{PHYMessage}\), respectively, as follows [38]:  
\[T_{tx}\ =\ T_{preamble}\ +T_{PHYMessage} \tag{5}\]  
\(T_{preamble}\) can be obtained as shown next [33]:  
\[T_{preamble}=T_{sym}\cdot\left(N_{pre}+4.25\right) \tag{6}\]  
where \(N_{pre}\) is the programmed number of symbols to be used by the radio transceiver, the actual physical length of the preamble is (\(N_{pre}+4.25\)) [7], and \(T_{sym}\) is the time of a symbol (in seconds), which depends on the SF and the channel bandwidth (BW, in Hz), as follows [38]:  
\[T_{sym}=\frac{2^{SF}}{BW} \tag{7}\]  
On the other hand, \(T_{PHYMessage}\) (in seconds) can be evaluated similarly:  
\[T_{PHYMessage}=T_{sym}*N_{PHY} \tag{8}\]  
where \(N_{PHY}\) indicates the number of symbols transmitted as the physical message (excluding the preamble), and it can be determined as follows [38]:  
\[N_{PHY}=8+\max\left[ceil\left[\frac{28+8\cdot PL+16\cdot CRC-4\cdot SF}{4\cdot \left(SF-2\cdot DE\right)}\right]\cdot\left(CR+4\right),0\right] \tag{9}\]  
In (9), \(SF\) corresponds to the spreading factor and can take values from 7 to 12 (which correspond to data rates from DR5 to DR0, respectively); \(CR\) denotes the coding rate and can take values from 1 to 4, for 4/5 to 4/8 coding rate, respectively; \(PL\) indicates the physical payload length, in bytes. \(CRC\) indicates the presence or not of the CRC field in the physical message (\(CRC\) is set to 0 if the CRC field is not present; otherwise, \(CRC\) is equal to 1); finally, \(DE\), which indicates whether the mechanism to avoid issues regarding drift of the crystal reference oscillator is used or not, takes value 1 for SF12 and SF11 (i.e., it is used for the lowest data rates), and value 0 for the rest of SFs. Equations (5)-(9) can be used to model the duration of both uplink and downlink transmissions (e.g., the latter may correspond to acknowledgments sent in response to uplink data messages, see Table 6). After modeling \(T_{tx}\), we proceed to determine the duration of a receive window when no preamble is detected, which occurs in both receive windows in unacknowledged transmission. We next model the behavior of the hardware module used in our experiments in each receive window. For the first receive window, \(T_{rx1w}\) can be determined as follows:  
\[T_{rx1w}=N_{dsym}\cdot T_{sym} \tag{10}\]The end-device stays in receive mode for the duration of \(N_{dsym}\) symbols \(N_{dsym}\) is 8 symbols for SF = 12 and SF = 11, and 12 symbols for the rest of SFs. For the second receive window, the receiver is active during a fraction of a CAD state (see Section 3.2.3). This fraction has a duration, denoted \(T_{rx2w}\), that can be calculated as shown next:  
\[T_{rx2w}=\frac{2^{SF}+32}{BW} \tag{11}\]  
After providing the models for determining \(T_{tx}\), \(T_{rx1w}\) and \(T_{rx2w}\), Table 6 summarizes their main values, along with relevant parameter settings used in our end-device platform. For \(T_{rx2w}\), we include the corresponding values for the different DR settings possible. However, in our experiments, only the \(T_{rx2w}\) value corresponding to DR0 was used. Once all variables required to compute \(I_{avg\_unACK}\) are determined, we can calculate the theoretical lifetime of a battery-operated end-device that performs unacknowledged transmissions, denoted \(T_{lifetime\_unACK}\), can be obtained on the basis of the battery capacity, \(C_{battery}\) (expressed in mA\(\cdot\)h), as shown next:  
\[T_{lifetime\_unACK}=\frac{C_{battery}}{I_{avg\_unACK}} \tag{12}\]  
Note that the above theoretical end-device lifetime calculation assumes an ideal battery with a linear behavior, whereas the characteristics of a real battery degrade over time.