# Modeling Network-Controlled Device-to-Device Communications in SimuLTE
## 5 Modeling Device-to-Device Communications in SimuLTE
### Modeling Resource Allocation
Assuming--for ease of exposition only--that the values of \(r_{t}\) and \(r_{i}\) are the same for all transmitters (we leave to the interested reader the simple, yet tedious generalization to the case of per-flow transmission and interference radiuses), and denoting with \(d(i,j)\) the Euclidean distance between UEs \(i\) and \(j\), the conflict conditions are the following (see the example in Figure 14):  
1. Inter-P2P: two P2P flows (\(i\),\(j\)) and (\(k\),\(l\)) are conflicting if \(\min\{d(i,l),d(k,j)\}\leq r_{i}\)
2. Inter-P2 MP: two P2 MP transmitters \(\alpha\) and \(\beta\) are conflicting if \(d(\alpha,\beta)\leq r_{t}+r_{i}\)
3. P2P with P2 MP (and vice versa): flow (\(i\),\(j\)) and transmitter \(\alpha\) are conflicting if \(d(i,\alpha)\leq r_{t}+r_{i}\)  
Note that the above conflict conditions may be more restricting than necessary. For instance, in Condition (3), the hidden hypothesis is that there actually _is_ at least one P2 MP receiver UE \(x\) such that \(d(x,x)\leq r_{t}\) and \(d(i,x)\leq r_{i}\), which may or may not be the case. Testing for the location of P2 MP receivers, however, is computationally complex (it may require up to \(O(N)\) operations per conflict), whereas each of the above three conditions can be tested in constant time. The above data structure can be used to devise reuse-aware schedulers, such as the one in [28], that prevent a priori resource sharing among some couples of transmitters. We remark that physical interference on D2D transmissions is always computed according to a SINR model a posteriori,  
Figure 13: Allocation map with frequency reuse. as explained in Section 5.3, hence the cumulative effects of small interferers would be felt by transmissions, though not anticipated by inspecting the above data structure. The main drawback of this approach is that algorithms allocating resources based on the conflict model cannot foresee the cumulative effect of small, faraway interferers [43]. We evaluate this phenomenon in Section 6.2. Finally, we want users to be able to choose, at configuration time, which type(s) of D2D connections should exploit frequency reuse. For instance, a user may want to limit frequency reuse to P2P D2D connections, scheduling P2 MP ones on exclusive resources. To make this efficient, we modeled SimuLTE scheduling so that connections which are not in the conflict graph are to be scheduled on mutually exclusive resources by default. Therefore, if a user configures a simulation where frequency reuse occurs only among P2P D2D connections, then only the topmost diagonal block of the conflict matrix will be instantiated and used, with reduced scheduling complexity. Besides managing resource allocation, the eNB has to perform mode selection for P2P D2D connections, i.e., decide which of them should be allocated on the SL and which on the UL/DL infrastructure path. Several papers advocate joint mode selection and resource allocation (e.g., [44; 45]), whereby the eNB does both at the same time. We disagree with the above approach, since mode-selection decisions (especially on a cell-wide basis) may take a considerable amount of time, and the ensuing MS operations may induce losses [18], hence they cannot be too frequent (certainly not every TTI). On the other hand, resource allocation must be done on a per-TTI basis to capitalize on the knowledge of fresh channel conditions and recent backlog. For this reason, in SimuLTE, mode selection is autonomous, and can be configured to run at the eNB at the desired frequency (we suggest once every 100-1000 TTIs, a timeframe comparable with appreciable changes in the relative distance of UEs in motion, hence their channel). We support mode selection schemes that can take into account both local and global (i.e., cell-level) metrics. For example, even if the SL between two D2D endpoints is experiencing poor channel conditions, switching it to the infrastructure mode might still be unadvisable, e.g., because the DL subframe is overloaded.