IoT scheduling for higher throughput and lower transmission power

The massive increase in the Internet of Things (IoT) has brought a diverse long-range, low-power, and low bit-rate wireless network technologies. The LoRa a low-power wide area network (LPWAN) gained popularity as radio technology for the realization of many IoT applications. LoRa is typically employed together with LoRaWAN MAC protocol and operates in the license-free ISM bands. LoRa networks have an issue with scalability when the number of end nodes connected to one network is larger than the shared number of channels, that causes a collision and packets loss through receiving a wide range of different message sizes from various application. In this paper, we describe an accurate and efficient way confirmed by simulation to calculate the probability of collision rate and packet loss in LPWANs under various circumstances. Moreover, based on the LoRaWAN specification, we consider a dense network deployment of IoT devices. In the event of collisions, our proposed algorithms is classified to two approaches. Firstly a time scheduling algorithm is proposed for LoRaWAN networks that consist of devices supporting LoRaWAN class C mode for synchronization in the beginning between the gateway and the end nodes. Afterwards these devices switch to class A to significantly decrease the collision and to enhance scalability by assigning a Guard Time to each end node. Gateway acknowledgment (ACK) messages to the end nodes are used through class C. Secondly, we also propose a distance spreading factor algorithm according to the distance of the end nodes from the gateway to reduce the probability of collision. Furthermore, many of these devices are battery powered, therefore low power consumption is required.


Introduction
The ''Internet of Things'' or IoT comprise a group of devices connected to the Internet which are usually characterized by their low complexity, and their low power consumption, such as battery-powered sensors connected to the Internet [1].These Internet of Things (IoT) devices produce new requirements and challenges for wireless networks [2].Recently, the current measured value of data has gained most attention in the industrial IoT [3].These ''things'' are transmitting a small amount of data such as humidity,temperature, location, etc.The majority of those devices will use wireless technology to transmit data and connect to the network backbone, that requires a high scalability wireless network that can serve massive numbers of end nodes [4].Wide area networks (WANs) play an essential role in connecting the primary facilitation through Low Power Wide Area Networks (LPWAN) is enabling power-efficient wireless communication over long distances.One of the LPWAN technologies that have reached great interest in recent studies is LoRaWAN.LoRa is one of the promising and significant in many Internet of Things application scenarios, such as smart grids, smart cities, geological monitoring [5]. Figure 1 illustrates the comparison between LPWAN technologies [5].
LoRa is a non-cellular modulation technology for LoRaWAN.LoRaWAN is the standard protocol for WAN communication.LoRa describes as good radio network for IoT solutions and has more reliable link budgets than other comparable radio technologies.LoRaWAN is an open standard protocol which defines the MAC layer for LPWAN technology designed by the LoRa Alliance.LoRaWAN uses an unlicensed spectrum, also it can be used by non-mobile operator customers to implement solutions.It should be noted that LoRaWAN networks interfere when more than one is operated in an area.LoRaWAN is essentially designed and optimized for up links where the end devices broadcast data to the gateway using periodic and aperiodic communication or due to a specified radio duty-cycle.However, this design does not support large data communication, such as video, photos.[6].However, this technology has limitations and challenges that need to be clearly understood to avoid disappointment.The nodes have a high probability of losing packets due to collisions, mainly when high spreading factors are used that increase time on air [7].In addition, the capture effect performance of LoRa transmission depends on transmission timings and power determined by empirical measurements.The capture effect occurs when two signals are present at the receiver, and the stronger signal represses the weaker signal [8].The selection of communication technology and LoRa parameters are used for transmissions to assume the probability of packet collisions and its scalability in [9].Furthermore, the range of values for the spreading factor of LoRa will affect the coverage area, and provide high density device deployments.Moreover, the probability of collisions is also influenced by traffic features, mainly the transmission periodicity, and payload size.The more increase in the payload size is required the more extended the time on-air and the channel occupancy will be.
In this paper, an accurate and efficient way is proposed to calculate the probability of collision probability and packet loss in LoRaWAN under various circumstances.Moreover, based on the LoRaWAN specification, we propose scheduling algorithm to significantly decrease the collision probability and to enhance the network scalability.Firstly, the proposed time scheduling algorithm is coordinated by the gateway, based on the idea that the most significant part of the data.For example, in agriculture, the data is sent periodically.In this case, the gateway adds guard time to each packet through the synchronization process while using class C after a collision occurred.Afterwards, the end nodes switched to class A for data transmission between end nodes and the gateway.Secondly, the distance spreading factor scheduling algorithm is proposed.The gateway decides which is the appropriate SF value to set for end nodes according to the distance between the gateway and the end nodes location.
The remainder of the paper is organized as follows: Related work is presented in Sect. 2. In Sect.3, we give an overview of LoRa and LoRaWAN and discuss the main LoRa parameters.Section 4 states the problem statement for LoRaWAN class A, followed by a detailed description of our proposed work and novel scheduling algorithms in Sect. 5. Section 6 presents the mathematical analysis.We present the simulation results for the proposed algorithms in Sect.7. Finally, Sect.8 presents the conclusion and future work.

Related work
In this section, we summarize state-of-the-art researches related to our proposed algorithms.Significant contributions have been done in our community investigating the collision, packet loss, and the scalability for long range networks.Bor et al. [10] present a simulator called LoR-aSim used to analyze and estimate the scalability of LoRa networks.The authors examine the range of communication options (bandwidth, spreading factor, carrier frequency, and coding rate) for a transmitter.Furthermore, they investigate the collision avoidance scenarios and the possibility of implementing a carrier activity detection mechanism.The achieved results confirm that to keep the Data Extraction Rate (DER) above 0.9, only 120 users are supported per antenna using standard LoRa settings.DER defined as the ratio of successfully received data by LoRa Gateway to transmitted data by the LoRa nodes within an estimation window.Georgiou and Raza [8] consider a single gateway LoRa network and propose a stochastic geometry framework to model their performance.Their analysis considered a single bandwidth frequency for all the nodes.The estimation of the coverage probabilities and the outage is based on the signal to noise ratio and on the co-spreading sequence interference.Their obtained result shows that the probability range decreases exponentially as the number of end-devices increases because of interfering signals using the same spreading factor.Abeele et al. [11] measure and analyze the scalability performance of LoR-aWAN through a LoRa ns-3 module.Their work explains the harmful effect of the downstream traffic on the delivery ratio of the upstream traffic.The authors showed that the increase of the gateway density could improve these effects, as stringent duty cycle requirements for gateways continue to limit downstream opportunities.Furthermore, with the obtained simulation results, the authors show that LoRaWAN can send six times more traffic compared to pure Aloha in a single-cell.By using 125-kHz channel bandwidth in the LoRaWAN network with the same number of end devices to avoid collision between the transmitted packets.In [12], the authors show a study for the uplink traffic in LoRaWAN where the packet delivery ratio decreases exponentially with increasing the number of end nodes in the network.Mikhaylov et al. [8] present an estimation of the throughput of LoRa technology, considering the time on air of the packet transmission.Accordingly, it is possible to determine the maximum number of end nodes that can communicate with the Gateway.Furthermore, the main technical difference is well explained in [9].The authors evaluated the main difference between LoRa and Sigfox by simulation.Voigt et al. [13] show that the impact of two methods to reduce the inter-network interference and enhance the reception rate.They consider the usage of directional antennas and the usage of multiple base stations.Through simulations, the authors determine that the multiple base stations and having end nodes with Omni-directional antennas.The data extraction rate is 56% corresponded to only 32% when directional antennas are used.Simulator tool extended to LoRaSimtool to support for LoRaWAN MAC protocol in [14], which utilize bidirectional communication.Furthermore, the authors present how downlink traffic considerably affects the uplink throughput.Optimizing the power and avoiding collisions allocating problems for using different channels, also presenting the effect of the spread-spectrum sensitivity is shown in [15].In [16], the authors present low-power distributed queuing (LPDQ), with highly competent and low power MAC protocol.LPDQ can self-schedule data transmissions; furthermore, the authors propose a design for implementing the LPDQ by using low-power commercial radio transceivers.However, there is extensive research to extend the LPDQ to multi-hop networks, which can enable a further range of wireless networks and improve the scalability and maintain their performance.LoRaWAN channel access limits presented in [17], the authors are focusing on the evaluation of the channel access performance as the most critical point for massive machine type communication.So far, a few works have been proposed to enhance the scalability issues, particularly by improving the spreading factor assignment to nodes [18,19].In [18], the authors present two novel approaches for allocating wireless resources, through SF assignments, in LoRaWAN systems.The idea of the authors is to consolidate the SF orthogonality and radio range to enhance the number of end nodes transmitting in the network.The future work for this research can be applied to the analysis of multi-gateway scenarios.In [19], the authors considered the Adaptive Data Rate (ADR) to evaluate the LoRa networks.Also, the authors develop an end to end LoRa simulator to study the energy efficiency and the reliability for LoRa networks.Ultimately, the authors showed that the results of ADR are useful when the variance of the channel is zero or very low.To the best of our knowledge, there are no relevant works that contribute information on this determination, nor studies the impact to select the best LoRaWAN throughput.
In this paper, unlike other works, we thoroughly study LoRaWAN performance by presenting the probability of collision and packet loss through both times and spreading factor parameter.We are improving the network scalability and increase the LoRaWAN networks throughput, which is the crucial contribution of this work.Scheduling algorithms are proposed to maintain a stable network structure while decreasing the collision probability and reducing the amount of data retransmitted by considering a synchronization ACK message by employing Class-C and adding the guard time to each packet.The main contribution of this paper is follow as: 1. Mathematical close form expression of the probability of collision and packet loss.2. Time scheduling algorithm is proposed.Through employing devices supporting LoRaWAN class C mode for synchronization.Afterward, these devices switch to class A to decrease the collision significantly and to enhance scalability by assigning a Guard Time to each end node.3. Distance spreading factor algorithm is proposed.
According to the distance of the end nodes from the gateway, and the time on-air values, we assign the best SF value for each packet.That leads to a decreased probability of collision and higher throughput.

LoRa and LoRaWAN overview
In this section, we overview the main LoRa and LoR-aWAN properties and define the basic parameters required for the implementation of our LoRaWAN channel simulations.
Many radio technologies co-exist to deploy LPWA networks.Onward with the Ultra-Narrowband (UNB) protocol, LoRa and its MAC layer implementation-LoRaWAN-is one of the LPWA network solutions.
Recently they are gaining the most considerable traction to sustain IoT applications and services.This modulation operates in the ISM bands (1.Industrial, 2.Scientific, 3.Medical) through the CSS (Chirp Spread Spectrum) feature, also supports bidirectional communication through spreading the narrowband signal over a larger frequency band.There is a significant differentiation between LoRa (Long Range) and LoRaWAN (Long Range Wide Area Network), which are usually both referred to as LoRa, LoRa Architecture shown in Fig. 2.More precisely, LoRa and LoRaWAN refer to the physical and the MAC layer of the LoRa protocol stack, respectively.LoRaWAN (Long Range Wide Area Network) is the MAC layer protocol of the protocol stack.LoRaWAN network architecture determines a star-of-stars topology of end-devices, gateways, and of central network server in the back-end.The LoRa Alliance defines the protocol.It is based on LoRa modulation, that exceeds the traditional modulation schemes, such as Frequency-Shift Keying (FSK).The LoRa performance is well suited to low-power and long-range transmissions discussed in [20].Gateways are connecting end-nodes, and the network server, While end-nodes communicate with the gateways over LoRa or FSK.The backhaul connectivity between gateways and the network server is based on Internet Protocol (IP).It allows much higher capacity, e.g., via Ethernet or 3G [20].End-devices are typically sensors or actuators with restricted data rate specifications, short messages, and low traffic intensity.LoRaWAN enables three different classes (Class A, B, and C) with different schemes of scheduling for downlink communication shown in Fig. 3.
The LoRaWAN specification define three different operating classes to address various applications: • Class A (Bi-directional end devices): End devices of class A allow for bi-directional communications.Each end device wakes up and transmits its messages to the gateway when the message is ready based on its preference, similar to the ALOHA based protocols.

LoRa parameters
In this section, we introduce the operational parameters that are critical for the deployment of our LoRaWAN Fig. 2 LoRa architecture channel simulator.Adjustment of these parameters permits tuning the tradeoffs between communication range and throughput.The throughput for radio transmission depends on the signal bandwidth (BW).The ISM stands for Industrial, Scientific, and Medical.These regulations allow the transceiver operating in an unlicensed band.Moreover, the end nodes do not require to obtain a government permit to use the spectrum.The standard width of the LoRaWAN channels in Europe is 125, 250, and 500 kHz.The LoRa modulation divides the data stream to one chip per second per Herz.Thus, the BW of the data transmission must be traded versus the frequency reduced the receiver sensitivity by introduced additional noise.On the contrary, decreasing the bandwidth results in higher receiver sensitivity, although it increases the Time on Air investigated in [21,22].LoRa is a Chirp Spreading Spectrum (CSS) technology, and it is Spreading Factor (SF) defines the number of chirps per symbol.SF can be configured from 7 to 12.A high value of spreading factor drives to increase the signal to noise ratio (SNR) and hence to enhanced receiver sensitivity to an increased range of the signal.The SF values in LoRa is considered to be orthogonal.Consequently, simultaneous transmissions with various values of SF do not collide with each other and can be successfully decoded.Considering LoRa modulation uses 2 SF chips per symbol, the chipping used by LoRa relates bit rate (R b ) and chip rate (R c ) by [23]: Accordingly, the pair of operating frequency and spreading factor composes a logical channel [20].The symbol time (T sym ) of LoRa is given by the formula [23]: Thus, a higher value of spreading factors rise the symbol duration that leads to an increase of the time on-air; however, also that increases the receiver sensitivity.Therefore, larger SFs can increase the transmission range.Finally, the Code Rate (CR) determines the redundancy bits used by Lora's Forward Error Correction (FEC) rate used by the LoRa modem to protect against interference.Possible values for the CR are in [1][2][3][4] corresponding to the coding rates of ½ 4 5 ; 4 6 ; 4 7 ; 4 8 resulting in the formula [24].
Reducing the Rate Code, respectively, increasing the CR results in lower Packet Error Rates (PER), but also increases the Time on Air.The higher the CR, the more robust the transmission.If there are too many interferences on the channel, then it is recommended increasing the value of CR.

Problem statements
Certain conditions cause collision such as arrival time overlap, spreading factor overlap, Coding Rate collision, etc. several conditions define whether the receiver can decode one or two simultaneous packets or nothing at all.The probability of packet collision also relies on the selection of LoRa parameters used for transmitting a packet.In this paper, we focus on two practical alternative methods to deal with interference.In the first case, packets are considered lost when the end nodes are transmitting the packets at the same time.This will be referred to as ''Time Collision''.In the second case, packets are corrupted when the end nodes are using the same spreading factor for sending the packets at the same time.This will be referred to as ''Spreading Factor Collision''.The collision probability model is analyzed in the following section.Both approaches aim at improving the collision probability, decrease the packet loss, and reach higher throughput.In Fig. 4 the algorithm show how to check cause of the collision probability at the end nodes.In this paper, we discuss the time collision and the spreading factor collision probability and propose two algorithms (M1 and M2) to decrease the rate of packet loss as explained in the following sections.

Proposed work
We assume that LoRa network consists of one gateway and many end nodes operating in the frequency of the main channels and two downlink channels.Firstly, we consider a Class-C for the synchronization between the gateway and the end nodes to specify the Guard Time as it is possible the same procedure used for FOTA (Firmware Upgrade Over The Air).Then switch to Class-A if the collision happened.That will be consider when the end nodes transmit the packets at the same time.The end nodes generate random packets according to a Poisson distribution process with total intensity k (that can be defined) and determine the mean time difference between two packets in milliseconds.The number of end devices operating in the channel can be configured in the simulation.The simulator generates packets for each end node, corresponding to the number of end nodes.The end nodes first send the data to the gateway as periodic sending through class-A, and then open up two reception windows (RX1 and RX2), providing the opportunity to the gateway for sending downlink acknowledgment message.In this transmission scheme, the gateway has the control on the end nodes through the concurrence using Class C, and this leads to increased latency of the downlink communications since it is required to wait for the next scheduled uplink transmission.This impacts on several applications where both low-latency and low-power consumption are playing essential issues such as structural health or seismic activity monitoring.[23,24].If no collision happens for up-link, the end nodes are acknowledged by the gateway.After each up-link transmission, the end nodes wait for an ACK from a gateway.
In order to save energy through decreasing the collision probability and packet loss.Secondly, by proposing distance spreading factor algorithm.When the end nodes send packets using the same spreading factor will cause packet loss and high collision probability.For this purpose, our algorithm compares the distance values for each collide packets of end nodes from the gateway, to give each end nodes the appropriate SF value according to the distance between the end nodes and the gateway.

Mathematical analysis
In this section, the mathematical models for collision probability and Gateway scheduling algorithms are presented.To overcome the collision problem, we developed a mathematical model of the re-transmission process according to the Gateway scheduling algorithm.The added time to each end node after receiving the acknowledgment message from the gateway is called Guard Time (GT) to decrease the collision probability.The time between the start of the guard time and the moment when the packet is sent is set by the gateway using Class-C between the specified parameters to decrease the random collisions in the radio environment.
A. Preliminaries For downlink frames, the end nodes received the acknowledgment from the central server; the PHY frame structure is similar: all the fields are identical, except the Cyclic redundancy check (CRC) field, which is not present.This work is done to have the messages as short as possible, with minimum impact on any duty-cycle restrictions of the ISM bands used in [25].
It is possible to calculate the packet time-on-air using the formula given in [24].A packet consists of a Preamble, followed by a header encoded with a code rate of 4  8 and protected by a CRC.The code rate encodes the Payload, and it is CRC.The preamble duration T preamble depends on the number of preamble n preamble and symbols duration T sym configured and can be measured by the following formula: The number of symbols of the packet payload Nsym Pload is calculated by [22]: where: • PL: Number of Payload bytes.
To indicate fixed-length packets for the header (H) can be set to 1.In this illustration, the header can be eliminated to decrease the length of the payload.To obtain more robust communication to frequency variations.The low data rate optimization can further help [24].This selection is not explicitly documented in the manuals and guides provided by Semtech.Still, the formula for the payload symbol calculation exposes that decreases the number of transmitted bits per symbol decrease by a factor of 2. Furthermore, to calculate the total duration of the packet by summing up the preamble and the payload duration: All formulas of this section have been adopted from [25], for example, how to calculate the Time on Air using the LoRa calculator provided by Semtech.Moreover, the authors in [20] explain the physical parameters of the LoRa modulation and derive a modified formula to compute the payload symbol number.Furthermore, the number of end nodes operating in the channel can be configured for the simulation.The simulator generates packets for each end node.A random packet length is uniformly distributed, and it is randomly assigned to each packet.The arrival time of a packet is Poisson distributed but has to respect the duty cycle.The algorithm for meeting the regulatory duty cycle constraint was implemented as specified by the LoRaWAN Specification 1.0.The formula given in the specification determines the backoff time (Toff): After sending a packet, end nodes wait at least for Toff, before they send the next packet.If the arrival time of the next packet generated by the Poisson process has a silent period lower than Toff, the start time of the next packet is set to previous arrival time ?Toff.The latest LoRaWAN specification gives the implementation of the algorithm guaranteeing the compliance to the duty cycle restriction open to the manufacturer.The second step is to find the colliding packets and finds the collision probability -all packets are generated by the end nodes randomly.Collisions are assumed by determining if the duration between a packet arrival and end overlaps within the period of another packet arrival.Also, collision happens when there is overlapping in Spreading Factor when two or more packets used the same SF value since the SF is pseudo-orthogonal in LoRa.Even when the same channel and the same bandwidth are used, the receiver may decode if it receives different SFs.
To express the base-band signal transmitted by the end nodes is given as follows: where: • f c ; k: the transmitted chirp at time kT s .
• S t : the transmitted symbols inside the packet p.
• k: the T s size.
The sleep period for the LoRa node will be at least equal to KT s dc -KT s , where dc is the duty cycle.According to the complex envelop determination of ( 9), we consider a system that is composed of one LoRa gateway and N LoRa end nodes.The end nodes n th transmit packets P s , and each packet sent by the end nodes with time on-air T a .We note a n the channel coefficient associated with the end nodes n th .Considering the received signal at the LoRa gateway R(t) is: Let T n b be the start time of the LoRa packet p.According to this, we define: where T s is a stationary random process with uniformly distributed entries, also it is used to model the various end node constraints in terms of communications with the gateway.We assumed that T s is uniformly distributed in the interval [T min ,T max ].This supposition is explained due to the massive number of IoT applications.
To calculate the probability of collision Pc  12), the collision case is defined as follows: The collision will happen between n 1 ðpÞ and n 2 ðpÞ if T n 2 ðpÞ 2 X C .Then we represent the probability of collision as follows: where the random variable T n 2 ðpÞ is the summation of multiple uniform random variables see (12).All packets are sorted by arrival time to find the collided packets.Packet collisions are assumed by deciding if the duration between a packet arrival and the packet end overlaps with the duration of any part of any packets.The following pseudo-code shows the condition for a packet collision: To decrease the collision probability we define Guard Time T Guard .The gateway (downlink) Ack messages to the end nodes are used to assign the value of the Guard Time utilizing Class-C.According to the down-link message through the gateway, each end nodes switch and re-transmit the collided packets with a specified delay called Guard Time in the interval [ 0, T max ] using Class-A.Therefore, the channel consists not only of the new packets but also of the previously collided packets, and that increases the mean traffic generated.Also, Guard Time calculation depends on the maximal synchronization period in the network and the end nodes accuracy.In our consideration, we did not assume the processing time that is essential for each packet to be processed by the end nodes before transmitting.
After adding the T Guard , we modify equation ( 12) to have the new start time packet T n b new as follows: Moreover, to calculate the collision probability according to the new value of the start time packet after adding the Guard Time, we have: With an increasing number of nodes per gateway, the number of simultaneous LoRa transmissions will increase as well, increasing the probability of collisions as a result of this affecting throughput.

Simulation results
In this section, to validate our approach, we consider the system composed of one gateway that can establish connections with N end nodes using the same spreading factor.
Our implementation for the proposed scheduling algorithms, the transmission through the gateway downlink message for end nodes is presented in two approach.The LoRa parameters used: fc= 868MHz, BW= 125kHz, and CR= 1.
Firstly, the time scheduling algorithm is proposed.The time is divided into time slots that can accommodate the communication in the network.The gateway is responsible for adding the guard time to each packet together with the acknowledgment message via class-C synchronicity with the end nodes.Then switch to Class-A if there is no collision happened and for periodicity.The implementation architecture for this scenario is shown in Fig. 5. Based on the time slot in the ACK message, the gateway determines the guard time after the packet collision happened from different end nodes.From that moment, after adding the guard time to each packet, the end nodes start increasing the time slot for each packet before transmitting arranged by the gateway.
Secondly, the distance spreading factor algorithm is proposed.Each end nodes randomly selects SF value from the allowed spreading factor from 7 to 12.A collision occurs when two end nodes send packets using the same spreading factor at the same time.Our proposed algorithm for nodes that are located close to the gateway assigns to them the lowest SF value.By comparing the distances for end nodes, how far there location from the gateway, we Fig. 5 scheduling algorithm assign the appropriate SF value for each end node.The determination of the distance according to the value of the received time on air.The details of the proposed algorithm for spreading factor scheduling collision is given in Algorithm 1, Fig. 6.
End nodes are geographically dispersed in the network.Simulations are done by Matlab using different number of end nodes (5,10,20,50,100) for each scenario.In the first scenario, we simulated with a slightly increased number of end nodes.Figure 7 shows the evaluation of the Time Scheduling algorithm.Thus, the assumed number of collided packets is 2 when we applied it for five end nodes.After using the time scheduling algorithm, the simulation results show improvements in terms of decreasing the probability of collision by 18%.To be able to evaluate the proposed solution under various conditions, Fig. 8 presents the collision parameters when the number of end nodes increases from 5 to 10.The results showed that increasing the collision probability due to the rise of the number of end nodes.From our obtained results, we can realize that after applying the time scheduling algorithm, the improvement of decreasing the probability of collision is 39.85%.
Moreover, to be able to evaluate our proposed algorithm, the results in Figs. 9 and 10 confirmed that the consumed energy increased with the increase of the number of colliding packets and the value of SF.By assuming that the number of end nodes increases from 5 and 10 to 20, and to 50, respectively.This leads to the efficient use of the proposed time scheduling algorithm.This minimizes the consumed energy, as well as the collision probability about 85.42 %, and 98.95%, respectively for 20 and 50 nodes.
This claim can support the results in Table 1.The table shows the various time and number of end nodes and  used in the simulation.Also, it shows that the improvement of minimizing the collision probability through increasing the number of end nodes in the network.
In the second scenario, we are proposed a solution to overcome the spreading factor collision when two or more end nodes using the same spreading value to transmit packets.By comparing the distance value how far it is located from the gateway for each end node to the time on air values.However, the experiments were performed considering the impact on the throughput by applying the distance spreading factor algorithm.The proposed algorithm is assumed to be periodic for each end node with a uniform distribution of transmission by end nodes in the first data period.End nodes are geographically distributed in the network.Figures 11 and 12 present the spreading factor collision, time spreading factor collision, and our proposed algorithm for two cases, namely for 5 and 10 end nodes.Simulation results show the improvement on the collision probability of the network after applying our proposed algorithm by 100%, 86.8% , respectively for 5 and 10 end nodes.Furthermore, Figs. 13 and 14 shows obtained results after applying the distance spreading factor algorithm.Simulation runs using 20, 50 end nodes, respectively.It is known that the number of collisions increases with the number of end nodes raise.This increase leads to the rise in   the number of frames re-transmit in LoRaWAN.By applying the proposed algorithm, the probability of spreading factor collision improved to 95.86% and 96.67%, respectively.Thus, to further assess the performance improvement of our solution, we compare various number of end nodes.Table 2 describes a comparison that gives more insights into the improvements that the proposed distance spreading factor algorithm brings.It can be realized in case of increasing the number of end nodes.Also, changing the value of the guard time has no significant effect on the obtained result.

Conclusion
Collision is one of the main factors that negatively impact the LoRaWAN throughput.In this paper, we present an efficient way to express the probability of collision rate and packet loss mathematically.Furthermore, this work proposes a time scheduling algorithm for LoRaWAN Class C used for synchronization and Class A used for periodicity.Simulations are carried out using matlab.We model a network with a single gateway and n end-nodes.The obtained results show the significant decrease of the collision probability.Moreover, we studied the number of packets collided when the end nodes are using the same spreading factor for transmitting the data.The proposed algorithm relies on the distance value for each end node through how far it is located from the gateway, and it is time on air values.The proposed methods work particularly well in case of large loads and in case of a high number of End Nodes.The gateway ACK messages to the end nodes are used in the proposed algorithm to decrease the collision probability and improve the scalability.The guard time introduced by the propagation distance, and the periodicity  of each packet is recorded.In our future work, we aim to propose an optimal algorithm using machine learning based on our scheduling algorithm to find the optimal gateway placement and optimize power consumption.

Fig. 1
Fig. 1 Low power wide area technologies

Fig. 4
Fig. 4 Algorithm for checking packet collision

n 2 ðpÞ n 1
ðpÞ between n 1 ðpÞ and n 2 ðpÞ at the LoRaWAN gateway, given that n 1 ðpÞ represent the node of interest.If c n 2 ðpÞ n 1 ðpÞ indicates the collision, based on (

Fig. 8 Fig. 9
Fig. 8 Probability of at least one collision for 10 EN

Fig. 10
Fig. 10 Probability of at least one collision for 50 EN

Fig. 12 D
Fig. 11 D-SF scheduling algorithm for 5 end nodes

Fig. 13 DFig. 14 D
Fig. 13 D-SF scheduling algorithm for 20 end nodes Each up-link transmission trigger two short down-link receive windows, After receive the ACK messages from the gateway the nodes go back to sleep mode.Class A is compatible with every LoRaWAN end device, and it provides the lowest power consumption.• Class B (Bi-directional end devices with scheduled receive slots): End devices of class B allow for periodic receive slots.Class B devices open extra receive windows at scheduled times; the gateway transmits beacon frames transmitted at regular intervals.This allows the server to know when the end-devices are listening.
• Class C (Bi-directional end devices with maximal receive slots): End devices continuously keep open receive windows closed only while transmitting.Class C end devices consume the most power but have the lowest latency for the server to end device communications.

Table 1
Time scheduling algorithm

Table 2
Distance spreading factor scheduling algorithm