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

Implements IEEE 802.11 Enhanced Distributed Channel Access Function. More...

#include <Edcaf.h>

Inheritance diagram for inet::ieee80211::Edcaf:
inet::ieee80211::IChannelAccess inet::ieee80211::IContention::ICallback inet::ieee80211::IRecoveryProcedure::ICwCalculator inet::ieee80211::ModeSetListener

Public Member Functions

virtual void requestChannel (IChannelAccess::ICallback *callback) override
 
virtual void releaseChannel (IChannelAccess::ICallback *callback) override
 
virtual void channelAccessGranted () override
 
virtual void expectedChannelAccess (simtime_t time) override
 
virtual void incrementCw () override
 
virtual void resetCw () override
 
virtual bool isOwning ()
 
virtual bool isInternalCollision ()
 
virtual AccessCategory getAccessCategory ()
 
virtual int getCw ()
 
- Public Member Functions inherited from inet::ieee80211::IChannelAccess
virtual ~IChannelAccess ()
 
- Public Member Functions inherited from inet::ieee80211::IContention::ICallback
 ~ICallback ()
 

Protected Member Functions

virtual int numInitStages () const override
 
virtual void initialize (int stage) override
 
virtual void updateDisplayString ()
 
virtual void receiveSignal (cComponent *source, simsignal_t signalID, cObject *obj, cObject *details) override
 
virtual AccessCategory getAccessCategory (const char *ac)
 
virtual int getAifsNumber (AccessCategory ac)
 
virtual int getCwMax (AccessCategory ac, int aCwMax, int aCwMin)
 
virtual int getCwMin (AccessCategory ac, int aCwMin)
 
virtual void calculateTimingParameters ()
 

Protected Attributes

IContentioncontention = nullptr
 
IChannelAccess::ICallbackcallback = nullptr
 
IEdcaCollisionControllercollisionController = nullptr
 
bool owning = false
 
simtime_t slotTime = -1
 
simtime_t sifs = -1
 
simtime_t ifs = -1
 
simtime_t eifs = -1
 
AccessCategory ac = AccessCategory(-1)
 
int cw = -1
 
int cwMin = -1
 
int cwMax = -1
 
- Protected Attributes inherited from inet::ieee80211::ModeSetListener
Ieee80211ModeSetmodeSet = nullptr
 

Detailed Description

Implements IEEE 802.11 Enhanced Distributed Channel Access Function.

Member Function Documentation

void inet::ieee80211::Edcaf::calculateTimingParameters ( )
protectedvirtual

Referenced by initialize(), and receiveSignal().

49 {
52  int aifsn = par("aifsn");
53  simtime_t aifs = sifs + fallback(getAifsNumber(ac), aifsn) * slotTime;
54  ifs = aifs;
56  ASSERT(ifs > sifs);
57  cwMin = par("cwMin");
58  cwMax = par("cwMax");
59  if (cwMin == -1)
61  if (cwMax == -1)
63  cw = cwMin;
64 }
simtime_t getSlotTime() const
Definition: Ieee80211ModeSet.h:78
simtime_t eifs
Definition: Edcaf.h:49
simtime_t sifs
Definition: Edcaf.h:47
const unsigned int LENGTH_ACK
Definition: Ieee80211Frame_m.h:43
virtual const simtime_t getDuration(int dataBitLength) const =0
int getCwMin() const
Definition: Ieee80211ModeSet.h:80
virtual int getAifsNumber(AccessCategory ac)
Definition: Edcaf.cc:81
int cwMax
Definition: Edcaf.h:54
Ieee80211ModeSet * modeSet
Definition: ModeSetListener.h:31
simtime_t ifs
Definition: Edcaf.h:48
virtual int getCwMin(AccessCategory ac, int aCwMin)
Definition: Edcaf.cc:163
simtime_t slotTime
Definition: Edcaf.h:46
simtime_t getSifsTime() const
Definition: Ieee80211ModeSet.h:77
virtual int getCwMax(AccessCategory ac, int aCwMax, int aCwMin)
Definition: Edcaf.cc:151
double fallback(double a, double b)
Definition: Edcaf.cc:28
int cwMin
Definition: Edcaf.h:53
int cw
Definition: Edcaf.h:52
AccessCategory ac
Definition: Edcaf.h:51
const IIeee80211Mode * getSlowestMandatoryMode() const
Definition: Ieee80211ModeSet.cc:239
int getCwMax() const
Definition: Ieee80211ModeSet.h:81
void inet::ieee80211::Edcaf::channelAccessGranted ( )
overridevirtual

Implements inet::ieee80211::IContention::ICallback.

107 {
108  ASSERT(callback != nullptr);
110  owning = true;
111  callback->channelGranted(this);
112  }
113  if (hasGUI())
115 }
bool owning
Definition: Edcaf.h:44
virtual void channelGranted(IChannelAccess *channelAccess)=0
IEdcaCollisionController * collisionController
Definition: Edcaf.h:42
virtual bool isInternalCollision(Edcaf *channelAccess)=0
virtual void updateDisplayString()
Definition: Edcaf.cc:184
IChannelAccess::ICallback * callback
Definition: Edcaf.h:41
void inet::ieee80211::Edcaf::expectedChannelAccess ( simtime_t  time)
overridevirtual

Implements inet::ieee80211::IContention::ICallback.

142 {
144 }
IEdcaCollisionController * collisionController
Definition: Edcaf.h:42
virtual void expectedChannelAccess(Edcaf *channelAccess, simtime_t time)=0
AccessCategory inet::ieee80211::Edcaf::getAccessCategory ( const char *  ac)
protectedvirtual

Referenced by inet::ieee80211::Hcf::channelGranted(), inet::ieee80211::EdcaCollisionController::expectedChannelAccess(), inet::ieee80211::Hcf::hasFrameToTransmit(), inet::ieee80211::EdcaCollisionController::isInternalCollision(), inet::ieee80211::Hcf::originatorProcessFailedFrame(), inet::ieee80211::Hcf::originatorProcessReceivedFrame(), inet::ieee80211::Hcf::originatorProcessRtsProtectionFailed(), inet::ieee80211::Hcf::originatorProcessTransmittedFrame(), and inet::ieee80211::Hcf::transmitFrame().

94 {
95  if (strcmp("AC_BK", ac) == 0)
96  return AC_BK;
97  if (strcmp("AC_VI", ac) == 0)
98  return AC_VI;
99  if (strcmp("AC_VO", ac) == 0)
100  return AC_VO;
101  if (strcmp("AC_BE", ac) == 0)
102  return AC_BE;
103  throw cRuntimeError("Unknown Access Category = %s", ac);
104 }
Definition: AccessCategory.h:31
Definition: AccessCategory.h:33
Definition: AccessCategory.h:34
Definition: AccessCategory.h:32
AccessCategory ac
Definition: Edcaf.h:51
virtual AccessCategory inet::ieee80211::Edcaf::getAccessCategory ( )
inlinevirtual

Referenced by initialize().

87 { return ac; }
AccessCategory ac
Definition: Edcaf.h:51
int inet::ieee80211::Edcaf::getAifsNumber ( AccessCategory  ac)
protectedvirtual

Referenced by calculateTimingParameters().

82 {
83  switch (ac)
84  {
85  case AC_BK: return 7;
86  case AC_BE: return 3;
87  case AC_VI: return 2;
88  case AC_VO: return 2;
89  default: throw cRuntimeError("Unknown access category = %d", ac);
90  }
91 }
Definition: AccessCategory.h:31
Definition: AccessCategory.h:33
Definition: AccessCategory.h:34
Definition: AccessCategory.h:32
AccessCategory ac
Definition: Edcaf.h:51
virtual int inet::ieee80211::Edcaf::getCw ( )
inlinevirtual
89 { return cw; }
int cw
Definition: Edcaf.h:52
int inet::ieee80211::Edcaf::getCwMax ( AccessCategory  ac,
int  aCwMax,
int  aCwMin 
)
protectedvirtual

Referenced by calculateTimingParameters().

152 {
153  switch (ac)
154  {
155  case AC_BK: return aCwMax;
156  case AC_BE: return aCwMax;
157  case AC_VI: return aCwMin;
158  case AC_VO: return (aCwMin + 1) / 2 - 1;
159  default: throw cRuntimeError("Unknown access category = %d", ac);
160  }
161 }
Definition: AccessCategory.h:31
Definition: AccessCategory.h:33
Definition: AccessCategory.h:34
Definition: AccessCategory.h:32
AccessCategory ac
Definition: Edcaf.h:51
int inet::ieee80211::Edcaf::getCwMin ( AccessCategory  ac,
int  aCwMin 
)
protectedvirtual

Referenced by calculateTimingParameters().

164 {
165  switch (ac)
166  {
167  case AC_BK: return aCwMin;
168  case AC_BE: return aCwMin;
169  case AC_VI: return (aCwMin + 1) / 2 - 1;
170  case AC_VO: return (aCwMin + 1) / 4 - 1;
171  default: throw cRuntimeError("Unknown access category = %d", ac);
172  }
173 }
Definition: AccessCategory.h:31
Definition: AccessCategory.h:33
Definition: AccessCategory.h:34
Definition: AccessCategory.h:32
AccessCategory ac
Definition: Edcaf.h:51
void inet::ieee80211::Edcaf::incrementCw ( )
overridevirtual

Implements inet::ieee80211::IRecoveryProcedure::ICwCalculator.

68 {
69  int newCw = 2 * cw + 1;
70  if (newCw > cwMax)
71  cw = cwMax;
72  else
73  cw = newCw;
74 }
int cwMax
Definition: Edcaf.h:54
int cw
Definition: Edcaf.h:52
void inet::ieee80211::Edcaf::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::ieee80211::ModeSetListener.

32 {
33  if (stage == INITSTAGE_LOCAL) {
34  getContainingNicModule(this)->subscribe(NF_MODESET_CHANGED, this);
35  ac = getAccessCategory(par("accessCategory"));
36  contention = check_and_cast<IContention *>(getSubmodule("contention"));
37  collisionController = check_and_cast<IEdcaCollisionController *>(getModuleByPath(par("collisionControllerModule")));
38  }
39  else if (stage == INITSTAGE_LINK_LAYER_2) {
40  auto rx = check_and_cast<IRx *>(getModuleByPath(par("rxModule")));
43  if (hasGUI())
45  }
46 }
IContention * contention
Definition: Edcaf.h:40
IEdcaCollisionController * collisionController
Definition: Edcaf.h:42
Abstract interface for Rx processes.
Definition: IRx.h:45
virtual void updateDisplayString()
Definition: Edcaf.cc:184
Local initializations.
Definition: InitStages.h:35
virtual AccessCategory getAccessCategory()
Definition: Edcaf.h:87
cModule * getContainingNicModule(cModule *from)
Find the nic module (inside the networkNode) containing the given module.
Definition: ModuleAccess.cc:96
simsignal_t NF_MODESET_CHANGED
Definition: NotifierConsts.cc:46
AccessCategory ac
Definition: Edcaf.h:51
virtual void registerContention(IContention *contention)=0
Additional link-layer initializations that depend on the previous stage.
Definition: InitStages.h:64
Definition: IEdcaCollisionController.h:28
virtual void calculateTimingParameters()
Definition: Edcaf.cc:48
Abstract interface for processes that implement contention-based channel access.
Definition: IContention.h:39
bool inet::ieee80211::Edcaf::isInternalCollision ( )
virtual
147 {
149 }
IEdcaCollisionController * collisionController
Definition: Edcaf.h:42
virtual bool isInternalCollision(Edcaf *channelAccess)=0
virtual bool inet::ieee80211::Edcaf::isOwning ( )
inlinevirtual
85 { return owning; }
bool owning
Definition: Edcaf.h:44
virtual int inet::ieee80211::Edcaf::numInitStages ( ) const
inlineoverrideprotectedvirtual

Reimplemented from inet::ieee80211::ModeSetListener.

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

Reimplemented from inet::ieee80211::ModeSetListener.

176 {
177  Enter_Method("receiveModeSetChangeNotification");
178  if (signalID == NF_MODESET_CHANGED) {
179  modeSet = check_and_cast<Ieee80211ModeSet*>(obj);
181  }
182 }
Definition: Ieee80211ModeSet.h:28
Ieee80211ModeSet * modeSet
Definition: ModeSetListener.h:31
simsignal_t NF_MODESET_CHANGED
Definition: NotifierConsts.cc:46
virtual void calculateTimingParameters()
Definition: Edcaf.cc:48
void inet::ieee80211::Edcaf::releaseChannel ( IChannelAccess::ICallback callback)
overridevirtual

Implements inet::ieee80211::IChannelAccess.

Referenced by inet::ieee80211::Edca::releaseChannelAccess().

118 {
119  ASSERT(owning);
120  owning = false;
121  this->callback = nullptr;
122  if (hasGUI())
124 }
bool owning
Definition: Edcaf.h:44
virtual void updateDisplayString()
Definition: Edcaf.cc:184
void inet::ieee80211::Edcaf::requestChannel ( IChannelAccess::ICallback callback)
overridevirtual

Implements inet::ieee80211::IChannelAccess.

Referenced by inet::ieee80211::Edca::requestChannelAccess().

127 {
128  this->callback = callback;
129  ASSERT(!owning);
131  EV_DETAIL << "Contention has already been started" << std::endl;
132  else {
133 // EV_DETAIL << "Starting contention with cw = " << cw << ", ifs = " << ifs << ", eifs = "
134 // << eifs << ", slotTime = " << slotTime << std::endl;
136  }
137  if (hasGUI())
139 }
bool owning
Definition: Edcaf.h:44
IContention * contention
Definition: Edcaf.h:40
simtime_t eifs
Definition: Edcaf.h:49
simtime_t ifs
Definition: Edcaf.h:48
virtual void updateDisplayString()
Definition: Edcaf.cc:184
simtime_t slotTime
Definition: Edcaf.h:46
virtual void startContention(int cw, simtime_t ifs, simtime_t eifs, simtime_t slotTime, ICallback *callback)=0
virtual bool isContentionInProgress()=0
IChannelAccess::ICallback * callback
Definition: Edcaf.h:41
int cw
Definition: Edcaf.h:52
void inet::ieee80211::Edcaf::resetCw ( )
overridevirtual

Implements inet::ieee80211::IRecoveryProcedure::ICwCalculator.

77 {
78  cw = cwMin;
79 }
int cwMin
Definition: Edcaf.h:53
int cw
Definition: Edcaf.h:52
void inet::ieee80211::Edcaf::updateDisplayString ( )
protectedvirtual

Referenced by channelAccessGranted(), initialize(), releaseChannel(), and requestChannel().

185 {
186  std::string displayString(printAccessCategory(ac));
187  if (owning)
188  displayString += "\n(Channel owner)";
190  displayString += "\n(Contention in progress)";
191  getDisplayString().setTagArg("t", 0, displayString.c_str());
192 }
bool owning
Definition: Edcaf.h:44
IContention * contention
Definition: Edcaf.h:40
virtual bool isContentionInProgress()=0
AccessCategory ac
Definition: Edcaf.h:51

Member Data Documentation

AccessCategory inet::ieee80211::Edcaf::ac = AccessCategory(-1)
protected
IChannelAccess::ICallback* inet::ieee80211::Edcaf::callback = nullptr
protected
IEdcaCollisionController* inet::ieee80211::Edcaf::collisionController = nullptr
protected
IContention* inet::ieee80211::Edcaf::contention = nullptr
protected
int inet::ieee80211::Edcaf::cw = -1
protected
int inet::ieee80211::Edcaf::cwMax = -1
protected
int inet::ieee80211::Edcaf::cwMin = -1
protected
simtime_t inet::ieee80211::Edcaf::eifs = -1
protected
simtime_t inet::ieee80211::Edcaf::ifs = -1
protected
bool inet::ieee80211::Edcaf::owning = false
protected
simtime_t inet::ieee80211::Edcaf::sifs = -1
protected
simtime_t inet::ieee80211::Edcaf::slotTime = -1
protected

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