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

#include <Ieee80211ModeSet.h>

Inheritance diagram for inet::physicallayer::Ieee80211ModeSet:
inet::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, int evFlags=0) 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, Hz bandwidth=Hz(NaN), int numSpatialStreams=-1) const
 
const IIeee80211ModefindMode (bps minBitrate, bps maxBitrate, Hz bandwidth=Hz(NaN), int numSpatialStreams=-1) const
 
const IIeee80211ModegetMode (bps bitrate, Hz bandwidth=Hz(NaN), int numSpatialStreams=-1) const
 
const IIeee80211ModegetMode (bps minBitrate, bps maxBitrate, Hz bandwidth=Hz(NaN), int numSpatialStreams=-1) 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::IPrintableObject
virtual ~IPrintableObject ()
 
virtual std::string printToString () const
 
virtual std::string printToString (int level, int evFlags=0) const
 
virtual std::string getInfoStringRepresentation (int evFlags=0) const
 
virtual std::string getDetailStringRepresentation (int evFlags=0) const
 
virtual std::string getDebugStringRepresentation (int evFlags=0) const
 
virtual std::string getTraceStringRepresentation (int evFlags=0) const
 
virtual std::string getCompleteStringRepresentation (int evFlags=0) 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::IPrintableObject
enum  PrintLevel {
  PRINT_LEVEL_TRACE, PRINT_LEVEL_DEBUG, PRINT_LEVEL_DETAIL, PRINT_LEVEL_INFO,
  PRINT_LEVEL_COMPLETE = INT_MIN
}
 
enum  PrintFlag { PRINT_FLAG_FORMATTED = (1 << 0), PRINT_FLAG_MULTILINE = (1 << 1) }
 

Constructor & Destructor Documentation

◆ Ieee80211ModeSet()

inet::physicallayer::Ieee80211ModeSet::Ieee80211ModeSet ( const char *  name,
const std::vector< Entry entries 
)
458  :
459  name(name),
461 {
462  std::vector<Entry> *nonConstEntries = const_cast<std::vector<Entry> *>(&this->entries);
463  std::stable_sort(nonConstEntries->begin(), nonConstEntries->end(), EntryNetBitrateComparator());
464  auto referenceMode = entries[0].mode;
465  for (auto entry : entries) {
466  auto mode = entry.mode;
467  if (mode->getSifsTime() != referenceMode->getSifsTime() ||
468  mode->getSlotTime() != referenceMode->getSlotTime() ||
469  mode->getPhyRxStartDelay() != referenceMode->getPhyRxStartDelay())
470  {
471  // FIXME throw cRuntimeError("Sifs, slot and phyRxStartDelay time must be identical within a ModeSet");
472  }
473  }
474 }

Member Function Documentation

◆ _getFastestMandatoryMode()

IIeee80211Mode* inet::physicallayer::Ieee80211ModeSet::_getFastestMandatoryMode ( ) const
inline
76 { return const_cast<IIeee80211Mode *>(getFastestMandatoryMode()); }

◆ _getFastestMode()

IIeee80211Mode* inet::physicallayer::Ieee80211ModeSet::_getFastestMode ( ) const
inline
74 { return const_cast<IIeee80211Mode *>(getFastestMode()); }

◆ _getSlowestMandatoryMode()

IIeee80211Mode* inet::physicallayer::Ieee80211ModeSet::_getSlowestMandatoryMode ( ) const
inline
75 { return const_cast<IIeee80211Mode *>(getSlowestMandatoryMode()); }

◆ _getSlowestMode()

IIeee80211Mode* inet::physicallayer::Ieee80211ModeSet::_getSlowestMode ( ) const
inline
73 { return const_cast<IIeee80211Mode *>(getSlowestMode()); }

◆ containsMode()

◆ findMode() [1/2]

const IIeee80211Mode * inet::physicallayer::Ieee80211ModeSet::findMode ( bps  bitrate,
Hz  bandwidth = Hz(NaN),
int  numSpatialStreams = -1 
) const
499 {
500  return findMode(bitrate - Mbps(0.05), bitrate + Mbps(0.05), bandwidth, numSpatialStreams);
501 }

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

◆ findMode() [2/2]

const IIeee80211Mode * inet::physicallayer::Ieee80211ModeSet::findMode ( bps  minBitrate,
bps  maxBitrate,
Hz  bandwidth = Hz(NaN),
int  numSpatialStreams = -1 
) const
504 {
505  for (size_t index = 0; index < entries.size(); index++) {
506  auto mode = entries[index].mode;
507  auto dataMode = mode->getDataMode();
508  auto bitrate = dataMode->getNetBitrate();
509  if (minBitrate <= bitrate && bitrate <= maxBitrate &&
510  (std::isnan(bandwidth.get()) || dataMode->getBandwidth() == bandwidth) &&
511  (numSpatialStreams == -1 || dataMode->getNumberOfSpatialStreams() == numSpatialStreams))
512  {
513  return entries[index].mode;
514  }
515  }
516  return nullptr;
517 }

◆ findModeIndex()

int inet::physicallayer::Ieee80211ModeSet::findModeIndex ( const IIeee80211Mode mode) const
protected
477 {
478  for (int index = 0; index < (int)entries.size(); index++)
479  if (entries[index].mode == mode)
480  return index;
481  return -1;
482 }

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

◆ findModeSet()

const Ieee80211ModeSet * inet::physicallayer::Ieee80211ModeSet::findModeSet ( const char *  mode)
static
602 {
603  for (int index = 0; index < (int)(&modeSets)->size(); index++) {
604  const Ieee80211ModeSet *modeSet = &(&modeSets)->at(index);
605  if (strcmp(modeSet->getName(), mode) == 0)
606  return modeSet;
607  }
608  return nullptr;
609 }

Referenced by getModeSet().

◆ getCwMax()

int inet::physicallayer::Ieee80211ModeSet::getCwMax ( ) const
inline
71 { return entries[0].mode->getLegacyCwMax(); }

◆ getCwMin()

int inet::physicallayer::Ieee80211ModeSet::getCwMin ( ) const
inline
70 { return entries[0].mode->getLegacyCwMin(); }

◆ getFasterMandatoryMode()

const IIeee80211Mode * inet::physicallayer::Ieee80211ModeSet::getFasterMandatoryMode ( const IIeee80211Mode mode) const
592 {
593  int index = findModeIndex(mode);
594  if (index >= 0)
595  for (int i = index + 1; i < (int)entries.size(); i++)
596  if (entries[i].isMandatory)
597  return entries[i].mode;
598  return nullptr;
599 }

◆ getFasterMode()

const IIeee80211Mode * inet::physicallayer::Ieee80211ModeSet::getFasterMode ( const IIeee80211Mode mode) const
557 {
558  int index = findModeIndex(mode);
559  if (index >= 0 && index < (int)entries.size() - 1)
560  return entries[index + 1].mode;
561  else
562  return nullptr;
563 }

◆ getFastestMandatoryMode()

const IIeee80211Mode * inet::physicallayer::Ieee80211ModeSet::getFastestMandatoryMode ( ) const
574 {
575  for (int i = (int)entries.size() - 1; i >= 0; i--)
576  if (entries[i].isMandatory)
577  return entries[i].mode;
578  return nullptr;
579 }

◆ getFastestMode()

const IIeee80211Mode * inet::physicallayer::Ieee80211ModeSet::getFastestMode ( ) const
543 {
544  return entries.back().mode;
545 }

Referenced by inet::physicallayer::Ieee80211TransmitterBase::initialize().

◆ getIsMandatory()

bool inet::physicallayer::Ieee80211ModeSet::getIsMandatory ( const IIeee80211Mode mode) const
494 {
495  return entries[getModeIndex(mode)].isMandatory;
496 }

◆ getMode() [1/2]

const IIeee80211Mode * inet::physicallayer::Ieee80211ModeSet::getMode ( bps  bitrate,
Hz  bandwidth = Hz(NaN),
int  numSpatialStreams = -1 
) const
520 {
521  const IIeee80211Mode *mode = getMode(bitrate - Mbps(0.05), bitrate + Mbps(0.05), bandwidth, numSpatialStreams);
522  if (mode == nullptr)
523  throw cRuntimeError("Unknown bitrate: %g in operation mode: '%s'", bitrate.get(), getName());
524  else
525  return mode;
526 }

Referenced by inet::physicallayer::Ieee80211TransmitterBase::computeTransmissionMode(), inet::physicallayer::Ieee80211TransmitterBase::initialize(), and inet::physicallayer::Ieee80211TransmitterBase::setModeSet().

◆ getMode() [2/2]

const IIeee80211Mode * inet::physicallayer::Ieee80211ModeSet::getMode ( bps  minBitrate,
bps  maxBitrate,
Hz  bandwidth = Hz(NaN),
int  numSpatialStreams = -1 
) const
529 {
530  const IIeee80211Mode *mode = findMode(minBitrate, maxBitrate, bandwidth, numSpatialStreams);
531  if (mode == nullptr)
532  throw cRuntimeError("Unknown bitrate: (%g - %g) in operation mode: '%s'", minBitrate.get(), maxBitrate.get(), getName());
533  else
534  return mode;
535 }

◆ getModeIndex()

int inet::physicallayer::Ieee80211ModeSet::getModeIndex ( const IIeee80211Mode mode) const
protected
485 {
486  int index = findModeIndex(mode);
487  if (index < 0)
488  throw cRuntimeError("Unknown mode");
489  else
490  return index;
491 }

Referenced by getIsMandatory().

◆ getModeSet()

const Ieee80211ModeSet * inet::physicallayer::Ieee80211ModeSet::getModeSet ( const char *  mode)
static
612 {
613  const Ieee80211ModeSet *modeSet = findModeSet(mode);
614  if (modeSet == nullptr) {
615  std::string validModeSets;
616  for (size_t index = 0; index < (&modeSets)->size(); index++) {
617  const Ieee80211ModeSet *modeSet = &(&modeSets)->at(index);
618  validModeSets += std::string("'") + modeSet->getName() + "' ";
619  }
620  throw cRuntimeError("Unknown 802.11 operational mode: '%s', valid modes are: %s", mode, validModeSets.c_str());
621  }
622  else
623  return modeSet;
624 }

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

◆ getName()

const char* inet::physicallayer::Ieee80211ModeSet::getName ( ) const
inlineoverride
46 { return name.c_str(); }

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

◆ getPhyRxStartDelay()

simtime_t inet::physicallayer::Ieee80211ModeSet::getPhyRxStartDelay ( ) const
inline
69 { return entries[0].mode->getPhyRxStartDelay(); }

◆ getSifsTime()

◆ getSlotTime()

◆ getSlowerMandatoryMode()

const IIeee80211Mode * inet::physicallayer::Ieee80211ModeSet::getSlowerMandatoryMode ( const IIeee80211Mode mode) const
582 {
583  int index = findModeIndex(mode);
584  if (index > 0)
585  for (int i = index - 1; i >= 0; i--)
586  if (entries[i].isMandatory)
587  return entries[i].mode;
588  return nullptr;
589 }

◆ getSlowerMode()

const IIeee80211Mode * inet::physicallayer::Ieee80211ModeSet::getSlowerMode ( const IIeee80211Mode mode) const
548 {
549  int index = findModeIndex(mode);
550  if (index > 0)
551  return entries[index - 1].mode;
552  else
553  return nullptr;
554 }

◆ getSlowestMandatoryMode()

const IIeee80211Mode * inet::physicallayer::Ieee80211ModeSet::getSlowestMandatoryMode ( ) const
566 {
567  for (size_t i = 0; i < entries.size(); i++)
568  if (entries[i].isMandatory)
569  return entries[i].mode;
570  return nullptr;
571 }

◆ getSlowestMode()

const IIeee80211Mode * inet::physicallayer::Ieee80211ModeSet::getSlowestMode ( ) const
538 {
539  return entries.front().mode;
540 }

◆ printToStream()

virtual std::ostream& inet::physicallayer::Ieee80211ModeSet::printToStream ( std::ostream &  stream,
int  level,
int  evFlags = 0 
) const
inlineoverridevirtual

Prints this object to the provided output stream.

Reimplemented from inet::IPrintableObject.

44 { return stream << "Ieee80211ModeSet, name = " << name; }

Member Data Documentation

◆ entries

◆ modeSets

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

Referenced by findModeSet(), and getModeSet().

◆ name

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

The documentation for this class was generated from the following files:
inet::units::units::Mbps
mega< bps >::type Mbps
Definition: Units.h:1171
inet::physicallayer::Ieee80211ModeSet::entries
const std::vector< Entry > entries
Definition: Ieee80211ModeSet.h:32
inet::physicallayer::Ieee80211ModeSet::name
std::string name
Definition: Ieee80211ModeSet.h:31
inet::physicallayer::Ieee80211ModeSet::Ieee80211ModeSet
Ieee80211ModeSet(const char *name, const std::vector< Entry > entries)
Definition: Ieee80211ModeSet.cc:458
inet::physicallayer::Ieee80211ModeSet::modeSets
static const DelayedInitializer< std::vector< Ieee80211ModeSet > > modeSets
Definition: Ieee80211ModeSet.h:35
inet::physicallayer::Ieee80211ModeSet::findModeIndex
int findModeIndex(const IIeee80211Mode *mode) const
Definition: Ieee80211ModeSet.cc:476
inet::physicallayer::Ieee80211ModeSet::findModeSet
static const Ieee80211ModeSet * findModeSet(const char *mode)
Definition: Ieee80211ModeSet.cc:601
inet::physicallayer::Ieee80211ModeSet::getSlowestMandatoryMode
const IIeee80211Mode * getSlowestMandatoryMode() const
Definition: Ieee80211ModeSet.cc:565
inet::physicallayer::Ieee80211ModeSet::getFastestMandatoryMode
const IIeee80211Mode * getFastestMandatoryMode() const
Definition: Ieee80211ModeSet.cc:573
inet::physicallayer::Ieee80211ModeSet::getModeIndex
int getModeIndex(const IIeee80211Mode *mode) const
Definition: Ieee80211ModeSet.cc:484
inet::physicallayer::Ieee80211ModeSet::findMode
const IIeee80211Mode * findMode(bps bitrate, Hz bandwidth=Hz(NaN), int numSpatialStreams=-1) const
Definition: Ieee80211ModeSet.cc:498
inet::physicallayer::Ieee80211ModeSet::getFastestMode
const IIeee80211Mode * getFastestMode() const
Definition: Ieee80211ModeSet.cc:542
inet::physicallayer::Ieee80211ModeSet::getSlowestMode
const IIeee80211Mode * getSlowestMode() const
Definition: Ieee80211ModeSet.cc:537
inet::physicallayer::Ieee80211ModeSet::getName
const char * getName() const override
Definition: Ieee80211ModeSet.h:46
inet::physicallayer::Ieee80211ModeSet::getMode
const IIeee80211Mode * getMode(bps bitrate, Hz bandwidth=Hz(NaN), int numSpatialStreams=-1) const
Definition: Ieee80211ModeSet.cc:519