# An Adaptive Data Rate Algorithm for Power-Constrained End Devices in Long Range Networks
## 5 Adaptive Data Rate Algorithm Design
### Adaptive Data Rate Control Algorithm Based on Network Performance Optimization
#### 5.2.2 Adaptive Data Rate Algorithm for Network Performance Optimization
Figure 11: Physical image of the gateway. Figure 10: Schematic diagram of gateway hardware architecture. #### 6.1.3 NS Design and Implementation

The NS is the core of the entire LoRa network, responsible for managing all devices and meeting various application service requirements. The NS designed for this study is developed using Java and deployed on an Alibaba Cloud Ubuntu 20.04 operating system. Figure 12: Schematic diagram of the ED hardware architecture. Figure 13: Physical image of the ED. It utilizes Docker technology to package the relevant environment and server program into a Docker image, simplifying the deployment process and enabling easy migration to different platforms. The architecture of the NS is based on the Spring Boot, MyBatis, and Netty frameworks to enhance system scalability. The front end uses the React framework and adopts a separation of front-end and back-end design to ensure low coupling. The back-end program is quickly built using Spring Boot, which simplifies the coding, deployment, and configuration processes. Additionally, MyBatis is used as the persistence layer framework, significantly reducing the complexity of SQL connection queries and storage procedures. Given that the NS needs to support concurrent connections from multiple gateways and devices, the Netty framework is employed to build TCP/UDP network applications, enabling it to handle large-scale, high-concurrency connections among network devices, thereby ensuring network stability and efficiency. Figure 14 shows the functional design of the NS. ### Single ED Communication Link Testing Scenario

In this test scenario, the GW was deployed on the roof of a 20 m high building, while the ED was located on a floor inside the same building, with a straight-line distance of 50 m between them. The deployment diagram of the ED and GW is shown in Figure 15. The initial communication parameters of the ED are shown in Table 10, configured with a 500 kHz modulation BW and SF 7. The node generates one 20-byte data packet per second. The position of the GW is fixed, while the EDs select suitable locations within the given distances for testing in a campus environment, such as inside buildings (50 m), on the playground (300 m), at the north gate (500 m), and in the northeast corner of the campus (1000 m). This scenario aims to test the optimization effects on the link performance of a single ED and compare the impact on PRR among I-SFA, LoRaWAN ADR, ADR+, and the algorithm proposed in this paper over a period of 3600 s.

Figure 14: Functional design of the NS. Figure 16 shows the variation of PRR over 3600 s for four adaptive data rate adjustment schemes under a single ED communication link at different testing distances, while Figure 17 compares the average PRR at four distances. The test results indicate that the proposed algorithm maintains a PRR of over 90% across all testing distances, with its advantages becoming increasingly apparent as the distance increases. Inside the building environment (50 m), the proposed algorithm is able to maintain a reliable link performance despite the link fluctuations caused by building shading and people walking around. At a distance of 1000 m, the PRR of the proposed algorithm improves by 20% compared to the standard LoRaWAN ADR algorithm. Although the ADR+ algorithm shows performance improvements over the standard LoRaWAN ADR algorithm, it still has limitations compared to the proposed algorithm. The I-SFA scheme primarily allocates the spreading factor during the initial phase at the ED, configured according to the sensitivity of the gateway, but does not consider the reliability and stability of the link, nor does it possess the ability to adaptively adjust the spreading factor. The standard ADR scheme uses the maximum SNR within a fixed time window to assess link status, while the ADR+ scheme employs the average SNR. However, both