INET Framework for OMNeT++/OMNEST
inet::ieee80211::OriginatorProtectionMechanism Class Reference

#include <OriginatorProtectionMechanism.h>

Inheritance diagram for inet::ieee80211::OriginatorProtectionMechanism:
inet::ieee80211::ModeSetListener

Public Member Functions

virtual ~OriginatorProtectionMechanism ()
 
virtual simtime_t computeDurationField (Ieee80211Frame *frame, Ieee80211DataOrMgmtFrame *pendingFrame)
 

Protected Member Functions

virtual int numInitStages () const override
 
virtual void initialize (int stage) override
 
virtual simtime_t computeRtsDurationField (Ieee80211RTSFrame *rtsFrame, Ieee80211DataOrMgmtFrame *pendingFrame)
 
virtual simtime_t computeDataFrameDurationField (Ieee80211DataFrame *dataFrame, Ieee80211DataOrMgmtFrame *pendingFrame)
 
virtual simtime_t computeMgmtFrameDurationField (Ieee80211ManagementFrame *mgmtFrame, Ieee80211DataOrMgmtFrame *pendingFrame)
 
- Protected Member Functions inherited from inet::ieee80211::ModeSetListener
virtual void receiveSignal (cComponent *source, simsignal_t signalID, cObject *obj, cObject *details) override
 

Protected Attributes

IRateSelectionrateSelection = nullptr
 
- Protected Attributes inherited from inet::ieee80211::ModeSetListener
Ieee80211ModeSetmodeSet = nullptr
 

Constructor & Destructor Documentation

virtual inet::ieee80211::OriginatorProtectionMechanism::~OriginatorProtectionMechanism ( )
inlinevirtual
42 { }

Member Function Documentation

simtime_t inet::ieee80211::OriginatorProtectionMechanism::computeDataFrameDurationField ( Ieee80211DataFrame dataFrame,
Ieee80211DataOrMgmtFrame pendingFrame 
)
protectedvirtual

Referenced by computeDurationField().

63 {
64  simtime_t ackToDataFrameDuration = rateSelection->computeResponseAckFrameMode(dataFrame)->getDuration(LENGTH_ACK);
65  if (dataFrame->getReceiverAddress().isMulticast())
66  return 0;
67  if (!dataFrame->getMoreFragments())
68  return ackToDataFrameDuration + modeSet->getSifsTime();
69  else {
70  simtime_t pendingFrameDuration = rateSelection->computeMode(pendingFrame)->getDuration(pendingFrame->getBitLength());
71  auto pendingFrameMode = rateSelection->computeMode(pendingFrame);
72  RateSelection::setFrameMode(pendingFrame, pendingFrameMode);
73  simtime_t ackToPendingFrame = pendingFrameMode->getDuration(LENGTH_ACK);
74  return pendingFrameDuration + ackToDataFrameDuration + ackToPendingFrame + 3 * modeSet->getSifsTime();
75  }
76 }
virtual MACAddress & getReceiverAddress()
const unsigned int LENGTH_ACK
Definition: Ieee80211Frame_m.h:43
virtual const IIeee80211Mode * computeMode(Ieee80211Frame *frame)=0
virtual const simtime_t getDuration(int dataBitLength) const =0
static void setFrameMode(Ieee80211Frame *frame, const IIeee80211Mode *mode)
Definition: RateSelection.cc:169
Ieee80211ModeSet * modeSet
Definition: ModeSetListener.h:31
virtual bool getMoreFragments() const
bool isMulticast() const
Returns true if this is a multicast logical address (first byte&#39;s lsb is 1).
Definition: MACAddress.h:146
simtime_t getSifsTime() const
Definition: Ieee80211ModeSet.h:77
virtual const IIeee80211Mode * computeResponseAckFrameMode(Ieee80211DataOrMgmtFrame *dataOrMgmtFrame)=0
IRateSelection * rateSelection
Definition: OriginatorProtectionMechanism.h:31
simtime_t inet::ieee80211::OriginatorProtectionMechanism::computeDurationField ( Ieee80211Frame frame,
Ieee80211DataOrMgmtFrame pendingFrame 
)
virtual

Referenced by inet::ieee80211::Dcf::transmitFrame().

103 {
104  if (auto rtsFrame = dynamic_cast<Ieee80211RTSFrame *>(frame))
105  return computeRtsDurationField(rtsFrame, pendingFrame);
106  else if (auto dataFrame = dynamic_cast<Ieee80211DataFrame*>(frame))
107  return computeDataFrameDurationField(dataFrame, pendingFrame);
108  else if (auto mgmtFrame = dynamic_cast<Ieee80211ManagementFrame*>(frame))
109  return computeMgmtFrameDurationField(mgmtFrame, pendingFrame);
110  else
111  throw cRuntimeError("Unknown frame");
112 }
virtual simtime_t computeMgmtFrameDurationField(Ieee80211ManagementFrame *mgmtFrame, Ieee80211DataOrMgmtFrame *pendingFrame)
Definition: OriginatorProtectionMechanism.cc:88
virtual simtime_t computeDataFrameDurationField(Ieee80211DataFrame *dataFrame, Ieee80211DataOrMgmtFrame *pendingFrame)
Definition: OriginatorProtectionMechanism.cc:62
virtual simtime_t computeRtsDurationField(Ieee80211RTSFrame *rtsFrame, Ieee80211DataOrMgmtFrame *pendingFrame)
Definition: OriginatorProtectionMechanism.cc:41
simtime_t inet::ieee80211::OriginatorProtectionMechanism::computeMgmtFrameDurationField ( Ieee80211ManagementFrame mgmtFrame,
Ieee80211DataOrMgmtFrame pendingFrame 
)
protectedvirtual

Referenced by computeDurationField().

89 {
90  simtime_t ackFrameDuration = rateSelection->computeResponseAckFrameMode(mgmtFrame)->getDuration(LENGTH_ACK);
91  if (mgmtFrame->getReceiverAddress().isMulticast())
92  return 0;
93  if (!mgmtFrame->getMoreFragments()) {
94  return ackFrameDuration + modeSet->getSifsTime();
95  }
96  else {
97  simtime_t pendingFrameDuration = rateSelection->computeMode(pendingFrame)->getDuration(pendingFrame->getBitLength());
98  return pendingFrameDuration + 2 * ackFrameDuration + 3 * modeSet->getSifsTime();
99  }
100 }
virtual MACAddress & getReceiverAddress()
const unsigned int LENGTH_ACK
Definition: Ieee80211Frame_m.h:43
virtual const IIeee80211Mode * computeMode(Ieee80211Frame *frame)=0
virtual const simtime_t getDuration(int dataBitLength) const =0
Ieee80211ModeSet * modeSet
Definition: ModeSetListener.h:31
virtual bool getMoreFragments() const
bool isMulticast() const
Returns true if this is a multicast logical address (first byte&#39;s lsb is 1).
Definition: MACAddress.h:146
simtime_t getSifsTime() const
Definition: Ieee80211ModeSet.h:77
virtual const IIeee80211Mode * computeResponseAckFrameMode(Ieee80211DataOrMgmtFrame *dataOrMgmtFrame)=0
IRateSelection * rateSelection
Definition: OriginatorProtectionMechanism.h:31
simtime_t inet::ieee80211::OriginatorProtectionMechanism::computeRtsDurationField ( Ieee80211RTSFrame rtsFrame,
Ieee80211DataOrMgmtFrame pendingFrame 
)
protectedvirtual

Referenced by computeDurationField().

42 {
43  auto pendingFrameMode = rateSelection->computeMode(pendingFrame);
44  RateSelection::setFrameMode(pendingFrame, pendingFrameMode); // FIXME: Kludge
45  simtime_t pendingFrameDuration = pendingFrameMode->getDuration(pendingFrame->getBitLength());
46  simtime_t ctsFrameDuration = rateSelection->computeResponseCtsFrameMode(rtsFrame)->getDuration(LENGTH_CTS);
47  simtime_t ackFrameDuration = rateSelection->computeResponseAckFrameMode(pendingFrame)->getDuration(LENGTH_ACK);
48  simtime_t durationId = ctsFrameDuration + pendingFrameDuration + ackFrameDuration;
49  return durationId + 3 * modeSet->getSifsTime();
50 }
virtual const IIeee80211Mode * computeResponseCtsFrameMode(Ieee80211RTSFrame *rtsFrame)=0
const unsigned int LENGTH_ACK
Definition: Ieee80211Frame_m.h:43
virtual const IIeee80211Mode * computeMode(Ieee80211Frame *frame)=0
virtual const simtime_t getDuration(int dataBitLength) const =0
static void setFrameMode(Ieee80211Frame *frame, const IIeee80211Mode *mode)
Definition: RateSelection.cc:169
Ieee80211ModeSet * modeSet
Definition: ModeSetListener.h:31
simtime_t getSifsTime() const
Definition: Ieee80211ModeSet.h:77
const unsigned int LENGTH_CTS
Definition: Ieee80211Frame_m.h:42
virtual const IIeee80211Mode * computeResponseAckFrameMode(Ieee80211DataOrMgmtFrame *dataOrMgmtFrame)=0
IRateSelection * rateSelection
Definition: OriginatorProtectionMechanism.h:31
void inet::ieee80211::OriginatorProtectionMechanism::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::ieee80211::ModeSetListener.

28 {
30  if (stage == INITSTAGE_LOCAL) {
31  rateSelection = check_and_cast<IRateSelection*>(getModuleByPath(par("rateSelectionModule")));
32  }
33 }
Abstract interface for rate selection.
Definition: IRateSelection.h:36
Local initializations.
Definition: InitStages.h:35
virtual void initialize(int stage) override
Definition: ModeSetListener.cc:25
IRateSelection * rateSelection
Definition: OriginatorProtectionMechanism.h:31
virtual int inet::ieee80211::OriginatorProtectionMechanism::numInitStages ( ) const
inlineoverrideprotectedvirtual

Reimplemented from inet::ieee80211::ModeSetListener.

34 { return NUM_INIT_STAGES; }
The number of initialization stages.
Definition: InitStages.h:116

Member Data Documentation

IRateSelection* inet::ieee80211::OriginatorProtectionMechanism::rateSelection = nullptr
protected

The documentation for this class was generated from the following files: