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

Implements the IEEE 802.11 MAC. More...

#include <Ieee80211Mac.h>

Inheritance diagram for inet::ieee80211::Ieee80211Mac:
inet::MacProtocolBase inet::LayeredProtocolBase inet::OperationalBase inet::OperationalMixin< cSimpleModule > inet::ILifecycle

Public Member Functions

 Ieee80211Mac ()
 
virtual ~Ieee80211Mac ()
 
virtual FcsMode getFcsMode () const
 
virtual const MacAddressgetAddress () const
 
virtual void sendUp (cMessage *message) override
 
virtual void sendUpFrame (Packet *frame)
 
virtual void sendDownFrame (Packet *frame)
 
virtual void sendDownPendingRadioConfigMsg ()
 
virtual void processUpperFrame (Packet *packet, const Ptr< const Ieee80211DataOrMgmtHeader > &header)
 
virtual void processLowerFrame (Packet *packet, const Ptr< const Ieee80211MacHeader > &header)
 
- Public Member Functions inherited from inet::OperationalMixin< cSimpleModule >
virtual ~OperationalMixin ()
 }@ More...
 
- Public Member Functions inherited from inet::ILifecycle
virtual ~ILifecycle ()
 

Protected Member Functions

virtual int numInitStages () const override
 
virtual void initialize (int) override
 
virtual void initializeRadioMode ()
 
virtual void receiveSignal (cComponent *source, simsignal_t signalID, intval_t value, cObject *details) override
 
virtual void configureRadioMode (physicallayer::IRadio::RadioMode radioMode)
 
virtual void configureNetworkInterface () override
 
virtual const MacAddressisInterfaceRegistered ()
 
virtual void handleMessageWhenUp (cMessage *message) override
 
virtual void handleUpperCommand (cMessage *msg) override
 Handle commands (msg kind+control info) coming from upper layers. More...
 
virtual void handleSelfMessage (cMessage *msg) override
 Handle timer self messages. More...
 
virtual void handleMgmtPacket (Packet *packet)
 Handle packets from management. More...
 
virtual void handleUpperPacket (Packet *packet) override
 Handle messages from upper layer. More...
 
virtual void handleLowerPacket (Packet *packet) override
 Handle messages from lower (physical) layer. More...
 
virtual void handleStartOperation (LifecycleOperation *operation) override
 
virtual void handleStopOperation (LifecycleOperation *operation) override
 
virtual void handleCrashOperation (LifecycleOperation *operation) override
 
virtual void encapsulate (Packet *packet)
 
virtual void decapsulate (Packet *packet)
 
virtual void receiveSignal (cComponent *source, simsignal_t signalID, cObject *obj, cObject *details) override
 
- Protected Member Functions inherited from inet::MacProtocolBase
 MacProtocolBase ()
 
virtual ~MacProtocolBase ()
 
virtual void registerInterface ()
 
virtual MacAddress parseMacAddressParameter (const char *addrstr)
 
virtual void deleteCurrentTxFrame ()
 
virtual void dropCurrentTxFrame (PacketDropDetails &details)
 
virtual void handleMessageWhenDown (cMessage *msg) override
 
virtual void sendDown (cMessage *message)
 
virtual bool isUpperMessage (cMessage *message) const override
 
virtual bool isLowerMessage (cMessage *message) const override
 
virtual bool isInitializeStage (int stage) const override
 
virtual bool isModuleStartStage (int stage) const override
 
virtual bool isModuleStopStage (int stage) const override
 
virtual void flushQueue (PacketDropDetails &details)
 should clear queue and emit signal "packetDropped" with entire packets More...
 
virtual void clearQueue ()
 should clear queue silently More...
 
virtual void receiveSignal (cComponent *source, simsignal_t signalID, cObject *obj, cObject *details) override
 
queueing::IPacketQueuegetQueue (cGate *gate) const
 
virtual bool canDequeuePacket () const
 
virtual PacketdequeuePacket ()
 
- Protected Member Functions inherited from inet::LayeredProtocolBase
virtual void handleUpperMessage (cMessage *message)
 
virtual void handleLowerMessage (cMessage *message)
 
virtual void handleLowerCommand (cMessage *message)
 
- Protected Member Functions inherited from inet::OperationalMixin< cSimpleModule >
virtual int numInitStages () const override
 
virtual void refreshDisplay () const override
 
virtual void handleMessage (cMessage *msg) override
 
virtual bool handleOperationStage (LifecycleOperation *operation, IDoneCallback *doneCallback) override
 Perform one stage of a lifecycle operation. More...
 
virtual State getInitialOperationalState () const
 Returns initial operational state: OPERATING or NOT_OPERATING. More...
 
virtual void handleActiveOperationTimeout (cMessage *message)
 
virtual bool isUp () const
 utility functions More...
 
virtual bool isDown () const
 
virtual void setOperationalState (State newState)
 
virtual void scheduleOperationTimeout (simtime_t timeout)
 
virtual void setupActiveOperation (LifecycleOperation *operation, IDoneCallback *doneCallback, State)
 
virtual void delayActiveOperationFinish (simtime_t timeout)
 
virtual void startActiveOperationExtraTime (simtime_t delay=SIMTIME_ZERO)
 
virtual void startActiveOperationExtraTimeOrFinish (simtime_t extraTime)
 
virtual void finishActiveOperation ()
 

Protected Attributes

FcsMode fcsMode
 
ModuleRefByPar< Ieee80211Mibmib
 
opp_component_ptr< IIeee80211Llcllc
 
opp_component_ptr< IDsds
 
opp_component_ptr< IRxrx
 
opp_component_ptr< ITxtx
 
opp_component_ptr< physicallayer::IRadioradio
 
const physicallayer::Ieee80211ModeSetmodeSet = nullptr
 
physicallayer::IRadio::TransmissionState transmissionState = physicallayer::IRadio::TransmissionState::TRANSMISSION_STATE_UNDEFINED
 
opp_component_ptr< Dcfdcf
 
opp_component_ptr< Pcfpcf
 
opp_component_ptr< Hcfhcf
 
opp_component_ptr< Mcfmcf
 
cMessage * pendingRadioConfigMsg = nullptr
 
- Protected Attributes inherited from inet::MacProtocolBase
int upperLayerInGateId = -1
 Gate ids. More...
 
int upperLayerOutGateId = -1
 
int lowerLayerInGateId = -1
 
int lowerLayerOutGateId = -1
 
opp_component_ptr< NetworkInterfacenetworkInterface
 
opp_component_ptr< cModule > hostModule
 
PacketcurrentTxFrame = nullptr
 Currently transmitted frame if any. More...
 
opp_component_ptr< queueing::IPacketQueuetxQueue
 Messages received from upper layer and to be transmitted later. More...
 
- Protected Attributes inherited from inet::OperationalMixin< cSimpleModule >
State operationalState
 
simtime_t lastChange
 
Operation activeOperation
 
cMessage * activeOperationTimeout
 
cMessage * activeOperationExtraTimer
 

Additional Inherited Members

- Protected Types inherited from inet::OperationalMixin< cSimpleModule >
enum  State
 

Detailed Description

Implements the IEEE 802.11 MAC.

The features, standards compliance and exact operation of the MAC depend on the plugged-in components (see IUpperMac, IRx, ITx, IContention and other interface classes).

Constructor & Destructor Documentation

◆ Ieee80211Mac()

inet::ieee80211::Ieee80211Mac::Ieee80211Mac ( )
38 {
39 }

◆ ~Ieee80211Mac()

inet::ieee80211::Ieee80211Mac::~Ieee80211Mac ( )
virtual
42 {
44  delete pendingRadioConfigMsg;
45 }

Member Function Documentation

◆ configureNetworkInterface()

void inet::ieee80211::Ieee80211Mac::configureNetworkInterface ( )
overrideprotectedvirtual

Implements inet::MacProtocolBase.

114 {
115  // TODO the mib module should use the mac address from NetworkInterface
116  mib->address = networkInterface->getMacAddress();
117  networkInterface->setMtu(par("mtu"));
118  // capabilities
119  networkInterface->setBroadcast(true);
120  networkInterface->setMulticast(true);
121  networkInterface->setPointToPoint(false);
122 }

◆ configureRadioMode()

void inet::ieee80211::Ieee80211Mac::configureRadioMode ( physicallayer::IRadio::RadioMode  radioMode)
protectedvirtual
328 {
329  if (radio->getRadioMode() != radioMode) {
330  ConfigureRadioCommand *configureCommand = new ConfigureRadioCommand();
331  configureCommand->setRadioMode(radioMode);
332  auto request = new Request("configureRadioMode", RADIO_C_CONFIGURE);
333  request->setControlInfo(configureCommand);
334  sendDown(request);
335  }
336 }

◆ decapsulate()

void inet::ieee80211::Ieee80211Mac::decapsulate ( Packet packet)
protectedvirtual
268 {
269  const auto& header = packet->popAtFront<Ieee80211DataOrMgmtHeader>();
270  auto packetProtocolTag = packet->addTagIfAbsent<PacketProtocolTag>();
271  if (dynamicPtrCast<const Ieee80211DataHeader>(header))
272  packetProtocolTag->setProtocol(llc->getProtocol());
273  else if (dynamicPtrCast<const Ieee80211MgmtHeader>(header))
274  packetProtocolTag->setProtocol(&Protocol::ieee80211Mgmt);
275  auto macAddressInd = packet->addTagIfAbsent<MacAddressInd>();
276  if (mib->mode == Ieee80211Mib::INDEPENDENT) {
277  macAddressInd->setSrcAddress(header->getTransmitterAddress());
278  macAddressInd->setDestAddress(header->getReceiverAddress());
279  }
280  else if (mib->mode == Ieee80211Mib::INFRASTRUCTURE) {
281  if (mib->bssStationData.stationType == Ieee80211Mib::ACCESS_POINT) {
282  macAddressInd->setSrcAddress(header->getTransmitterAddress());
283  macAddressInd->setDestAddress(header->getAddress3());
284  }
285  else if (mib->bssStationData.stationType == Ieee80211Mib::STATION) {
286  macAddressInd->setSrcAddress(header->getAddress3());
287  macAddressInd->setDestAddress(header->getReceiverAddress());
288  }
289  else
290  throw cRuntimeError("Unknown station type");
291  }
292  else
293  throw cRuntimeError("Unknown mode");
294  if (header->getType() == ST_DATA_WITH_QOS) {
295  auto dataHeader = dynamicPtrCast<const Ieee80211DataHeader>(header);
296  int tid = dataHeader->getTid();
297  if (tid < 8)
298  packet->addTagIfAbsent<UserPriorityInd>()->setUserPriority(tid);
299  }
300  packet->addTagIfAbsent<InterfaceInd>()->setInterfaceId(networkInterface->getInterfaceId());
301  packet->popAtBack<Ieee80211MacTrailer>(B(4));
302 }

◆ encapsulate()

void inet::ieee80211::Ieee80211Mac::encapsulate ( Packet packet)
protectedvirtual
232 {
233  auto macAddressReq = packet->getTag<MacAddressReq>();
234  auto destAddress = macAddressReq->getDestAddress();
235  const auto& header = makeShared<Ieee80211DataHeader>();
236  header->setTransmitterAddress(mib->address);
237  if (mib->mode == Ieee80211Mib::INDEPENDENT)
238  header->setReceiverAddress(destAddress);
239  else if (mib->mode == Ieee80211Mib::INFRASTRUCTURE) {
240  if (mib->bssStationData.stationType == Ieee80211Mib::ACCESS_POINT) {
241  header->setFromDS(true);
242  header->setAddress3(mib->address);
243  header->setReceiverAddress(destAddress);
244  }
245  else if (mib->bssStationData.stationType == Ieee80211Mib::STATION) {
246  header->setToDS(true);
247  header->setReceiverAddress(mib->bssData.bssid);
248  header->setAddress3(destAddress);
249  }
250  else
251  throw cRuntimeError("Unknown station type");
252  }
253  else
254  throw cRuntimeError("Unknown mode");
255  if (auto userPriorityReq = packet->findTag<UserPriorityReq>()) {
256  // make it a QoS frame, and set TID
257  header->setType(ST_DATA_WITH_QOS);
258  header->addChunkLength(QOSCONTROL_PART_LENGTH);
259  header->setTid(userPriorityReq->getUserPriority());
260  }
261  packet->insertAtFront(header);
262  packet->insertAtBack(makeShared<Ieee80211MacTrailer>());
263  auto packetProtocolTag = packet->addTagIfAbsent<PacketProtocolTag>();
264  packetProtocolTag->setProtocol(&Protocol::ieee80211Mac);
265 }

◆ getAddress()

virtual const MacAddress& inet::ieee80211::Ieee80211Mac::getAddress ( ) const
inlinevirtual
101 { return mib->address; }

Referenced by inet::ieee80211::Tx::transmitFrame().

◆ getFcsMode()

virtual FcsMode inet::ieee80211::Ieee80211Mac::getFcsMode ( ) const
inlinevirtual
100 { return fcsMode; }

Referenced by inet::ieee80211::Tx::transmitFrame().

◆ handleCrashOperation()

void inet::ieee80211::Ieee80211Mac::handleCrashOperation ( LifecycleOperation operation)
overrideprotectedvirtual

Reimplemented from inet::MacProtocolBase.

413 {
414 }

◆ handleLowerPacket()

void inet::ieee80211::Ieee80211Mac::handleLowerPacket ( Packet packet)
overrideprotectedvirtual

Handle messages from lower (physical) layer.

Reimplemented from inet::LayeredProtocolBase.

183 {
184  if (rx->lowerFrameReceived(packet)) {
185  auto header = packet->peekAtFront<Ieee80211MacHeader>();
186  processLowerFrame(packet, header);
187  }
188  else { // corrupted frame received
189  if (mib->qos)
190  hcf->corruptedFrameReceived();
191  else
192  dcf->corruptedFrameReceived();
193  }
194 }

◆ handleMessageWhenUp()

void inet::ieee80211::Ieee80211Mac::handleMessageWhenUp ( cMessage *  message)
overrideprotectedvirtual

Reimplemented from inet::LayeredProtocolBase.

125 {
126  if (message->arrivedOn("mgmtIn")) {
127  if (!message->isPacket())
128  handleUpperCommand(message);
129  else
130  handleMgmtPacket(check_and_cast<Packet *>(message));
131  }
132  else
134 }

◆ handleMgmtPacket()

void inet::ieee80211::Ieee80211Mac::handleMgmtPacket ( Packet packet)
protectedvirtual

Handle packets from management.

142 {
143  const auto& header = makeShared<Ieee80211MgmtHeader>();
144  header->setType((Ieee80211FrameType)packet->getTag<Ieee80211SubtypeReq>()->getSubtype());
145  header->setReceiverAddress(packet->getTag<MacAddressReq>()->getDestAddress());
146  if (mib->mode == Ieee80211Mib::INFRASTRUCTURE && mib->bssStationData.stationType == Ieee80211Mib::ACCESS_POINT)
147  header->setAddress3(mib->bssData.bssid);
148  packet->insertAtFront(header);
149  packet->insertAtBack(makeShared<Ieee80211MacTrailer>());
150  processUpperFrame(packet, header);
151 }

◆ handleSelfMessage()

void inet::ieee80211::Ieee80211Mac::handleSelfMessage ( cMessage *  msg)
overrideprotectedvirtual

Handle timer self messages.

Reimplemented from inet::LayeredProtocolBase.

137 {
138  ASSERT(false);
139 }

◆ handleStartOperation()

void inet::ieee80211::Ieee80211Mac::handleStartOperation ( LifecycleOperation operation)
overrideprotectedvirtual

Reimplemented from inet::MacProtocolBase.

399 {
400  if (!operation)
401  return; // do nothing when called from initialize()
402 
404 }

◆ handleStopOperation()

void inet::ieee80211::Ieee80211Mac::handleStopOperation ( LifecycleOperation operation)
overrideprotectedvirtual

Reimplemented from inet::MacProtocolBase.

408 {
409 }

◆ handleUpperCommand()

void inet::ieee80211::Ieee80211Mac::handleUpperCommand ( cMessage *  msg)
overrideprotectedvirtual

Handle commands (msg kind+control info) coming from upper layers.

Reimplemented from inet::LayeredProtocolBase.

197 {
198  if (msg->getKind() == RADIO_C_CONFIGURE) {
199  EV_DEBUG << "Passing on command " << msg->getName() << " to physical layer\n";
200  if (pendingRadioConfigMsg != nullptr) {
201  // merge contents of the old command into the new one, then delete it
202  Ieee80211ConfigureRadioCommand *oldConfigureCommand = check_and_cast<Ieee80211ConfigureRadioCommand *>(pendingRadioConfigMsg->getControlInfo());
203  Ieee80211ConfigureRadioCommand *newConfigureCommand = check_and_cast<Ieee80211ConfigureRadioCommand *>(msg->getControlInfo());
204  if (newConfigureCommand->getChannelNumber() == -1 && oldConfigureCommand->getChannelNumber() != -1)
205  newConfigureCommand->setChannelNumber(oldConfigureCommand->getChannelNumber());
206  if (std::isnan(newConfigureCommand->getBitrate().get()) && !std::isnan(oldConfigureCommand->getBitrate().get()))
207  newConfigureCommand->setBitrate(oldConfigureCommand->getBitrate());
208  delete pendingRadioConfigMsg;
209  pendingRadioConfigMsg = nullptr;
210  }
211 
212  if (rx->isMediumFree()) { // TODO this should be just the physical channel sense!!!!
213  EV_DEBUG << "Sending it down immediately\n";
214 // PhyControlInfo *phyControlInfo = dynamic_cast<PhyControlInfo *>(msg->getControlInfo());
215 // if (phyControlInfo)
216 // phyControlInfo->setAdaptiveSensitivity(true);
217  // end dynamic power
218  sendDown(msg);
219  }
220  else {
221  // TODO waiting potentially indefinitely?! wtf?!
222  EV_DEBUG << "Delaying " << msg->getName() << " until next IDLE or DEFER state\n";
223  pendingRadioConfigMsg = msg;
224  }
225  }
226  else {
227  throw cRuntimeError("Unrecognized command from mgmt layer: (%s)%s msgkind=%d", msg->getClassName(), msg->getName(), msg->getKind());
228  }
229 }

◆ handleUpperPacket()

void inet::ieee80211::Ieee80211Mac::handleUpperPacket ( Packet packet)
overrideprotectedvirtual

Handle messages from upper layer.

Reimplemented from inet::LayeredProtocolBase.

154 {
155  if (mib->mode == Ieee80211Mib::INFRASTRUCTURE && mib->bssStationData.stationType == Ieee80211Mib::STATION && !mib->bssStationData.isAssociated) {
156  EV << "STA is not associated with an access point, discarding packet " << packet << "\n";
157  PacketDropDetails details;
158  details.setReason(OTHER_PACKET_DROP);
159  emit(packetDroppedSignal, packet, &details);
160  delete packet;
161  return;
162  }
163  encapsulate(packet);
164  const auto& header = packet->peekAtFront<Ieee80211DataOrMgmtHeader>();
165  if (mib->mode == Ieee80211Mib::INFRASTRUCTURE && mib->bssStationData.stationType == Ieee80211Mib::ACCESS_POINT) {
166  auto receiverAddress = header->getReceiverAddress();
167  if (!receiverAddress.isMulticast()) {
168  auto it = mib->bssAccessPointData.stations.find(receiverAddress);
169  if (it == mib->bssAccessPointData.stations.end() || it->second != Ieee80211Mib::ASSOCIATED) {
170  EV << "STA with MAC address " << receiverAddress << " not associated with this AP, dropping frame\n";
171  PacketDropDetails details;
172  details.setReason(OTHER_PACKET_DROP);
173  emit(packetDroppedSignal, packet, &details);
174  delete packet;
175  return;
176  }
177  }
178  }
179  processUpperFrame(packet, header);
180 }

◆ initialize()

void inet::ieee80211::Ieee80211Mac::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::MacProtocolBase.

48 {
50  if (stage == INITSTAGE_LOCAL) {
51  modeSet = Ieee80211ModeSet::getModeSet(par("modeSet"));
52  fcsMode = parseFcsMode(par("fcsMode"));
53  mib.reference(this, "mibModule", true);
54  mib->qos = par("qosStation");
55  }
56  else if (stage == INITSTAGE_LINK_LAYER) {
57  cModule *llcModule = gate("upperLayerOut")->getNextGate()->getOwnerModule();
58  llc = check_and_cast<IIeee80211Llc *>(llcModule);
59  cModule *radioModule = gate("lowerLayerOut")->getNextGate()->getOwnerModule();
60  radioModule->subscribe(IRadio::radioModeChangedSignal, this);
61  radioModule->subscribe(IRadio::receptionStateChangedSignal, this);
62  radioModule->subscribe(IRadio::transmissionStateChangedSignal, this);
63  radioModule->subscribe(IRadio::receivedSignalPartChangedSignal, this);
64  radio = check_and_cast<IRadio *>(radioModule);
65  ds = check_and_cast<IDs *>(getSubmodule("ds"));
66  rx = check_and_cast<IRx *>(getSubmodule("rx"));
67  tx = check_and_cast<ITx *>(getSubmodule("tx"));
69  if (isUp())
71  rx = check_and_cast<IRx *>(getSubmodule("rx"));
72  tx = check_and_cast<ITx *>(getSubmodule("tx"));
73  dcf = check_and_cast<Dcf *>(getSubmodule("dcf"));
74  hcf = check_and_cast_nullable<Hcf *>(getSubmodule("hcf"));
75  if (mib->qos && !hcf)
76  throw cRuntimeError("Missing hcf module, required for QoS");
77  }
78 }

◆ initializeRadioMode()

void inet::ieee80211::Ieee80211Mac::initializeRadioMode ( )
protectedvirtual
80  {
81  const char *initialRadioMode = par("initialRadioMode");
82  if (!strcmp(initialRadioMode, "off"))
83  radio->setRadioMode(IRadio::RADIO_MODE_OFF);
84  else if (!strcmp(initialRadioMode, "sleep"))
85  radio->setRadioMode(IRadio::RADIO_MODE_SLEEP);
86  else if (!strcmp(initialRadioMode, "receiver"))
87  radio->setRadioMode(IRadio::RADIO_MODE_RECEIVER);
88  else if (!strcmp(initialRadioMode, "transmitter"))
90  else if (!strcmp(initialRadioMode, "transceiver"))
92  else
93  throw cRuntimeError("Unknown initialRadioMode");
94 }

◆ isInterfaceRegistered()

const MacAddress & inet::ieee80211::Ieee80211Mac::isInterfaceRegistered ( )
protectedvirtual
97 {
98 // if (!par("multiMac"))
99 // return MacAddress::UNSPECIFIED_ADDRESS;
100  IInterfaceTable *ift = findModuleFromPar<IInterfaceTable>(par("interfaceTableModule"), this);
101  if (!ift)
103  cModule *interfaceModule = findModuleUnderContainingNode(this);
104  if (!interfaceModule)
105  throw cRuntimeError("NIC module not found in the host");
106  std::string interfaceName = utils::stripnonalnum(interfaceModule->getFullName());
107  NetworkInterface *e = ift->findInterfaceByName(interfaceName.c_str());
108  if (e)
109  return e->getMacAddress();
111 }

◆ numInitStages()

virtual int inet::ieee80211::Ieee80211Mac::numInitStages ( ) const
inlineoverrideprotectedvirtual
62 { return NUM_INIT_STAGES; }

◆ processLowerFrame()

void inet::ieee80211::Ieee80211Mac::processLowerFrame ( Packet packet,
const Ptr< const Ieee80211MacHeader > &  header 
)
virtual
387 {
388  Enter_Method("processLowerFrame(\"%s\")", packet->getName());
389  take(packet);
390  if (mib->qos)
391  hcf->processLowerFrame(packet, header);
392  else
393  // TODO what if the received frame is ST_DATA_WITH_QOS? drop?
394  dcf->processLowerFrame(packet, header);
395 }

◆ processUpperFrame()

void inet::ieee80211::Ieee80211Mac::processUpperFrame ( Packet packet,
const Ptr< const Ieee80211DataOrMgmtHeader > &  header 
)
virtual
375 {
376  Enter_Method("processUpperFrame(\"%s\")", packet->getName());
377  take(packet);
378  EV_INFO << "Frame " << packet << " received from higher layer, receiver = " << header->getReceiverAddress() << "\n";
379  ASSERT(!header->getReceiverAddress().isUnspecified());
380  if (mib->qos)
381  hcf->processUpperFrame(packet, header);
382  else
383  dcf->processUpperFrame(packet, header);
384 }

Referenced by inet::ieee80211::Ds::distributeDataFrame().

◆ receiveSignal() [1/2]

void inet::MacProtocolBase::receiveSignal
overrideprotected
152 {
153  Enter_Method("%s", cComponent::getSignalName(signalID));
154 }

◆ receiveSignal() [2/2]

void inet::ieee80211::Ieee80211Mac::receiveSignal ( cComponent *  source,
simsignal_t  signalID,
intval_t  value,
cObject *  details 
)
overrideprotectedvirtual
305 {
306  Enter_Method("%s", cComponent::getSignalName(signalID));
307 
308  if (signalID == IRadio::receptionStateChangedSignal) {
309  rx->receptionStateChanged(static_cast<IRadio::ReceptionState>(value));
310  }
311  else if (signalID == IRadio::transmissionStateChangedSignal) {
312  auto oldTransmissionState = transmissionState;
313  transmissionState = static_cast<IRadio::TransmissionState>(value);
314  bool transmissionFinished = (oldTransmissionState == IRadio::TRANSMISSION_STATE_TRANSMITTING && transmissionState == IRadio::TRANSMISSION_STATE_IDLE);
315  if (transmissionFinished) {
316  tx->radioTransmissionFinished();
317  EV_DEBUG << "changing radio to receiver mode\n";
318  configureRadioMode(IRadio::RADIO_MODE_RECEIVER); // FIXME this is in a very wrong place!!! should be done explicitly from coordination function!
319  }
320  rx->transmissionStateChanged(transmissionState);
321  }
322  else if (signalID == IRadio::receivedSignalPartChangedSignal) {
323  rx->receivedSignalPartChanged(static_cast<IRadioSignal::SignalPart>(value));
324  }
325 }

◆ sendDownFrame()

void inet::ieee80211::Ieee80211Mac::sendDownFrame ( Packet frame)
virtual
358 {
359  Enter_Method("sendDownFrame(\"%s\")", frame->getName());
360  take(frame);
362  frame->addTagIfAbsent<PacketProtocolTag>()->setProtocol(&Protocol::ieee80211Mac);
363  sendDown(frame);
364 }

Referenced by inet::ieee80211::Tx::handleMessage(), and inet::ieee80211::Tx::transmitFrame().

◆ sendDownPendingRadioConfigMsg()

void inet::ieee80211::Ieee80211Mac::sendDownPendingRadioConfigMsg ( )
virtual
367 {
368  if (pendingRadioConfigMsg != nullptr) {
370  pendingRadioConfigMsg = nullptr;
371  }
372 }

Referenced by inet::ieee80211::Contention::handleWithFSM().

◆ sendUp()

void inet::ieee80211::Ieee80211Mac::sendUp ( cMessage *  message)
overridevirtual

Reimplemented from inet::MacProtocolBase.

339 {
340  Enter_Method("sendUp(\"%s\")", msg->getName());
341  take(msg);
343 }

Referenced by inet::ieee80211::Ds::processDataFrame().

◆ sendUpFrame()

void inet::ieee80211::Ieee80211Mac::sendUpFrame ( Packet frame)
virtual
346 {
347  Enter_Method("sendUpFrame(\"%s\")", frame->getName());
348  take(frame);
349  const auto& header = frame->peekAtFront<Ieee80211DataOrMgmtHeader>();
350  decapsulate(frame);
351  if (!(header->getType() & 0x30))
352  send(frame, "mgmtOut");
353  else
354  ds->processDataFrame(frame, dynamicPtrCast<const Ieee80211DataHeader>(header));
355 }

Member Data Documentation

◆ dcf

opp_component_ptr<Dcf> inet::ieee80211::Ieee80211Mac::dcf
protected

◆ ds

opp_component_ptr<IDs> inet::ieee80211::Ieee80211Mac::ds
protected

◆ fcsMode

FcsMode inet::ieee80211::Ieee80211Mac::fcsMode
protected

◆ hcf

opp_component_ptr<Hcf> inet::ieee80211::Ieee80211Mac::hcf
protected

◆ llc

opp_component_ptr<IIeee80211Llc> inet::ieee80211::Ieee80211Mac::llc
protected

◆ mcf

opp_component_ptr<Mcf> inet::ieee80211::Ieee80211Mac::mcf
protected

◆ mib

ModuleRefByPar<Ieee80211Mib> inet::ieee80211::Ieee80211Mac::mib
protected

◆ modeSet

const physicallayer::Ieee80211ModeSet* inet::ieee80211::Ieee80211Mac::modeSet = nullptr
protected

◆ pcf

opp_component_ptr<Pcf> inet::ieee80211::Ieee80211Mac::pcf
protected

◆ pendingRadioConfigMsg

cMessage* inet::ieee80211::Ieee80211Mac::pendingRadioConfigMsg = nullptr
protected

◆ radio

opp_component_ptr<physicallayer::IRadio> inet::ieee80211::Ieee80211Mac::radio
protected

◆ rx

opp_component_ptr<IRx> inet::ieee80211::Ieee80211Mac::rx
protected

◆ transmissionState

physicallayer::IRadio::TransmissionState inet::ieee80211::Ieee80211Mac::transmissionState = physicallayer::IRadio::TransmissionState::TRANSMISSION_STATE_UNDEFINED
protected

◆ tx

opp_component_ptr<ITx> inet::ieee80211::Ieee80211Mac::tx
protected

The documentation for this class was generated from the following files:
inet::MacProtocolBase::networkInterface
opp_component_ptr< NetworkInterface > networkInterface
Definition: MacProtocolBase.h:30
inet::ieee80211::Ieee80211Mac::pendingRadioConfigMsg
cMessage * pendingRadioConfigMsg
Definition: Ieee80211Mac.h:59
inet::ieee80211::Ieee80211Mac::initializeRadioMode
virtual void initializeRadioMode()
Definition: Ieee80211Mac.cc:80
inet::LayeredProtocolBase::handleMessageWhenUp
virtual void handleMessageWhenUp(cMessage *message) override
Definition: LayeredProtocolBase.cc:14
inet::ieee80211::Ieee80211Mib::INDEPENDENT
@ INDEPENDENT
Definition: Ieee80211Mib.h:22
inet::OperationalMixin< cSimpleModule >::isUp
virtual bool isUp() const
utility functions
Definition: OperationalMixin.h:66
inet::physicallayer::IRadio::RADIO_MODE_TRANSCEIVER
@ RADIO_MODE_TRANSCEIVER
The radio is prepared for simultaneous frame reception and transmission, power consumption is low whe...
Definition: IRadio.h:111
inet::MacProtocolBase::sendUp
virtual void sendUp(cMessage *message)
Definition: MacProtocolBase.cc:59
inet::ieee80211::Ieee80211Mac::encapsulate
virtual void encapsulate(Packet *packet)
Definition: Ieee80211Mac.cc:231
inet::physicallayer::ConfigureRadioCommand::getBitrate
virtual ::inet::bps getBitrate() const
inet::Protocol::ieee80211Mgmt
static const Protocol ieee80211Mgmt
Definition: Protocol.h:80
inet::findModuleUnderContainingNode
cModule * findModuleUnderContainingNode(const cModule *from)
Find the ancestor module under the node containing the given module.
Definition: ModuleAccess.cc:48
inet::physicallayer::IRadio::RADIO_MODE_OFF
@ RADIO_MODE_OFF
The radio is turned off, frame reception or transmission is not possible, power consumption is zero,...
Definition: IRadio.h:84
inet::ieee80211::Ieee80211Mac::llc
opp_component_ptr< IIeee80211Llc > llc
Definition: Ieee80211Mac.h:44
inet::ieee80211::Ieee80211Mib::INFRASTRUCTURE
@ INFRASTRUCTURE
Definition: Ieee80211Mib.h:21
inet::physicallayer::IRadio::RADIO_MODE_SLEEP
@ RADIO_MODE_SLEEP
The radio is sleeping, frame reception or transmission is not possible, power consumption is minimal,...
Definition: IRadio.h:90
inet::ieee80211::Ieee80211Mac::transmissionState
physicallayer::IRadio::TransmissionState transmissionState
Definition: Ieee80211Mac.h:51
inet::units::constants::e
const value< double, units::C > e(1.602176487e-19)
inet::ieee80211::Ieee80211Mib::STATION
@ STATION
Definition: Ieee80211Mib.h:28
inet::ieee80211::Ieee80211Mac::handleUpperCommand
virtual void handleUpperCommand(cMessage *msg) override
Handle commands (msg kind+control info) coming from upper layers.
Definition: Ieee80211Mac.cc:196
inet::physicallayer::IRadio::transmissionStateChangedSignal
static simsignal_t transmissionStateChangedSignal
This signal is emitted when the radio transmission state of the radio is changed.
Definition: IRadio.h:60
inet::modesetChangedSignal
simsignal_t modesetChangedSignal
Definition: Simsignals.cc:24
inet::physicallayer::IRadio::RADIO_MODE_TRANSMITTER
@ RADIO_MODE_TRANSMITTER
The radio is prepared for frame transmission, frame reception is not possible, power consumption is l...
Definition: IRadio.h:104
inet::packetDroppedSignal
simsignal_t packetDroppedSignal
Definition: Simsignals.cc:85
inet::physicallayer::IRadio::ReceptionState
ReceptionState
This enumeration specifies the reception state of the radio.
Definition: IRadio.h:124
PacketProtocolTag
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down PacketProtocolTag
Definition: IUdp-gates.txt:25
inet::ieee80211::Ieee80211Mac::processLowerFrame
virtual void processLowerFrame(Packet *packet, const Ptr< const Ieee80211MacHeader > &header)
Definition: Ieee80211Mac.cc:386
inet::physicallayer::IRadio::receivedSignalPartChangedSignal
static simsignal_t receivedSignalPartChangedSignal
This signal is emitted when the received part is changed by the radio.
Definition: IRadio.h:66
inet::ieee80211::Ieee80211Mac::tx
opp_component_ptr< ITx > tx
Definition: Ieee80211Mac.h:48
inet::physicallayer::Ieee80211ConfigureRadioCommand
Class generated from inet/physicallayer/wireless/ieee80211/packetlevel/Ieee80211ControlInfo....
Definition: Ieee80211ControlInfo_m.h:70
inet::ieee80211::Ieee80211Mac::processUpperFrame
virtual void processUpperFrame(Packet *packet, const Ptr< const Ieee80211DataOrMgmtHeader > &header)
Definition: Ieee80211Mac.cc:374
inet::units::units::B
intscale< b, 1, 8 > B
Definition: Units.h:1168
inet::physicallayer::IRadio::RADIO_MODE_RECEIVER
@ RADIO_MODE_RECEIVER
The radio is prepared for frame reception, frame transmission is not possible, power consumption is l...
Definition: IRadio.h:97
inet::physicallayer::Ieee80211ConfigureRadioCommand::setChannelNumber
virtual void setChannelNumber(int channelNumber)
inet::utils::stripnonalnum
std::string stripnonalnum(const char *s)
Removes non-alphanumeric characters from the given string.
Definition: INETUtils.cc:98
inet::ieee80211::Ieee80211Mac::configureRadioMode
virtual void configureRadioMode(physicallayer::IRadio::RadioMode radioMode)
Definition: Ieee80211Mac.cc:327
inet::MacProtocolBase::sendDown
virtual void sendDown(cMessage *message)
Definition: MacProtocolBase.cc:66
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
inet::physicallayer::IRadio::TRANSMISSION_STATE_TRANSMITTING
@ TRANSMISSION_STATE_TRANSMITTING
The radio medium is busy, the radio is currently transmitting a signal.
Definition: IRadio.h:171
inet::ieee80211::Ieee80211Mac::decapsulate
virtual void decapsulate(Packet *packet)
Definition: Ieee80211Mac.cc:267
inet::physicallayer::IRadioSignal::SignalPart
SignalPart
This enumeration specifies a part of a radio signal.
Definition: IRadioSignal.h:24
inet::OTHER_PACKET_DROP
@ OTHER_PACKET_DROP
Definition: Simsignals_m.h:84
NUM_INIT_STAGES
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
inet::ieee80211::Ieee80211Mac::ds
opp_component_ptr< IDs > ds
Definition: Ieee80211Mac.h:45
inet::ieee80211::ST_DATA_WITH_QOS
@ ST_DATA_WITH_QOS
Definition: Ieee80211Frame_m.h:169
inet::MacProtocolBase::initialize
virtual void initialize(int stage) override
Definition: MacProtocolBase.cc:37
inet::physicallayer::RADIO_C_CONFIGURE
@ RADIO_C_CONFIGURE
Definition: RadioControlInfo_m.h:62
inet::ieee80211::Ieee80211Mac::handleMgmtPacket
virtual void handleMgmtPacket(Packet *packet)
Handle packets from management.
Definition: Ieee80211Mac.cc:141
inet::ieee80211::Ieee80211Mac::mib
ModuleRefByPar< Ieee80211Mib > mib
Definition: Ieee80211Mac.h:43
inet::ieee80211::Ieee80211Mac::radio
opp_component_ptr< physicallayer::IRadio > radio
Definition: Ieee80211Mac.h:49
inet::physicallayer::ConfigureRadioCommand
Class generated from inet/physicallayer/wireless/common/contract/packetlevel/RadioControlInfo....
Definition: RadioControlInfo_m.h:85
inet::ieee80211::Ieee80211Mac::hcf
opp_component_ptr< Hcf > hcf
Definition: Ieee80211Mac.h:55
Enter_Method
#define Enter_Method(...)
Definition: SelfDoc.h:71
inet::ieee80211::Ieee80211Mac::dcf
opp_component_ptr< Dcf > dcf
Definition: Ieee80211Mac.h:53
inet::physicallayer::IRadio::TransmissionState
TransmissionState
This enumeration specifies the transmission state of the radio.
Definition: IRadio.h:155
inet::units::value::get
const value_type & get() const
Definition: Units.h:108
inet::ieee80211::QOSCONTROL_PART_LENGTH
const b QOSCONTROL_PART_LENGTH
Definition: Ieee80211Frame_m.h:101
inet::ieee80211::Ieee80211Mac::rx
opp_component_ptr< IRx > rx
Definition: Ieee80211Mac.h:47
inet::parseFcsMode
FcsMode parseFcsMode(const char *fcsModeString)
Definition: FcsMode.cc:14
inet::physicallayer::Ieee80211ConfigureRadioCommand::getChannelNumber
virtual int getChannelNumber() const
inet::Protocol::ieee80211Mac
static const Protocol ieee80211Mac
Definition: Protocol.h:79
inet::MacAddress::UNSPECIFIED_ADDRESS
static const MacAddress UNSPECIFIED_ADDRESS
The unspecified MAC address, 00:00:00:00:00:00.
Definition: MacAddress.h:31
inet::physicallayer::Ieee80211ModeSet::getModeSet
static const Ieee80211ModeSet * getModeSet(const char *mode)
Definition: Ieee80211ModeSet.cc:611
inet::ieee80211::Ieee80211Mib::ACCESS_POINT
@ ACCESS_POINT
Definition: Ieee80211Mib.h:27
inet::physicallayer::IRadio::TRANSMISSION_STATE_IDLE
@ TRANSMISSION_STATE_IDLE
The radio is not transmitting a signal on the radio medium.
Definition: IRadio.h:166
inet::ieee80211::Ieee80211Mac::fcsMode
FcsMode fcsMode
Definition: Ieee80211Mac.h:41
inet::ieee80211::Ieee80211Mib::ASSOCIATED
@ ASSOCIATED
Definition: Ieee80211Mib.h:34
inet::ieee80211::Ieee80211Mac::modeSet
const physicallayer::Ieee80211ModeSet * modeSet
Definition: Ieee80211Mac.h:50
inet::ieee80211::Ieee80211FrameType
Ieee80211FrameType
Enum generated from inet/linklayer/ieee80211/mac/Ieee80211Frame.msg:56 by opp_msgtool.
Definition: Ieee80211Frame_m.h:148
inet::physicallayer::ConfigureRadioCommand::setRadioMode
virtual void setRadioMode(int radioMode)
inet::INITSTAGE_LINK_LAYER
INET_API InitStage INITSTAGE_LINK_LAYER
Initialization of link-layer protocols.
inet::physicallayer::IRadio::receptionStateChangedSignal
static simsignal_t receptionStateChangedSignal
This signal is emitted when the radio reception state of the radio is changed.
Definition: IRadio.h:54
inet::physicallayer::ConfigureRadioCommand::setBitrate
virtual void setBitrate(::inet::bps bitrate)
inet::physicallayer::IRadio::radioModeChangedSignal
static simsignal_t radioModeChangedSignal
This signal is emitted when the radio mode of the radio is changed.
Definition: IRadio.h:42