# LoRaWAN Behaviour Analysis through Dataset Traffic Investigation
## 4 LoRaWAN Analysis
### Duty-Cycle Enforcement  
The LoRaWAN standard foresees a regulation on the duty-cycle that all devices should enforce. In the case of LoRaWAN, the duty-cycle is the ratio of time during which a packet is actively sent on the air over the time of radio silence. An example of duty-cycle behavior is reported in Figure 13.  
Figure 12: Structure of the PHYPayload of a join request message.  
The duty-cycle limitations depends on several factors including the region of operation, on the channel in use or the type of packets sent. In the band EU868 the maximum duty-cycle attainable is 1.0%, i.e., a device can send packets on the air 1% of the time and should be silent 99% of the time. The time of operation of the radio depends on the Time-on-Air of a packet and ultimately on the LoRa radio parameters. For example, if a device sends a join request (23 bytes of payload) using \(SF10\) and a 125 kHz channel with a final ToA of \(\approx\)500 ms, it needs to wait 99 \(\times\) 500 = 49,500 ms before sending a new message.  
We investigate whether the duty-cycle constraints are respected by the end-devices in the real LoRaWAN depicted by the LoED dataset. Since the LoRaWAN used to collect LoED dataset is based in London, we look LoRaWAN specification to see the constraint on the duty-cycle imposed in United Kingdom and it has to be \(<\)1%.  
The strategy used to compute the duty-cycle for each device seen in the network follows essentially three steps:  
1. Find the period of time of connection of the device to the network, computed as \(T_{Dev}=T^{f}_{Dev}-T^{i}_{Dev}\) where \(T^{i}_{Dev}\) is the first time in which the device is seen in the network and \(T^{f}_{Dev}\) is the last time in which the device is seen in the network;
2. Compute the amount of time \(T^{act}_{Dev}\) in which the device was active, we find this amount time by sum all the ToA of the packets sent by the device;
3. Compute the duty-cycle percentage as \[\%DutyCycle=\frac{T^{act}_{Dev}}{T_{Dev}}100.\]  
The previous three steps are performed for each device address observed in the network. In order to calculate the ToA of a packet we applied the following formula:  
\[ToA=\left(m_{ph}+\frac{8\times P}{4\times SF}\times(4+RDD)\right)\times\frac{2 ^{SF}}{BW}\]  
In that relation we have:  
* Preamble \(m_{ph}=1\);
* \(RDD=1\);
* Spreading factor of the packet \(SF\);
* Length of the payload \(P\) of the packet;
* Bandwidth used to transmit the packet expressed in Hz.  
By applying the strategy explained before we obtain the following plots.  
In the bottom-right part of Figure 14 the plot of the CDF distribution of all the device over the percentage duty-cycle is reported. The constraint of 1% correspond to the vertical blue line and as we can see by looking at the plot, this constraint is respected by all the devices. In the zoomed section, of the plot there is a green line representing the other most common LoRa duty-cycle constraint of 0.1%. It is also specified the CDF value of 0.91 correspondent to the intersection between the vertical green line and the red curve. This means that the 91% of the devices maintain the duty-cycle lower than 0.1%.  
Figure 13: Schema representing behaviour of device respecting a duty-cycle of 1%.