D2dUeMacBase< Base > Class Template Reference

Simu5G: D2dUeMacBase< Base > Class Template Reference
Simu5G
D2dUeMacBase< Base > Class Template Reference

#include <D2dUeMacBase.h>

Protected Member Functions

void recordBufferOverflow (Direction dir, double sample) override
 The D2D directions are serviced here; everything else defers to the core MAC.
void initialize (int stage) override
void handleMessage (cMessage *msg) override
bool isBsrPending () const override
int64_t appendBsr (inet::Ptr< LteMacPdu > macPdu) override
bool buildStandaloneBsr () override
MacNodeId pduDestId (MacCid destCid) override
 D2D bearers are peer-addressed: the destination comes from the flow, not the cell.
bool shouldSkipScheduleEntry (unsigned int sduPerCid) const override
UnitList reserveTxHarqUnits (LteHarqBufferTx *txBuf, Direction dir) override
void macHandleRac (cPacket *pkt) override
LteHarqBufferRx * createRxHarqBuffer (MacNodeId src, const UserControlInfo *userInfo) override
 HARQ buffer factories: add support for the D2D and D2D_MULTI directions.
LcgScheduler * createLcgScheduler () override
 Factory override: use the D2D-capable LCG scheduler.

Detailed Description

template<class Base>
class simu5g::D2dUeMacBase< Base >

CRTP mixin that adds D2D support to a UE MAC.

The core UE MACs (LteMacUe and its NR subclass NrMacUe) carry no D2D code; this mixin layers the D2D UE-MAC logic (D2D BSR handling, D2D RAC requests, mode-switch dispatch, D2D H-ARQ buffer factories, the D2D macPduMake seams) on top of either of them, so the LTE and NR D2D MACs share one implementation. The D2D state and mode-switch machinery live in D2dUeMacHelper; the mixin holds the module-side logic the two leaf classes used to duplicate. It has native protected access to the Base internals it needs.

The concrete Define_Module'd MACs are: LteMacUeD2D = D2dUeMacBase<LteMacUe> (+ the LTE-specific main loop, see LteMacUeD2D.h) NrMacUeD2D = D2dUeMacBase<NrMacUe>

The LTE/NR differences inside the shared macPduMake body flow through the two D2D-agnostic Base seams isCarrierActive() (numerology period) and reserveTxHarqUnits() (synchronous vs. asynchronous H-ARQ), preserving each variant's historical behavior exactly.

Signals: every D2D signal id in this package is obtained by interning the name at RUNTIME – from a module's initialize(), or from a helper's constructor – never by a static registerSignal() initializer. Static registration happens at load time in link order, so a static in any D2D translation unit would insert D2D names into the middle of the core's signal-id sequence, shifting the order in which results are recorded and with it the 'sz' fingerprint ingredient, in a way that depends on the link line. Interning at runtime keeps every core signal id identical whether or not the D2D package is linked in, which is what makes the feature-off build genuinely equivalent to the core alone.

Member Function Documentation

◆ recordBufferOverflow()

template<class Base>
void recordBufferOverflow ( Direction dir,
double sample )
inlineoverrideprotected

The D2D directions are serviced here; everything else defers to the core MAC.

◆ initialize()

template<class Base>
void initialize ( int stage)
overrideprotected

Reads MAC parameters for the UE and performs initialization.

References simu5g::NODEID_NONE.

◆ handleMessage()

template<class Base>
void handleMessage ( cMessage * msg)
overrideprotected

Analyze gate of incoming packet and call proper handler

◆ isBsrPending()

template<class Base>
bool isBsrPending ( ) const
inlineoverrideprotected

D2D delta for the base main loop: a pending D2D multicast BSR also warrants a BSR-only MAC PDU.

Referenced by shouldSkipScheduleEntry().

◆ appendBsr()

template<class Base>
int64_t appendBsr ( inet::Ptr< LteMacPdu > macPdu)
inlineoverrideprotected

Extends the base by also clearing the D2D-multicast trigger, so that one appended BSR consumes whichever of the two triggers was pending.

◆ buildStandaloneBsr()

template<class Base>
bool buildStandaloneBsr ( )
overrideprotected

A UE in D2D mode that is granted UL resources with nothing scheduled answers with a standalone BSR-only PDU covering just its D2D (or D2D multicast) flows. Returns true if such a PDU was built and placed in macPduList_, in which case macPduMake() skips the SDU loop entirely.

◆ pduDestId()

template<class Base>
MacNodeId pduDestId ( MacCid destCid)
inlineoverrideprotected

D2D bearers are peer-addressed: the destination comes from the flow, not the cell.

◆ shouldSkipScheduleEntry()

template<class Base>
bool shouldSkipScheduleEntry ( unsigned int sduPerCid) const
inlineoverrideprotected

An entry with no SDUs is only worth a PDU if it can carry a pending BSR (either the Uu one or the D2D multicast one – see isBsrPending()).

References isBsrPending().

◆ reserveTxHarqUnits()

template<class Base>
UnitList reserveTxHarqUnits ( LteHarqBufferTx * txBuf,
Direction dir )
inlineoverrideprotected

D2D_MULTI has no feedback, so it always uses the current process, as the historical LTE D2D MAC did for every direction; other directions follow the Base policy (synchronous for LTE, first available for NR).

◆ macHandleRac()

template<class Base>
void macHandleRac ( cPacket * pkt)
overrideprotected

TODO flush all buffers here

◆ createRxHarqBuffer()

template<class Base>
LteHarqBufferRx * createRxHarqBuffer ( MacNodeId src,
const UserControlInfo * userInfo )
overrideprotected

HARQ buffer factories: add support for the D2D and D2D_MULTI directions.

◆ createLcgScheduler()

template<class Base>
LcgScheduler * createLcgScheduler ( )
overrideprotected

Factory override: use the D2D-capable LCG scheduler.