## 2 LoRaWAN Overview  
LoRa is a protocol in the physical layer of an IoT network. This protocol operates in the industrial, scientific, and medical radio bands (ISM band), or 902-928 MHz in Thailand. The LoRa protocol can endure the noise floor and interference by Chirp spread spectrum (\(CSS\)) techniques. The highlighted advantages are low power consumption and long-range coverage area. The characteristics of the CSS modulation depend on the LoRa's parameters such as bandwidth (\(BW\)), SF, Coding Rate (\(CR\)), and the airtime defined in terms of the symbol period (\(T_{S}\)) shown in Equation (1). The bit rate (\(R_{b}\)) is related to \(BW\), \(SF\), and \(CR\), as shown in Equation (2).  
\[T_{s}=\frac{2^{SF}}{BW}, \tag{1}\]  
\[R_{b}=SF\times\frac{BW}{2^{SF}}\times CR, \tag{2}\]  
LoRaWAN is a network architecture consisting of end devices or nodes that employ the LoRa protocol for transmitting and receiving packets as well as the LoRa gateway, network server, and application server. In LoRaWAN, we can define the data rate, time-on-air (ToA), and signal range by assigning the SF values, which are the unique parameters in LoRa modulation, as shown in Figure 1.  
LoRaWAN utilizes the Adaptive Data Rate (ADR), which is a default mechanism for optimizing the data rate, airtime, distance, and energy consumption when the signal strength varies dynamically, for example, in the case of dense and moving nodes. The link budget is the RSSI sensitivity level, which depends on the Signal-to-Noise Ratio (\(SNR\)), Noise Figure of receiver (\(NF\)), and bandwidth (\(BW\)). The link budget is presented in terms of the sensitivity value (\(S\)) shown in Equation (3). The SNR limit is dependent on the end device, and the \(NF\) of a typical LoRa gateway chipset is 7 dB [11]. The sensitivity level is also displayed in Figure 1.  
\[S=-174+10 logBW+NF+SNR_{lim}, \tag{3}\]  
Time-on-air (ToA) refers to the amount of time a device spends transmitting a packet. It is a crucial metric that directly impacts network performance and energy consumption. In a network with nodes and a single gateway, \(ToA\) can be considered synonymous with latency. \(ToA\) can be calculated using Equation (4).  
\[ToA=T_{preamble}+T_{payload} \tag{4}\]  
where  
Figure 1: Relationship of SF, data rate, ToA, energy consumption, and sensitivity level.  
\(T_{premble}\) is the preamble duration (in second);  
\(T_{payload}\) is the payload duration (in second);  
\(T_{payload}\) is directly proportional to the number of payload symbols (\(n_{payload}\)), which can be calculated as  
\[n_{payload}=8+max\bigg{[}Ceil\bigg{(}\frac{8 PL-4 SF+28+16 CRC-20H}{4(SF-2 DE)} \bigg{)}\times(CR+4),0\bigg{]}, \tag{5}\]  
where  
\(PL=\) Payload Length (in Bytes);  
\(H=\) the explicit header (\(H=0\) when enabled, = 1 when not);  
\(CRC=\) the Cyclic Redundancy Check (\(CRC=1\) when enabled, = 0 when not);  
\(CR=\) Coding Rate (\(CR=1\), 2, 3, 4);  
\(DE=\) Low Data Rate Optimization (\(DE=1\) when used, = 0 when not).  
It can be deduced from Equations (4) and (5) that ToA is indeed a function of SF value and also increases with the SF value, as illustrated in Figure 1.  
Equation (6) demonstrates the direct correlation between the total ToA and total energy consumption (\(E\)) (in joules) across all \(S\) identical nodes, indicating that higher SF values lead to increased energy consumption. Note that the transmission current as well as the supplied voltage to the node are assumed equal for all nodes.  
\[E=\sum_{n=1}^{S}{(ToA_{n}\times I\times V)}, \tag{6}\]  
where  
\(ToA_{n}\) is the ToA of the successfully sent \(n\)th node (in seconds);  
\(I\) is the transmission current of the node (in A);  
\(V\) is the supplied voltage to the node (3 V) [2].