# Modeling Network-Controlled Device-to-Device Communications in SimuLTE
## 5 Modeling Device-to-Device Communications in SimuLTE
### Modeling Resource Allocation  
D2D transmissions require resource allocation to be modified. As explained in Section 2, D2D transmissions are allocated on the UL subframe, hence D2D and UL transmissions share the RBs of the UL subframe. Our solution is to enforce no static segregation between RBs \"dedicated\" to one or the other, since this leads to inefficiencies. The only case when static segregation is in place is when ARS allocation is enforced (typically, for P2 MP communications): in this case, in fact, resources are allocated statically according to the standard, and accessed autonomously (and with contention) by the UEs. In all the other cases where resources are scheduled, all UEs can be scheduled anywhere anytime. Given that D2D transmissions share RBs with the UL ones, we enhance the LteSchedulerEnbUl class at the eNB's MAC to include both P2P and P2 MP D2D connections in the scheduling process. This only requires that the eNB MAC maintains BSR buffers for D2D connections as well: these BSR buffers are updated on reception of P2P D2D and P2 MP D2D BSRs from the sender UEs of a D2D connection. Apart from that, the UL scheduling operations described in Section 4 are unmodified. The resulting schedule list is composed of UL, P2P D2D and P2 MP D2D connections, arbitrarily interleaved according to the employed scheduling policy. When scanning the schedule list to send  
Figure 12: Management of the mode switching. transmission grants to the UE, the eNB MAC module takes care to include in the control packet the direction the granted RBs refers to. As mentioned above, scheduled D2D transmissions can exploit spatial reuse, i.e., allocate the same RB to more than one connection (under controlled circumstances), to reduce the frame occupancy. To allow for this, the LteSchedulerEnbUl class is adapted to produce an allocation map that allows it to store more than one transmitting UE in one RB. Figure 13 exemplifies such modified data structure, where each entry (i.e., each RB) contains a set of UEs. Our support for D2D-aware resource allocation algorithms in SimuLTE allows one to enforce frequency reuse among D2D connections (both P2P and P2 MP), but prevents two UL connections in the same cell to share resources. To keep track of reuse, we make available a data structure that computes potential conflicting transmissions based on a topological approach. In the latter, we assume that the position of the UEs in the floorplan is known. The above assumption is being widely used in the literature (see, e.g., [41; 42]), and becomes more credible with the spread of location-based services and Multi-access Edge Computing. The eNB MAC module can get the position of each UE by querying the Binder, and uses it to build a Conflict Graph (CG), i.e., a symmetric graph that states which pairs of transmitters conflict with each other, hence should not be activated simultaneously. The CG can be represented in matrix form. With reference to Figure 14, the topmost diagonal block of the conflict matrix stores inter-P2P conflicts, whereas the bottom diagonal block stores inter-P2 MP conflicts. Both blocks are symmetric. The non-diagonal blocks hold P2P-P2 MP conflicts. The heading of each row/column is the name of the related flow, and we use a couple of lowercase letters to indicate the transmitter and receiver for P2P flows and a single Greek letter to indicate the transmitter of a P2 MP flow. Each transmitter has two radiuses: a transmission radius \(r_{t}\), which corresponds to the maximum distance at which a receiver has a \"high\" probability of decoding, and an interference radius \(r_{i}\), \(r_{i}>r_{t}\), corresponding to the maximum distance where its interference is considered to be detrimental to other receivers. These radiuses can be set based on the transmission power and the pathloss model.