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

The default implementation of IRx. More...

#include <Rx.h>

Inheritance diagram for inet::ieee80211::Rx:
inet::ieee80211::IRx

Public Member Functions

 Rx ()
 
 ~Rx ()
 
virtual bool isReceptionInProgress () const override
 
virtual bool isMediumFree () const override
 
virtual void receptionStateChanged (IRadio::ReceptionState newReceptionState) override
 
virtual void transmissionStateChanged (IRadio::TransmissionState transmissionState) override
 
virtual void receivedSignalPartChanged (IRadioSignal::SignalPart part) override
 
virtual bool lowerFrameReceived (Ieee80211Frame *frame) override
 
virtual void frameTransmitted (simtime_t durationField) override
 
virtual void registerContention (IContention *contention) override
 
- Public Member Functions inherited from inet::ieee80211::IRx
virtual ~IRx ()
 

Protected Member Functions

virtual int numInitStages () const override
 
virtual void initialize (int stage) override
 
virtual void handleMessage (cMessage *msg) override
 
virtual void setOrExtendNav (simtime_t navInterval)
 
virtual bool isFcsOk (Ieee80211Frame *frame) const
 
virtual void recomputeMediumFree ()
 
virtual void refreshDisplay () const override
 

Protected Attributes

std::vector< IContention * > contentions
 
IStatisticsstatistics = nullptr
 
MACAddress address
 
cMessage * endNavTimer = nullptr
 
IRadio::ReceptionState receptionState = IRadio::RECEPTION_STATE_UNDEFINED
 
IRadio::TransmissionState transmissionState = IRadio::TRANSMISSION_STATE_UNDEFINED
 
IRadioSignal::SignalPart receivedPart = IRadioSignal::SIGNAL_PART_NONE
 
bool mediumFree = true
 

Detailed Description

The default implementation of IRx.

Constructor & Destructor Documentation

inet::ieee80211::Rx::Rx ( )
31 {
32 }
inet::ieee80211::Rx::~Rx ( )
35 {
36  cancelAndDelete(endNavTimer);
37 }
cMessage * endNavTimer
Definition: Rx.h:42

Member Function Documentation

void inet::ieee80211::Rx::frameTransmitted ( simtime_t  durationField)
overridevirtual

Implements inet::ieee80211::IRx.

89 {
90  Enter_Method_Silent();
91  // the txIndex that transmitted the frame should already own the TXOP, so
92  // it has no need to (and should not) check the NAV.
93  setOrExtendNav(durationField);
94 }
virtual void setOrExtendNav(simtime_t navInterval)
Definition: Rx.cc:139
void inet::ieee80211::Rx::handleMessage ( cMessage *  msg)
overrideprotectedvirtual
56 {
57  if (msg == endNavTimer) {
58  EV_INFO << "The radio channel has become free according to the NAV" << std::endl;
60  }
61  else
62  throw cRuntimeError("Unexpected self message");
63 }
cMessage * endNavTimer
Definition: Rx.h:42
virtual void recomputeMediumFree()
Definition: Rx.cc:107
void inet::ieee80211::Rx::initialize ( int  stage)
overrideprotectedvirtual
40 {
41  if (stage == INITSTAGE_LOCAL) {
42  endNavTimer = new cMessage("NAV");
43  WATCH(address);
44  WATCH(receptionState);
45  WATCH(transmissionState);
46  WATCH(mediumFree);
47  }
48  else if (stage == INITSTAGE_LINK_LAYER) {
49  // statistics = check_and_cast<IStatistics *>(getModuleByPath(par("statisticsModule")));
50  address = check_and_cast<Ieee80211Mac*>(getContainingNicModule(this)->getSubmodule("mac"))->getAddress();
52  }
53 }
cMessage * endNavTimer
Definition: Rx.h:42
Implements the IEEE 802.11 MAC.
Definition: Ieee80211Mac.h:47
IRadio::ReceptionState receptionState
Definition: Rx.h:43
virtual void recomputeMediumFree()
Definition: Rx.cc:107
Local initializations.
Definition: InitStages.h:35
Initialization of link-layer protocols.
Definition: InitStages.h:59
cModule * getContainingNicModule(cModule *from)
Find the nic module (inside the networkNode) containing the given module.
Definition: ModuleAccess.cc:96
IRadio::TransmissionState transmissionState
Definition: Rx.h:44
MACAddress address
Definition: Rx.h:41
bool mediumFree
Definition: Rx.h:46
bool inet::ieee80211::Rx::isFcsOk ( Ieee80211Frame frame) const
protectedvirtual

Referenced by lowerFrameReceived().

103 {
104  return !frame->hasBitError();
105 }
virtual bool inet::ieee80211::Rx::isMediumFree ( ) const
inlineoverridevirtual

Implements inet::ieee80211::IRx.

62 { return mediumFree; }
bool mediumFree
Definition: Rx.h:46
bool inet::ieee80211::Rx::isReceptionInProgress ( ) const
overridevirtual

Implements inet::ieee80211::IRx.

97 {
100 }
IRadioSignal::SignalPart receivedPart
Definition: Rx.h:45
The radio medium is busy, a signal strong enough to receive is detected.
Definition: IRadio.h:161
IRadio::ReceptionState receptionState
Definition: Rx.h:43
bool inet::ieee80211::Rx::lowerFrameReceived ( Ieee80211Frame frame)
overridevirtual

Implements inet::ieee80211::IRx.

66 {
67  Enter_Method("lowerFrameReceived(\"%s\")", frame->getName());
68  take(frame);
69 
70  bool isFrameOk = isFcsOk(frame);
71  if (isFrameOk) {
72  EV_INFO << "Received frame from PHY: " << frame << endl;
73  if (frame->getReceiverAddress() != address)
74  setOrExtendNav(frame->getDuration());
75 // statistics->frameReceived(frame);
76  return true;
77  }
78  else {
79  EV_INFO << "Received an erroneous frame from PHY, dropping it." << std::endl;
80  delete frame;
81  for (auto contention : contentions)
82  contention->corruptedFrameReceived();
83 // statistics->erroneousFrameReceived();
84  return false;
85  }
86 }
virtual MACAddress & getReceiverAddress()
std::vector< IContention * > contentions
Definition: Rx.h:38
virtual ::omnetpp::simtime_t getDuration() const
virtual void setOrExtendNav(simtime_t navInterval)
Definition: Rx.cc:139
virtual bool isFcsOk(Ieee80211Frame *frame) const
Definition: Rx.cc:102
MACAddress address
Definition: Rx.h:41
virtual int inet::ieee80211::Rx::numInitStages ( ) const
inlineoverrideprotectedvirtual
49 { return NUM_INIT_STAGES; }
The number of initialization stages.
Definition: InitStages.h:116
void inet::ieee80211::Rx::receivedSignalPartChanged ( IRadioSignal::SignalPart  part)
overridevirtual

Implements inet::ieee80211::IRx.

126 {
127  Enter_Method_Silent();
128  receivedPart = part;
130 }
IRadioSignal::SignalPart receivedPart
Definition: Rx.h:45
virtual void recomputeMediumFree()
Definition: Rx.cc:107
void inet::ieee80211::Rx::receptionStateChanged ( IRadio::ReceptionState  newReceptionState)
overridevirtual

Implements inet::ieee80211::IRx.

119 {
120  Enter_Method_Silent();
121  receptionState = state;
123 }
IRadio::ReceptionState receptionState
Definition: Rx.h:43
virtual void recomputeMediumFree()
Definition: Rx.cc:107
void inet::ieee80211::Rx::recomputeMediumFree ( )
protectedvirtual

Referenced by handleMessage(), initialize(), receivedSignalPartChanged(), receptionStateChanged(), setOrExtendNav(), and transmissionStateChanged().

108 {
109  bool oldMediumFree = mediumFree;
110  // note: the duration of mode switching (rx-to-tx or tx-to-rx) should also count as busy
112  if (mediumFree != oldMediumFree) {
113  for (auto contention : contentions)
114  contention->mediumStateChanged(mediumFree);
115  }
116 }
std::vector< IContention * > contentions
Definition: Rx.h:38
cMessage * endNavTimer
Definition: Rx.h:42
IRadio::ReceptionState receptionState
Definition: Rx.h:43
The radio medium is free, no signal is detected.
Definition: IRadio.h:148
IRadio::TransmissionState transmissionState
Definition: Rx.h:44
The transmission state is undefined or meaningless.
Definition: IRadio.h:172
bool mediumFree
Definition: Rx.h:46
void inet::ieee80211::Rx::refreshDisplay ( ) const
overrideprotectedvirtual
157 {
158  if (mediumFree)
159  getDisplayString().setTagArg("t", 0, "FREE");
160  else {
161  std::stringstream os;
162  os << "BUSY (";
163  bool addSpace = false;
165  switch (transmissionState) {
166  case IRadio::IRadio::TRANSMISSION_STATE_UNDEFINED: break; // cannot happen
167  case IRadio::IRadio::TRANSMISSION_STATE_IDLE: os << "Tx-Idle"; break;
168  case IRadio::IRadio::TRANSMISSION_STATE_TRANSMITTING: os << "Tx"; break;
169  }
170  addSpace = true;
171  }
172  else {
173  switch (receptionState) {
174  case IRadio::RECEPTION_STATE_UNDEFINED: os << "Switching"; break;
175  case IRadio::RECEPTION_STATE_IDLE: os << "Rx-Idle"; break; // cannot happen
176  case IRadio::RECEPTION_STATE_BUSY: os << "Noise"; break;
177  case IRadio::RECEPTION_STATE_RECEIVING: os << "Recv"; break;
178  }
179  addSpace = true;
180  }
181  if (endNavTimer->isScheduled()) {
182  os << (addSpace ? " " : "") << "NAV";
183  }
184  os << ")";
185  getDisplayString().setTagArg("t", 0, os.str().c_str());
186  }
187 }
The radio medium is busy, a signal strong enough to receive is detected.
Definition: IRadio.h:161
The radio medium state is unknown, reception state is meaningless, signal detection is not possible...
Definition: IRadio.h:142
cMessage * endNavTimer
Definition: Rx.h:42
The radio medium is busy, a signal is detected but it is not strong enough to receive.
Definition: IRadio.h:155
IRadio::ReceptionState receptionState
Definition: Rx.h:43
The radio medium is free, no signal is detected.
Definition: IRadio.h:148
IRadio::TransmissionState transmissionState
Definition: Rx.h:44
The transmission state is undefined or meaningless.
Definition: IRadio.h:172
bool mediumFree
Definition: Rx.h:46
void inet::ieee80211::Rx::registerContention ( IContention contention)
overridevirtual

Implements inet::ieee80211::IRx.

190 {
191  contention->mediumStateChanged(mediumFree);
192  contentions.push_back(contention);
193 }
virtual void mediumStateChanged(bool mediumFree)=0
std::vector< IContention * > contentions
Definition: Rx.h:38
bool mediumFree
Definition: Rx.h:46
void inet::ieee80211::Rx::setOrExtendNav ( simtime_t  navInterval)
protectedvirtual

Referenced by frameTransmitted(), and lowerFrameReceived().

140 {
141  ASSERT(navInterval >= 0);
142  if (navInterval > 0) {
143  simtime_t endNav = simTime() + navInterval;
144  if (endNavTimer->isScheduled()) {
145  simtime_t oldEndNav = endNavTimer->getArrivalTime();
146  if (endNav < oldEndNav)
147  return; // never decrease NAV
148  cancelEvent(endNavTimer);
149  }
150  EV_INFO << "Setting NAV to " << navInterval << std::endl;
151  scheduleAt(endNav, endNavTimer);
153  }
154 }
cMessage * endNavTimer
Definition: Rx.h:42
virtual void recomputeMediumFree()
Definition: Rx.cc:107
void inet::ieee80211::Rx::transmissionStateChanged ( IRadio::TransmissionState  transmissionState)
overridevirtual

Implements inet::ieee80211::IRx.

133 {
134  Enter_Method_Silent();
135  transmissionState = state;
137 }
virtual void recomputeMediumFree()
Definition: Rx.cc:107
IRadio::TransmissionState transmissionState
Definition: Rx.h:44

Member Data Documentation

MACAddress inet::ieee80211::Rx::address
protected

Referenced by initialize(), and lowerFrameReceived().

std::vector<IContention *> inet::ieee80211::Rx::contentions
protected
cMessage* inet::ieee80211::Rx::endNavTimer = nullptr
protected
bool inet::ieee80211::Rx::mediumFree = true
protected
IRadioSignal::SignalPart inet::ieee80211::Rx::receivedPart = IRadioSignal::SIGNAL_PART_NONE
protected
IStatistics* inet::ieee80211::Rx::statistics = nullptr
protected

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