D2dBinder.h Source File

Simu5G: D2dBinder.h Source File
Simu5G
D2dBinder.h
1//
2// Simu5G
3//
4// Copyright (C) 2012-2021 Giovanni Nardini, Giovanni Stea, Antonio Virdis et al. (University of Pisa)
5// Copyright (C) 2022-2026 Giovanni Nardini, Giovanni Stea et al. (University of Pisa)
6//
7// This file is part of a software released under the license included in file
8// "license.pdf". Please read LICENSE and README files before using it.
9// The above files and the present reference are part of the software itself,
10// and cannot be removed from it.
11//
12
13#ifndef _D2DBINDER_H_
14#define _D2DBINDER_H_
15
16#include <map>
17#include <set>
18
19#include <inet/common/ModuleRefByPar.h>
20
21#include "simu5g/common/LteCommon.h"
22#include "simu5g/common/binder/Binder.h"
23
24namespace simu5g {
25
26using namespace omnetpp;
27
28class PhyBase;
29
44class D2dBinder : public cSimpleModule, public cListener
45{
46 private:
47 // reference to the core Binder, used for node and serving-cell lookups
48 inet::ModuleRefByPar<Binder> binder_;
49
50 // determines if two D2D-capable UEs are communicating in D2D mode or Infrastructure Mode
51 std::map<MacNodeId, std::map<MacNodeId, LteD2DMode>> d2dPeeringMap_;
52
53 // set of D2D one-to-many (multicast) transmitters
54 std::set<MacNodeId> multicastTransmitterSet_;
55
56 // The DRB ids in use within each sidelink node pair -- a UE and a peer UE, or a UE
57 // and a multicast group -- pooled network-wide, since a sidelink bearer's ends are
58 // UEs whose serving base stations may differ and change (a base station pools the
59 // pairs it is itself a party to, see ConnectionControlEnb::assignDrbId())
60 std::map<std::pair<MacNodeId, MacNodeId>, std::set<DrbId>> sidelinkDrbIds_;
61
62 public:
63 /*
64 * The flow that established each multicast bearer, kept so that a node joining the group
65 * later can still be given its RX leg (see ConnectionControlEnbD2D::multicastGroupJoined()).
66 * The sender's base station provisions the members that exist when the sender starts,
67 * which is all of them only if the node population is static; with nodes created
68 * during the simulation the joiner would otherwise receive PDUs for a connection its
69 * stack knows nothing about.
70 *
71 * Keyed by (multicast group id, sender id): the RX side of a bearer is keyed by its
72 * sender (see FlowId::rxDrbKey, and MacCid(senderId, lcid) in
73 * BearerManagement::createIncomingConnection), so a group served by several senders --
74 * at once, or one after another as vehicles come and go -- needs one remembered flow per
75 * sender. Each entry is dropped when its sender leaves, see receiveSignal().
76 */
77 struct MulticastFlow {
78 FlowId flow;
79 BearerRequest req;
80 bool withPdcp = false;
81
82 friend std::ostream& operator<<(std::ostream& os, const MulticastFlow& e)
83 {
84 os << "flow=[" << e.flow << "] req=[" << e.req << "] withPdcp=" << e.withPdcp;
85 return os;
86 }
87 };
88
89 private:
90 std::map<std::pair<MacNodeId, MacNodeId>, MulticastFlow> multicastFlows_;
91
92 // D2D-capable UE PHYs by node id, registered at init (see registerD2dPhy)
93 std::map<MacNodeId, opp_component_ptr<PhyBase>> d2dPhys_;
94
95 protected:
96 void initialize() override;
97 void handleMessage(cMessage *msg) override {}
98
99 // compute the initial D2D mode for the given transmitter/receiver UE pair
100 virtual LteD2DMode computeD2DCapability(MacNodeId src, MacNodeId dst);
101
108 void receiveSignal(cComponent *source, simsignal_t signalID, long nodeId, cObject *details) override;
109
110 public:
116 virtual void registerD2dPhy(MacNodeId nodeId, PhyBase *phy);
117
122 virtual PhyBase *getD2dPhy(MacNodeId nodeId);
123
128 virtual bool checkD2DCapability(MacNodeId src, MacNodeId dst);
129
134 virtual bool getD2DCapability(MacNodeId src, MacNodeId dst);
135
140 virtual LteD2DMode getD2DMode(MacNodeId src, MacNodeId dst);
141
146 const std::map<MacNodeId, std::map<MacNodeId, LteD2DMode>>& getD2DPeeringModeMap() const { return d2dPeeringMap_; }
147
152 virtual void setD2DMode(MacNodeId src, MacNodeId dst, LteD2DMode mode);
153
154 // add one D2D one-to-many (multicast) transmitter
155 virtual void addD2DMulticastTransmitter(MacNodeId nodeId);
156 // get the set of D2D one-to-many (multicast) transmitters
157 virtual std::set<MacNodeId>& getD2DMulticastTransmitters();
158
159 // The DRB id pool of a sidelink node pair (see sidelinkDrbIds_); the pair is ordered
160 virtual std::set<DrbId>& sidelinkDrbIdPool(const std::pair<MacNodeId, MacNodeId>& pair);
161 // Remember the flow that established a multicast bearer, unless the sender's flow
162 // for the group is remembered already (see multicastFlows_)
163 virtual void rememberMulticastFlow(MacNodeId groupId, MacNodeId senderId, const FlowId& flow, const BearerRequest& req, bool withPdcp);
164 virtual const std::map<std::pair<MacNodeId, MacNodeId>, MulticastFlow>& getMulticastFlows() const { return multicastFlows_; }
165};
166
167} //namespace
168
169#endif
Definition D2dBinder.h:45
void receiveSignal(cComponent *source, simsignal_t signalID, long nodeId, cObject *details) override
virtual bool getD2DCapability(MacNodeId src, MacNodeId dst)
virtual void registerD2dPhy(MacNodeId nodeId, PhyBase *phy)
const std::map< MacNodeId, std::map< MacNodeId, LteD2DMode > > & getD2DPeeringModeMap() const
Definition D2dBinder.h:146
virtual LteD2DMode getD2DMode(MacNodeId src, MacNodeId dst)
virtual void setD2DMode(MacNodeId src, MacNodeId dst, LteD2DMode mode)
virtual bool checkD2DCapability(MacNodeId src, MacNodeId dst)
virtual PhyBase * getD2dPhy(MacNodeId nodeId)
Definition AlertReceiver.h:24