3.1. Standard ADR Algorithm and ADR+ Algorithm
In this section, the speed regulation mechanism of the ADR algorithm is introduced, and then we describe the standard ADR algorithm and ADR+ algorithm. Finally, the algorithm of the SF and TP adjustment stage is optimized on the basis of the ADR+ algorithm, and the optimization process is described in detail.
The ADR mechanism can be divided into two parts: the network server (NS)-side algorithm is responsible for increasing the data transmission rate of end nodes, while the end node (ED)-side algorithm is responsible for decreasing the data transmission rate of end nodes. The ED-side algorithm for ADR is defined by the LoRa Alliance, while developers can choose basic ADR algorithms or configure their own algorithms for the NS side [
15]. Additionally, the NS is located at the core of the network, allowing it to access global information. This enables the NS-side algorithm to dynamically adjust SF and TP of end nodes based on global information, leading to better optimization of network performance compared to node-side algorithms. The ADR algorithm in the LoRaWAN standard protocol includes both the ED-side algorithm and the NS-side algorithm. The ED-side algorithm relies on acknowledge character (ACK) feedback to determine if the data transmission is successful. If the node does not receive an acknowledgment from the gateway within two receiving windows, it considers the data transmission as failed and activates the retransmission mechanism. It automatically reduces the data transmission rate before retransmitting the data. The NS-side algorithm determines the link quality based on the signal-to-noise ratio (
) of the recently received data and adjusts the SF and TP accordingly. The ADR+ algorithm, compared to the ADR algorithm, only modifies the NS-side algorithm while keeping the node-side algorithm unchanged. Algorithm 1 describes the implementation steps of the NS-side ADR+ algorithm [
14]. In Algorithm 1, the input SF value ranges from 7 to 12 in steps of 1, and the input TP value ranges from 2 to 14 in steps of 3. It involves calculating the required SNR (
) based on the current SF, averaging the SNR of the latest received 20 data packets to obtain
, determining the appropriate SF based on
, and then computing the SNR margin (
) and the adjustment steps (
) using Equations (1) and (2):
Ultimately, through iteration, the values of SF and TP are gradually adjusted until certain conditions are met, and then the adjusted values of SF and TP are output.
Table 2 lists the minimum SNR required for different SFs. If the SNR margin (
) is positive, it indicates that the current channel quality is good, and the node can increase the data rate or decrease the transmission power to reduce power consumption and extend the node’s battery life. If the SNR margin is negative, it indicates that the node is currently using a transmission power that is too low, resulting in a low SNR for the uplink signal. Therefore, it is necessary to increase the transmission power or decrease the data rate.
Algorithm 1 NS ADR+ Algorithm |
Input: , |
Output: and |
|
|
|
|
- 7.
|
|
|
|
- 8.
|
|
|
|
The flowchart of the ADR+ algorithm is presented in
Figure 3.
3.2. Algorithm Optimization
In this section, we will introduce the idea of algorithm optimization and the optimized algorithm.
The ADR+ algorithm has powerful capabilities in controlling data rates, which can improve the communication success rate and reduce the overall network energy consumption to some extent. However, from the ADR+ algorithm flow, it is evident that the ADR+ algorithm always starts by changing the spreading factor and tends to decrease it. In a network with a large number of deployed LoRa nodes, this can lead to numerous nodes operating on the same spreading channel, resulting in severe data collisions, increased triggering of the node’s retransmission mechanism, and inevitably increasing network energy consumption while reducing the communication success rate.
To address these issues, we propose the communication time algorithm to allocate signal transmission times for nodes with the same spreading factor. The message types in LoRaWAN are divided into uplink messages and downlink messages. The data packet structure of uplink messages mainly consists of five parts as shown in
Figure 4: Preamble, PHDR (Physical Header), PHDR_CRC (Physical Header Cyclic Redundancy Check), PHYPayload (Physical Payload), and CRC (Cyclic Redundancy Check). The PHDR_CRC is the Cyclic Redundancy Check for the PHDR, which is used to detect errors in the header information. The CRC is for the PHYPayload, ensuring the integrity of the data payload [
10].
The transmission time of a LoRaWAN data packet is composed of the transmission time of the preamble and the transmission time of the payload. The transmission time of the preamble is determined by the symbol effective length
and the time to send a single symbol
, where
is related to the symbol rate
of LoRa. The specific calculation formula is as follows:
Here, represents bandwidth, and represents spreading factor.
The transmission time of the payload is related to the selected header type. In explicit header mode, the header contains information such as payload length, forward error correction rate, and whether CRC is used. In implicit header mode, the payload bytes, forward error correction rate, and CRC need to be manually set. The number of payload symbols (
) is calculated as follows:
where
is the number of bytes in the payload.
represents the selected header type, where
indicates explicit header mode and
indicates implicit header mode.
represents whether low data rate optimization is used during data transmission, where
indicates it is used and
indicates it is not used.
denotes the maximum value function, and
represents the ceiling function for rounding up.
After obtaining the number of payload symbols, the formula to calculate the transmission time of the payload (
) is defined as:
Finally, by adding the transmission time of the preamble and the transmission time of the payload, we can determine the transmission time of the LoRa data packet (
):
From the derivation of the above data packet transmission time formulas, we can see that the factors affecting the data packet transmission time include
,
,
,
,
, header type, and whether low data rate optimization is used. In this article, our algorithm only dynamically adjusts the SF and TP of the LoRa node. Therefore, we preset the variables
,
,
, header type, and whether low data rate optimization is used. We set
to 125 kHz,
to 1,
to 8,
to 23 bytes,
for explicit header, and
for not using the low data rate optimization configuration. By using the formulas, we can calculate the number of payload symbols
and the transmission time
of the LoRa data packet for different spreading factors, as shown in
Table 3.
From
Table 3, it can be observed that if a LoRa node uses SF12 to transmit a data packet, then within the corresponding time, 21 LoRa nodes using SF7 can complete the transmission of one data packet. Next, we established a communication time algorithm for all nodes based on their channel, spreading factor, and node number. We calculated the communication time interval
which characterizes the time interval from the beginning to the end of data transmission by a LoRa node i at the SF, where the time occupied by a spreading factor channel is denoted as
, such as
. The time interval between node communications is denoted as
, such as
. Assuming the starting time of the first node is
, the formula to determine the interval of
is defined as:
Based on the time interval
, a new algorithm called TA-ADR (Time Slot Adaptive Data Rate) is proposed. The algorithm flow of TA-ADR is detailed in Algorithm 2.
Algorithm 2 NS TA-ADR Algorithm |
Input: ; Time range of the current node; Timetable of communication of all nodes in LoRa gateway. |
Output: and update timetable of all node communications for all spread spectrum channels of LoRa Gateway. |
|
|
|
|
- 7.
|
|
|
|
|
; |
|
|
|
|
|
- 8.
|
|
|
|
- 9.
|
|
|
|
|
; |
|
|
|
|
|
3.3. Algorithm Implementation
In
Section 3.2 of our paper, we delved into a novel ADR management algorithm, dubbed the Time-Allocation Adaptive Data Rate algorithm. This algorithm is designed to optimize data transmission and significantly reduce conflicts between nodes on the same frequency channel using the same SF. This section will elaborate on the details of implementing the TA-ADR algorithm.
The input parameters for the TA-ADR algorithm include the SF range of the current node, the TP range, the time range
of nodes that need to be optimized, and the communication schedule
of all nodes within the LoRa gateway. The output of the algorithm is the adjusted SF and TP values, along with an updated communication schedule for all nodes across all spread spectrum channels. To illustrate the relationship between
,
, and
, let us consider an example in a LoRaWAN network with six LoRa nodes, all having a TP of 2 dBm. Among these, three nodes use a SF of 7, while the other three use SF8, and the initial send time is 0 s. Therefore, the communication time intervals for these six nodes are
,
,
,
,
, and
, respectively. From this, we can derive the theoretical communication timetable
for these nodes, as presented in
Table 4.
After the nodes 2 and 3 using SF8 transmit their data, the NS calculates that these nodes have
with both having an
of 1. Therefore, NS optimizes the parameters for these nodes under SF8 using Algorithm 2. For node 2 under SF8 (with
being
), after evaluating intersections with
, it is found that
intersects with
, indicating that node 2 should maintain its original settings. For node 3 under SF8 (with
being
), no intersections are found with
suggesting the time slot under SF7 is available. Thus, NS sends frame information containing the adjusted SF value and the new communication interval to node 3 during its receive window. Node 3 then resets its parameters accordingly. The updated communication timetable
is displayed in
Table 5.
Next, the parameter calculation and cyclic part of algorithm 2 are discussed. Initially, the algorithm calculates the minimum SNR required () for the current SF, and computes the average SNR () from the last 20 frames of data. Then, it adjusts the SF based on the . Then, the algorithm calculates the SNR margin (), which is the difference between the average SNR and the required SNR, minus the device margin (). This SNR margin is then divided by 3 to determine the number of adjustment steps (). Then, the loop is entered; if is greater than 0, indicating that the SNR is higher than required, the algorithm attempts to reduce the TP to save energy. For each reduction in TP (by 3 dB each time), is decreased by 1, until TP reaches the minimum value or becomes 0. If there are remaining after reducing TP, the algorithm tries to decrease the SF. It first checks if lowering the SF would cause a conflict with the communication schedule of other nodes. If there is no conflict, SF is reduced, and is set to 0. If there is a conflict, the algorithm further decreases SF (by 1 each time), and for each decrease in SF, TP is increased by 3 dB, until a conflict-free configuration is found or SF is lowered to its minimum value. If the original nsteps is less than 0, indicating that the SNR is lower than required, the algorithm attempts to increase TP to improve signal quality. For each increase in TP (by 3 dB each time), is incremented by 1, until TP reaches its maximum value or nsteps becomes 0. If nsteps is still less than 0 after increasing TP, the algorithm tries to increase SF. Similarly, it checks for conflicts with the schedule after increasing SF, and if there is a conflict, it continues to increase SF (by 1 each time), and for each increase in SF, TP is decreased by 3 dB, until a conflict-free configuration is found or SF is increased to its maximum value.
It is important to emphasize that our proposed TA-ADR algorithm is implemented on the NS end. All logic and computational operations are performed internally within the NS, sparing the LoRa nodes any additional burden. The NS, after processing through Algorithm 2, sends the optimized SF, TP, transmission time, and the addresses of the specific nodes needing optimization to the gateway. The gateway then conveys this information to the respective nodes, which adjust their parameters and transmission times upon receipt. Additionally, to achieve time synchronization among the nodes, we make the LoRaWAN gateways periodically broadcast time stamp updates to ensure all LoRa nodes are precisely synchronized.