# Narrowband-Internet of Things Device-to-Device Simulation: An Open-Sourced Framework
## 4 Simulation Output and Discussions  
Compared to studies such as [15; 43], the proposed NB-IoT D2D simulation minimizes the latency from uplink/downlink service requests, as presented in Figures 15 and 16. Our framework also reduces the energy consumption that comes from the uplink/downlink service request, as shown in Figures 17 and 18. Furthermore, it improves the coexistence between normal and extreme coverage classes, as illustrated in Figure 19, and enhances the lifetime of the NB-IoT device's battery, as illustrated in Figure 20. Based on the cell radius and selected propagation scenario, our open-sourced model presents the path loss graph, as illustrated in Figure 21. As a result, the IoT system designer can use our model to develop the most accurate estimations, allowing for a decrease in energy consumption and an increase in performance by varying the simulator parameters. Figures 22-24 show the path loss average between CHs and BSs for the NB-IoT D2D simulation framework compared with the MCL. Figure 21: Path loss in the urban scenario, BS No. 21. Figure 20: The lifetime of a device’s battery \(L_{j}\) versus \(t\) and \(td\). Figure 23: Average path loss in the urban scenario. Figure 24: Average path loss in the rural cell scenario. Figure 22: Average path loss in the microcell scenario. As shown in Figure 20, the maximum lifetime for class 1 is \(td=0.526\) and \(t=1.00\), whereas the maximum lifetime for class 2 is \(td=0.626\) and \(t=1.00\). Figure 15 illustrates that the minimum latency of an uplink for class 1 is \(td=0.001\) and \(t=1.00\), while the minimum latency of an uplink for class 2 is \(td=0.001\) and \(t=1.00\). As shown in Figure 16, the minimum latency of a downlink for class 1 is \(td=0.051\) and \(t=0.05\) however, the minimum latency of a downlink for class 2 is \(td=0.051\) and \(t=0.05\). The NB-IoT attocell network topology integrates with the LEACH algorithm to reduce several queues to a few (Figure 25 vs. Figure 26). This NB-IoT D2D framework, as shown in Figure 25A,B, produces a BS queuing matrix \((vBSnx)\) that shows the total expected energy consumption for the respective associated nodes, the total expected energy consumption for uplink and downlink services, the devices' energy consumption for a downlink request \((\xi_{dj})\), the device's energy consumption for an uplink request \((\xi_{uj})\), the time between two NPDCCH schedules \((td)\), the time between two NPRACH schedules \((t)\), the type of coverage class, the path loss during communication, and the distance to the respective CHs, respectively. Figure 26A,B explains the queue at BS No. 18 and BS No. 19 in case of traditional NB-IoT (i.e., without using LEACH protocol). It shows the total expected energy consumption for the respective associated nodes, the devices' energy consumption for a downlink request \((\xi_{dj})\), the device's energy consumption for an uplink request \((\xi_{uj})\), the type of coverage class, the path loss during communication, and the distance to the node. The queuing matrix (vBSnx) can indicate the queue at each BS in case of the NB-IoT D2D and conventional NB-IoT, but BS No. 18 and BS No. 19 have been randomly selected as examples. Figure 25A confirms there are only three CHs queuing at BS No. 18, and Figure 25B shows there are only two CHs queuing at BS No. 19). Figure 26A,B shows there are 19 nodes queuing at BS No. 18 and 17 nodes queuing at BS No. 19, respectively. This proves practically that when the LEACH model is used, the queues at each BS are minimized. This reduces the latency (i.e., delay time) and energy consumption at each BS. In addition, there is a queue at each CH \((mtrxCH(:,:,n))\), as illustrated in Figure 27A,B. It displays the total expected energy consumption for uplink and downlink services, the devices' energy consumption for a downlink request \((\xi_{dj})\), the device's energy consumption for an uplink request \((\xi_{uj})\), the coverage class, the path loss between devices, the distance between CH and its NCHs, and the respective associated cluster nodes.