High-Performance Long Range-Based Medium Access Control Layer Protocol

: Long Range (LoRa) has become one of the most promising physical layer technologies for the Internet of Things (IoT) ecosystem. Although it manifests low-power consumption and long-distance communication, LoRa encounters a large number of collisions in the IoT environment, which severely affects the system’s throughput and delay performance. In this paper, a code division carrier sense multiple access (CD/CSMA) protocol that resolves the traditional channel collision problem and implements multi-channel transmission is proposed for the LoRa medium access control (MAC) layer. To reduce data transmission delay and maximize the throughput of the system, the adaptive p-persistent CSMA protocol divides the channel load into four states and dynamically adjusts the data transmission probability. Then, to reduce channel collisions signiﬁcantly, the code division multiple access (CDMA) protocol is performed on different channel states. Moreover, the combination of the proposed adaptive p-persistent CSMA protocol and the CDMA successfully reduces the number of data retransmissions and makes LoRa more stable. The simulation results demonstrate that the proposed adaptive p-persistent CD/CSMA protocol can achieve near-optimal and occasionally even better performance than some conventional MAC protocols, especially in a heavy load channel.


Introduction
With the development of wireless sensor networks, the emergent Internet of Things (IoT) uses machines and networks to provide people with convenient services, such as health monitoring, environmental testing, smart appliances and so on. These services have created a new demand for wireless networks, so the improvement of performance of IoT systems has become an interesting topic of research. Long Range (LoRa) is a physical layer technology of Semtech [1,2], which has received widespread attention in recent years, mainly because of its long-range communication coverage and low-power requirements as well as the availability of modulation/demodulation hardware [3].
Similar to the medium access control (MAC) layer protocol of LoRa, Long Range Wide Area Network (LoRaWAN) is an emerging low-complexity protocol for wireless communication in the unlicensed spectrum using LoRa modulation [4,5]. It is also considered to be one of the most promising wireless technologies for IoT because of the low complexity, the low power consumption equipment, and its open business model [6,7]. LoRaWAN specifications propose interesting solutions regarding MAC layer operations to deliver the best communication performance to connected things despite its crucial impact on the overall performance. Nevertheless, the LoRaWAN MAC layer has not been sufficiently considered by research studies [8,9]. Currently, the most widely used protocols in the As explained in [24], LoRa has unavoidably experienced too many collisions that significantly reduce the average throughput and increase time delay in large-scale IoT environments. The throughput and delay performance determine whether an IoT system can be effectively applied in practice. Therefore, it is necessary to improve the throughput and reduce the delay of conventional LoRa MAC layer.
In this paper, we propose an adaptive p-persistent CD/CSMA MAC layer protocol algorithm for improving the performance of the LoRa protocol. Then, we set different levels of the network offered traffic and divide the channel load into four states in the LoRa module to further maximize the overall throughput and improve the robustness of the system. According to the load size, the value of p will be dynamically adjusted to reduce the load of the network in each condition. Compared with some existing p-persistent CSMA based schemes, the code division multiple access (CDMA) technology is introduced into the adaptive p-persistent scheme. Further, the orthogonal spread spectrum code is embedded to realize CDMA transmission for enhancing the system's anti-interference capability. Ultimately, we use OPNET to construct LoRa nodes and build a network topology that simulates actual conditions for simulation experiments. The simulation results verify that the proposed adaptive p-persistent CD/CSMA protocol has better performance than the traditional adaptive p-persistent scheme without CDMA protocol under the same conditions and can further reduce channel collision rate.
The rest of the paper is organized as follows. Section 2 describes the conventional p-persistent CSMA protocol. In Section 3, we elaborate the proposed adaptive p-persistent CD/CSMA protocol. Section 4 involves the simulation model design and the results. Finally, the conclusions are presented in Section 5.

Conventional p-Persistent CSMA Protocol
Some of the related terms and the time structure of the p-persistent CSMA are shown in Figure 1. Time is slotted in the p-persistent CSMA protocol. The size of the slot is a which is the normalized propagation delay, and all transmissions start at the beginning of each time slot with a packet length equal to t. It is always assumed that the length of each transmission period (TP) is T, i.e., if the secondary station (STA) sends packets at time T = 0, all the other STAs should wait until T = t + a (where a is the propagation delay as mentioned previously). When an STA sends a packet, it first senses the channel and then checks it. If the channel is busy, STA insists on sensing the next slot. If the channel is idle, STA sends data with probability p and is delayed for the next slot with probability (1 − p). This process will loop until the data packet is sent out. Since the transmission is deferred with probability (1 − p) even the channel is detected idle, there exists a silent period between two TPs which is called initial random transmission delay (IRTD) [25,26].  Figure 2 shows the conventional p-persistent CSMA algorithm that uses a time slot media access control method [19]. When the node detects that the channel is idle, it will generate a Bernoulli random variable x with the mean of p. When x = 1, the node will start sending packets.    2 shows the conventional p-persistent CSMA algorithm that uses a time slot media access control method. When the node detects that the channel is idle, it will generate a Bernoulli random variable x with the mean of p . When 1 x  , the node will start sending packets.
All packets from all STAs are modelled as a single Poisson process, providing a load G for mathematical simplicity [23]. The system throughput is defined as the number of successful transmitted bits per unit time by using probabilistic analysis and renewal theory and is presented by equation (1) where t is the duration of the IRTD before the first TP, t is the duration of the IRTD before other TPs and 0  is the probability that no packet arrives during a TP c R represents the average throughput over the channel fading statistics which is given by the following equation:  All packets from all STAs are modelled as a single Poisson process, providing a load G for mathematical simplicity [27]. The system throughput is defined as the number of successful transmitted bits per unit time by using probabilistic analysis and renewal theory and is presented by Equation (1) below: wheret is the duration of the IRTD before the first TP,t is the duration of the IRTD before other TPs and π 0 is the probability that no packet arrives during a TP. R c represents the average throughput over the channel fading statistics which is given by the following equation: where R o is the ergodic capacity of a single transmission and π n is given by P s (n) represents the probability of transmitting a data packet without any collision in the presence of n STAs successfully. It can be expressed as The above formulas indicate that the selection of the probability p should be based on the load G so that we can obtain the optimal system throughput. Generally, it is suitable to choose a large p value when the traffic is low; on the contrary, a small p should be selected. However, once p is selected, it is difficult to change, if it does not match the traffic, there will be channel collision, high delay, or low channel utilization.

Proposed Adaptive p-Persistent CD/CSMA Protocol
According to the different load status of the channel, the conventional p-persistent CSMA protocols mentioned above are not able to properly select the transmission probability p and are also limited owing to utilizing single channel communication. When the channel load is heavy, a series of challenging problems are encountered in practice, such as channel conflicts problem. Therefore, to solve the heavy load problem, we propose an adaptive p-persistent CD/CSMA protocol, in which the CDMA protocol is introduced to further improve the system throughput.

CDMA Protocol
The core of the CDMA protocol is spread spectrum, i.e., modulation with a pseudo-random code sequence whose bandwidth is much larger than the signal bandwidth, so that the bandwidth of the original signal is expanded and then modulated by the carrier and transmitted [28]. The CDMA spread spectrum model is shown in Figure 3. The signal a(t) is encoded by an encoder to become signal b(t), and then modulated with a spreading code through spread spectrum modulation. RF modulation is performed with a carrier signal u(t). The signal received by the receiver is given by the following equation: where n(t) is the sum of all kinds of noise. The receiver uses the coherent carrier to demodulate the composite signal as given in Equation (6): After multiplying by c(t) to complete the despreading process, baseband filtering and decoding are performed to obtain the information from the transmitter.
in the presence of n STAs successfully. It can be expressed as The above formula indicates that the selection of the probability p should be based on the load G so that we can obtain the optimal system throughput. Generally, it is suitable to choose a large p value when the traffic is low; on the contrary, a small p should be selected. However, once p is selected, it is difficult to change, if it does not match the traffic, there will be channel collision, high delay, or low channel utilization.
Faced with the heavy load channel of the IoT, the traditional p-persistent CSMA will cause serious channel conflicts and heavy load problem. In this section, we propose an adaptive p-persistent CSMA protocol to solve the heavy load problem and use the CDMA protocol to improve the throughput of the system further.
The core of the CDMA protocol is spread spectrum, i.e., modulation with a pseudo-random code sequence whose bandwidth is much larger than the signal bandwidth, so that the bandwidth of the original signal is expanded and then modulated by the carrier and transmitted. The CDMA spread spectrum model is shown in Fig. 3.  In order to improve performance, the most important problem is how to choose the spread spectrum code. The terminal hardware battery is small and cannot be replaced, which results in the inability to install chips with strong computing power. Hence, if the spread spectrum code order is too large, it may cause terminal overload. By contrast, if the order of spread spectrum code is too small and the total amount of users is larger than the total amount of orthogonal spread code, a large number of users will share a certain spread spectrum code. In this case, the purpose of distinguishing users by the code cannot be achieved. Thus, we will choose the appropriate spread spectrum code order using theoretical analysis.
If a node sends a packet successfully at time t 0 , during the 2T time from t 0 − T to t 0 + T, there is no node that uses the same spread spectrum code to send data. If there are terminals transmitting signals at the same time in 2T time, the probability that the i-th terminal and the other k − 1 terminals do not use the same spread spectrum code is given by [11] where M is the order of the selected orthogonal spreading code. During this 2T time, the probability of k terminals transmitting simultaneously is where G is the channel load. Then, the data frames sent successfully are equal to The average number of retransmissions for a data frame is given by Additionally, the normalized average delay is where m is the m-th spreading code. LoRa is a modulation technology in which the secondary spread spectrum mechanism is formed by embedding CDMA into a LoRa node again. In this paper, the LoRa spread spectrum mechanism is used directly and exploits the six original spread spectrum factors. The optional order of the spreading code M is generally between 1 and 16. With increasing M, the transmission distance will increase, and then the data transmission rate will be decreased. Therefore, in order to balance the system data transmission rate and guarantee enough transmission distance between nodes, the order of the spreading code is set to M = 5.

Adaptive p-Persistent CSMA Protocol
In the theoretical model, we assume that the system contains n nodes, which continuously send packets and compete for a link at the same time, so the channel will be busy. Besides, the data frames of all end nodes are sent at the same rate. Finally, the link is an ideal channel without other unrelated signals and noise interference. Assuming that a stable network has n end nodes and the transmission probability of an end node is p i , the probability of collision p c can be expressed as Then, the probability of at least one terminal being sent within the observed slot is Furthermore, the probability that one of the nodes will successfully send is Equations (10)- (14) show that the number of end nodes n and their transmission probability p i will affect the collision probability p c and transmission success probability p b . The propagation delay can be significantly optimized by reducing the number of channel transmission collisions and collision probability. The contention window model of different end nodes can be expressed as Electronics 2020, 9, 1273 7 of 16 The throughput of the (i + 1)-th end node can be calculated as in Equation (16), The normalized throughput of the system is given by where p b p tr E[P] represents the average payload successfully received by the receiver in a time slot, and (1 − p tr )σ + p b p tr T s + p tr (1 − p b )T c is the length of the transmission time slot. P is the payload information sent in a time slot and E[P] is the average value of P. In addition, T s is the average time for data to successfully reach the destination node, T c is the time of experiencing a collision in the process of data transmission, and σ is the length of the free time slot. Because the effective data frame length is the same, the system throughput is inversely proportional to the length of idle time slot. The total throughput of all stations can be calculated as The channel load is predicated on the premise of the advantages of CSMA being preserved. When the network is at the light load state, the traditional protocol is used to minimize the delay of media access. When the network is overloaded, the probability of sending data is reduced owing to the increase in the number of conflicts. Table 1 shows the differences of the proposed p-persistent CD/CSMA protocol and some existing protocols. Figure 4 shows the flow chart of proposed adaptive p-persistent CD/CSMA protocol that is used to resolve channel conflicts. The system first monitors the channel before sending the data frame because it is necessary to assess the channel state and set the random transmission probability p i . The network load is divided into the following four cases based on the collection and analysis of the above network state parameters, i.e., the light load, the moderate load, the heavier load, and the heaviest load. When the current transmission back-off times are N p ≤ 4, the system is at the light load and we let p i = 1. When N p > 4 and the number of last transmission back-off is N p ≥ N l , the system is at the moderate load and we let p i = 2p i . When 4 < N p < N l < 8, the system is at the heavier load and p i = p i /2. If the current transmission back-off times are N p > 4 and N l > 8, the current channel state is at the heaviest load and p i = p i /3. According to the different load conditions, we can dynamically adjust the p i value. Additionally, with the load of channel increasing, the number of transmission data conflicts R increases whereas the transmission probability p i = 1/R will decrease. Therefore, the near-optimal p i value can be ascertained by simulation. Finally, if the channel data are not transmitted successfully, the system will enter a new waiting state. The channel load is predicted on the premise of the advantages of CSMA being preserved. When the network is at the light load state, the traditional protocol is used to minimize the delay of media access. When the network is overloaded, the probability of sending data is reduced owing to the increase in the number of conflicts.

Simulation Results
In this section, to evaluate the effectiveness and scalability of the proposed p-persistent CD/CSMA protocol, the simulation experiments were conducted by using the OPNET Modeler14.5 and NS-3. When building the network topology structure, it was assumed that all of the nodes were distributed in a square area, and the sink node was located at the center of the area. Then the node layer and MAC layer model were deployed in detail. After a brief description of the deployment scenario, simulation results are presented and discussed in detail.
In the simulations, each channel of the LoRa network had a bandwidth of 125 kHz. We set the packet inter-arrival time (i.e., traffic) parameters for the experiment, which were Poisson (60), Poisson

Network Topology
Firstly, the model performed within the range of 6 km × 6 km in the OPNET simulative scene. The scenario involved 230 terminals that communicate with one sink. The centre of the simulation scene is a sink node and the others are terminal nodes. Each edge of the model contained 40 terminals, and each terminal was 100 m apart. The arrangement of nodes is shown in Figure 5.

B. Node layer model
The object-oriented simulation method is used in OPNET, with all nodes changed on the basis of the same model. In this subsection, we divide the nodes into four layers from bottom to top, as shown in Fig. 6.

Physical Layer
The physical layer mainly configures the parameters both of the transmitter and receiver. In order to accurately reflect the characteristics of LoRa, the peak data transmission rate, channel bandwidth and the lowest frequency of data transmission were set in the transmitter and receiver. The channel bandwidth of the transmitter and receiver were set to 125 kHz in the simulation, and the maximum channel rate was 5 kbps. Moreover, the range of the LoRa frequency band was 470-518 MHz by default, so the minimum frequency of the transceiver was set to 470 MHz. The channel model mainly adopts the free space propagation model in OPNET.

Node Layer Model
The object-oriented simulation method is used in OPNET, with all nodes changed on the basis of the same model. In this subsection, we divide the nodes into four layers from bottom to top, as shown in Figure 6.

B. Node layer model
The object-oriented simulation method is used in OPNET, with all nodes changed on the basis of the same model. In the subsection, we divide the nodes into four layers from bottom to top, as shown in Fig. 6.   [29,30]. The function of the Sink model was to destroy the packets, which were delivered to the destination node and count the throughput and packet loss rate of the system before their destruction. The network layer controls the routing function of users when sending data. It also drives the MAC model to complete the networking process of the wireless ad hoc network, which initiates the initialization of the network and transmits data packets generated by the application layer. The MAC layer was based on the IEEE802.15.4g communication rules to control how to select wireless communication links when transmitting information [31,32]. The MAC layer protocol of LoRa supports CSMA and conflict avoidance technology [33,34]. The physical layer was composed of two models; the wireless receiver and the wireless transmitter, as shown in Figure 6.

MAC Process Model
The main innovations of our proposed LoRa module are in MAC layer. The proposed adaptive p-persistent CD/CSMA protocol that is used in MAC layer to resolve channel conflicts. The CDMA spread spectrum protocol enables packets to realize wireless channel transmission on multiple channels. The MAC process model is shown in Figure 7. The Idle state is an interrupt state that detects the channel before sending packet data. When the channel is idle, it is transferred to the Wt_free state machine. Inversely, when the channel is busy, the idle state automatically turns to the Defer_0 state. Irrespective of the state the packet is transferred to, it will be given a random transmission probability p i . The random p i value was compared with the set p i value size, and the back-off algorithm was performed when the random value was less than the set value. Otherwise, the channel will enter the Wt_free state.

Simulation Results
To evaluate link performance, the system overall throughput and the packet reception rate (PRR) both served as metrics. The system overall throughput S can be obtained as S = LP r [35], where L denotes the network offered traffic and P r denotes the PRR. In this context, adopting the system overall throughput as a metric not only can evaluate system performance from the ratio between the number of successfully received packets and the total number of sent packets, but also can deploy different levels of the network offered traffic to further maximize the overall throughput of the system and achieve very competitive performance in various system settings. Thus, we consider the scenarios of different traffic and loads and evaluate the performance in terms of system throughput and delay.
To validate the effectiveness of the adaptive p-persistent CSMA protocol, we compare the existing Class A, ALOHA, conventional p-persistent CSMA, and adaptive p-persistent CSMA protocols. The simulation parameters are presented in Table 2. It can be seen from Figure 8 that the throughput of the 0.5-persistent CSMA protocol is higher than that of 1-persistent CSMA and 0.1-persistent CSMA protocols about 100 and 160 bits/s, respectively. This is due to traffic not being spread equally on the channels for high traffic that causes more serious channel collisions. As the limits of the adaptive p-persistent CSMA protocol are much closer to being optimal, the load is spread more uniformly over the channels at high traffic. Thus, we see a drop in collision rate and increased throughput by using the adaptive p. For this reason, the average throughputs of Class A and ALOHA protocols are far much lower than that of the adaptive p-persistent CSMA protocol. In conclusion, the adaptive p-persistent CSMA protocol can achieve a better system performance than other p-persistent CSMA protocols without adaptive p. Moreover, to make the comparison results more intuitive, a summary table has been added at the end of this section. As demonstrated in Table 3, our protocol can achieve higher throughput, lower latency than the others when the deployments of the network offered traffic or the channel loads varies, which is of great significance for diverse practical applications.  We investigate the impact of duty-cycled transmissions at the end device and the system throughput implemented on NS-3. The NS-3 LoRaWAN module is an extension of the NS-3 module for the low power wide area network. The collision model used in the NS-3 module is based on the capture effect. The LoRaWAN physical layer and MAC layer components are running over each LoRa device and the gateway. The physical layer of each device interacts with that of the respective gateway via the NS-3 spectrum physical module, implementing the devices air interface and channel-specific parameters. More specifically, in the physical layer, which includes the sender and receiver, the bandwidth is 125 kHz, the coding rate is 4/5, the order of spread spectrum code is 6, the peak data transmission rate is 5468 bps/s, and the frequency band is 868 MHz. In this case, a duty cycle of 1% [35] is beneficial for the system because it limits traffic and hence collisions, thus providing a higher throughput than the system without duty cycle restrictions. Figure 9 shows a comparison of the system throughput of the proposed protocol for a given value of the network offered traffic and different loads. It can be seen from the simulation results that for a given value of traffic, a higher load can obtain better system overall throughput in the condition of fulfilling the duty cycle requirements.   Figure 10 shows the average throughput of the proposed adaptive p-persistent CD/CSMA and the adaptive p-persistent CSMA without CDMA protocols for different traffic and loads. The average throughput of the proposed adaptive p-persistent CD/CSMA protocol is significantly improved by approximately 3000 bits/s compared with the adaptive p-persistent CSMA without the CDMA protocol for the scenario of high traffic and load. In the case of low traffic and load, although the average throughput of the two protocols is close to each other after stabilization, the proposed protocol is also superior to that of the adaptive p-persistent CSMA without CDMA protocol. Therefore, the proposed protocol significantly outperforms the adaptive p-persistent CSMA without CDMA protocol.  Figure 11 shows a comparison of the system delay between the proposed protocol and the adaptive p-persistent CSMA without CDMA protocol for high traffic channel and different loads. The simulation results indicate that the proposed adaptive p-persistent CD/CSMA protocol delivers lower delay even at Poisson (5) of packet inter-arrival time than the adaptive p-persistent CSMA without CDMA protocol. Moreover, when higher load is taken into account, it can be seen that the adaptive p-persistent CSMA protocol has a very high collision rate.  Figure 12 shows the average throughput in terms of the proposed adaptive p-persistent CD/CSMA protocol and adaptive p-persistent CSMA without CDMA protocol for different traffic and high load. The curve of the highest average throughput for the adaptive p-persistent CSMA protocol is Poisson (10), which is superior to the average throughput of Poisson (5) and Poisson (3). Normally, when the system traffic increases for the adaptive p-persistent CSMA protocol, the average throughput should increase as well, but the average throughput of Poisson (5) and Poisson (3) do not increase. This occurs because the channel for this protocol is saturated. On the contrary, the proposed adaptive p-persistent CD/CSMA protocol has the highest average throughput of Poisson (3), which exceeds approximately 3300 bits/s compared with the adaptive p-persistent CSMA protocol. It has been verified that the CDMA protocol is able to decrease collided frames efficiently and reduce the number of retransmission. Therefore, the proposed protocol could be used in cases of high traffic and load to resolve the channel collision problem.

Conclusions
In this paper, we propose an adaptive p-persistent code division carrier sense multiple access (CD/CSMA) protocol for a LoRa network service with high real-time data and throughput requirements. First, we develop a method to select an appropriate throughput for the p-CSMA protocol under high traffic. Then, according to various load conditions, we propose to use an adaptive p-algorithm to divide the network into four states and dynamically adjust the sending probability for these load states. Furthermore, we utilize the idea of the code division multiple access protocols to embed orthogonal spread spectrum code to achieve code division multi-channel transmission and enhance the system's anti-interference capability. The simulation results demonstrate that the proposed method outperforms the conventional CSMA protocol in terms of both system throughput and traffic delay. Consequently, the proposed adaptive p-persistent CD/CSMA protocol holds great potential for application in LoRaWAN.

Conflicts of Interest:
The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.

Abbreviations
The following abbreviations are used in this manuscript: