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

#include <SingleProtectionMechanism.h>

Inheritance diagram for inet::ieee80211::SingleProtectionMechanism:
inet::ieee80211::ModeSetListener

Public Member Functions

virtual ~SingleProtectionMechanism ()
 
virtual simtime_t computeDurationField (Ieee80211Frame *frame, Ieee80211DataOrMgmtFrame *pendingFrame, TxopProcedure *txop, IRecipientQoSAckPolicy *ackPolicy)
 

Protected Member Functions

virtual int numInitStages () const override
 
virtual void initialize (int stage) override
 
virtual simtime_t computeRtsDurationField (Ieee80211RTSFrame *rtsFrame, Ieee80211DataOrMgmtFrame *pendingFrame, TxopProcedure *txop, IRecipientQoSAckPolicy *ackPolicy)
 
virtual simtime_t computeCtsDurationField (Ieee80211CTSFrame *ctsFrame)
 
virtual simtime_t computeBlockAckReqDurationField (Ieee80211BlockAckReq *blockAckReq)
 
virtual simtime_t computeBlockAckDurationField (Ieee80211BlockAck *blockAck)
 
virtual simtime_t computeDataOrMgmtFrameDurationField (Ieee80211DataOrMgmtFrame *dataOrMgmtFrame, Ieee80211DataOrMgmtFrame *pendingFrame, TxopProcedure *txop, IRecipientQoSAckPolicy *ackPolicy)
 
- Protected Member Functions inherited from inet::ieee80211::ModeSetListener
virtual void receiveSignal (cComponent *source, simsignal_t signalID, cObject *obj, cObject *details) override
 

Protected Attributes

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

Constructor & Destructor Documentation

virtual inet::ieee80211::SingleProtectionMechanism::~SingleProtectionMechanism ( )
inlinevirtual
54 { }

Member Function Documentation

simtime_t inet::ieee80211::SingleProtectionMechanism::computeBlockAckDurationField ( Ieee80211BlockAck blockAck)
protectedvirtual

Referenced by computeDurationField().

97 {
98  throw cRuntimeError("Unimplemented");
99 }
simtime_t inet::ieee80211::SingleProtectionMechanism::computeBlockAckReqDurationField ( Ieee80211BlockAckReq blockAckReq)
protectedvirtual

Referenced by computeDurationField().

80 {
81  // TODO: ACK or BlockAck frame, as applicable
82  if (dynamic_cast<Ieee80211BasicBlockAckReq*>(blockAckReq)) {
83  simtime_t blockAckFrameDuration = rateSelection->computeResponseBlockAckFrameMode(blockAckReq)->getDuration(LENGTH_BASIC_BLOCKACK);
84  simtime_t blockAckReqDurationPerId = blockAckFrameDuration + modeSet->getSifsTime();
85  return blockAckReqDurationPerId;
86  }
87  else
88  throw cRuntimeError("Compressed and Multi-Tid Block Ack Requests are not supported");
89 }
IQoSRateSelection * rateSelection
Definition: SingleProtectionMechanism.h:40
virtual const simtime_t getDuration(int dataBitLength) const =0
const unsigned int LENGTH_BASIC_BLOCKACK
Definition: Ieee80211Frame_m.h:46
Ieee80211ModeSet * modeSet
Definition: ModeSetListener.h:31
simtime_t getSifsTime() const
Definition: Ieee80211ModeSet.h:77
virtual const IIeee80211Mode * computeResponseBlockAckFrameMode(Ieee80211BlockAckReq *blockAckReq)=0
simtime_t inet::ieee80211::SingleProtectionMechanism::computeCtsDurationField ( Ieee80211CTSFrame ctsFrame)
protectedvirtual

Referenced by computeDurationField().

71 {
72  throw cRuntimeError("Self CTS is not supported");
73 }
simtime_t inet::ieee80211::SingleProtectionMechanism::computeDataOrMgmtFrameDurationField ( Ieee80211DataOrMgmtFrame dataOrMgmtFrame,
Ieee80211DataOrMgmtFrame pendingFrame,
TxopProcedure txop,
IRecipientQoSAckPolicy ackPolicy 
)
protectedvirtual

Referenced by computeDurationField().

121 {
122  bool mgmtFrame = false;
123  bool mgmtFrameWithNoAck = false;
124  bool groupAddressed = dataOrMgmtFrame->getReceiverAddress().isMulticast();
125  if (dynamic_cast<Ieee80211ManagementFrame*>(dataOrMgmtFrame)) {
126  mgmtFrame = true;
127  mgmtFrameWithNoAck = false; // FIXME: ack policy?
128  }
129  bool nonQoSData = dataOrMgmtFrame->getType() == ST_DATA;
130  bool individuallyAddressedDataWithNormalAck = false;
131  bool individuallyAddressedDataWithNoAckOrBlockAck = false;
132  if (auto dataFrame = dynamic_cast<Ieee80211DataFrame*>(dataOrMgmtFrame)) {
133  individuallyAddressedDataWithNormalAck = !groupAddressed && dataFrame->getAckPolicy() == AckPolicy::NORMAL_ACK;
134  individuallyAddressedDataWithNoAckOrBlockAck = !groupAddressed && (dataFrame->getAckPolicy() == AckPolicy::NO_ACK || dataFrame->getAckPolicy() == AckPolicy::BLOCK_ACK);
135  }
136  if (mgmtFrame || nonQoSData || individuallyAddressedDataWithNormalAck) {
137  simtime_t ackFrameDuration = rateSelection->computeResponseAckFrameMode(dataOrMgmtFrame)->getDuration(LENGTH_ACK);
138  if (txop->isFinalFragment(dataOrMgmtFrame)) {
139  return ackFrameDuration + modeSet->getSifsTime();
140  }
141  else {
142  simtime_t ackFrameDuration = rateSelection->computeResponseAckFrameMode(dataOrMgmtFrame)->getDuration(LENGTH_ACK);
143  simtime_t duration = ackFrameDuration + modeSet->getSifsTime();
144  if (pendingFrame) {
145  auto pendingFrameMode = rateSelection->computeMode(pendingFrame, txop);
146  simtime_t pendingFrameDuration = pendingFrameMode->getDuration(pendingFrame->getBitLength());
147  duration += pendingFrameDuration + modeSet->getSifsTime();
148  if (ackPolicy->isAckNeeded(pendingFrame)) {
149  RateSelection::setFrameMode(pendingFrame, pendingFrameMode); // FIXME: Kludge
150  simtime_t ackToPendingFrameDuration = rateSelection->computeResponseAckFrameMode(pendingFrame)->getDuration(LENGTH_ACK);
151  duration += ackToPendingFrameDuration + modeSet->getSifsTime();
152  }
153  }
154  return duration;
155  }
156  }
157  if (individuallyAddressedDataWithNoAckOrBlockAck || mgmtFrameWithNoAck || groupAddressed) {
158  if (txop->isFinalFragment(dataOrMgmtFrame))
159  return 0;
160  else {
161  simtime_t duration = 0;
162  if (pendingFrame) {
163  auto pendingFrameMode = rateSelection->computeMode(pendingFrame, txop);
164  simtime_t pendingFrameDuration = pendingFrameMode->getDuration(pendingFrame->getBitLength());
165  duration = pendingFrameDuration + modeSet->getSifsTime();
166  if (ackPolicy->isAckNeeded(pendingFrame)) {
167  RateSelection::setFrameMode(pendingFrame, pendingFrameMode); // FIXME: Kludge
168  simtime_t ackToPendingFrameDuration = rateSelection->computeResponseAckFrameMode(pendingFrame)->getDuration(LENGTH_ACK);
169  duration += ackToPendingFrameDuration + modeSet->getSifsTime();
170  }
171  }
172  return duration;
173  }
174  }
175  throw cRuntimeError("Unknown frame");
176 }
virtual MACAddress & getReceiverAddress()
virtual bool isFinalFragment(Ieee80211Frame *frame) const
Definition: TxopProcedure.cc:102
virtual short getType() const
Definition: Ieee80211Frame_m.h:140
virtual const IIeee80211Mode * computeMode(Ieee80211Frame *frame, TxopProcedure *txopProcedure)=0
Definition: Ieee80211Frame_m.h:142
const unsigned int LENGTH_ACK
Definition: Ieee80211Frame_m.h:43
IQoSRateSelection * rateSelection
Definition: SingleProtectionMechanism.h:40
virtual const simtime_t getDuration(int dataBitLength) const =0
Definition: Ieee80211Frame_m.h:139
static void setFrameMode(Ieee80211Frame *frame, const IIeee80211Mode *mode)
Definition: RateSelection.cc:169
Ieee80211ModeSet * modeSet
Definition: ModeSetListener.h:31
virtual const IIeee80211Mode * computeResponseAckFrameMode(Ieee80211DataOrMgmtFrame *dataOrMgmtFrame)=0
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
Definition: Ieee80211Frame_m.h:116
virtual bool isAckNeeded(Ieee80211DataOrMgmtFrame *frame) const =0
simtime_t inet::ieee80211::SingleProtectionMechanism::computeDurationField ( Ieee80211Frame frame,
Ieee80211DataOrMgmtFrame pendingFrame,
TxopProcedure txop,
IRecipientQoSAckPolicy ackPolicy 
)
virtual

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

179 {
180  if (auto rtsFrame = dynamic_cast<Ieee80211RTSFrame*>(frame))
181  return computeRtsDurationField(rtsFrame, pendingFrame, txop, ackPolicy);
182  else if (auto ctsFrame = dynamic_cast<Ieee80211CTSFrame*>(frame))
183  return computeCtsDurationField(ctsFrame);
184  else if (auto blockAckReq = dynamic_cast<Ieee80211BlockAckReq*>(frame))
185  return computeBlockAckReqDurationField(blockAckReq);
186  else if (auto blockAck = dynamic_cast<Ieee80211BlockAck*>(frame))
187  return computeBlockAckDurationField(blockAck);
188  else if (auto dataOrMgmtFrame = dynamic_cast<Ieee80211DataOrMgmtFrame*>(frame))
189  return computeDataOrMgmtFrameDurationField(dataOrMgmtFrame, pendingFrame, txop, ackPolicy);
190  else
191  throw cRuntimeError("Unknown frame type");
192 }
virtual simtime_t computeDataOrMgmtFrameDurationField(Ieee80211DataOrMgmtFrame *dataOrMgmtFrame, Ieee80211DataOrMgmtFrame *pendingFrame, TxopProcedure *txop, IRecipientQoSAckPolicy *ackPolicy)
Definition: SingleProtectionMechanism.cc:120
virtual simtime_t computeBlockAckDurationField(Ieee80211BlockAck *blockAck)
Definition: SingleProtectionMechanism.cc:96
virtual simtime_t computeBlockAckReqDurationField(Ieee80211BlockAckReq *blockAckReq)
Definition: SingleProtectionMechanism.cc:79
virtual simtime_t computeRtsDurationField(Ieee80211RTSFrame *rtsFrame, Ieee80211DataOrMgmtFrame *pendingFrame, TxopProcedure *txop, IRecipientQoSAckPolicy *ackPolicy)
Definition: SingleProtectionMechanism.cc:43
virtual simtime_t computeCtsDurationField(Ieee80211CTSFrame *ctsFrame)
Definition: SingleProtectionMechanism.cc:70
simtime_t inet::ieee80211::SingleProtectionMechanism::computeRtsDurationField ( Ieee80211RTSFrame rtsFrame,
Ieee80211DataOrMgmtFrame pendingFrame,
TxopProcedure txop,
IRecipientQoSAckPolicy ackPolicy 
)
protectedvirtual

Referenced by computeDurationField().

44 {
45  // TODO: We assume that the RTS frame is not part of a dual clear-to-send
46  auto pendingFrameMode = rateSelection->computeMode(pendingFrame, txop);
47  simtime_t pendingFrameDuration = pendingFrameMode->getDuration(pendingFrame->getBitLength());
48  simtime_t ctsFrameDuration = rateSelection->computeResponseCtsFrameMode(rtsFrame)->getDuration(LENGTH_CTS);
49  simtime_t durationId = ctsFrameDuration + modeSet->getSifsTime() + pendingFrameDuration + modeSet->getSifsTime();
50  if (auto dataOrMgmtFrame = dynamic_cast<Ieee80211DataOrMgmtFrame*>(pendingFrame)) {
51  if (ackPolicy->isAckNeeded(dataOrMgmtFrame)) {
52  RateSelection::setFrameMode(dataOrMgmtFrame, pendingFrameMode); // FIXME: KLUDGE
53  simtime_t ackFrameDuration = rateSelection->computeResponseAckFrameMode(dataOrMgmtFrame)->getDuration(LENGTH_ACK);
54  durationId += ackFrameDuration + modeSet->getSifsTime();
55  }
56  }
57  return durationId;
58 }
virtual const IIeee80211Mode * computeMode(Ieee80211Frame *frame, TxopProcedure *txopProcedure)=0
const unsigned int LENGTH_ACK
Definition: Ieee80211Frame_m.h:43
IQoSRateSelection * rateSelection
Definition: SingleProtectionMechanism.h:40
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 const IIeee80211Mode * computeResponseAckFrameMode(Ieee80211DataOrMgmtFrame *dataOrMgmtFrame)=0
simtime_t getSifsTime() const
Definition: Ieee80211ModeSet.h:77
virtual const IIeee80211Mode * computeResponseCtsFrameMode(Ieee80211RTSFrame *rtsFrame)=0
const unsigned int LENGTH_CTS
Definition: Ieee80211Frame_m.h:42
virtual bool isAckNeeded(Ieee80211DataOrMgmtFrame *frame) const =0
void inet::ieee80211::SingleProtectionMechanism::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::ieee80211::ModeSetListener.

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

Reimplemented from inet::ieee80211::ModeSetListener.

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

Member Data Documentation

IQoSRateSelection* inet::ieee80211::SingleProtectionMechanism::rateSelection = nullptr
protected

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