# Firmware Updates over the Air via LoRa: Unicast and Broadcast Combination for Boosting Update Speed
## 5 Simulation Tests and Results
### Simulation Environment  
The simulations include a single gateway, located in the center of the virtual scenario, and a number of nodes to be updated, distributed in a circular area around it (Figure 6). The distance to the gateway follows a uniform distribution between 0 and the maximum radius. The setup uses the LoRa Phy layer developed in [28], with the Nagakami loss model [33], which matches the scenarios of interest. The Spreading Factor (SF) is fixed to 7, and the bandwidth of the LoRa channel is always 125 kHz. These two parameters are chosen  
Figure 5: _Only broadcast_ method: total update time for different values of the number of nodes and the number of initial broadcast rounds: **(a)** loss probability = 1% and **(b)** loss probability = 40%. Note that the \(Y\) axis is in logarithmic scale, and that the ranges of **(a,b)** are different. Figure 6: Circular scenario with 10 peers and a maximum radius of 2000 m.  
because they are widely used in commercial deployments. A 1% duty cycle is used, as required by the LoRa Alliance in many cases. The frames have a header of 23 bytes plus a payload of 192 bytes (by default). The size of the payload must be a multiple of 16 bytes, because this is the block size of the AES ciphering algorithm. In some tests, different frame sizes are employed. As a summary, Table 1 includes all the parameters employed. Figure 7 shows the architecture of the simulation environment. On the one hand, it has the next input parameters: LoRa Spreading Factor, number of nodes, size of the firmware, number of iterations to be simulated, size of each firmware chunk, size of the ACKs, maximum radius, and number of broadcast rounds (only applicable in the broadcast methods). On the other hand, the simulation outputs are conformed by several csv files that include the peer coordinates on the scenario and the detailed results of the three FUOTA methods: the timestamp and RSSI (Received Signal Strength Indicator) of each frame exchange. The total time required for updating the whole project corresponds to the timestamp of the last frame. The simulator uses a set of ns-3 libraries, including _LoRa Phy_, _LoRa End Device_, _LoRa Gateway_, and Delay/Loss Models. Furthermore, different C++ layers are included on top of ns-3: _LoRaSimGeo_ (as scenario generator), _LoRaSimConst_ (managing simulation constants), \begin{table}
\begin{tabular}{c c} \hline \hline
**Parameter** & **Range/Values** \\ \hline Circle scenario radius & From 100 to 2000 m \\ Number of nodes to update (\(N\)) & 10 to 150 nodes \\ Number of initial broadcast rounds (\(B\)) (only & 1 by default \\ for the broadcast methods) & \\ Default size of a frame containing a firmware & 215 bytes (23 header + 192 payload) \\ chunk & Fixed to 100 kB \\ Firmware size & Fixed to 100 kB \\ Spreading factor & Fixed to SF7 \\ Bandwidth of the LoRa channel & Fixed to 125 kHz \\ Channel & 868 MHz \\ Sensitivity of the LoRa receptors & Fixed to \(-\)125 dBm \\ Duty cycle & 1\% \\ Propagation model & Log Distance \\  & (ns3::LogDistancePropagationLossModel) \\ Loss model & Nagakami \\  & (ns3::NakagamiPropagationLossModel) \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Simulation parameters. Figure 7: LoRa simulation environment (on top of ns-3). and _LoRaSimLogs_ (for handling and saving logs and simulation results). _LoRaSim_ is the main simulation layer, which handles the simulation parameters and launches each simulation iteration (for each FUOTA method), extracting results on the output files. Finally, a set of Python scripts are used to manage the output files and build the graphs showing the results. The Pandas, Seaborn, and Matplotlib modules are used for that aim. We first present a set of results for single runs of the OTA update of 10 nodes, with each of the three methods, using two values for the maximum radius: 400 m and 2 km. They are useful for obtaining insights about the behavior of each method.