# Resource Allocation to Massive Internet of Things in LoRaWANs
## 4 Proposed Spreading Factor Allocation Schemes  
### Channel-Adaptive SF Recovery Algorithm at the ED Side  
According to the LoRaWAN specification [1], if an ED has not received an ACK in both RWs, it must wait for at least _ACK_TIMEOUT_ seconds before starting retransmission. Based on retransmissions, a typical SF management scheme suggests incrementing by one SF, each time two successive retransmissions fail and maintains that SF during the following transmissions of the ED, as shown in Figure 2[1; 2; 3]. As mentioned, the higher SF increases the ToA, and thus the network suffers from high \(\hat{\mu}D\) and \(\hat{\mu}D_{ack}\) delays. Because the transmission failure may happen due to collisions, we could use a smaller SF to enhance the \(P_{SR}\), as described in [1; 2]. If the following conditions are satisfied, the SF is incremented by one, as shown in Figure 2.  
1. The SF is smaller than the _Max_SF_.
2. The ED has not already performed the maximum number of retransmissions.
3. The number of \(ReTx\_Left\_CNT\) is a multiple of two.  
Figure 1: SINR threshold for different spreading factor combinations.  
Figure 2: Typical SF scheme at the ED side [1; 2; 3].  
In a massive LoRaWAN network, only incrementing the SF can create a situation where most of the EDs switch their SF to higher values, resulting in a high ToA and hence, a collision possibility [37]. Besides, the UL transmission becomes a bottleneck for dense LoRaWAN deployments, wherein the packet loss rate increases with the high traffic load situation. As a result, the power depletion of each ED causes a reduction of their battery lifetimes. Hence, in such cases, EDs should decrease their corresponding SF to lower the ToA if they can still reach the GW.  
The proposed channel-adaptive SF scheme is based on a typical SF management scheme [1; 2; 3]. The proposed channel-adaptive SF scheme is triggered after the retransmission is initiated from the ED. When the transmission starts, the proposed scheme checks for ACK failure. If the ACK failure is detected (i.e., no ACK is received in either of the RWs), then the next UL packet will be sent as a retransmission. If \(ReTx\_Left\_CNT\) is a multiple of two, the recovery SF scheme decides to increase the SF to a higher value, as in the typical SF assignment scheme. The SF is increased because of the ACK failure caused by packet congestion and unreliable wireless channel status. However, in the proposed channel-adaptive SF, as shown in Figure 3, if any changes are detected to the SF, a counter, denoted as \(SF\_CHANGE\_TRACK\), keeps a count of the SF change.  
On the other hand, if transmission of a packet is successful (i.e., the ACK was successfully received), the algorithm keeps track of the successfully received ACKs by using a counter, \(ACK\_CNT\). If \(ACK\_CNT\) reaches \(\alpha\), the network reliability is satisfied. Furthermore, the \(SF\_CHANGE\_TRACK\) value is verified if it is greater than zero. It shows that SF is higher than seven (\(Min\_SF<SF\leq Max\_SF\)). Therefore, it can be decremented, and the proposed channel-adaptive SF scheme lowers the SF further to decrease the ToA when the channel is determined to be stable. The detailed working of the recovery SF scheme and symbols are shown in Figure 3 and Table 4, respectively.  
Figure 3: Proposed channel-adaptive SF scheme on the ED side.  
The proposed scheme can be further enhanced by taking into account the two types of DL PER: (1) \(PER_{DL}^{UL}\), which is the number of correctly received DL ACK packets to the number of confirmed UL packets; and (2) \(PER_{DL}^{ACK}\), which is the ratio of successfully received DL ACK packets to the number of sent DL ACK packets. These PER methods can be used as a decision metric to decrement the SF instead of \(ACK\_CNT\) on the left side of the proposed scheme, as shown in Figure 3.