An embedded LoRaWAN gateway based on just-in-time double-buffer queue algorithm

By introducing a just-in-time scheduling algorithm using ring queues and sequential queues into the LoRaWAN gateway, the problem of packet scheduling conflicts is solved, data throughput and scheduling capabilities are improved, and hardware costs are reduced.

CN115696615BActive Publication Date: 2026-05-29NO 719 RES INST CHINA SHIPBUILDING IND

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
NO 719 RES INST CHINA SHIPBUILDING IND
Filing Date
2022-09-16
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

In LoRaWAN gateways, packet collisions caused by untimely packet scheduling result in actual data throughput being far lower than theoretical values, and existing technologies have failed to effectively resolve the packet scheduling conflict problem.

Method used

An embedded LoRaWAN gateway based on a just-in-time double-buffered queue algorithm is adopted. By introducing a circular queue and a sequential queue, combined with an optimized just-in-time scheduling algorithm, data packets with similar timestamps are processed first, avoiding blocking caused by thread locks and improving data forwarding performance.

Benefits of technology

It significantly improved the gateway's data throughput, reduced packet loss, enhanced the ability to schedule different types of data, and reduced hardware costs and computing resource consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115696615B_ABST
    Figure CN115696615B_ABST
Patent Text Reader

Abstract

The application discloses an embedded LoRaWAN gateway based on a just-in-time double-buffer queue algorithm and belongs to the technical field of LoRa wireless communication. The gateway comprises a host subsystem, a concentrator subsystem and a power supply subsystem; the host subsystem provides an operation environment for a gateway main program and is connected with a network server in a wide area network, and the gateway main program realizes data interaction with the network server through a downlink data forwarding mechanism; the concentrator subsystem is connected to a LoRa radio frequency network and realizes data interaction with terminal nodes; and the power supply subsystem converts an external power supply and provides required voltage levels for the host subsystem and the concentrator subsystem. The application improves the downlink data forwarding mechanism of the gateway, introduces a ring queue into a downlink data link in the gateway to form a double-buffer queue, and is supplemented by an optimized just-in-time scheduling algorithm, so that the data throughput of the gateway is greatly improved and the scheduling capacity for different types of data is enhanced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of LoRa wireless communication technology, specifically relating to an embedded LoRaWAN gateway based on a just-in-time double-buffered queue algorithm. Background Technology

[0002] LoRa is an ultra-long-range IoT wireless communication technology based on spread spectrum, while LoRaWAN is a low-power wide-area network standard based on LoRa. The LoRaWAN standard primarily defines the network framework, data transmission mechanism, MAC layer message format, and physical layer parameters for actual deployment depending on the region, including frequency band and channel allocation, data transmission rate, maximum transmit power, etc. LoRaWAN networks use star or near-star topologies, with a typical network consisting of three layers: terminal nodes, gateways, and servers. Gateways act as a bridge between nodes and servers, primarily relaying data between them. Gateways communicate wirelessly with nodes using LoRa modulation technology and connect to network servers in the wide area network via standard IP links, making them a key device for network deployment. Given the large number of terminal nodes in a LoRaWAN network, gateways, as crucial devices directly determining network capacity, need to possess characteristics such as high data processing speed, strong device compatibility, high software concurrency, high communication sensitivity, and low maintenance costs.

[0003] In the LoRaWAN specification, Class A data packets carry a Unix timestamp set by the server. The gateway needs to send the data packet at the time specified by the timestamp. If the packet is sent before the timestamp, the terminal device may not have opened its receive window yet, and even if the packet is successfully sent from the gateway, the terminal will not receive the data. Conversely, if the gateway fails to send the packet at the timestamp, the receive window may have already closed, and the terminal will also not receive the data. To ensure that data packets are sent at their timestamps, the gateway must schedule the packets in advance. To avoid signal superposition interference, no other data packets can be sent during the airborne transmission time after the packet is sent from the gateway. Therefore, the gateway forwards a data packet not instantaneously but requires a certain amount of time. If the timestamps of two or more data packets are too close together on the timeline, the gateway may not be able to complete the forwarding and scheduling of all data packets in time. The resulting data packet loss is called a "collision" between data packets. It is precisely because of the existence of data packet collisions that the actual data throughput of the gateway is far from its theoretical value. Summary of the Invention

[0004] In view of this, the present invention provides an embedded LoRaWAN gateway based on a just-in-time double-buffered queue algorithm. The gateway improves the downlink data forwarding mechanism, thereby increasing the data throughput of the gateway and enhancing its scheduling capability for different types of data.

[0005] An embedded LoRaWAN gateway based on a just-in-time double-buffered queue algorithm includes a host subsystem, a concentrator subsystem, and a power supply system;

[0006] The host subsystem provides a runtime environment for the gateway main program and connects to the network server in the wide area network. The gateway main program realizes data interaction with the network server through the downlink data forwarding mechanism.

[0007] The concentrator subsystem is connected to the LoRa radio frequency network to enable data interaction with the terminal nodes;

[0008] The power supply system converts the external power supply to provide the required voltage levels for the host subsystem and the concentrator subsystem.

[0009] Furthermore, the process of data interaction between the downlink data forwarding mechanism and the network server includes the following steps:

[0010] Step 1: The gateway is powered on, the host subsystem and concentrator subsystem are initialized, the gateway main program starts running, the concentrator subsystem accesses the terminal node network through LoRa radio frequency communication, and the host subsystem connects to the network server in the wide area network through Ethernet communication.

[0011] Step 2: The downlink processing thread of the gateway main program receives downlink data packets from the network server through a socket and inserts the filtered data packets into the tail of the circular queue.

[0012] Step 3: The just-in-time scheduling thread of the gateway main program takes the data packets that meet the requirements from the head of the circular queue and inserts them into the tail of the sequential queue. Then, it reorders the data packets in the sequential queue according to the just-in-time scheduling algorithm, with the highest priority data packet located at the head of the sequential queue.

[0013] Step 4: The timely scheduling thread of the gateway main program retrieves the highest priority data packet to be forwarded from the head of the sequential queue and sends it to the concentrator subsystem. The concentrator subsystem converts the data packet into a LoRaWAN standard message and then sends it to the target node via LoRa radio frequency communication.

[0014] Furthermore, the downlink data link in the gateway main program involves two threads: a downlink processing thread and a just-in-time scheduling thread.

[0015] The downlink processing thread uses network sockets to receive downlink data packets from the server, and the filtered data packets are inserted into the tail of the circular queue.

[0016] The just-in-time scheduling thread retrieves data packets from the head of the circular queue, inserts them into the tail of the sequential queue, and then selects the highest priority data packet from the sequential queue according to the just-in-time scheduling algorithm to send to the concentrator subsystem.

[0017] Furthermore, the circular queue is used to efficiently transfer data packets between the downlink processing thread and the time-based scheduling thread, and the queue can be operated by both the downlink processing thread and the time-based scheduling thread.

[0018] Furthermore, the sequential queue is the direct object for implementing the just-in-time scheduling algorithm. As a secondary buffer for downlink data, the sequential queue can only be operated by the just-in-time scheduling thread.

[0019] Furthermore, the core principle of the just-in-time scheduling algorithm is to prioritize scheduling data packets whose timestamps are close to but not later than the current time. The closer the timestamp of a data packet is to the current time, the higher its scheduling priority, which means that the data packet needs to be forwarded to the terminal node as soon as possible. That is, regardless of the time order in which the gateway receives data packets from the server, it will try its best to select the data packet that needs to be forwarded most at the current time for processing.

[0020] Beneficial effects:

[0021] 1. The embedded LoRaWAN gateway of the present invention includes a host subsystem, a concentrator subsystem, and a power supply system. The host subsystem provides a running environment for the gateway main program and connects to a network server in the wide area network. The gateway main program realizes data interaction with the network server through a downlink data forwarding mechanism. By introducing a ring queue to form a double-buffered queue in the downlink data link inside the gateway, and supplementing it with an optimized just-in-time scheduling algorithm, not only is the data throughput of the gateway greatly improved, but the scheduling capability for different types of data is also enhanced.

[0022] 2. This invention proposes a just-in-time double-buffered queue algorithm for the downlink data link inside the gateway. It uses a circular queue to transmit data between threads, avoiding the use of blocking structures like locks. By using a large-capacity circular queue as the primary data buffer, the length of the sequential queue, which is the direct data source for just-in-time scheduling, can be controlled. This ensures the implementation efficiency of the just-in-time algorithm without sacrificing data buffer capacity, effectively mitigating packet loss caused by packet collisions and significantly improving the gateway's data throughput. Furthermore, by optimizing software efficiency to improve the gateway's data forwarding performance, it can save computational resources, reduce hardware performance dependence, and help save on gateway hardware costs.

[0023] 3. In the gateway main program of this invention, the timely scheduling thread retrieves data packets from the head of the circular queue and inserts them into the tail of the sequential queue. The circular queue is used to efficiently transfer data packets between the downlink processing thread and the timely scheduling thread. This queue can be operated by both the downlink processing thread and the timely scheduling thread, thereby avoiding the use of blocking thread synchronization methods such as thread locks. Attached Figure Description

[0024] Figure 1 This is a schematic diagram of the hardware composition of the embedded LoRaWAN gateway of the present invention;

[0025] Figure 2 This is a schematic diagram illustrating the connection relationship between the gateway hardware components of this invention;

[0026] Figure 3 This is a schematic diagram of the downlink data link of the gateway main program of the present invention;

[0027] Figure 4 This is a flowchart of the downlink processing thread in the gateway main program of this invention;

[0028] Figure 5 This is a flowchart of the just-in-time scheduling thread in the gateway main program of this invention.

[0029] Among them, 1-i.MX6ULL microprocessor, 2-LAN8720A chip, 3-RJ45 network port, 4-SX1301 chip, 5, 6-SX1255 chip, 7-SMA RF antenna, 8-powered electronic system. Detailed Implementation

[0030] The present invention will now be described in detail with reference to the accompanying drawings and embodiments.

[0031] This invention provides an embedded LoRaWAN gateway based on a just-in-time double-buffered queue algorithm, such as... Figure 1 As shown, it mainly includes an i.MX6ULL microprocessor 1, a LAN8720A chip 2, an RJ45 network port 3, an SX1301 chip 4, an SX1255 chip 5, an SX1255 chip 6, an SMA RF antenna 7, and a power supply system 8. The SMA RF antenna has a frequency range of 460MHz to 490MHz and conforms to the LoRaWAN specification. Figure 2The connection relationships between the different components of the gateway are shown. When using this gateway, the i.MX6ULL microprocessor, LAN8720A Ethernet PHY chip, RJ45 network port, and corresponding peripheral circuits (the peripheral circuits mainly include electronic components such as capacitors, resistors, and inductors to ensure the normal operation of the chip) constitute the host subsystem. The SX1301 baseband chip 4, two SX1255 RF front-end chips, SMA RF antenna 7, and corresponding peripheral circuits constitute the concentrator subsystem. The i.MX6ULL microprocessor is directly connected to the SX1301 baseband chip and the LAN8720A Ethernet PHY chip. LoRa RF communication is achieved by controlling the two SX1255 RF front-end chips and the RF antenna through the SX1301. Ethernet communication is achieved through its integrated MAC controller, LAN8720A, and RJ45 network port. The power supply module is connected to both the host subsystem and the concentrator subsystem, with an input voltage of DC 12V and output voltages of DC 5V and DC 3.3V.

[0032] The gateway main program of this invention runs in the i.MX6ULL microprocessor of the host subsystem. The basic functions of the gateway main program include terminal management, protocol conversion and data forwarding. This invention improves the data forwarding performance of the gateway by introducing a just-in-time double-buffered queue algorithm, specifically by optimizing the downlink data link in the main program.

[0033] Figure 3 This is a schematic diagram of the downlink data link in the gateway main program of this invention. The gateway obtains downlink messages from the network server through Ethernet communication. After the downlink processing thread parses the downlink messages and converts them into data packets, the data packets are inserted into a circular queue. The just-in-time scheduling thread takes the data packets from the circular queue and inserts them into the sequential queue. Then, based on the current time and the timestamp of the data packets, it selects data packets that meet the just-in-time scheduling rules from the sequential queue and sends them to the concentrator subsystem. The concentrator subsystem forwards the data packets to the terminal nodes through LoRa radio frequency communication.

[0034] Figure 4 This is a flowchart of the downlink processing thread, which includes the following steps:

[0035] Step 1: Initialize the circular queue;

[0036] Step 2: Create a dedicated network socket for the downlink data link;

[0037] Step 3: Determine if the thread has exited the flag. If not, proceed to the next step; otherwise, terminate directly.

[0038] Step 4: Determine whether the socket has received downlink data packets. If yes, proceed to the next step; otherwise, return to step 3.

[0039] Step 5: Determine if the data packet format conforms to the specifications. If yes, proceed to the next step; otherwise, return to step 3.

[0040] Step 6: Determine if the data packet transmission power and frequency meet the requirements. If yes, proceed to the next step; otherwise, return to step 3.

[0041] Step 7: Insert the data packet at the end of the circular queue and update the statistics.

[0042] Figure 5 This is a flowchart of a time-based scheduled thread, including the following steps:

[0043] Step 1: Initialize the sequential queue;

[0044] Step 2: Determine if the thread has exited the flag. If not, proceed to the next step; otherwise, terminate directly.

[0045] Step 3: Take a data packet from the head of the circular queue;

[0046] Step 4: Determine if the data packet timestamp is too small or the enqueue time is too late. If so, remove the data packet from the circular queue and return to Step 2. If not, proceed to the next step.

[0047] Step 5: Determine if the data packet timestamp is too large or the enqueue time is too early. If yes, return to step 2; otherwise, proceed to the next step.

[0048] Step 6: Calculate and record the pre-send margin and post-send margin of the data packet;

[0049] Step 7: Will the data packet collide with an existing data packet in the queue? If yes, return to step 2; otherwise, proceed to the next step.

[0050] Step 8: Remove the data packet from the head of the circular queue and insert it into the tail of the sequential queue;

[0051] Step 9: Traverse the sequential queue and remove data packets whose timestamps are earlier than the current time.

[0052] Step 10: Reorder the data packets in the sequence in ascending order by timestamp size, with the data packet at the head of the sequence queue being the one with the smallest timestamp;

[0053] Step 11: Determine if the timestamp of the header data packet minus its pre-send margin is later than the current time. If no, return to step 2; if yes, proceed to the next step.

[0054] Step 12: Determine if the concentrator subsystem is normal and in an idle state. If not, return to step 2; if yes, proceed to the next step.

[0055] Step 13: Retrieve the data packet from the head of the queue and send it to the concentrator subsystem to update the statistics.

[0056] The gateway of this invention for implementing downlink data forwarding in LoRaWAN IoT mainly includes the following steps:

[0057] Step 1: After the gateway power supply system is connected to an external power source, the host subsystem and concentrator subsystem automatically power on and perform initialization settings. The gateway main program starts running, reading the configuration file stored in storage and performing the corresponding configuration. After initialization is complete, the gateway enters a listening state for terminal nodes and network servers.

[0058] Step 2: Receive downlink data packets from the network server via a socket, and insert data packets that conform to the LoRaWAN specification and whose transmission power and frequency meet the requirements into the tail of the circular queue.

[0059] Step 3: Attempt to retrieve a data packet from the head of the circular queue. If the data packet's timestamp is earlier than the current time, remove the data packet from the circular queue. If the data packet's timestamp is still a long time away from the current time or will collide with an existing data packet in the sequential queue, abandon this operation. If the data packet's timestamp is within a reasonable range and will not collide with an existing data packet in the queue, retrieve the data packet from the head of the circular queue and insert it into the tail of the sequential queue.

[0060] Step 4: Traverse the sequential queue and remove data packets whose timestamps are earlier than the current time. Then, reorder the data packets in the sequential queue in ascending order of timestamp size. The data packet at the head of the sequential queue has the smallest timestamp and has the highest scheduling priority.

[0061] Step 5: Determine the timestamp of the data packet at the head of the sequential queue. If the timestamp of the data packet minus the pre-send margin is later than the current time and the concentrator is in an idle state, then retrieve the data packet from the sequential queue and send it to the concentrator subsystem. In the concentrator subsystem, the data packet is converted into a LoRaWAN standard message and then sent to the target node via LoRa radio frequency communication.

[0062] In summary, the above are merely preferred embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. An embedded LoRaWAN gateway based on a just-in-time double-buffered queue algorithm, characterized in that, Includes the main unit subsystem, the concentrator subsystem, and the power supply system; The host subsystem provides a runtime environment for the gateway main program and connects to the network server in the wide area network. The gateway main program realizes data interaction with the network server through the downlink data forwarding mechanism. The concentrator subsystem is connected to the LoRa radio frequency network to enable data interaction with the terminal nodes; The power supply system converts the external power supply to provide the required voltage levels for the host subsystem and the concentrator subsystem. The downlink data forwarding mechanism implements the data interaction process with the network server, which includes the following steps: Step 1: The gateway is powered on, the host subsystem and concentrator subsystem are initialized, the gateway main program starts running, the concentrator subsystem accesses the terminal node network through LoRa radio frequency communication, and the host subsystem connects to the network server in the wide area network through Ethernet communication. Step 2: The downlink processing thread of the gateway main program receives downlink data packets from the network server through a socket and inserts the filtered data packets into the tail of the circular queue. Step 3: The just-in-time scheduling thread of the gateway main program takes the data packets that meet the requirements from the head of the circular queue and inserts them into the tail of the sequential queue. Then, it reorders the data packets in the sequential queue according to the just-in-time scheduling algorithm, with the highest priority data packet located at the head of the sequential queue. Step 4: The timely scheduling thread of the gateway main program retrieves the highest priority data packet to be forwarded from the head of the sequential queue and sends it to the concentrator subsystem. The concentrator subsystem converts the data packet into a LoRaWAN specification message and then sends it to the target node via LoRa radio frequency communication. The downlink data link in the gateway main program involves two threads: a downlink processing thread and a just-in-time scheduling thread. The downlink processing thread uses network sockets to receive downlink data packets from the server, and the filtered data packets are inserted into the tail of the circular queue. The just-in-time scheduling thread retrieves data packets from the head of the circular queue, inserts them into the tail of the sequential queue, and then selects the highest priority data packet from the sequential queue according to the just-in-time scheduling algorithm to send to the concentrator subsystem.

2. The embedded LoRaWAN gateway based on the just-in-time double-buffered queue algorithm as described in claim 1, characterized in that, The circular queue is used to efficiently transfer data packets between the downlink processing thread and the time-based scheduling thread, thereby avoiding the use of blocking thread synchronization methods such as thread locks. The queue can be operated by both the downlink processing thread and the time-based scheduling thread.

3. The embedded LoRaWAN gateway based on the just-in-time double-buffered queue algorithm as described in claim 2, characterized in that, The sequential queue is the direct object for implementing the just-in-time scheduling algorithm. As a secondary buffer for downlink data, the sequential queue can only be operated by the just-in-time scheduling thread.

4. The embedded LoRaWAN gateway based on the just-in-time double-buffered queue algorithm as described in claim 2 or 3, characterized in that, The core principle of the just-in-time scheduling algorithm is to prioritize scheduling data packets whose timestamps are close to but not later than the current time. The closer the timestamp of a data packet is to the current time, the higher its scheduling priority, which means that the data packet needs to be forwarded to the terminal node as soon as possible. That is, regardless of the time order in which the gateway receives data packets from the server, it selects the data packet that needs to be forwarded most at the current time for processing.