# Narrowband-Internet of Things Device-to-Device Simulation: An Open-Sourced Framework
## 3 NB-IoT D2D Framework, Model, and Simulation
### Latency-Energy Model  
NB-IoT can handle three coverage classes, i.e., robust (extended), extreme, and normal, for serving devices with constrained resources and suffering varying path loss levels [41]. However, the requirements of latency and throughput are maintained in the extreme coverage class, whereas improved performance is ensured in the extended or normal coverage class [42]. Therefore, in this work, we focus on normal and extreme coverage classes. This latency-energy model is taken from [15; 43]. A total of two coverage classes are defined as \(C=2\). On the basis of estimated path loss, a class is assigned to a device by the BS that informs the assigned device of the dedicated path between them. Class \(j\) and \(\forall j\) are supported by the replicas number \(cj\), which are transmitted based on data and the control packet [15]. The uplink/downlink access technique is modeled as two servers working for the associated traffic queues, as shown in Figure 14[15]. For the purpose of brevity, interested readers are referred to [15] for further information on Figure 14. The reserved NPRACH period of class \(j\) is denoted by \(cj\tau\). The unit length \(\tau\) of the NPRACH for the class of coverage is denoted by \(cj=1\). The average time duration between the NPDCCH occurrences is represented by \(td\) in this latency-energy model. Those signals that are multiplexed with respect to time undergo trade-off analysis in the NP channel using the down and uplink algorithm under the assumption that the coverage classes in the network are the two represented by \(C=2\). The first coverage class corresponds to the CH with the normalized path loss, whi  
Figure 14: LEACH-based NB-IoT traffic queuing model. Figure 13: Signal Interference to Noise Ratio for BS No. 15 in a rural macrocell scenario. to clusters having extreme path loss. The path loss of the second group of clusters is in the communication and in the evaluation of trade-offs. Considering the presence of the available radio resources of the NB-IoT subsystem and the amount of traffic data, the scheduling is optimized with the minimum latency, extended battery lifetime, and reduced power performance necessary to maintain the existing scheduling policy. The number of communication sessions corresponds to the speed of arrival of the uplink and downlink requests made in a day by the specific device to the given system. The rate depends on the number of sessions that a cluster achieves daily and is denoted of service requests by the following:  
\[G_{u}=Sp_{u}N, \tag{13}\]  
where \(S\) is the required sessions per day and \(p_{u}\) is the probability of the uplink requests for the service. For the \(G_{d}\), the probability of downlink becomes \(1-p_{u}\), which produces the equation as represented in (14):  
\[G_{d}=(1-p_{u})\ N\ S. \tag{14}\]  
Synchronization is required by CH for the uplink and downlink services with the BS on top of NSSS and NPSS, where the synchronization delay required is \(D_{syj}\); \(D_{sy1}\) = 0.33 s, \(D_{sy2}\) = 0.66 s and also the power consumption of \(P_{l}\) = 0.1, to make the listening represented by \(E_{syj}\):  
\[E_{sy_{j}}=D_{sy_{j}}P_{l}. \tag{15}\]  
A Random-Access request (RA) is sent by a CH, and the BS responds with a Random Access Response (RAR) containing the NPDCCH message. A device connects to the BS in a deep sleep mode and reconnects for the transmission of RA messages along with a random number. The number of attempts made depends on the probability of available resources and is denoted by \(N_{max}\), whereas the probability \(P_{j}\) depends on the class of the devices that are attempting to connect to the system.