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

#include <QoSRateSelection.h>

Inheritance diagram for inet::ieee80211::QoSRateSelection:
inet::ieee80211::IQoSRateSelection inet::ieee80211::ModeSetListener

Public Member Functions

virtual const IIeee80211ModecomputeResponseCtsFrameMode (Ieee80211RTSFrame *rtsFrame) override
 
virtual const IIeee80211ModecomputeResponseAckFrameMode (Ieee80211DataOrMgmtFrame *dataOrMgmtFrame) override
 
virtual const IIeee80211ModecomputeResponseBlockAckFrameMode (Ieee80211BlockAckReq *blockAckReq) override
 
virtual const IIeee80211ModecomputeMode (Ieee80211Frame *frame, TxopProcedure *txopProcedure) override
 
virtual void frameTransmitted (Ieee80211Frame *frame)
 
- Public Member Functions inherited from inet::ieee80211::IQoSRateSelection
virtual ~IQoSRateSelection ()
 

Protected Member Functions

virtual int numInitStages () const override
 
virtual void initialize (int stage) override
 
virtual void receiveSignal (cComponent *source, simsignal_t signalID, cObject *obj, cObject *details) override
 
virtual const IIeee80211ModegetMode (Ieee80211Frame *frame)
 
virtual const IIeee80211ModecomputeControlFrameMode (Ieee80211Frame *frame, TxopProcedure *txopProcedure)
 
virtual const IIeee80211ModecomputeDataOrMgmtFrameMode (Ieee80211DataOrMgmtFrame *dataOrMgmtFrame)
 
virtual bool isControlResponseFrame (Ieee80211Frame *frame, TxopProcedure *txopProcedure)
 

Protected Attributes

IRateControldataOrMgmtRateControl = nullptr
 
const Ieee80211ModeSetmodeSet = nullptr
 
std::map< MACAddress, const IIeee80211Mode * > lastTransmittedFrameMode
 
const IIeee80211ModemulticastFrameMode = nullptr
 
const IIeee80211ModefastestMandatoryMode = nullptr
 
const IIeee80211ModedataFrameMode = nullptr
 
const IIeee80211ModemgmtFrameMode = nullptr
 
const IIeee80211ModecontrolFrameMode = nullptr
 
const IIeee80211ModeresponseAckFrameMode = nullptr
 
const IIeee80211ModeresponseCtsFrameMode = nullptr
 
const IIeee80211ModeresponseBlockAckFrameMode = nullptr
 
- Protected Attributes inherited from inet::ieee80211::ModeSetListener
Ieee80211ModeSetmodeSet = nullptr
 

Member Function Documentation

const IIeee80211Mode * inet::ieee80211::QoSRateSelection::computeControlFrameMode ( Ieee80211Frame frame,
TxopProcedure txopProcedure 
)
protectedvirtual

Referenced by computeMode().

175 {
176  ASSERT(!isControlResponseFrame(frame, txopProcedure));
177  if (controlFrameMode)
178  return controlFrameMode;
179  // This subclause describes the rate selection rules for control frames that initiate a TXOP and that are not carried
180  // in an A-MPDU.
181  if (txopProcedure->isTxopInitiator(frame)) {
182  // If a control frame other than a Basic BlockAckReq or Basic BlockAck is carried in a non-HT PPDU, the
183  // transmitting STA shall transmit the frame using one of the rates in the BSSBasicRateSet parameter or a rate
184  // from the mandatory rate set of the attached PHY if the BSSBasicRateSet is empty.
185  if (!dynamic_cast<Ieee80211BasicBlockAck *>(frame) && !dynamic_cast<Ieee80211BasicBlockAckReq *>(frame)) {
186  // TODO: BSSBasicRateSet
187  return fastestMandatoryMode;
188  }
189  // If a Basic BlockAckReq or Basic BlockAck frame is carried in a non-HT PPDU, the transmitting STA shall
190  // transmit the frame using a rate supported by the receiver STA, if known (as reported in the Supported Rates
191  // element and/or Extended Supported Rates element in frames transmitted by that STA). If the supported rate set
192  // of the receiving STA or STAs is not known, the transmitting STA shall transmit using a rate from the
193  // BSSBasicRateSet parameter or using a rate from the mandatory rate set of the attached PHY if the
194  // BSSBasicRateSet is empty.
195  else {
196  // TODO: supported rate set of the receiving STA
197  return fastestMandatoryMode;
198  }
199  }
200  // This subclause describes the rate selection rules for control frames that are not control response frames, are not
201  // the frame that initiates a TXOP, are not the frame that terminates a TXOP, and are not carried in an A-MPDU.
202  else if (!txopProcedure->isTxopTerminator(frame)) {
203  // A frame other than a BlockAckReq or BlockAck that is carried in a non-HT PPDU shall be transmitted by the
204  // STA using a rate no higher than the highest rate in the BSSBasicRateSet parameter that is less than or equal to
205  // the rate or non-HT reference rate (see 9.7.9) of the previously transmitted frame that was directed to the same
206  // receiving STA. If no rate in the BSSBasicRateSet parameter meets these conditions, the control frame shall be
207  // transmitted at a rate no higher than the highest mandatory rate of the attached PHY that is less than or equal to
208  // the rate or non-HT reference rate (see 9.7.9) of the previously transmitted frame that was directed to the same
209  // receiving STA.
210  // TODO: BSSBasicRateSet
211  if (!dynamic_cast<Ieee80211BasicBlockAck *>(frame) && !dynamic_cast<Ieee80211BasicBlockAckReq *>(frame)) {
212  // TODO: frame sequence context
213  auto it = lastTransmittedFrameMode.find(frame->getReceiverAddress());
214  if (it != lastTransmittedFrameMode.end()) {
215  return it->second;
216  }
217  else
218  return fastestMandatoryMode;
219  }
220  // A BlockAckReq or BlockAck that is carried in a non-HT PPDU shall be transmitted by the STA using a rate
221  // supported by the receiver STA, as reported in the Supported Rates element and/or Extended Supported Rates
222  // element in frames transmitted by that STA. When the supported rate set of the receiving STA or STAs is not
223  // known, the transmitting STA shall transmit using a rate from the BSSBasicRateSet parameter or from the
224  // mandatory rate set of the attached PHY if the BSSBasicRateSet is empty.
225  else {
226  // TODO: BSSBasicRateSet
227  // TODO: Supported Rates element and/or Extended Supported Rates
228  return fastestMandatoryMode;
229  }
230  }
231  else
232  throw cRuntimeError("Control frames cannot terminate TXOPs");
233 }
virtual MACAddress & getReceiverAddress()
virtual bool isControlResponseFrame(Ieee80211Frame *frame, TxopProcedure *txopProcedure)
Definition: QoSRateSelection.cc:60
const IIeee80211Mode * controlFrameMode
Definition: QoSRateSelection.h:55
const IIeee80211Mode * fastestMandatoryMode
Definition: QoSRateSelection.h:51
virtual bool isTxopTerminator(Ieee80211Frame *frame) const
Definition: TxopProcedure.cc:114
Class generated from inet/linklayer/ieee80211/mac/Ieee80211Frame.msg:335 by nedtool.
Definition: Ieee80211Frame_m.h:1067
std::map< MACAddress, const IIeee80211Mode * > lastTransmittedFrameMode
Definition: QoSRateSelection.h:47
virtual bool isTxopInitiator(Ieee80211Frame *frame) const
Definition: TxopProcedure.cc:108
const IIeee80211Mode * inet::ieee80211::QoSRateSelection::computeDataOrMgmtFrameMode ( Ieee80211DataOrMgmtFrame dataOrMgmtFrame)
protectedvirtual

Referenced by computeMode().

127 {
128  if (dynamic_cast<Ieee80211DataFrame*>(dataOrMgmtFrame) && dataFrameMode)
129  return dataFrameMode;
130  if (dynamic_cast<Ieee80211ManagementFrame*>(dataOrMgmtFrame) && mgmtFrameMode)
131  return mgmtFrameMode;
132  // This subclause describes the rate selection rules for group addressed data and management frames, excluding
133  // the following:
134  // — Non-STBC Beacon and non-STBC PSMP frames
135  // — STBC group addressed data and management frames
136  // — Data frames located in an FMS stream (see 10.23.7)
137  if (dataOrMgmtFrame->getReceiverAddress().isMulticast()) {
138  // If the BSSBasicRateSet parameter is not empty, a data or management frame (excluding the frames listed
139  // above) with a group address in the Address 1 field shall be transmitted in a non-HT PPDU using one of the
140  // rates included in the BSSBasicRateSet parameter or the rate chosen by the AP, described in 10.23.7, if the data
141  // frames are part of an FMS stream.
142  // TODO: BSSBasicRateSet
143  // If the BSSBasicRateSet parameter is empty and the BSSBasicMCSSet parameter is not empty, the frame shall
144  // be transmitted in an HT PPDU using one of the MCSs included in the BSSBasicMCSSet parameter.
145 
146  // If both the BSSBasicRateSet parameter and the BSSBasicMCSSet parameter are empty (e.g., a scanning STA
147  // that is not yet associated with a BSS), the frame shall be transmitted in a non-HT PPDU using one of the
148  // mandatory PHY rates.
150  return dataOrMgmtRateControl->getRate();
151  else
152  return fastestMandatoryMode;
153  }
154  // A data or management frame not identified in 9.7.5.1 through 9.7.5.5 shall be sent using any data rate or MCS
155  // subject to the following constraints:
156  // — A STA shall not transmit a frame using a rate or MCS that is not supported by the receiver STA or
157  // STAs, as reported in any Supported Rates element, Extended Supported Rates element, or
158  // Supported MCS field in management frames transmitted by the receiver STA.
159  // — A STA shall not transmit a frame using a value for the CH_BANDWIDTH parameter of the
160  // TXVECTOR that is not supported by the receiver STA.
161  // — A STA shall not initiate transmission of a frame at a data rate higher than the greatest rate in the
162  // OperationalRateSet or the HTOperationalMCSset, which are parameters of the MLME-
163  // JOIN.request primitive.
164  else {
165  // TODO: Supported Rates element, Extended Supported Rates element
166  // TODO: OperationalRateSet or the HTOperationalMCSset
168  return dataOrMgmtRateControl->getRate();
169  else
170  return fastestMandatoryMode;
171  }
172 }
virtual MACAddress & getReceiverAddress()
const IIeee80211Mode * dataFrameMode
Definition: QoSRateSelection.h:53
const IIeee80211Mode * mgmtFrameMode
Definition: QoSRateSelection.h:54
const IIeee80211Mode * fastestMandatoryMode
Definition: QoSRateSelection.h:51
virtual const IIeee80211Mode * getRate()=0
bool isMulticast() const
Returns true if this is a multicast logical address (first byte&#39;s lsb is 1).
Definition: MACAddress.h:146
IRateControl * dataOrMgmtRateControl
Definition: QoSRateSelection.h:44
const IIeee80211Mode * inet::ieee80211::QoSRateSelection::computeMode ( Ieee80211Frame frame,
TxopProcedure txopProcedure 
)
overridevirtual

Implements inet::ieee80211::IQoSRateSelection.

236 {
237  if (auto dataOrMgmtFrame = dynamic_cast<Ieee80211DataOrMgmtFrame*>(frame))
238  return computeDataOrMgmtFrameMode(dataOrMgmtFrame);
239  else
240  return computeControlFrameMode(frame, txopProcedure);
241 }
virtual const IIeee80211Mode * computeDataOrMgmtFrameMode(Ieee80211DataOrMgmtFrame *dataOrMgmtFrame)
Definition: QoSRateSelection.cc:126
virtual const IIeee80211Mode * computeControlFrameMode(Ieee80211Frame *frame, TxopProcedure *txopProcedure)
Definition: QoSRateSelection.cc:174
const IIeee80211Mode * inet::ieee80211::QoSRateSelection::computeResponseAckFrameMode ( Ieee80211DataOrMgmtFrame dataOrMgmtFrame)
overridevirtual

Implements inet::ieee80211::IQoSRateSelection.

79 {
80  // TODO: BSSBasicRateSet, alternate rate
81  auto mode = getMode(dataOrMgmtFrame);
82  ASSERT(modeSet->containsMode(mode));
83  if (!responseAckFrameMode) {
84  if (modeSet->getIsMandatory(mode))
85  return mode;
86  else if (auto slowerMode = modeSet->getSlowerMandatoryMode(mode))
87  return slowerMode;
88  else
89  throw cRuntimeError("Mandatory mode not found");
90  }
91  else
92  return responseAckFrameMode;
93 }
const IIeee80211Mode * getSlowerMandatoryMode(const IIeee80211Mode *mode) const
Definition: Ieee80211ModeSet.cc:255
bool getIsMandatory(const IIeee80211Mode *mode) const
Definition: Ieee80211ModeSet.cc:187
virtual const IIeee80211Mode * getMode(Ieee80211Frame *frame)
Definition: QoSRateSelection.cc:49
const Ieee80211ModeSet * modeSet
Definition: QoSRateSelection.h:46
bool containsMode(const IIeee80211Mode *mode) const
Definition: Ieee80211ModeSet.h:60
const IIeee80211Mode * responseAckFrameMode
Definition: QoSRateSelection.h:57
const IIeee80211Mode * inet::ieee80211::QoSRateSelection::computeResponseBlockAckFrameMode ( Ieee80211BlockAckReq blockAckReq)
overridevirtual

Implements inet::ieee80211::IQoSRateSelection.

119 {
120  if (dynamic_cast<Ieee80211BasicBlockAckReq *>(blockAckReq))
122  else
123  throw cRuntimeError("Unknown BlockAckReq frame type");
124 }
const IIeee80211Mode * responseBlockAckFrameMode
Definition: QoSRateSelection.h:59
virtual const IIeee80211Mode * getMode(Ieee80211Frame *frame)
Definition: QoSRateSelection.cc:49
const IIeee80211Mode * inet::ieee80211::QoSRateSelection::computeResponseCtsFrameMode ( Ieee80211RTSFrame rtsFrame)
overridevirtual

Implements inet::ieee80211::IQoSRateSelection.

96 {
97  // TODO: BSSBasicRateSet, alternate rate
98  auto mode = getMode(rtsFrame);
99  ASSERT(modeSet->containsMode(mode));
100  if (!responseCtsFrameMode) {
101  if (modeSet->getIsMandatory(mode))
102  return mode;
103  else if (auto slowerMode = modeSet->getSlowerMandatoryMode(mode))
104  return slowerMode;
105  else
106  throw cRuntimeError("Mandatory mode not found");
107  }
108  else
109  return responseCtsFrameMode;
110 }
const IIeee80211Mode * getSlowerMandatoryMode(const IIeee80211Mode *mode) const
Definition: Ieee80211ModeSet.cc:255
bool getIsMandatory(const IIeee80211Mode *mode) const
Definition: Ieee80211ModeSet.cc:187
virtual const IIeee80211Mode * getMode(Ieee80211Frame *frame)
Definition: QoSRateSelection.cc:49
const Ieee80211ModeSet * modeSet
Definition: QoSRateSelection.h:46
const IIeee80211Mode * responseCtsFrameMode
Definition: QoSRateSelection.h:58
bool containsMode(const IIeee80211Mode *mode) const
Definition: Ieee80211ModeSet.h:60
void inet::ieee80211::QoSRateSelection::frameTransmitted ( Ieee80211Frame frame)
virtual
253 {
254  auto receiverAddr = frame->getReceiverAddress();
255  lastTransmittedFrameMode[receiverAddr] = getMode(frame);
256 }
virtual MACAddress & getReceiverAddress()
virtual const IIeee80211Mode * getMode(Ieee80211Frame *frame)
Definition: QoSRateSelection.cc:49
std::map< MACAddress, const IIeee80211Mode * > lastTransmittedFrameMode
Definition: QoSRateSelection.h:47
const IIeee80211Mode * inet::ieee80211::QoSRateSelection::getMode ( Ieee80211Frame frame)
protectedvirtual

Referenced by computeResponseAckFrameMode(), computeResponseBlockAckFrameMode(), computeResponseCtsFrameMode(), and frameTransmitted().

50 {
51  auto txReq = dynamic_cast<Ieee80211TransmissionRequest*>(frame->getControlInfo());
52  if (txReq)
53  return txReq->getMode();
54  auto rxInd = dynamic_cast<Ieee80211ReceptionIndication*>(frame->getControlInfo());
55  if (rxInd)
56  return rxInd->getMode();
57  throw cRuntimeError("Missing mode");
58 }
Class generated from inet/physicallayer/ieee80211/packetlevel/Ieee80211ControlInfo.msg:146 by nedtool.
Definition: Ieee80211ControlInfo_m.h:135
Class generated from inet/physicallayer/ieee80211/packetlevel/Ieee80211ControlInfo.msg:157 by nedtool.
Definition: Ieee80211ControlInfo_m.h:194
void inet::ieee80211::QoSRateSelection::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::ieee80211::ModeSetListener.

28 {
30  if (stage == INITSTAGE_LINK_LAYER_2) {
31  dataOrMgmtRateControl = dynamic_cast<IRateControl*>(getModuleByPath(par("rateControlModule")));
32  double multicastFrameBitrate = par("multicastFrameBitrate");
33  multicastFrameMode = (multicastFrameBitrate == -1) ? nullptr : modeSet->getMode(bps(multicastFrameBitrate));
34  double dataFrameBitrate = par("dataFrameBitrate");
35  dataFrameMode = (dataFrameBitrate == -1) ? nullptr : modeSet->getMode(bps(dataFrameBitrate));
36  double mgmtFrameBitrate = par("mgmtFrameBitrate");
37  mgmtFrameMode = (mgmtFrameBitrate == -1) ? nullptr : modeSet->getMode(bps(mgmtFrameBitrate));
38  double controlFrameBitrate = par("controlFrameBitrate");
39  controlFrameMode = (controlFrameBitrate == -1) ? nullptr : modeSet->getMode(bps(controlFrameBitrate));
40  double responseAckFrameBitrate = par("responseAckFrameBitrate");
41  responseAckFrameMode = (responseAckFrameBitrate == -1) ? nullptr : modeSet->getMode(bps(responseAckFrameBitrate));
42  double responseBlockAckFrameBitrate = par("responseBlockAckFrameBitrate");
43  responseBlockAckFrameMode = (responseBlockAckFrameBitrate == -1) ? nullptr : modeSet->getMode(bps(responseBlockAckFrameBitrate));
44  double responseCtsFrameBitrate = par("responseCtsFrameBitrate");
45  responseCtsFrameMode = (responseCtsFrameBitrate == -1) ? nullptr : modeSet->getMode(bps(responseCtsFrameBitrate));
46  }
47 }
const IIeee80211Mode * multicastFrameMode
Definition: QoSRateSelection.h:50
const IIeee80211Mode * dataFrameMode
Definition: QoSRateSelection.h:53
const IIeee80211Mode * mgmtFrameMode
Definition: QoSRateSelection.h:54
const IIeee80211Mode * responseBlockAckFrameMode
Definition: QoSRateSelection.h:59
const IIeee80211Mode * controlFrameMode
Definition: QoSRateSelection.h:55
const Ieee80211ModeSet * modeSet
Definition: QoSRateSelection.h:46
const IIeee80211Mode * responseCtsFrameMode
Definition: QoSRateSelection.h:58
const IIeee80211Mode * getMode(bps bitrate) const
Definition: Ieee80211ModeSet.cc:202
virtual void initialize(int stage) override
Definition: ModeSetListener.cc:25
Abstract interface for auto rate control algorithms.
Definition: IRateControl.h:35
Definition: Units.h:69
Additional link-layer initializations that depend on the previous stage.
Definition: InitStages.h:64
const IIeee80211Mode * responseAckFrameMode
Definition: QoSRateSelection.h:57
IRateControl * dataOrMgmtRateControl
Definition: QoSRateSelection.h:44
bool inet::ieee80211::QoSRateSelection::isControlResponseFrame ( Ieee80211Frame frame,
TxopProcedure txopProcedure 
)
protectedvirtual

Referenced by computeControlFrameMode().

61 {
62  bool nonSelfCts = dynamic_cast<Ieee80211CTSFrame *>(frame) && !txopProcedure->isTxopInitiator(frame);
63  bool blockAck = dynamic_cast<Ieee80211BlockAck *>(frame);
64  bool ack = dynamic_cast<Ieee80211ACKFrame *>(frame);
65  return ack || blockAck || nonSelfCts;
66 }
Class generated from inet/linklayer/ieee80211/mac/Ieee80211Frame.msg:397 by nedtool.
Definition: Ieee80211Frame_m.h:1231
Class generated from inet/linklayer/ieee80211/mac/Ieee80211Frame.msg:130 by nedtool.
Definition: Ieee80211Frame_m.h:276
virtual bool isTxopInitiator(Ieee80211Frame *frame) const
Definition: TxopProcedure.cc:108
Class generated from inet/linklayer/ieee80211/mac/Ieee80211Frame.msg:157 by nedtool.
Definition: Ieee80211Frame_m.h:397
virtual int inet::ieee80211::QoSRateSelection::numInitStages ( ) const
inlineoverrideprotectedvirtual

Reimplemented from inet::ieee80211::ModeSetListener.

62 { return NUM_INIT_STAGES; }
The number of initialization stages.
Definition: InitStages.h:116
void inet::ieee80211::QoSRateSelection::receiveSignal ( cComponent *  source,
simsignal_t  signalID,
cObject *  obj,
cObject *  details 
)
overrideprotectedvirtual

Reimplemented from inet::ieee80211::ModeSetListener.

244 {
245  Enter_Method("receiveModeSetChangeNotification");
246  if (signalID == NF_MODESET_CHANGED) {
247  modeSet = check_and_cast<Ieee80211ModeSet*>(obj);
249  }
250 }
Definition: Ieee80211ModeSet.h:28
const Ieee80211ModeSet * modeSet
Definition: QoSRateSelection.h:46
const IIeee80211Mode * fastestMandatoryMode
Definition: QoSRateSelection.h:51
simsignal_t NF_MODESET_CHANGED
Definition: NotifierConsts.cc:46
const IIeee80211Mode * getFastestMandatoryMode() const
Definition: Ieee80211ModeSet.cc:247

Member Data Documentation

const IIeee80211Mode* inet::ieee80211::QoSRateSelection::controlFrameMode = nullptr
protected
const IIeee80211Mode* inet::ieee80211::QoSRateSelection::dataFrameMode = nullptr
protected
IRateControl* inet::ieee80211::QoSRateSelection::dataOrMgmtRateControl = nullptr
protected
const IIeee80211Mode* inet::ieee80211::QoSRateSelection::fastestMandatoryMode = nullptr
protected
std::map<MACAddress, const IIeee80211Mode *> inet::ieee80211::QoSRateSelection::lastTransmittedFrameMode
protected
const IIeee80211Mode* inet::ieee80211::QoSRateSelection::mgmtFrameMode = nullptr
protected
const Ieee80211ModeSet* inet::ieee80211::QoSRateSelection::modeSet = nullptr
protected
const IIeee80211Mode* inet::ieee80211::QoSRateSelection::multicastFrameMode = nullptr
protected

Referenced by initialize().

const IIeee80211Mode* inet::ieee80211::QoSRateSelection::responseAckFrameMode = nullptr
protected
const IIeee80211Mode* inet::ieee80211::QoSRateSelection::responseBlockAckFrameMode = nullptr
protected
const IIeee80211Mode* inet::ieee80211::QoSRateSelection::responseCtsFrameMode = nullptr
protected

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