# Collision Avoidance Adaptive Data Rate Algorithm for LoRaWAN
## 4 System Model  
We consider a LoRaWAN network using European regional parameters with confirmed traffic transmissions for Class A end devices. The network uses modulation with a fixed bandwidth of 125 kHz and consists of one GW positioned in the centre of the coverage region. We assume that the GW can emulate eight receivers operating in parallel on the channel line-up given in [15]. EDs are static and homogenous and located randomly with uniform distribution in the coverage area. The network covers a topographical area of 10 km by 10 km. EDs generate packets of fixed payload for a given SF at the same application data interval regardless of the proximity to the GW. The transmission start time for each ED is chosen randomly. In our algorithm, the NS uses the average SNR values [46; 47] of the previous four packets sent by the ED to approximate the link quality, in comparison with the standard ADR protocol that uses the maximum SNR value of twenty packets, saving on computational costs [42]. In this context, the traffic model for every ED is considered to be periodic and uniformly distributed. This means that the data transmission from each ED occurs at regular intervals and is spread evenly across the network. We use the Log Distance Propagation path loss model [48]. This model provides a way to estimate how the signal strength decreases as it travels over a distance, taking into account factors like attenuation and interference. The system model incorporates the interference arising from simultaneous uplink transmissions on a specific appropriate uplink transmission. A transmitted packet will be received or dropped according to the sensitivity values given in Table 1. Therefore, SF should be allocated to an ED, guaranteeing that the received signal strength is higher than the receiver sensitivity, as shown in (3) below.  
\[SNR_{margin}=SNR_{avg}-SNR_{thresh}-D_{margin}, \tag{3}\]  
where \(SNR_{avg}\) denotes the average SNR of the packets in the ReceivedPacketList, \(SNR_{thresh}\) is the minimum SNR threshold, and \(D_{margin}\) is the device margin. The received signal power at the GW in dB is given in (4):  
\[P_{rx(dB)}=P_{tx}(dB)+G_{a}(dB)-L_{p}(dB)\,, \tag{4}\]  
where \(P_{tx}\) is the transmit power at the \(i^{th}\) ED, \(G_{a}\) is the antenna gain, and \(L_{p}\) is the path loss.  
The path loss propagation is given by:  
\[L_{p}=-10\log_{10}(d_{i}^{\alpha}f_{c}^{2}*10^{-2.8})\,, \tag{5}\]  
where \(d_{i}\) is the distance between the \(i^{th}\) ED and the gateway, \(\alpha\) is the pathloss exponent (3.76), and \(f_{c}\) is the carrier frequency (868.1 MHz).  
The network is partitioned into K regions wherein K represents the number of available spreading factors. The simulations are conducted using an ns-3 simulator [49] using a LoRaWAN module developed by [50]. The simulation is carried out with a fixed number of EDs and it is assumed that their number does not change during the simulation. Figure 2 shows a NetAnim output of the LoRaWAN network scenario implementing 100 EDs. The simulation settings are presented in Table 3. A four-state energy consumption model is assumed, comprising the transmit, idle, receive, and sleep states. Table 4 shows how the energy model links the voltage and current usage to each state. To compute network energy usage, we track each node's energy usage during simulation. Semtech produced these parameters for the SX1272 LoRa transceiver used in this work for transmit power 10 dBm [51]. These parameters are employed in conjunction with Table 1. The model estimates ED battery life and energy consumption. Total energy consumption for each ED is given by:  
\[E_{ED}=E_{tx}+E_{rx}+E_{i}+E_{s}\,, \tag{6}\]  
where \(E_{tx}\) is the energy consumed when the ED is transmitting a packet, \(E_{rx}\) is the energy consumed when the ED is receiving an incoming packet, \(E_{i}\) is the energy consumed when listening for incoming packets, and \(E_{s}\) is the energy consumed when the ED is in sleep mode.