INET Framework for OMNeT++/OMNEST
inet::physicallayer::Ieee80211ModeSet Class Reference

#include <Ieee80211ModeSet.h>

Inheritance diagram for inet::physicallayer::Ieee80211ModeSet:
inet::physicallayer::IPrintableObject

Classes

class  Entry
 
struct  EntryNetBitrateComparator
 

Public Member Functions

 Ieee80211ModeSet (const char *name, const std::vector< Entry > entries)
 
virtual std::ostream & printToStream (std::ostream &stream, int level) const override
 Prints this object to the provided output stream. More...
 
const char * getName () const override
 
bool containsMode (const IIeee80211Mode *mode) const
 
bool getIsMandatory (const IIeee80211Mode *mode) const
 
const IIeee80211ModefindMode (bps bitrate) const
 
const IIeee80211ModegetMode (bps bitrate) const
 
const IIeee80211ModegetSlowestMode () const
 
const IIeee80211ModegetFastestMode () const
 
const IIeee80211ModegetSlowerMode (const IIeee80211Mode *mode) const
 
const IIeee80211ModegetFasterMode (const IIeee80211Mode *mode) const
 
const IIeee80211ModegetSlowestMandatoryMode () const
 
const IIeee80211ModegetFastestMandatoryMode () const
 
const IIeee80211ModegetSlowerMandatoryMode (const IIeee80211Mode *mode) const
 
const IIeee80211ModegetFasterMandatoryMode (const IIeee80211Mode *mode) const
 
simtime_t getSifsTime () const
 
simtime_t getSlotTime () const
 
simtime_t getPhyRxStartDelay () const
 
int getCwMin () const
 
int getCwMax () const
 
IIeee80211Mode_getSlowestMode () const
 
IIeee80211Mode_getFastestMode () const
 
IIeee80211Mode_getSlowestMandatoryMode () const
 
IIeee80211Mode_getFastestMandatoryMode () const
 
- Public Member Functions inherited from inet::physicallayer::IPrintableObject
virtual ~IPrintableObject ()
 
virtual std::string getInfoStringRepresentation () const
 
virtual std::string getDetailStringRepresentation () const
 
virtual std::string getDebugStringRepresentation () const
 
virtual std::string getTraceStringRepresentation () const
 
virtual std::string getCompleteStringRepresentation () const
 

Static Public Member Functions

static const Ieee80211ModeSetfindModeSet (const char *mode)
 
static const Ieee80211ModeSetgetModeSet (const char *mode)
 

Static Public Attributes

static const DelayedInitializer< std::vector< Ieee80211ModeSet > > modeSets
 

Protected Member Functions

int findModeIndex (const IIeee80211Mode *mode) const
 
int getModeIndex (const IIeee80211Mode *mode) const
 

Protected Attributes

std::string name
 
const std::vector< Entryentries
 

Additional Inherited Members

- Public Types inherited from inet::physicallayer::IPrintableObject
enum  PrintLevel {
  PRINT_LEVEL_TRACE, PRINT_LEVEL_DEBUG, PRINT_LEVEL_DETAIL, PRINT_LEVEL_INFO,
  PRINT_LEVEL_COMPLETE = INT_MIN
}
 

Constructor & Destructor Documentation

inet::physicallayer::Ieee80211ModeSet::Ieee80211ModeSet ( const char *  name,
const std::vector< Entry entries 
)
152  :
153  name(name),
155 {
156  std::vector<Entry> *nonConstEntries = const_cast<std::vector<Entry> *>(&this->entries);
157  std::stable_sort(nonConstEntries->begin(), nonConstEntries->end(), EntryNetBitrateComparator());
158  auto referenceMode = entries[0].mode;
159  for (auto entry : entries) {
160  auto mode = entry.mode;
161  if (mode->getSifsTime() != referenceMode->getSifsTime() ||
162  mode->getSlotTime() != referenceMode->getSlotTime() ||
163  mode->getPhyRxStartDelay() != referenceMode->getPhyRxStartDelay())
164  {
165  // FIXME: throw cRuntimeError("Sifs, slot and phyRxStartDelay time must be identical within a ModeSet");
166  }
167  }
168 }
std::string name
Definition: Ieee80211ModeSet.h:43
const std::vector< Entry > entries
Definition: Ieee80211ModeSet.h:44

Member Function Documentation

IIeee80211Mode* inet::physicallayer::Ieee80211ModeSet::_getFastestMandatoryMode ( ) const
inline
86 { return const_cast<IIeee80211Mode*>(getFastestMandatoryMode()); }
const IIeee80211Mode * getFastestMandatoryMode() const
Definition: Ieee80211ModeSet.cc:247
IIeee80211Mode* inet::physicallayer::Ieee80211ModeSet::_getFastestMode ( ) const
inline
84 { return const_cast<IIeee80211Mode*>(getFastestMode()); }
const IIeee80211Mode * getFastestMode() const
Definition: Ieee80211ModeSet.cc:216
IIeee80211Mode* inet::physicallayer::Ieee80211ModeSet::_getSlowestMandatoryMode ( ) const
inline
85 { return const_cast<IIeee80211Mode*>(getSlowestMandatoryMode()); }
const IIeee80211Mode * getSlowestMandatoryMode() const
Definition: Ieee80211ModeSet.cc:239
IIeee80211Mode* inet::physicallayer::Ieee80211ModeSet::_getSlowestMode ( ) const
inline
83 { return const_cast<IIeee80211Mode*>(getSlowestMode()); }
const IIeee80211Mode * getSlowestMode() const
Definition: Ieee80211ModeSet.cc:211
const IIeee80211Mode * inet::physicallayer::Ieee80211ModeSet::findMode ( bps  bitrate) const

Referenced by getMode(), and inet::physicallayer::Ieee80211TransmitterBase::setMode().

193 {
194  for (int index = 0; index < (int)entries.size(); index++) {
195  const IIeee80211Mode *mode = entries[index].mode;
196  if (mode->getDataMode()->getNetBitrate() == bitrate)
197  return entries[index].mode;
198  }
199  return nullptr;
200 }
const std::vector< Entry > entries
Definition: Ieee80211ModeSet.h:44
int inet::physicallayer::Ieee80211ModeSet::findModeIndex ( const IIeee80211Mode mode) const
protected

Referenced by getFasterMandatoryMode(), getFasterMode(), getModeIndex(), getSlowerMandatoryMode(), and getSlowerMode().

171 {
172  for (int index = 0; index < (int)entries.size(); index++)
173  if (entries[index].mode == mode)
174  return index;
175  return -1;
176 }
const std::vector< Entry > entries
Definition: Ieee80211ModeSet.h:44
const Ieee80211ModeSet * inet::physicallayer::Ieee80211ModeSet::findModeSet ( const char *  mode)
static

Referenced by getModeSet().

276 {
277  for (int index = 0; index < (int)(&modeSets)->size(); index++) {
278  const Ieee80211ModeSet *modeSet = &(&modeSets)->at(index);
279  if (strcmp(modeSet->getName(), mode) == 0)
280  return modeSet;
281  }
282  return nullptr;
283 }
static const DelayedInitializer< std::vector< Ieee80211ModeSet > > modeSets
Definition: Ieee80211ModeSet.h:47
Ieee80211ModeSet(const char *name, const std::vector< Entry > entries)
Definition: Ieee80211ModeSet.cc:152
int inet::physicallayer::Ieee80211ModeSet::getCwMax ( ) const
inline

Referenced by inet::ieee80211::Dcaf::calculateTimingParameters(), and inet::ieee80211::Edcaf::calculateTimingParameters().

81 { return entries[0].mode->getLegacyCwMax(); }
const std::vector< Entry > entries
Definition: Ieee80211ModeSet.h:44
int inet::physicallayer::Ieee80211ModeSet::getCwMin ( ) const
inline

Referenced by inet::ieee80211::Dcaf::calculateTimingParameters(), and inet::ieee80211::Edcaf::calculateTimingParameters().

80 { return entries[0].mode->getLegacyCwMin(); }
const std::vector< Entry > entries
Definition: Ieee80211ModeSet.h:44
const IIeee80211Mode * inet::physicallayer::Ieee80211ModeSet::getFasterMandatoryMode ( const IIeee80211Mode mode) const
266 {
267  int index = findModeIndex(mode);
268  if (index >= 0)
269  for (int i = index+1; i < (int)entries.size(); i++)
270  if (entries[i].isMandatory)
271  return entries[i].mode;
272  return nullptr;
273 }
int findModeIndex(const IIeee80211Mode *mode) const
Definition: Ieee80211ModeSet.cc:170
const std::vector< Entry > entries
Definition: Ieee80211ModeSet.h:44
const IIeee80211Mode * inet::physicallayer::Ieee80211ModeSet::getFasterMode ( const IIeee80211Mode mode) const

Referenced by inet::ieee80211::RateControlBase::increaseRateIfPossible().

231 {
232  int index = findModeIndex(mode);
233  if (index >= 0 && index < (int)entries.size()-1)
234  return entries[index + 1].mode;
235  else
236  return nullptr;
237 }
int findModeIndex(const IIeee80211Mode *mode) const
Definition: Ieee80211ModeSet.cc:170
const std::vector< Entry > entries
Definition: Ieee80211ModeSet.h:44
const IIeee80211Mode * inet::physicallayer::Ieee80211ModeSet::getFastestMandatoryMode ( ) const

Referenced by inet::ieee80211::RateSelection::initialize(), inet::ieee80211::RateControlBase::receiveSignal(), inet::ieee80211::RateSelection::receiveSignal(), and inet::ieee80211::QoSRateSelection::receiveSignal().

248 {
249  for (int i = (int)entries.size()-1; i >= 0; i--)
250  if (entries[i].isMandatory)
251  return entries[i].mode;
252  return nullptr;
253 }
const std::vector< Entry > entries
Definition: Ieee80211ModeSet.h:44
const IIeee80211Mode * inet::physicallayer::Ieee80211ModeSet::getFastestMode ( ) const
217 {
218  return entries.back().mode;
219 }
const std::vector< Entry > entries
Definition: Ieee80211ModeSet.h:44
bool inet::physicallayer::Ieee80211ModeSet::getIsMandatory ( const IIeee80211Mode mode) const
const IIeee80211Mode * inet::physicallayer::Ieee80211ModeSet::getMode ( bps  bitrate) const

Referenced by inet::physicallayer::Ieee80211TransmitterBase::computeTransmissionMode(), inet::physicallayer::Ieee80211TransmitterBase::initialize(), inet::ieee80211::RateSelection::initialize(), inet::ieee80211::QoSRateSelection::initialize(), inet::ieee80211::RateControlBase::receiveSignal(), and inet::physicallayer::Ieee80211TransmitterBase::setModeSet().

203 {
204  const IIeee80211Mode *mode = findMode(bitrate);
205  if (mode == nullptr)
206  throw cRuntimeError("Unknown bitrate: %g in operation mode: '%s'", bitrate.get(), getName());
207  else
208  return mode;
209 }
const IIeee80211Mode * findMode(bps bitrate) const
Definition: Ieee80211ModeSet.cc:192
const char * getName() const override
Definition: Ieee80211ModeSet.h:58
int inet::physicallayer::Ieee80211ModeSet::getModeIndex ( const IIeee80211Mode mode) const
protected

Referenced by getIsMandatory().

179 {
180  int index = findModeIndex(mode);
181  if (index < 0)
182  throw cRuntimeError("Unknown mode");
183  else
184  return index;
185 }
int findModeIndex(const IIeee80211Mode *mode) const
Definition: Ieee80211ModeSet.cc:170
const Ieee80211ModeSet * inet::physicallayer::Ieee80211ModeSet::getModeSet ( const char *  mode)
static

Referenced by inet::physicallayer::Ieee80211Radio::handleUpperCommand(), inet::physicallayer::Ieee80211ReceiverBase::initialize(), inet::physicallayer::Ieee80211TransmitterBase::initialize(), and inet::ieee80211::Ieee80211Mac::initialize().

286 {
287  const Ieee80211ModeSet *modeSet = findModeSet(mode);
288  if (modeSet == nullptr) {
289  std::string validModeSets;
290  for (int index = 0; index < (int)(&modeSets)->size(); index++) {
291  const Ieee80211ModeSet *modeSet = &(&modeSets)->at(index);
292  validModeSets += std::string("'") + modeSet->getName() + "' ";
293  }
294  throw cRuntimeError("Unknown 802.11 operational mode: '%s', valid modes are: %s", mode, validModeSets.c_str());
295  }
296  else
297  return modeSet;
298 }
static const DelayedInitializer< std::vector< Ieee80211ModeSet > > modeSets
Definition: Ieee80211ModeSet.h:47
Ieee80211ModeSet(const char *name, const std::vector< Entry > entries)
Definition: Ieee80211ModeSet.cc:152
static const Ieee80211ModeSet * findModeSet(const char *mode)
Definition: Ieee80211ModeSet.cc:275
const char* inet::physicallayer::Ieee80211ModeSet::getName ( ) const
inlineoverride

Referenced by findModeSet(), getMode(), and getModeSet().

58 { return name.c_str(); }
std::string name
Definition: Ieee80211ModeSet.h:43
simtime_t inet::physicallayer::Ieee80211ModeSet::getPhyRxStartDelay ( ) const
inline
79 { return entries[0].mode->getPhyRxStartDelay(); }
const std::vector< Entry > entries
Definition: Ieee80211ModeSet.h:44
simtime_t inet::physicallayer::Ieee80211ModeSet::getSifsTime ( ) const
inline

Referenced by inet::ieee80211::Dcaf::calculateTimingParameters(), inet::ieee80211::Edcaf::calculateTimingParameters(), inet::ieee80211::RecipientAckPolicy::computeAckDurationField(), inet::ieee80211::RecipientQoSAckPolicy::computeAckDurationField(), inet::ieee80211::RecipientQoSAckPolicy::computeBasicBlockAckDurationField(), inet::ieee80211::SingleProtectionMechanism::computeBlockAckReqDurationField(), inet::ieee80211::QoSCtsPolicy::computeCtsDurationField(), inet::ieee80211::CtsPolicy::computeCtsDurationField(), inet::ieee80211::OriginatorProtectionMechanism::computeDataFrameDurationField(), inet::ieee80211::SingleProtectionMechanism::computeDataOrMgmtFrameDurationField(), inet::ieee80211::OriginatorProtectionMechanism::computeMgmtFrameDurationField(), inet::ieee80211::OriginatorProtectionMechanism::computeRtsDurationField(), inet::ieee80211::SingleProtectionMechanism::computeRtsDurationField(), inet::ieee80211::OriginatorAckPolicy::getAckTimeout(), inet::ieee80211::OriginatorQoSAckPolicy::getAckTimeout(), inet::ieee80211::OriginatorQoSAckPolicy::getBlockAckTimeout(), inet::ieee80211::RtsPolicy::getCtsTimeout(), inet::ieee80211::QoSRtsPolicy::getCtsTimeout(), inet::ieee80211::FrameSequenceContext::getIfs(), inet::ieee80211::Dcf::transmitControlResponseFrame(), and inet::ieee80211::Hcf::transmitControlResponseFrame().

77 { return entries[0].mode->getSifsTime(); }
const std::vector< Entry > entries
Definition: Ieee80211ModeSet.h:44
const IIeee80211Mode * inet::physicallayer::Ieee80211ModeSet::getSlowerMandatoryMode ( const IIeee80211Mode mode) const

Referenced by inet::ieee80211::QoSRateSelection::computeResponseAckFrameMode(), and inet::ieee80211::QoSRateSelection::computeResponseCtsFrameMode().

256 {
257  int index = findModeIndex(mode);
258  if (index > 0)
259  for (int i = index-1; i >= 0; i--)
260  if (entries[i].isMandatory)
261  return entries[i].mode;
262  return nullptr;
263 }
int findModeIndex(const IIeee80211Mode *mode) const
Definition: Ieee80211ModeSet.cc:170
const std::vector< Entry > entries
Definition: Ieee80211ModeSet.h:44
const IIeee80211Mode * inet::physicallayer::Ieee80211ModeSet::getSlowerMode ( const IIeee80211Mode mode) const

Referenced by inet::ieee80211::RateControlBase::decreaseRateIfPossible().

222 {
223  int index = findModeIndex(mode);
224  if (index > 0)
225  return entries[index - 1].mode;
226  else
227  return nullptr;
228 }
int findModeIndex(const IIeee80211Mode *mode) const
Definition: Ieee80211ModeSet.cc:170
const std::vector< Entry > entries
Definition: Ieee80211ModeSet.h:44
const IIeee80211Mode * inet::physicallayer::Ieee80211ModeSet::getSlowestMandatoryMode ( ) const

Referenced by inet::ieee80211::Dcaf::calculateTimingParameters(), inet::ieee80211::Edcaf::calculateTimingParameters(), and inet::ieee80211::TxopProcedure::startTxop().

240 {
241  for (int i = 0; i < (int)entries.size(); i++)
242  if (entries[i].isMandatory)
243  return entries[i].mode;
244  return nullptr;
245 }
const std::vector< Entry > entries
Definition: Ieee80211ModeSet.h:44
const IIeee80211Mode * inet::physicallayer::Ieee80211ModeSet::getSlowestMode ( ) const
212 {
213  return entries.front().mode;
214 }
const std::vector< Entry > entries
Definition: Ieee80211ModeSet.h:44
virtual std::ostream& inet::physicallayer::Ieee80211ModeSet::printToStream ( std::ostream &  stream,
int  level 
) const
inlineoverridevirtual

Prints this object to the provided output stream.

Function calls to operator<< with pointers or references either const or not are all forwarded to this function.

Reimplemented from inet::physicallayer::IPrintableObject.

56 { return stream << "Ieee80211ModeSet, name = " << name; }
std::string name
Definition: Ieee80211ModeSet.h:43

Member Data Documentation

const DelayedInitializer< std::vector< Ieee80211ModeSet > > inet::physicallayer::Ieee80211ModeSet::modeSets
static

Referenced by findModeSet(), and getModeSet().

std::string inet::physicallayer::Ieee80211ModeSet::name
protected

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