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

#include <Ieee80211Radio.h>

Inheritance diagram for inet::physicallayer::Ieee80211Radio:
inet::physicallayer::FlatRadioBase inet::physicallayer::NarrowbandRadioBase inet::physicallayer::Radio inet::physicallayer::PhysicalLayerBase inet::physicallayer::IRadio inet::LayeredProtocolBase inet::IPhysicalLayer inet::IPhysicalLayer inet::IPrintableObject inet::OperationalBase inet::OperationalMixin< cSimpleModule > inet::ILifecycle

Public Member Functions

 Ieee80211Radio ()
 
virtual void setModeSet (const Ieee80211ModeSet *modeSet)
 
virtual void setMode (const IIeee80211Mode *mode)
 
virtual void setBand (const IIeee80211Band *band)
 
virtual void setChannel (const Ieee80211Channel *channel)
 
virtual void setChannelNumber (int newChannelNumber)
 
- Public Member Functions inherited from inet::physicallayer::FlatRadioBase
 FlatRadioBase ()
 
virtual void setPower (W newPower)
 
virtual void setBitrate (bps newBitrate)
 
- Public Member Functions inherited from inet::physicallayer::NarrowbandRadioBase
 NarrowbandRadioBase ()
 
virtual void setModulation (const IModulation *newModulation)
 
virtual void setCenterFrequency (Hz newCenterFrequency)
 
virtual void setBandwidth (Hz newBandwidth)
 
- Public Member Functions inherited from inet::physicallayer::Radio
 Radio ()
 
virtual ~Radio ()
 
virtual int getId () const override
 Returns an identifier for this radio which is globally unique for the whole lifetime of the simulation among all radios. More...
 
virtual std::ostream & printToStream (std::ostream &stream, int level, int evFlags=0) const override
 Prints this object to the provided output stream. More...
 
virtual const IAntennagetAntenna () const override
 Returns the antenna used by the transceiver of this radio. More...
 
virtual const ITransmittergetTransmitter () const override
 Returns the transmitter part of this radio. More...
 
virtual const IReceivergetReceiver () const override
 Returns the receiver part of this radio. More...
 
virtual const IRadioMediumgetMedium () const override
 Returns the radio medium where this radio is transmitting and receiving radio signals. More...
 
virtual const cGate * getRadioGate () const override
 Returns the gate of the radio that receives incoming signals. More...
 
virtual RadioMode getRadioMode () const override
 Returns the current radio mode, This is the same mode as the one emitted with the last radioModeChangedSignal. More...
 
virtual void setRadioMode (RadioMode newRadioMode) override
 Changes the current radio mode. More...
 
virtual ReceptionState getReceptionState () const override
 Returns the current radio reception state. More...
 
virtual TransmissionState getTransmissionState () const override
 Returns the current radio transmission state. More...
 
virtual const ITransmissiongetTransmissionInProgress () const override
 Returns the ongoing transmission that the transmitter is currently transmitting or nullptr. More...
 
virtual const ITransmissiongetReceptionInProgress () const override
 Returns the ongoing reception that the receiver is currently receiving or nullptr. More...
 
virtual IRadioSignal::SignalPart getTransmittedSignalPart () const override
 Returns the signal part of the ongoing transmission that the transmitter is currently transmitting or -1 if no transmission is in progress. More...
 
virtual IRadioSignal::SignalPart getReceivedSignalPart () const override
 Returns the signal part of the ongoing reception that the receiver is currently receiving or -1 if no reception is in progress. More...
 
- Public Member Functions inherited from inet::OperationalMixin< cSimpleModule >
virtual ~OperationalMixin ()
 }@ More...
 
- Public Member Functions inherited from inet::ILifecycle
virtual ~ILifecycle ()
 
- Public Member Functions inherited from inet::IPhysicalLayer
virtual ~IPhysicalLayer ()
 
- 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 Ptr< const Ieee80211PhyHeaderpopIeee80211PhyHeaderAtFront (Packet *packet, b length=b(-1), int flags=0)
 
static const Ptr< const Ieee80211PhyHeaderpeekIeee80211PhyHeaderAtFront (const Packet *packet, b length=b(-1), int flags=0)
 
- Static Public Member Functions inherited from inet::physicallayer::IRadio
static const char * getRadioModeName (RadioMode radioMode)
 Returns the name of the provided radio mode. More...
 
static const char * getRadioReceptionStateName (ReceptionState receptionState)
 Returns the name of the provided radio reception state. More...
 
static const char * getRadioTransmissionStateName (TransmissionState transmissionState)
 Returns the name of the provided radio transmission state. More...
 

Static Public Attributes

static simsignal_t radioChannelChangedSignal = cComponent::registerSignal("radioChannelChanged")
 This signal is emitted every time the radio channel changes. More...
 
- Static Public Attributes inherited from inet::physicallayer::IRadio
static simsignal_t radioModeChangedSignal = cComponent::registerSignal("radioModeChanged")
 This signal is emitted when the radio mode of the radio is changed. More...
 
static simsignal_t listeningChangedSignal = cComponent::registerSignal("listeningChanged")
 This signal is emitted when the radio listening of the radio is changed. More...
 
static simsignal_t receptionStateChangedSignal = cComponent::registerSignal("receptionStateChanged")
 This signal is emitted when the radio reception state of the radio is changed. More...
 
static simsignal_t transmissionStateChangedSignal = cComponent::registerSignal("transmissionStateChanged")
 This signal is emitted when the radio transmission state of the radio is changed. More...
 
static simsignal_t receivedSignalPartChangedSignal = cComponent::registerSignal("receivedSignalPartChanged")
 This signal is emitted when the received part is changed by the radio. More...
 
static simsignal_t transmittedSignalPartChangedSignal = cComponent::registerSignal("transmittedSignalPartChanged")
 This signal is emitted when the transmitted part is changed by the radio. More...
 

Protected Member Functions

virtual void initialize (int stage) override
 
virtual void handleUpperCommand (cMessage *message) override
 
virtual void insertCrc (const Ptr< Ieee80211PhyHeader > &phyHeader) const
 
virtual bool verifyCrc (const Ptr< const Ieee80211PhyHeader > &phyHeader) const
 
virtual void encapsulate (Packet *packet) const override
 
virtual void decapsulate (Packet *packet) const override
 
- Protected Member Functions inherited from inet::physicallayer::Radio
virtual void initializeRadioMode ()
 
virtual void handleMessageWhenDown (cMessage *message) override
 
virtual void handleSelfMessage (cMessage *message) override
 
virtual void handleSwitchTimer (cMessage *message)
 
virtual void handleTransmissionTimer (cMessage *message)
 
virtual void handleReceptionTimer (cMessage *message)
 
virtual void handleLowerCommand (cMessage *command) override
 
virtual void handleUpperPacket (Packet *packet) override
 
virtual void handleSignal (WirelessSignal *signal) override
 
virtual void handleStartOperation (LifecycleOperation *operation) override
 
virtual void handleStopOperation (LifecycleOperation *operation) override
 
virtual void handleCrashOperation (LifecycleOperation *operation) override
 
virtual void startTransmission (Packet *macFrame, IRadioSignal::SignalPart part)
 
virtual void continueTransmission ()
 
virtual void endTransmission ()
 
virtual void abortTransmission ()
 
virtual WirelessSignalcreateSignal (Packet *packet) const
 
virtual void startReception (cMessage *timer, IRadioSignal::SignalPart part)
 
virtual void continueReception (cMessage *timer)
 
virtual void endReception (cMessage *timer)
 
virtual void abortReception (cMessage *timer)
 
virtual void captureReception (cMessage *timer)
 
virtual void sendUp (Packet *macFrame)
 
virtual cMessage * createReceptionTimer (WirelessSignal *signal) const
 
virtual bool isReceptionTimer (const cMessage *message) const
 
virtual bool isReceiverMode (IRadio::RadioMode radioMode) const
 
virtual bool isTransmitterMode (IRadio::RadioMode radioMode) const
 
virtual bool isListeningPossible () const
 
virtual void updateTransceiverState ()
 
virtual void updateTransceiverPart ()
 
- Protected Member Functions inherited from inet::physicallayer::PhysicalLayerBase
virtual void handleLowerMessage (cMessage *message) override
 
virtual void sendUp (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
 
- Protected Member Functions inherited from inet::LayeredProtocolBase
virtual void handleMessageWhenUp (cMessage *message) override
 
virtual void handleUpperMessage (cMessage *message)
 
virtual void handleLowerPacket (Packet *packet)
 
- 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

CrcMode crcMode = CRC_MODE_UNDEFINED
 
- Protected Attributes inherited from inet::physicallayer::Radio
const int id = nextId++
 An identifier which is globally unique for the whole lifetime of the simulation among all radios. More...
 
const IAntennaantenna = nullptr
 The radio antenna model is never nullptr. More...
 
const ITransmittertransmitter = nullptr
 The transmitter model is never nullptr. More...
 
const IReceiverreceiver = nullptr
 The receiver model is never nullptr. More...
 
ModuleRefByPar< IRadioMediummedium
 The radio medium model is never nullptr. More...
 
int mediumModuleId = -1
 The module id of the medim model. More...
 
simtime_t switchingTimes [RADIO_MODE_SWITCHING][RADIO_MODE_SWITCHING]
 Simulation time required to switch from one radio mode to another. More...
 
bool sendRawBytes = false
 When true packets are serialized into a sequence of bytes before sending out. More...
 
bool separateTransmissionParts = false
 Determines whether the transmission of the preamble, header and data part are simulated separately or not. More...
 
bool separateReceptionParts = false
 Determines whether the reception of the preamble, header and data part are simulated separately or not. More...
 
cGate * upperLayerOut = nullptr
 Gates. More...
 
cGate * upperLayerIn = nullptr
 
cGate * radioIn = nullptr
 
RadioMode radioMode = RADIO_MODE_OFF
 State. More...
 
RadioMode nextRadioMode = RADIO_MODE_OFF
 The radio is switching to this radio radio mode if a switch is in progress, otherwise this is the same as the current radio mode. More...
 
RadioMode previousRadioMode = RADIO_MODE_OFF
 The radio is switching from this radio mode to another if a switch is in progress, otherwise this is the same as the current radio mode. More...
 
ReceptionState receptionState = RECEPTION_STATE_UNDEFINED
 The current reception state. More...
 
TransmissionState transmissionState = TRANSMISSION_STATE_UNDEFINED
 The current transmission state. More...
 
IRadioSignal::SignalPart receivedSignalPart = IRadioSignal::SIGNAL_PART_NONE
 The current received signal part. More...
 
IRadioSignal::SignalPart transmittedSignalPart = IRadioSignal::SIGNAL_PART_NONE
 The current transmitted signal part. More...
 
cMessage * transmissionTimer = nullptr
 The timer that is scheduled to the end of the current transmission. More...
 
cMessage * receptionTimer = nullptr
 The timer that is scheduled to the end of the current reception. More...
 
cMessage * switchTimer = nullptr
 The timer that is scheduled to the end of the radio mode switch. More...
 
- Protected Attributes inherited from inet::physicallayer::PhysicalLayerBase
int upperLayerInGateId = -1
 
int upperLayerOutGateId = -1
 
int radioInGateId = -1
 
- Protected Attributes inherited from inet::OperationalMixin< cSimpleModule >
State operationalState
 
simtime_t lastChange
 
Operation activeOperation
 
cMessage * activeOperationTimeout
 
cMessage * activeOperationExtraTimer
 

Additional Inherited Members

- Public Types inherited from inet::physicallayer::IRadio
enum  RadioMode {
  RADIO_MODE_OFF, RADIO_MODE_SLEEP, RADIO_MODE_RECEIVER, RADIO_MODE_TRANSMITTER,
  RADIO_MODE_TRANSCEIVER, RADIO_MODE_SWITCHING
}
 This enumeration specifies the requested operational mode of the radio. More...
 
enum  ReceptionState { RECEPTION_STATE_UNDEFINED, RECEPTION_STATE_IDLE, RECEPTION_STATE_BUSY, RECEPTION_STATE_RECEIVING }
 This enumeration specifies the reception state of the radio. More...
 
enum  TransmissionState { TRANSMISSION_STATE_UNDEFINED, TRANSMISSION_STATE_IDLE, TRANSMISSION_STATE_TRANSMITTING }
 This enumeration specifies the transmission state of the radio. More...
 
- 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) }
 
- Protected Types inherited from inet::OperationalMixin< cSimpleModule >
enum  State
 
- Static Protected Attributes inherited from inet::physicallayer::IRadio
static int nextId = 0
 
static cEnum * radioModeEnum = nullptr
 The enumeration registered for radio mode. More...
 
static cEnum * receptionStateEnum = nullptr
 The enumeration registered for radio reception state. More...
 
static cEnum * transmissionStateEnum = nullptr
 The enumeration registered for radio transmission state. More...
 

Constructor & Destructor Documentation

◆ Ieee80211Radio()

inet::physicallayer::Ieee80211Radio::Ieee80211Radio ( )
35  :
37 {
38 }

Member Function Documentation

◆ decapsulate()

void inet::physicallayer::Ieee80211Radio::decapsulate ( Packet packet) const
overrideprotectedvirtual

Reimplemented from inet::physicallayer::Radio.

271 {
272  auto mode = packet->getTag<Ieee80211ModeInd>()->getMode();
274  if (phyHeader->isIncorrect() || phyHeader->isIncomplete() || phyHeader->isImproperlyRepresented() || !verifyCrc(phyHeader))
275  packet->setBitError(true);
276  auto tailLength = dynamic_cast<const Ieee80211OfdmMode *>(mode) ? b(6) : b(0);
277  auto paddingLength = mode->getDataMode()->getPaddingLength(B(phyHeader->getLengthField()));
278  if (tailLength + paddingLength != b(0))
279  packet->popAtBack(tailLength + paddingLength, Chunk::PF_ALLOW_INCORRECT);
280  packet->getTagForUpdate<PacketProtocolTag>()->setProtocol(&Protocol::ieee80211Mac);
281 }

◆ encapsulate()

void inet::physicallayer::Ieee80211Radio::encapsulate ( Packet packet) const
overrideprotectedvirtual

Reimplemented from inet::physicallayer::Radio.

233 {
234  auto ieee80211Transmitter = check_and_cast<const Ieee80211TransmitterBase *>(transmitter);
235  auto mode = ieee80211Transmitter->computeTransmissionMode(packet);
236  auto phyHeader = mode->getHeaderMode()->createHeader();
237  phyHeader->setChunkLength(b(mode->getHeaderMode()->getLength()));
238  phyHeader->setLengthField(B(packet->getTotalLength()));
239  insertCrc(phyHeader);
240  packet->insertAtFront(phyHeader);
241 
242  auto tailLength = dynamic_cast<const Ieee80211OfdmMode *>(mode) ? b(6) : b(0);
243  auto paddingLength = mode->getDataMode()->getPaddingLength(B(phyHeader->getLengthField()));
244  if (tailLength + paddingLength != b(0)) {
245  const auto& phyTrailer = makeShared<BitCountChunk>(tailLength + paddingLength);
246  packet->insertAtBack(phyTrailer);
247  }
248  const Protocol *protocol = nullptr;
249  if (dynamic_cast<Ieee80211FhssPhyHeader *>(phyHeader.get()))
251  else if (dynamic_cast<Ieee80211IrPhyHeader *>(phyHeader.get()))
253  else if (dynamic_cast<Ieee80211DsssPhyHeader *>(phyHeader.get()))
255  else if (dynamic_cast<Ieee80211HrDsssPhyHeader *>(phyHeader.get()))
257  else if (dynamic_cast<Ieee80211OfdmPhyHeader *>(phyHeader.get()))
259  else if (dynamic_cast<Ieee80211ErpOfdmPhyHeader *>(phyHeader.get()))
261  else if (dynamic_cast<Ieee80211HtPhyHeader *>(phyHeader.get()))
263  else if (dynamic_cast<Ieee80211VhtPhyHeader *>(phyHeader.get()))
265  else
266  throw cRuntimeError("Invalid IEEE 802.11 PHY header type.");
267  packet->getTagForUpdate<PacketProtocolTag>()->setProtocol(protocol);
268 }

◆ handleUpperCommand()

void inet::physicallayer::Ieee80211Radio::handleUpperCommand ( cMessage *  message)
overrideprotectedvirtual

Reimplemented from inet::physicallayer::FlatRadioBase.

56 {
57  if (message->getKind() == RADIO_C_CONFIGURE) {
58  Ieee80211ConfigureRadioCommand *configureCommand = dynamic_cast<Ieee80211ConfigureRadioCommand *>(message->getControlInfo());
59  if (configureCommand != nullptr) {
60  const char *opMode = configureCommand->getOpMode();
61  if (*opMode)
63  const Ieee80211ModeSet *modeSet = configureCommand->getModeSet();
64  if (modeSet != nullptr)
65  setModeSet(modeSet);
66  const IIeee80211Mode *mode = configureCommand->getMode();
67  if (mode != nullptr)
68  setMode(mode);
69  const IIeee80211Band *band = configureCommand->getBand();
70  if (band != nullptr)
71  setBand(band);
72  const Ieee80211Channel *channel = configureCommand->getChannel();
73  if (channel != nullptr)
74  setChannel(channel);
75  int newChannelNumber = configureCommand->getChannelNumber();
76  if (newChannelNumber != -1)
77  setChannelNumber(newChannelNumber);
78  }
79  }
81 }

◆ initialize()

void inet::physicallayer::Ieee80211Radio::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::physicallayer::Radio.

41 {
43 
44  if (stage == INITSTAGE_LOCAL) {
45  const char *crcModeString = par("crcMode");
46  crcMode = parseCrcMode(crcModeString, true);
47  }
48  if (stage == INITSTAGE_PHYSICAL_LAYER) {
49  int channelNumber = par("channelNumber");
50  if (channelNumber != -1)
51  setChannelNumber(channelNumber);
52  }
53 }

◆ insertCrc()

void inet::physicallayer::Ieee80211Radio::insertCrc ( const Ptr< Ieee80211PhyHeader > &  phyHeader) const
protectedvirtual
139 {
140  if (auto header = dynamic_cast<Ieee80211FhssPhyHeader *>(phyHeader.get())) {
141  header->setCrcMode(crcMode);
142  switch (crcMode) {
143  case CRC_COMPUTED:
144  header->setCrc(0); // TODO calculate CRC
145  break;
147  header->setCrc(0xC00D);
148  break;
150  header->setCrc(0xBAAD);
151  break;
152  default:
153  throw cRuntimeError("Invalid CRC mode: %i", (int)crcMode);
154  }
155  }
156  else if (auto header = dynamic_cast<Ieee80211IrPhyHeader *>(phyHeader.get())) {
157  header->setCrcMode(crcMode);
158  switch (crcMode) {
159  case CRC_COMPUTED:
160  header->setCrc(0); // TODO calculate CRC
161  break;
163  header->setCrc(0xC00D);
164  break;
166  header->setCrc(0xBAAD);
167  break;
168  default:
169  throw cRuntimeError("Invalid CRC mode: %i", (int)crcMode);
170  }
171  }
172  else if (auto header = dynamic_cast<Ieee80211DsssPhyHeader *>(phyHeader.get())) {
173  header->setCrcMode(crcMode);
174  switch (crcMode) {
175  case CRC_COMPUTED:
176  header->setCrc(0); // TODO calculate CRC
177  break;
179  header->setCrc(0xC00D);
180  break;
182  header->setCrc(0xBAAD);
183  break;
184  default:
185  throw cRuntimeError("Invalid CRC mode: %i", (int)crcMode);
186  }
187  }
188 }

Referenced by encapsulate().

◆ peekIeee80211PhyHeaderAtFront()

const Ptr< const Ieee80211PhyHeader > inet::physicallayer::Ieee80211Radio::peekIeee80211PhyHeaderAtFront ( const Packet packet,
b  length = b(-1),
int  flags = 0 
)
static
307 {
308  int id = packet->getTag<PacketProtocolTag>()->getProtocol()->getId();
309  if (id == Protocol::ieee80211FhssPhy.getId())
310  return packet->peekAtFront<Ieee80211FhssPhyHeader>(length, flags);
311  else if (id == Protocol::ieee80211IrPhy.getId())
312  return packet->peekAtFront<Ieee80211IrPhyHeader>(length, flags);
313  else if (id == Protocol::ieee80211DsssPhy.getId())
314  return packet->peekAtFront<Ieee80211DsssPhyHeader>(length, flags);
315  else if (id == Protocol::ieee80211HrDsssPhy.getId())
316  return packet->peekAtFront<Ieee80211HrDsssPhyHeader>(length, flags);
317  else if (id == Protocol::ieee80211OfdmPhy.getId())
318  return packet->peekAtFront<Ieee80211OfdmPhyHeader>(length, flags);
319  else if (id == Protocol::ieee80211ErpOfdmPhy.getId())
320  return packet->peekAtFront<Ieee80211ErpOfdmPhyHeader>(length, flags);
321  else if (id == Protocol::ieee80211HtPhy.getId())
322  return packet->peekAtFront<Ieee80211HtPhyHeader>(length, flags);
323  else if (id == Protocol::ieee80211VhtPhy.getId())
324  return packet->peekAtFront<Ieee80211VhtPhyHeader>(length, flags);
325  else
326  throw cRuntimeError("Invalid IEEE 802.11 PHY protocol.");
327 }

Referenced by inet::physicallayer::Ieee80211ScalarTransmitter::createTransmission(), and inet::physicallayer::Ieee80211DimensionalTransmitter::createTransmission().

◆ popIeee80211PhyHeaderAtFront()

const Ptr< const Ieee80211PhyHeader > inet::physicallayer::Ieee80211Radio::popIeee80211PhyHeaderAtFront ( Packet packet,
b  length = b(-1),
int  flags = 0 
)
static
284 {
285  int id = packet->getTag<PacketProtocolTag>()->getProtocol()->getId();
286  if (id == Protocol::ieee80211FhssPhy.getId())
287  return packet->popAtFront<Ieee80211FhssPhyHeader>(length, flags);
288  else if (id == Protocol::ieee80211IrPhy.getId())
289  return packet->popAtFront<Ieee80211IrPhyHeader>(length, flags);
290  else if (id == Protocol::ieee80211DsssPhy.getId())
291  return packet->popAtFront<Ieee80211DsssPhyHeader>(length, flags);
292  else if (id == Protocol::ieee80211HrDsssPhy.getId())
293  return packet->popAtFront<Ieee80211HrDsssPhyHeader>(length, flags);
294  else if (id == Protocol::ieee80211OfdmPhy.getId())
295  return packet->popAtFront<Ieee80211OfdmPhyHeader>(length, flags);
296  else if (id == Protocol::ieee80211ErpOfdmPhy.getId())
297  return packet->popAtFront<Ieee80211ErpOfdmPhyHeader>(length, flags);
298  else if (id == Protocol::ieee80211HtPhy.getId())
299  return packet->popAtFront<Ieee80211HtPhyHeader>(length, flags);
300  else if (id == Protocol::ieee80211VhtPhy.getId())
301  return packet->popAtFront<Ieee80211VhtPhyHeader>(length, flags);
302  else
303  throw cRuntimeError("Invalid IEEE 802.11 PHY protocol.");
304 }

Referenced by decapsulate(), and inet::Ieee80211PhyProtocolDissector::dissect().

◆ setBand()

void inet::physicallayer::Ieee80211Radio::setBand ( const IIeee80211Band band)
virtual
104 {
105  Ieee80211TransmitterBase *ieee80211Transmitter = const_cast<Ieee80211TransmitterBase *>(check_and_cast<const Ieee80211TransmitterBase *>(transmitter));
106  Ieee80211ReceiverBase *ieee80211Receiver = const_cast<Ieee80211ReceiverBase *>(check_and_cast<const Ieee80211ReceiverBase *>(receiver));
107  ieee80211Transmitter->setBand(band);
108  ieee80211Receiver->setBand(band);
109  EV << "Changing radio band to " << band << endl;
110  receptionTimer = nullptr;
111  emit(listeningChangedSignal, 0);
112 }

Referenced by handleUpperCommand().

◆ setChannel()

void inet::physicallayer::Ieee80211Radio::setChannel ( const Ieee80211Channel channel)
virtual
115 {
116  Ieee80211TransmitterBase *ieee80211Transmitter = const_cast<Ieee80211TransmitterBase *>(check_and_cast<const Ieee80211TransmitterBase *>(transmitter));
117  Ieee80211ReceiverBase *ieee80211Receiver = const_cast<Ieee80211ReceiverBase *>(check_and_cast<const Ieee80211ReceiverBase *>(receiver));
118  ieee80211Transmitter->setChannel(channel);
119  ieee80211Receiver->setChannel(channel);
120  EV << "Changing radio channel to " << channel->getChannelNumber() << endl;
121  receptionTimer = nullptr;
122  emit(radioChannelChangedSignal, channel->getChannelNumber());
123  emit(listeningChangedSignal, 0);
124 }

Referenced by handleUpperCommand().

◆ setChannelNumber()

void inet::physicallayer::Ieee80211Radio::setChannelNumber ( int  newChannelNumber)
virtual
127 {
128  Ieee80211TransmitterBase *ieee80211Transmitter = const_cast<Ieee80211TransmitterBase *>(check_and_cast<const Ieee80211TransmitterBase *>(transmitter));
129  Ieee80211ReceiverBase *ieee80211Receiver = const_cast<Ieee80211ReceiverBase *>(check_and_cast<const Ieee80211ReceiverBase *>(receiver));
130  ieee80211Transmitter->setChannelNumber(newChannelNumber);
131  ieee80211Receiver->setChannelNumber(newChannelNumber);
132  EV << "Changing radio channel to " << newChannelNumber << ".\n";
133  receptionTimer = nullptr;
134  emit(radioChannelChangedSignal, newChannelNumber);
135  emit(listeningChangedSignal, 0);
136 }

Referenced by handleUpperCommand(), and initialize().

◆ setMode()

void inet::physicallayer::Ieee80211Radio::setMode ( const IIeee80211Mode mode)
virtual
95 {
96  Ieee80211TransmitterBase *ieee80211Transmitter = const_cast<Ieee80211TransmitterBase *>(check_and_cast<const Ieee80211TransmitterBase *>(transmitter));
97  ieee80211Transmitter->setMode(mode);
98  EV << "Changing radio mode to " << mode << endl;
99  receptionTimer = nullptr;
100  emit(listeningChangedSignal, 0);
101 }

Referenced by handleUpperCommand().

◆ setModeSet()

void inet::physicallayer::Ieee80211Radio::setModeSet ( const Ieee80211ModeSet modeSet)
virtual
84 {
85  Ieee80211TransmitterBase *ieee80211Transmitter = const_cast<Ieee80211TransmitterBase *>(check_and_cast<const Ieee80211TransmitterBase *>(transmitter));
86  Ieee80211ReceiverBase *ieee80211Receiver = const_cast<Ieee80211ReceiverBase *>(check_and_cast<const Ieee80211ReceiverBase *>(receiver));
87  ieee80211Transmitter->setModeSet(modeSet);
88  ieee80211Receiver->setModeSet(modeSet);
89  EV << "Changing radio mode set to " << modeSet << endl;
90  receptionTimer = nullptr;
91  emit(listeningChangedSignal, 0);
92 }

Referenced by handleUpperCommand().

◆ verifyCrc()

bool inet::physicallayer::Ieee80211Radio::verifyCrc ( const Ptr< const Ieee80211PhyHeader > &  phyHeader) const
protectedvirtual
191 {
192  if (auto header = dynamicPtrCast<const Ieee80211FhssPhyHeader>(phyHeader)) {
193  switch (header->getCrcMode()) {
194  case CRC_COMPUTED:
195  return true; // TODO calculate and check CRC
197  return true;
199  return false;
200  default:
201  throw cRuntimeError("Invalid CRC mode: %i", (int)crcMode);
202  }
203  }
204  else if (auto header = dynamicPtrCast<const Ieee80211IrPhyHeader>(phyHeader)) {
205  switch (header->getCrcMode()) {
206  case CRC_COMPUTED:
207  return true; // TODO calculate and check CRC
209  return true;
211  return false;
212  default:
213  throw cRuntimeError("Invalid CRC mode: %i", (int)crcMode);
214  }
215  }
216  else if (auto header = dynamicPtrCast<const Ieee80211DsssPhyHeader>(phyHeader)) {
217  switch (header->getCrcMode()) {
218  case CRC_COMPUTED:
219  return true; // TODO calculate and check CRC
221  return true;
223  return false;
224  default:
225  throw cRuntimeError("Invalid CRC mode: %i", (int)crcMode);
226  }
227  }
228  else
229  return true;
230 }

Referenced by decapsulate().

Member Data Documentation

◆ crcMode

CrcMode inet::physicallayer::Ieee80211Radio::crcMode = CRC_MODE_UNDEFINED
protected

Referenced by initialize(), insertCrc(), and verifyCrc().

◆ radioChannelChangedSignal

simsignal_t inet::physicallayer::Ieee80211Radio::radioChannelChangedSignal = cComponent::registerSignal("radioChannelChanged")
static

This signal is emitted every time the radio channel changes.

The signal value is the new radio channel.

Referenced by inet::ieee80211::Ieee80211MgmtAp::initialize(), inet::ieee80211::Ieee80211MgmtAp::receiveSignal(), setChannel(), and setChannelNumber().


The documentation for this class was generated from the following files:
inet::physicallayer::Ieee80211Radio::setChannel
virtual void setChannel(const Ieee80211Channel *channel)
Definition: Ieee80211Radio.cc:114
inet::Protocol::ieee80211ErpOfdmPhy
static const Protocol ieee80211ErpOfdmPhy
Definition: Protocol.h:74
inet::physicallayer::FlatRadioBase::FlatRadioBase
FlatRadioBase()
Definition: FlatRadioBase.cc:20
protocol
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down protocol
Definition: IUdp-gates.txt:25
inet::Protocol::ieee80211HtPhy
static const Protocol ieee80211HtPhy
Definition: Protocol.h:77
inet::physicallayer::Ieee80211Radio::verifyCrc
virtual bool verifyCrc(const Ptr< const Ieee80211PhyHeader > &phyHeader) const
Definition: Ieee80211Radio.cc:190
inet::physicallayer::Ieee80211Radio::popIeee80211PhyHeaderAtFront
static const Ptr< const Ieee80211PhyHeader > popIeee80211PhyHeaderAtFront(Packet *packet, b length=b(-1), int flags=0)
Definition: Ieee80211Radio.cc:283
inet::CRC_COMPUTED
@ CRC_COMPUTED
Definition: CrcMode_m.h:59
inet::Chunk::PF_ALLOW_IMPROPERLY_REPRESENTED
@ PF_ALLOW_IMPROPERLY_REPRESENTED
Definition: Chunk.h:282
inet::parseCrcMode
CrcMode parseCrcMode(const char *crcModeString, bool allowDisable)
Definition: CrcMode.cc:14
inet::physicallayer::Ieee80211Radio::setModeSet
virtual void setModeSet(const Ieee80211ModeSet *modeSet)
Definition: Ieee80211Radio.cc:83
inet::physicallayer::Ieee80211Radio::crcMode
CrcMode crcMode
Definition: Ieee80211Radio.h:34
inet::Protocol::ieee80211IrPhy
static const Protocol ieee80211IrPhy
Definition: Protocol.h:78
PacketProtocolTag
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down PacketProtocolTag
Definition: IUdp-gates.txt:25
inet::Protocol::ieee80211DsssPhy
static const Protocol ieee80211DsssPhy
Definition: Protocol.h:73
inet::units::units::B
intscale< b, 1, 8 > B
Definition: Units.h:1168
inet::Chunk::PF_ALLOW_INCOMPLETE
@ PF_ALLOW_INCOMPLETE
Definition: Chunk.h:280
inet::physicallayer::Radio::receiver
const IReceiver * receiver
The receiver model is never nullptr.
Definition: Radio.h:70
inet::physicallayer::Radio::receptionTimer
cMessage * receptionTimer
The timer that is scheduled to the end of the current reception.
Definition: Radio.h:152
inet::Protocol::ieee80211OfdmPhy
static const Protocol ieee80211OfdmPhy
Definition: Protocol.h:81
inet::physicallayer::IRadio::listeningChangedSignal
static simsignal_t listeningChangedSignal
This signal is emitted when the radio listening of the radio is changed.
Definition: IRadio.h:48
inet::physicallayer::Ieee80211Radio::insertCrc
virtual void insertCrc(const Ptr< Ieee80211PhyHeader > &phyHeader) const
Definition: Ieee80211Radio.cc:138
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
inet::physicallayer::Radio::transmitter
const ITransmitter * transmitter
The transmitter model is never nullptr.
Definition: Radio.h:66
inet::INITSTAGE_PHYSICAL_LAYER
INET_API InitStage INITSTAGE_PHYSICAL_LAYER
Initialization of physical layer protocols includes:
inet::units::values::b
value< int64_t, units::b > b
Definition: Units.h:1241
inet::Chunk::PF_ALLOW_INCORRECT
@ PF_ALLOW_INCORRECT
Definition: Chunk.h:281
inet::physicallayer::Ieee80211Radio::radioChannelChangedSignal
static simsignal_t radioChannelChangedSignal
This signal is emitted every time the radio channel changes.
Definition: Ieee80211Radio.h:29
inet::CRC_DECLARED_CORRECT
@ CRC_DECLARED_CORRECT
Definition: CrcMode_m.h:57
inet::physicallayer::Radio::initialize
virtual void initialize(int stage) override
Definition: Radio.cc:36
inet::physicallayer::RADIO_C_CONFIGURE
@ RADIO_C_CONFIGURE
Definition: RadioControlInfo_m.h:62
inet::CRC_DECLARED_INCORRECT
@ CRC_DECLARED_INCORRECT
Definition: CrcMode_m.h:58
inet::physicallayer::Ieee80211Radio::setMode
virtual void setMode(const IIeee80211Mode *mode)
Definition: Ieee80211Radio.cc:94
inet::Protocol::ieee80211HrDsssPhy
static const Protocol ieee80211HrDsssPhy
Definition: Protocol.h:76
inet::physicallayer::Ieee80211Radio::setBand
virtual void setBand(const IIeee80211Band *band)
Definition: Ieee80211Radio.cc:103
inet::physicallayer::FlatRadioBase::handleUpperCommand
void handleUpperCommand(cMessage *message) override
Definition: FlatRadioBase.cc:25
inet::Protocol::ieee80211Mac
static const Protocol ieee80211Mac
Definition: Protocol.h:79
inet::physicallayer::Ieee80211ModeSet::getModeSet
static const Ieee80211ModeSet * getModeSet(const char *mode)
Definition: Ieee80211ModeSet.cc:611
inet::physicallayer::Radio::getId
virtual int getId() const override
Returns an identifier for this radio which is globally unique for the whole lifetime of the simulatio...
Definition: Radio.h:209
inet::Protocol::ieee80211VhtPhy
static const Protocol ieee80211VhtPhy
Definition: Protocol.h:82
inet::physicallayer::Ieee80211Radio::setChannelNumber
virtual void setChannelNumber(int newChannelNumber)
Definition: Ieee80211Radio.cc:126
inet::Protocol::ieee80211FhssPhy
static const Protocol ieee80211FhssPhy
Definition: Protocol.h:75