# Modeling Network-Controlled Device-to-Device Communications in SimuLTE
## 5 Modeling Device-to-Device Communications in SimuLTE
### Modeling Air Transmissions of D2D MAC PDUs  
The modeling paradigm for air transmissions in SimuLTE, exploiting direct OMNeT++ messages, on the one hand, and SINR computation at the receiver, on the other, naturally lends itself to account for D2D transmissions. The first issue to be solved is endpoint identification, i.e., to keep track of which pairs (groups) of UEs are eligible as endpoints of a D2D communication at any time. Figure 14: Example of conflict matrix (**left**); and a node disposition which produces it (**right**). For P2P D2D, SimuLTE maintains a peering map within the Binder, as shown in Figure 15. For each D2D-capable sender \(s\), the map contains the set of possible destinations for which a D2D peering session might be established at some point, i.e., all the D2D-capable receivers to which \(s\) has already sent a message. This last condition keeps the map compact, since considerably fewer P2P flows are simulated than the cross-product of all the D2D-capable UEs. When a UE receives an IP datagram to be sent to a new destination, it checks through the Binder if the latter is a D2D-capable LTE device, in which case it adds the new related entry to the map. Each eNB performs mode-selection decisions on those flows in the peering map having both endpoints under its control (P2P D2D flows across cell borders are not supported in SimuLTE, and we believe that they are generally undvisable, as discussed in [18]), and stores the result directly in the peering map. By default, the communication mode is set to infrastructure, and is modified through MS operations. Moreover, when two endpoints in the peering map are under the same eNB, CQI reporting on the SL is also enabled. When a new IP datagram arrives from the upper layers, the UE's PDCP checks the peering map to associate the packet to either the UL or the D2D direction. In the latter case, the node ID of the peering UE selected as destination ID, which represents the argument of the single sendDirect() invocation used to send a message. For P2 MP D2D, the problem is to identify the interested receivers of a multicast transmission. In SimuLTE, we use the concept of multicast groups, each identified by an ID: at the reception of an IP datagram from the upper layers whose destination address is a multicast one (i.e., comprised within the range 224.0.0.0-239.255.255.255), the UE's PDCP layer considers the last eight bits of such address as the destination ID. Coherently, the packet is associated to the P2 MP D2D direction. The sender UE then creates a copy of the MAC PDU for every UE in the multicast group (identified by the destination ID) and invokes the sendDirect() accordingly. From a physical standpoint, each receiver of a sendDirect() (originating from either a P2P or a P2 MP transmission) computes the SINR as shown in Section 4.2, irrespective of who the sender is (an UE PHY module instead of an eNB's). All it takes is to add D2D transmitters to the UTM, so that they contribute to the general interference in the UL spectrum (for both SL and--less critically--UL transmissions). For P2 MP transmissions, an optimization has been implemented to reduce the number of sendDirect() invocations and ensuing SINR computations at the receivers. Since D2D transmissions are low-power, there exists a physical transmission horizon for each sender, beyond which successful decoding would be vanishingly unlikely in any case, because the received power would be too small. Such horizon can be computed based on the transmission power. All the destinations beyond the horizon line could then be eliminated from the target list of a message, with a relatively small loss in modeling accuracy. Below, we show how this optimization allows a remarkable speedup in some scenarios (e.g., vehicular communications with macro cells), where membership of the same multicast group is geographically diffuse, hence there is a high probability that the distance between two members is considerably larger than a transmission range.