Skip to content

Commit fe1dcec

Browse files
committed
all: refactor: methods made virtual
To allow overriding in subclasses. DrbTable is left alone on purpose: it is a by-value member of NrSdap, so it can never be substituted polymorphically and a vtable would buy nothing. Also adds the virtual destructors that the newly polymorphic classes need. ConflictGraph is a genuine fix rather than a precaution: it already had pure virtual methods, and LteMacEnbD2D holds a DistanceBasedConflictGraph through a ConflictGraph pointer, so destroying one was undefined behaviour. RlcRetransmissionBuffer's destructor is made virtual along with it, as the class becomes polymorphic here. The four TR 38.901 path loss helpers in NrChannelModel_3GPP38_901 have the same signatures as the ones in NrChannelModel and were hiding them; they are marked override now that the base ones are virtual. This does not change behaviour, because both classes override computePathLoss(), which is their only caller. The same applies to getStdDev(), whose only caller computeShadowing() is likewise overridden. Note that computeLosProbability() is deliberately left non-virtual for now: NrChannelModel_3GPP38_901 does not override getAttenuation(), so making it virtual would genuinely change which LOS model runs, and needs its own fix.
1 parent 7b2e728 commit fe1dcec

75 files changed

Lines changed: 2437 additions & 372 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/simu5g/stack/compManager/LteCompManagerBase.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ class LteCompManagerBase : public cSimpleModule
7676

7777
protected:
7878
static CompNodeType parseNodeType(const char *nodeType);
79-
void runClientOperations();
80-
void runCoordinatorOperations();
81-
void handleX2Message(inet::Packet *pkt);
82-
void sendClientRequest(X2CompRequestIE *requestIe);
83-
void sendCoordinatorReply(X2NodeId clientId, X2CompReplyIE *replyIe);
79+
virtual void runClientOperations();
80+
virtual void runCoordinatorOperations();
81+
virtual void handleX2Message(inet::Packet *pkt);
82+
virtual void sendClientRequest(X2CompRequestIE *requestIe);
83+
virtual void sendCoordinatorReply(X2NodeId clientId, X2CompReplyIE *replyIe);
8484

8585
virtual void provisionalSchedule() = 0; // run the provisional scheduling algorithm (client side)
8686
virtual void doCoordination() = 0; // run the coordination algorithm (coordinator side)
@@ -91,7 +91,7 @@ class LteCompManagerBase : public cSimpleModule
9191
virtual X2CompReplyIE *buildCoordinatorReply(X2NodeId clientId) = 0;
9292
virtual void handleCoordinatorReply(inet::IntrusivePtr<X2CompMsg> compMsg) = 0;
9393

94-
void setUsableBands(UsableBands& usableBands);
94+
virtual void setUsableBands(UsableBands& usableBands);
9595

9696
public:
9797
void initialize(int stage) override;

src/simu5g/stack/compManager/compManagerProportional/LteCompManagerProportional.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class LteCompManagerProportional : public LteCompManagerBase
4040
std::vector<unsigned int> offset_;
4141

4242
// utility function: convert a vector of double to a vector of integer, preserving the sum of the elements
43-
std::vector<unsigned int> roundVector(std::vector<double>& vec, int sum);
43+
virtual std::vector<unsigned int> roundVector(std::vector<double>& vec, int sum);
4444

4545
void provisionalSchedule() override; // run the provisional scheduling algorithm (client side)
4646
void doCoordination() override; // run the coordination algorithm (coordinator side)
@@ -51,7 +51,7 @@ class LteCompManagerProportional : public LteCompManagerBase
5151
X2CompProportionalReplyIE *buildCoordinatorReply(X2NodeId clientId) override;
5252
void handleCoordinatorReply(inet::Ptr<X2CompMsg> compMsg) override;
5353

54-
UsableBands parseAllowedBlocksMap(std::vector<CompRbStatus>& allowedBlocksMap);
54+
virtual UsableBands parseAllowedBlocksMap(std::vector<CompRbStatus>& allowedBlocksMap);
5555

5656
public:
5757

src/simu5g/stack/dcX2Forwarder/DcX2Forwarder.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class DcX2Forwarder : public cSimpleModule
3838
cGate *x2ManagerInGate_ = nullptr;
3939
cGate *x2ManagerOutGate_ = nullptr;
4040

41-
void handleX2Message(cMessage *msg);
41+
virtual void handleX2Message(cMessage *msg);
4242

4343
protected:
4444

@@ -47,10 +47,10 @@ class DcX2Forwarder : public cSimpleModule
4747
void handleMessage(cMessage *msg) override;
4848

4949
// send a PDCP PDU to the X2 Manager
50-
void forwardDataToTargetNode(inet::Packet *pkt, MacNodeId targetNode);
50+
virtual void forwardDataToTargetNode(inet::Packet *pkt, MacNodeId targetNode);
5151

5252
// receive PDCP PDU from X2 Manager and send it to the PDCP layer
53-
void receiveDataFromSourceNode(inet::Packet *pkt, MacNodeId sourceNode);
53+
virtual void receiveDataFromSourceNode(inet::Packet *pkt, MacNodeId sourceNode);
5454
};
5555

5656
} //namespace

src/simu5g/stack/handoverX2Forwarder/HandoverX2Forwarder.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,20 @@ class HandoverX2Forwarder : public cSimpleModule
5252
int numInitStages() const override { return inet::NUM_INIT_STAGES; }
5353
void handleMessage(cMessage *msg) override;
5454

55-
void handleX2Message(cPacket *pkt);
55+
virtual void handleX2Message(cPacket *pkt);
5656

5757
// receive handover command on X2 from the source eNB
58-
void receiveHandoverCommand(MacNodeId ueId, MacNodeId enb, bool startHo);
58+
virtual void receiveHandoverCommand(MacNodeId ueId, MacNodeId enb, bool startHo);
5959

6060
// send an IP datagram to the X2 Manager (called internally via gate)
61-
void forwardDataToTargetEnb(inet::Packet *datagram, MacNodeId targetEnb);
61+
virtual void forwardDataToTargetEnb(inet::Packet *datagram, MacNodeId targetEnb);
6262

6363
// receive data from X2 message and send it to the HandoverPacketHolder
64-
void receiveDataFromSourceEnb(inet::Packet *datagram, MacNodeId sourceEnb);
64+
virtual void receiveDataFromSourceEnb(inet::Packet *datagram, MacNodeId sourceEnb);
6565

6666
public:
6767
// send handover command on X2 to the eNB
68-
void sendHandoverCommand(MacNodeId ueId, MacNodeId enb, bool startHo);
68+
virtual void sendHandoverCommand(MacNodeId ueId, MacNodeId enb, bool startHo);
6969

7070
};
7171

src/simu5g/stack/ip2nic/HandoverPacketHolderEnb.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ class HandoverPacketHolderEnb : public cSimpleModule
5757

5858
public:
5959
~HandoverPacketHolderEnb() override;
60-
void triggerHandoverSource(MacNodeId ueId, MacNodeId targetEnb);
61-
void triggerHandoverTarget(MacNodeId ueId, MacNodeId sourceEnb);
62-
void sendTunneledPacketOnHandover(inet::Packet *datagram, MacNodeId targetEnb);
63-
void receiveTunneledPacketOnHandover(inet::Packet *datagram);
64-
void signalHandoverCompleteSource(MacNodeId ueId, MacNodeId targetEnb);
65-
void signalHandoverCompleteTarget(MacNodeId ueId, MacNodeId sourceEnb);
60+
virtual void triggerHandoverSource(MacNodeId ueId, MacNodeId targetEnb);
61+
virtual void triggerHandoverTarget(MacNodeId ueId, MacNodeId sourceEnb);
62+
virtual void sendTunneledPacketOnHandover(inet::Packet *datagram, MacNodeId targetEnb);
63+
virtual void receiveTunneledPacketOnHandover(inet::Packet *datagram);
64+
virtual void signalHandoverCompleteSource(MacNodeId ueId, MacNodeId targetEnb);
65+
virtual void signalHandoverCompleteTarget(MacNodeId ueId, MacNodeId sourceEnb);
6666
};
6767

6868
} //namespace

src/simu5g/stack/ip2nic/HandoverPacketHolderUe.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ class HandoverPacketHolderUe : public cSimpleModule
5151
int numInitStages() const override { return inet::NUM_INIT_STAGES; }
5252
void handleMessage(cMessage *msg) override;
5353

54-
void fromIpUe(inet::Packet *datagram);
54+
virtual void fromIpUe(inet::Packet *datagram);
5555
virtual void toStackUe(inet::Packet *datagram);
5656

5757
public:
5858
~HandoverPacketHolderUe() override;
59-
void triggerHandoverUe(MacNodeId newMasterId, bool isNr = false);
60-
void signalHandoverCompleteUe(bool isNr = false);
59+
virtual void triggerHandoverUe(MacNodeId newMasterId, bool isNr = false);
60+
virtual void signalHandoverCompleteUe(bool isNr = false);
6161

6262
MacNodeId getServingNodeId() const { return servingNodeId_; }
6363
MacNodeId getNrServingNodeId() const { return nrServingNodeId_; }

src/simu5g/stack/ip2nic/Ip2Nic.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,20 +116,20 @@ class Ip2Nic : public cSimpleModule
116116
virtual void toStackUe(inet::Packet *datagram);
117117

118118
// Packet analysis (moved from PDCP): classifies the packet and fills FlowControlInfo tag
119-
void analyzePacket(inet::Packet *pkt, inet::Ipv4Address srcAddr, inet::Ipv4Address destAddr, uint16_t typeOfService);
120-
MacNodeId getNextHopNodeId(const inet::Ipv4Address& destAddr, bool useNR, MacNodeId sourceId);
121-
LteTrafficClass getTrafficCategory(cPacket *pkt);
122-
LteRlcType getRlcType(LteTrafficClass trafficCategory);
123-
DrbId lookupOrAssignDrbId(const ConnectionKey& key, const FlowControlInfo *lteInfo);
119+
virtual void analyzePacket(inet::Packet *pkt, inet::Ipv4Address srcAddr, inet::Ipv4Address destAddr, uint16_t typeOfService);
120+
virtual MacNodeId getNextHopNodeId(const inet::Ipv4Address& destAddr, bool useNR, MacNodeId sourceId);
121+
virtual LteTrafficClass getTrafficCategory(cPacket *pkt);
122+
virtual LteRlcType getRlcType(LteTrafficClass trafficCategory);
123+
virtual DrbId lookupOrAssignDrbId(const ConnectionKey& key, const FlowControlInfo *lteInfo);
124124

125125
// Establish the (duplex) bearer for the flow via the Binder, then register the
126126
// mirrored flow->DRB mapping at the peer's Ip2Nic so reverse application traffic
127127
// resolves to this bearer's reverse leg instead of allocating a new DRB.
128-
void establishConnection(FlowControlInfo *lteInfo, const ConnectionKey& key);
128+
virtual void establishConnection(FlowControlInfo *lteInfo, const ConnectionKey& key);
129129

130130
// Called by a peer's Ip2Nic: bind an incoming flow key to the DRB of a bearer
131131
// established from the remote side (no-op if the key is already bound).
132-
void registerDrbMapping(const ConnectionKey& key, DrbId drbId);
132+
virtual void registerDrbMapping(const ConnectionKey& key, DrbId drbId);
133133

134134
public:
135135
// Radio link failure handling is data-plane only here: BearerManagement (RRC) drives
@@ -138,10 +138,10 @@ class Ip2Nic : public cSimpleModule
138138

139139
// Start dropping a peer's future DL/UL packets (UE Context Release). Its bearer
140140
// re-establishes on demand once resumeUe() is called.
141-
void releaseUe(MacNodeId ueId);
141+
virtual void releaseUe(MacNodeId ueId);
142142

143143
// Stop dropping the peer's packets (RRC re-establishment complete); traffic resumes.
144-
void resumeUe(MacNodeId ueId);
144+
virtual void resumeUe(MacNodeId ueId);
145145
};
146146

147147
} //namespace

src/simu5g/stack/mac/LteMacBase.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ class LteMacBase : public cSimpleModule
188188
protected:
189189

190190
unsigned int getNumerologyPeriodCounter(NumerologyIndex index) { return numerologyPeriodCounter_[index].current; }
191-
void decreaseNumerologyPeriodCounter();
191+
virtual void decreaseNumerologyPeriodCounter();
192192

193193
public:
194194

@@ -249,7 +249,7 @@ class LteMacBase : public cSimpleModule
249249
* Extracts a MacCid from FlowControlInfo.
250250
* Converts DrbId (from PDCP/RLC) to LogicalCid (MAC layer).
251251
*/
252-
MacCid ctrlInfoToMacCid(const FlowControlInfo *info) {
252+
virtual MacCid ctrlInfoToMacCid(const FlowControlInfo *info) {
253253
return MacCid(ctrlInfoToUeId(info), drbIdToLcid(info->getDrbId()));
254254
}
255255

@@ -372,13 +372,13 @@ class LteMacBase : public cSimpleModule
372372
return false;
373373
}
374374

375-
void unregisterHarqBufferRx(MacNodeId nodeId);
375+
virtual void unregisterHarqBufferRx(MacNodeId nodeId);
376376

377377
// visualization
378378
void refreshDisplay() const override;
379379

380-
void recordHarqErrorRate(unsigned int sample, Direction dir);
381-
double getHarqErrorRate(Direction dir);
380+
virtual void recordHarqErrorRate(unsigned int sample, Direction dir);
381+
virtual double getHarqErrorRate(Direction dir);
382382

383383
/*
384384
* @author Alessandro Noferi
@@ -430,15 +430,15 @@ class LteMacBase : public cSimpleModule
430430
*
431431
* @param pkt Packet to send
432432
*/
433-
void sendLowerPackets(cPacket *pkt);
433+
virtual void sendLowerPackets(cPacket *pkt);
434434

435435
/**
436436
* sendUpperPackets() is used
437437
* to send packets to upper layer
438438
*
439439
* @param pkt Packet to send
440440
*/
441-
void sendUpperPackets(cPacket *pkt);
441+
virtual void sendUpperPackets(cPacket *pkt);
442442

443443
/*
444444
* Functions to be redefined by derived classes
@@ -519,7 +519,7 @@ class LteMacBase : public cSimpleModule
519519
virtual void updateUserTxParam(cPacket *pkt) = 0;
520520

521521
/// Upper Layer Handler
522-
void fromRlc(cPacket *pkt);
522+
virtual void fromRlc(cPacket *pkt);
523523

524524
/// Lower Layer Handler
525525
virtual void fromPhy(cPacket *pkt);

0 commit comments

Comments
 (0)