# Slotted ALOHA on LoRaWAN-Design, Analysis, and Deployment
## 7 S-ALOHA Evaluation in a Real Deployment
### S-ALOHA Evaluation  
In order to accomplish a performance analysis of the S-ALOHA on LoRaWAN and to make a comparison with the standard LoRaWAN, a detailed log of the status of each device is collected by a database, which is managed by LoRaWAN server. Two packet-send and packet-loss counters were introduced in the state machine indicating the total number of packets that each node sent and those gone lost. The packet-send counter is incremented every time the microcontroller is in the sending state, while to check if the acknowledgment has been received a logical value is set to true a flag present in the receiver function, whenever it assumes logical value true it means that it is received a packet in response, otherwise the S-ALOHA state machine resumes the transmission by increasing the packet-loss counter. Moreover, the gateway detects the channel access time of each end-node, measuring the effective RTC synchronization of the WSN. The payload of each message sent by the end nodes contains the log information, allowing through a debug window to read in real-time the statistics of each node. In order to make the analysis possible, however, it was necessary to memorize this data on a support that can be analyzed remotely with numerical analysis programs such as Matlab or Python.  
Tests have been carried out to assess whether the introduction of the S-ALOHA protocol in the LoRa stack leads to an improvement in the overall performance of the network. The LoRaWAN protocol is similar both in terms of channel access and as a transmission algorithm to the P-ALOHA, but it is necessary to consider the fact that the statistical analysis of the P-ALOHA does not take into account the channel occupation for acknowledgment messages. The transmission of the ACK by the gateway in the same channel can, in fact, collide with the other frames that have in the meantime been transmitted by the other devices.  
We carried out three tests for the S-ALOHA protocol in three different network traffic conditions with the goal to evaluate the performances gap between the theory, statistical models, and a real deployment. The main variables of these tests are the number of devices as well as the transmission frequency of the messages. Indeed, other parameters, such as payload size and SF are kept constant. In all tests, confirmed messages are used and the same firmware S-ALOHA with a back-off algorithm is implemented in whole devices. The following tables and plots show the comparison between the  
Figure 11: Sensor node deployment in CINECA. (**a**) Hallway positioning, (**b**) the sensor node is under the data center floor, (**c**) CINECA data center map.  
performance of both protocols in terms of traffic offered and disposed of by the network. These values are temporally normalized, so the results are independent of the duration of the experiment and the overall use of the channel is expressed in percentage value.  
For the channel traffic calculation (\(G\)) the total number of packets sent in the channel in the time unit (packet/second) was considered; this means that, on average, values greater than \(G=1\) denote that multiples end nodes transmit simultaneously in the same slots. The overall throughput from the channel is therefore given by the product of \(G\) for the average percentage of packages successful disposed of, as described in Equations (7) and (8). The packet time is calculated considering the \(T_{\text{LoRaWAN}}\):  
\[G=\frac{\text{Packet}_{\text{sent}}}{T_{\text{test}}} \tag{7}\]  
\[S=G*P_{\text{success}} \tag{8}\]  
Values reported in Table 2 and Figure 12 confirm a correct implementation of the S-ALOHA over a LoRaWAN protocol, indeed the maximum theoretical throughput is doubled, with a trend similar to standard S-ALOHA statistical model.