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

This class is the default implementation of the IRadio interface. More...

#include <Radio.h>

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

Protected Attributes

const int id = nextId++
 An identifier which is globally unique for the whole lifetime of the simulation among all radios. More...
 
Parameters that determine the behavior of the radio.
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...
 
- 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
 

Timer

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...
 
void parseRadioModeSwitchingTimes ()
 
void startRadioModeSwitch (RadioMode newRadioMode, simtime_t switchingTime)
 
void completeRadioModeSwitch (RadioMode newRadioMode)
 
virtual void initialize (int stage) override
 
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 handleUpperCommand (cMessage *command) override
 
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 ()
 
 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...
 
virtual void encapsulate (Packet *packet) const
 
virtual void decapsulate (Packet *packet) const
 

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) }
 
- 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 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 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 Types inherited from inet::OperationalMixin< cSimpleModule >
enum  State
 
- 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 ()
 
- 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...
 

Detailed Description

This class is the default implementation of the IRadio interface.

The transmission process starts when the radio module receives a packet from the higher layer. The radio must be in transmitter or transceiver mode before receiving a packet, otherwise it throws an exception. The radio changes its transmitter state to transmitting, and emits a transmitter state changed signal. Finally, it schedules a timer to the end of the transmission.

The transmission process ends when the above timer expires. The radio changes its transmitter state back to idle, and emits a transmitter state changed signal.

The reception process starts when the radio module receives a packet. The radio must be in receiver or transceiver mode before the packet arrives, otherwise it just ignores the packet. The radio changes its receiver state to the appropriate value, and emits a receiver state changed signal. Finally, it schedules a timer to the end of the reception.

The reception process ends when one of the above timer expires. If the timer corresponds to an attempted reception, then the radio determines the reception decision. Independently of whether the reception is successful or not, the encapsulated packet is sent up to the higher layer. Finally, the radio changes its receiver state to the appropriate value, and emits a receiver state changed signal.

Constructor & Destructor Documentation

◆ Radio()

inet::physicallayer::Radio::Radio ( )
inline
206 {}

◆ ~Radio()

inet::physicallayer::Radio::~Radio ( )
virtual
27 {
28  // NOTE: can't use the medium module here, because it may have been already deleted
29  cModule *medium = getSimulation()->getModule(mediumModuleId);
30  if (medium != nullptr)
31  check_and_cast<IRadioMedium *>(medium)->removeRadio(this);
32  cancelAndDelete(transmissionTimer);
33  cancelAndDelete(switchTimer);
34 }

Member Function Documentation

◆ abortReception()

void inet::physicallayer::Radio::abortReception ( cMessage *  timer)
protectedvirtual
490 {
491  auto signal = static_cast<WirelessSignal *>(timer->getControlInfo());
492  auto part = (IRadioSignal::SignalPart)timer->getKind();
493  auto reception = signal->getReception();
494  EV_INFO << "Reception \x1b[1maborted\x1b[0m: for " << (IWirelessSignal *)signal << " " << IRadioSignal::getSignalPartName(part) << " as " << reception << endl;
495  if (timer == receptionTimer)
496  receptionTimer = nullptr;
499 }

Referenced by completeRadioModeSwitch().

◆ abortTransmission()

void inet::physicallayer::Radio::abortTransmission ( )
protectedvirtual
380 {
381  auto part = (IRadioSignal::SignalPart)transmissionTimer->getKind();
382  auto signal = static_cast<WirelessSignal *>(transmissionTimer->getContextPointer());
383  auto transmission = signal->getTransmission();
384  transmissionTimer->setContextPointer(nullptr);
385  EV_INFO << "Transmission aborted: " << (IWirelessSignal *)signal << " " << IRadioSignal::getSignalPartName(part) << " as " << transmission << endl;
386  EV_WARN << "Aborting ongoing transmissions is not supported" << endl;
387  cancelEvent(transmissionTimer);
390 }

Referenced by completeRadioModeSwitch(), handleCrashOperation(), and handleStopOperation().

◆ captureReception()

void inet::physicallayer::Radio::captureReception ( cMessage *  timer)
protectedvirtual
502 {
503  // TODO this would be called when the receiver switches to a stronger signal while receiving a weaker one
504  throw cRuntimeError("Not yet implemented");
505 }

◆ completeRadioModeSwitch()

void inet::physicallayer::Radio::completeRadioModeSwitch ( RadioMode  newRadioMode)
private
158 {
159  EV_INFO << "Radio mode changed from \x1b[1m" << getRadioModeName(previousRadioMode) << "\x1b[0m to \x1b[1m" << getRadioModeName(newRadioMode) << "\x1b[0m." << endl;
160  if (!isReceiverMode(newRadioMode) && receptionTimer != nullptr)
162  if (!isTransmitterMode(newRadioMode) && transmissionTimer->isScheduled())
164  radioMode = previousRadioMode = nextRadioMode = newRadioMode;
165  emit(radioModeChangedSignal, newRadioMode);
168 }

Referenced by handleCrashOperation(), handleStopOperation(), handleSwitchTimer(), initializeRadioMode(), and setRadioMode().

◆ continueReception()

void inet::physicallayer::Radio::continueReception ( cMessage *  timer)
protectedvirtual
432 {
433  auto previousPart = (IRadioSignal::SignalPart)timer->getKind();
434  auto nextPart = (IRadioSignal::SignalPart)(previousPart + 1);
435  auto signal = static_cast<WirelessSignal *>(timer->getControlInfo());
436  auto arrival = signal->getArrival();
437  auto reception = signal->getReception();
438  if (timer == receptionTimer && isReceiverMode(radioMode) && arrival->getEndTime(previousPart) == simTime()) {
439  auto transmission = signal->getTransmission();
440  bool isReceptionSuccessful = medium->isReceptionSuccessful(this, transmission, previousPart);
441  EV_INFO << "Reception ended: " << (isReceptionSuccessful ? "\x1b[1msuccessfully\x1b[0m" : "\x1b[1munsuccessfully\x1b[0m") << " for " << (IWirelessSignal *)signal << " " << IRadioSignal::getSignalPartName(previousPart) << " as " << reception << endl;
442  if (!isReceptionSuccessful)
443  receptionTimer = nullptr;
444  auto isReceptionAttempted = medium->isReceptionAttempted(this, transmission, nextPart);
445  EV_INFO << "Reception started: " << (isReceptionAttempted ? "\x1b[1mattempting\x1b[0m" : "\x1b[1mnot attempting\x1b[0m") << " " << (IWirelessSignal *)signal << " " << IRadioSignal::getSignalPartName(nextPart) << " as " << reception << endl;
446  if (!isReceptionAttempted)
447  receptionTimer = nullptr;
448  // FIXME see handling packets with incorrect PHY headers in the TODO file
449  }
450  else {
451  EV_INFO << "Reception ended: \x1b[1mignoring\x1b[0m " << (IWirelessSignal *)signal << " " << IRadioSignal::getSignalPartName(previousPart) << " as " << reception << endl;
452  EV_INFO << "Reception started: \x1b[1mignoring\x1b[0m " << (IWirelessSignal *)signal << " " << IRadioSignal::getSignalPartName(nextPart) << " as " << reception << endl;
453  }
454  timer->setKind(nextPart);
455  scheduleAt(arrival->getEndTime(nextPart), timer);
458 }

Referenced by handleReceptionTimer().

◆ continueTransmission()

void inet::physicallayer::Radio::continueTransmission ( )
protectedvirtual
352 {
353  auto previousPart = (IRadioSignal::SignalPart)transmissionTimer->getKind();
354  auto nextPart = (IRadioSignal::SignalPart)(previousPart + 1);
355  auto signal = static_cast<WirelessSignal *>(transmissionTimer->getContextPointer());
356  auto transmission = signal->getTransmission();
357  EV_INFO << "Transmission ended: " << (IWirelessSignal *)signal << " " << IRadioSignal::getSignalPartName(previousPart) << " as " << signal->getTransmission() << endl;
358  transmissionTimer->setKind(nextPart);
359  scheduleAt(transmission->getEndTime(nextPart), transmissionTimer);
360  EV_INFO << "Transmission started: " << (IWirelessSignal *)signal << " " << IRadioSignal::getSignalPartName(nextPart) << " as " << transmission << endl;
363 }

Referenced by handleTransmissionTimer().

◆ createReceptionTimer()

cMessage * inet::physicallayer::Radio::createReceptionTimer ( WirelessSignal signal) const
protectedvirtual
515 {
516  cMessage *timer = new cMessage("receptionTimer");
517  timer->setControlInfo(signal);
518  return timer;
519 }

Referenced by handleSignal().

◆ createSignal()

WirelessSignal * inet::physicallayer::Radio::createSignal ( Packet packet) const
protectedvirtual
393 {
394  encapsulate(packet);
395  if (sendRawBytes) {
396  // TODO this doesn't always work, because the packet length may not be divisible by 8
397  auto bytes = packet->peekDataAsBytes();
398  packet->eraseAll();
399  packet->insertAtFront(bytes);
400  }
401  WirelessSignal *signal = check_and_cast<WirelessSignal *>(medium->transmitPacket(this, packet));
402  ASSERT(signal->getDuration() != 0);
403  return signal;
404 }

Referenced by startTransmission().

◆ decapsulate()

virtual void inet::physicallayer::Radio::decapsulate ( Packet packet) const
inlinevirtual

◆ encapsulate()

virtual void inet::physicallayer::Radio::encapsulate ( Packet packet) const
inlinevirtual

◆ endReception()

void inet::physicallayer::Radio::endReception ( cMessage *  timer)
protectedvirtual
461 {
462  auto part = (IRadioSignal::SignalPart)timer->getKind();
463  auto signal = static_cast<WirelessSignal *>(timer->getControlInfo());
464  auto arrival = signal->getArrival();
465  auto reception = signal->getReception();
466  if (timer == receptionTimer && isReceiverMode(radioMode) && arrival->getEndTime() == simTime()) {
467  auto transmission = signal->getTransmission();
468  // TODO this would draw twice from the random number generator in isReceptionSuccessful: auto isReceptionSuccessful = medium->isReceptionSuccessful(this, transmission, part);
469  auto isReceptionSuccessful = medium->getReceptionDecision(this, signal->getListening(), transmission, part)->isReceptionSuccessful();
470  EV_INFO << "Reception ended: " << (isReceptionSuccessful ? "\x1b[1msuccessfully\x1b[0m" : "\x1b[1munsuccessfully\x1b[0m") << " for " << (IWirelessSignal *)signal << " " << IRadioSignal::getSignalPartName(part) << " as " << reception << endl;
471  auto macFrame = medium->receivePacket(this, signal);
472  take(macFrame);
473  // FIXME see handling packets with incorrect PHY headers in the TODO file
474  decapsulate(macFrame);
475  sendUp(macFrame);
476  emit(receptionEndedSignal, check_and_cast<const cObject *>(reception));
477  }
478  else
479  EV_INFO << "Reception ended: \x1b[1mignoring\x1b[0m " << (IWirelessSignal *)signal << " " << IRadioSignal::getSignalPartName(part) << " as " << reception << endl;
482  if (timer == receptionTimer)
483  receptionTimer = nullptr;
484  delete timer;
485  // TODO move to radio medium
486  check_and_cast<RadioMedium *>(medium.get())->emit(IRadioMedium::signalArrivalEndedSignal, check_and_cast<const cObject *>(reception));
487 }

Referenced by handleReceptionTimer().

◆ endTransmission()

void inet::physicallayer::Radio::endTransmission ( )
protectedvirtual
366 {
367  auto part = (IRadioSignal::SignalPart)transmissionTimer->getKind();
368  auto signal = static_cast<WirelessSignal *>(transmissionTimer->getContextPointer());
369  auto transmission = signal->getTransmission();
370  transmissionTimer->setContextPointer(nullptr);
371  EV_INFO << "Transmission ended: " << (IWirelessSignal *)signal << " " << IRadioSignal::getSignalPartName(part) << " as " << transmission << endl;
374  emit(transmissionEndedSignal, check_and_cast<const cObject *>(transmission));
375  // TODO move to radio medium
376  check_and_cast<RadioMedium *>(medium.get())->emit(IRadioMedium::signalDepartureEndedSignal, check_and_cast<const cObject *>(transmission));
377 }

Referenced by handleTransmissionTimer().

◆ getAntenna()

virtual const IAntenna* inet::physicallayer::Radio::getAntenna ( ) const
inlineoverridevirtual

Returns the antenna used by the transceiver of this radio.

This function never returns nullptr.

Implements inet::physicallayer::IRadio.

213 { return antenna; }

◆ getId()

virtual int inet::physicallayer::Radio::getId ( ) const
inlineoverridevirtual

Returns an identifier for this radio which is globally unique for the whole lifetime of the simulation among all radios.

Implements inet::physicallayer::IRadio.

209 { return id; }

Referenced by inet::physicallayer::Ieee80211Radio::peekIeee80211PhyHeaderAtFront(), inet::physicallayer::Ieee80211Radio::popIeee80211PhyHeaderAtFront(), startTransmission(), and inet::physicallayer::CommunicationLog::writeTransmission().

◆ getMedium()

virtual const IRadioMedium* inet::physicallayer::Radio::getMedium ( ) const
inlineoverridevirtual

Returns the radio medium where this radio is transmitting and receiving radio signals.

This function never returns nullptr.

Implements inet::physicallayer::IRadio.

216 { return medium; }

◆ getRadioGate()

virtual const cGate* inet::physicallayer::Radio::getRadioGate ( ) const
inlineoverridevirtual

Returns the gate of the radio that receives incoming signals.

Implements inet::physicallayer::IRadio.

218 { return radioIn; }

◆ getRadioMode()

virtual RadioMode inet::physicallayer::Radio::getRadioMode ( ) const
inlineoverridevirtual

Returns the current radio mode, This is the same mode as the one emitted with the last radioModeChangedSignal.

Implements inet::physicallayer::IRadio.

220 { return radioMode; }

Referenced by inet::physicallayer::RadioMedium::isPotentialReceiver().

◆ getReceivedSignalPart()

IRadioSignal::SignalPart inet::physicallayer::Radio::getReceivedSignalPart ( ) const
overridevirtual

Returns the signal part of the ongoing reception that the receiver is currently receiving or -1 if no reception is in progress.

This is the same part as the one emitted with the last receivedPartChangedSignal.

Implements inet::physicallayer::IRadio.

192 {
193  return receivedSignalPart;
194 }

◆ getReceiver()

virtual const IReceiver* inet::physicallayer::Radio::getReceiver ( ) const
inlineoverridevirtual

Returns the receiver part of this radio.

This function never returns nullptr.

Implements inet::physicallayer::IRadio.

215 { return receiver; }

◆ getReceptionInProgress()

const ITransmission * inet::physicallayer::Radio::getReceptionInProgress ( ) const
overridevirtual

Returns the ongoing reception that the receiver is currently receiving or nullptr.

Implements inet::physicallayer::IRadio.

179 {
180  if (receptionTimer == nullptr)
181  return nullptr;
182  else
183  return static_cast<WirelessSignal *>(receptionTimer->getControlInfo())->getTransmission();
184 }

◆ getReceptionState()

virtual ReceptionState inet::physicallayer::Radio::getReceptionState ( ) const
inlineoverridevirtual

Returns the current radio reception state.

This is the same state as the one emitted with the last receptionStateChangedSignal.

Implements inet::physicallayer::IRadio.

223 { return receptionState; }

◆ getTransmissionInProgress()

const ITransmission * inet::physicallayer::Radio::getTransmissionInProgress ( ) const
overridevirtual

Returns the ongoing transmission that the transmitter is currently transmitting or nullptr.

Implements inet::physicallayer::IRadio.

171 {
172  if (!transmissionTimer->isScheduled())
173  return nullptr;
174  else
175  return static_cast<WirelessSignal *>(transmissionTimer->getContextPointer())->getTransmission();
176 }

◆ getTransmissionState()

virtual TransmissionState inet::physicallayer::Radio::getTransmissionState ( ) const
inlineoverridevirtual

Returns the current radio transmission state.

This is the same state as the one emitted with the last transmissionStateChangedSignal.

Implements inet::physicallayer::IRadio.

224 { return transmissionState; }

◆ getTransmittedSignalPart()

IRadioSignal::SignalPart inet::physicallayer::Radio::getTransmittedSignalPart ( ) const
overridevirtual

Returns the signal part of the ongoing transmission that the transmitter is currently transmitting or -1 if no transmission is in progress.

This is the same part as the one emitted with the last transmittedPartChangedSignal.

Implements inet::physicallayer::IRadio.

187 {
188  return transmittedSignalPart;
189 }

◆ getTransmitter()

virtual const ITransmitter* inet::physicallayer::Radio::getTransmitter ( ) const
inlineoverridevirtual

Returns the transmitter part of this radio.

This function never returns nullptr.

Implements inet::physicallayer::IRadio.

214 { return transmitter; }

◆ handleCrashOperation()

void inet::physicallayer::Radio::handleCrashOperation ( LifecycleOperation operation)
overrideprotectedvirtual

Implements inet::OperationalMixin< cSimpleModule >.

308 {
309  cancelEvent(switchTimer);
310  if (transmissionTimer->isScheduled())
313 }

◆ handleLowerCommand()

void inet::physicallayer::Radio::handleLowerCommand ( cMessage *  command)
overrideprotectedvirtual

Reimplemented from inet::LayeredProtocolBase.

262 {
263  throw cRuntimeError("Unsupported command");
264 }

◆ handleMessageWhenDown()

void inet::physicallayer::Radio::handleMessageWhenDown ( cMessage *  message)
overrideprotectedvirtual

Reimplemented from inet::OperationalMixin< cSimpleModule >.

197 {
198  if (message->getArrivalGate() == radioIn || isReceptionTimer(message))
199  delete message;
200  else
202 }

◆ handleReceptionTimer()

void inet::physicallayer::Radio::handleReceptionTimer ( cMessage *  message)
protectedvirtual
236 {
237  if (message->getKind() == IRadioSignal::SIGNAL_PART_WHOLE)
238  endReception(message);
239  else if (message->getKind() == IRadioSignal::SIGNAL_PART_PREAMBLE)
240  continueReception(message);
241  else if (message->getKind() == IRadioSignal::SIGNAL_PART_HEADER)
242  continueReception(message);
243  else if (message->getKind() == IRadioSignal::SIGNAL_PART_DATA)
244  endReception(message);
245  else
246  throw cRuntimeError("Unknown self message");
247 }

Referenced by handleSelfMessage().

◆ handleSelfMessage()

void inet::physicallayer::Radio::handleSelfMessage ( cMessage *  message)
overrideprotectedvirtual

Reimplemented from inet::LayeredProtocolBase.

205 {
206  if (message == switchTimer)
207  handleSwitchTimer(message);
208  else if (message == transmissionTimer)
209  handleTransmissionTimer(message);
210  else if (isReceptionTimer(message))
211  handleReceptionTimer(message);
212  else
213  throw cRuntimeError("Unknown self message");
214 }

◆ handleSignal()

void inet::physicallayer::Radio::handleSignal ( WirelessSignal signal)
overrideprotectedvirtual

◆ handleStartOperation()

void inet::physicallayer::Radio::handleStartOperation ( LifecycleOperation operation)
overrideprotectedvirtual

Implements inet::OperationalMixin< cSimpleModule >.

293 {
294  // NOTE: we ignore radio mode switching during start
296 }

◆ handleStopOperation()

void inet::physicallayer::Radio::handleStopOperation ( LifecycleOperation operation)
overrideprotectedvirtual

Implements inet::OperationalMixin< cSimpleModule >.

299 {
300  // NOTE: we ignore radio mode switching and ongoing transmission during shutdown
301  cancelEvent(switchTimer);
302  if (transmissionTimer->isScheduled())
305 }

◆ handleSwitchTimer()

void inet::physicallayer::Radio::handleSwitchTimer ( cMessage *  message)
protectedvirtual
217 {
219 }

Referenced by handleSelfMessage().

◆ handleTransmissionTimer()

void inet::physicallayer::Radio::handleTransmissionTimer ( cMessage *  message)
protectedvirtual
222 {
223  if (message->getKind() == IRadioSignal::SIGNAL_PART_WHOLE)
224  endTransmission();
225  else if (message->getKind() == IRadioSignal::SIGNAL_PART_PREAMBLE)
227  else if (message->getKind() == IRadioSignal::SIGNAL_PART_HEADER)
229  else if (message->getKind() == IRadioSignal::SIGNAL_PART_DATA)
230  endTransmission();
231  else
232  throw cRuntimeError("Unknown self message");
233 }

Referenced by handleSelfMessage().

◆ handleUpperCommand()

void inet::physicallayer::Radio::handleUpperCommand ( cMessage *  command)
overrideprotectedvirtual

Reimplemented from inet::LayeredProtocolBase.

Reimplemented in inet::physicallayer::Ieee80211Radio, inet::physicallayer::NarrowbandRadioBase, and inet::physicallayer::FlatRadioBase.

250 {
251  if (message->getKind() == RADIO_C_CONFIGURE) {
252  ConfigureRadioCommand *configureCommand = check_and_cast<ConfigureRadioCommand *>(message->getControlInfo());
253  if (configureCommand->getRadioMode() != -1)
254  setRadioMode((RadioMode)configureCommand->getRadioMode());
255  delete message;
256  }
257  else
258  throw cRuntimeError("Unsupported command");
259 }

Referenced by inet::physicallayer::NarrowbandRadioBase::handleUpperCommand().

◆ handleUpperPacket()

void inet::physicallayer::Radio::handleUpperPacket ( Packet packet)
overrideprotectedvirtual

Reimplemented from inet::LayeredProtocolBase.

Reimplemented in inet::physicallayer::ApskRadio.

267 {
268  emit(packetReceivedFromUpperSignal, packet);
270  if (transmissionTimer->isScheduled())
271  throw cRuntimeError("Received frame from upper layer while already transmitting.");
274  else
276  }
277  else {
278  EV_ERROR << "Radio is not in transmitter or transceiver mode, dropping frame." << endl;
279  delete packet;
280  }
281 }

Referenced by inet::physicallayer::ApskRadio::handleUpperPacket().

◆ initialize()

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

Reimplemented from inet::physicallayer::PhysicalLayerBase.

Reimplemented in inet::physicallayer::Ieee80211Radio, and inet::physicallayer::ApskRadio.

37 {
39  if (stage == INITSTAGE_LOCAL) {
40  switchTimer = new cMessage("switchTimer");
41  transmissionTimer = new cMessage("transmissionTimer");
42  antenna = check_and_cast<IAntenna *>(getSubmodule("antenna"));
43  transmitter = check_and_cast<ITransmitter *>(getSubmodule("transmitter"));
44  receiver = check_and_cast<IReceiver *>(getSubmodule("receiver"));
45  medium.reference(this, "radioMediumModule", true);
46  mediumModuleId = check_and_cast<cModule *>(medium.get())->getId();
47  upperLayerIn = gate("upperLayerIn");
48  upperLayerOut = gate("upperLayerOut");
49  radioIn = gate("radioIn");
50  radioIn->setDeliverImmediately(true);
51  sendRawBytes = par("sendRawBytes");
52  separateTransmissionParts = par("separateTransmissionParts");
53  separateReceptionParts = par("separateReceptionParts");
54  WATCH(radioMode);
55  WATCH(receptionState);
56  WATCH(transmissionState);
57  WATCH(receivedSignalPart);
58  WATCH(transmittedSignalPart);
59  }
60  else if (stage == INITSTAGE_PHYSICAL_LAYER) {
61  medium->addRadio(this);
62  if (medium->getCommunicationCache()->getNumTransmissions() == 0 && isListeningPossible())
63  throw cRuntimeError("Receiver is busy without any ongoing transmission, probably energy detection level is too low or background noise level is too high");
66  }
67  else if (stage == INITSTAGE_LAST) {
68  EV_INFO << "Initialized " << getCompleteStringRepresentation() << endl;
69  }
70 }

Referenced by inet::physicallayer::ApskRadio::initialize(), and inet::physicallayer::Ieee80211Radio::initialize().

◆ initializeRadioMode()

void inet::physicallayer::Radio::initializeRadioMode ( )
protectedvirtual
72  {
73  const char *initialRadioMode = par("initialRadioMode");
74  if (!strcmp(initialRadioMode, "off"))
76  else if (!strcmp(initialRadioMode, "sleep"))
78  else if (!strcmp(initialRadioMode, "receiver"))
80  else if (!strcmp(initialRadioMode, "transmitter"))
82  else if (!strcmp(initialRadioMode, "transceiver"))
84  else
85  throw cRuntimeError("Unknown initialRadioMode");
86 }

Referenced by handleStartOperation(), and initialize().

◆ isListeningPossible()

bool inet::physicallayer::Radio::isListeningPossible ( ) const
protectedvirtual
537 {
538  const simtime_t now = simTime();
539  const Coord& position = antenna->getMobility()->getCurrentPosition();
540  // TODO use 2 * minInterferenceTime for lookahead? or maybe simply use 0 duration listening?
541  const IListening *listening = receiver->createListening(this, now, now + 1E-12, position, position);
542  const IListeningDecision *listeningDecision = medium->listenOnMedium(this, listening);
543  bool isListeningPossible = listeningDecision->isListeningPossible();
544  delete listening;
545  delete listeningDecision;
546  return isListeningPossible;
547 }

Referenced by initialize(), and updateTransceiverState().

◆ isReceiverMode()

bool inet::physicallayer::Radio::isReceiverMode ( IRadio::RadioMode  radioMode) const
protectedvirtual

◆ isReceptionTimer()

bool inet::physicallayer::Radio::isReceptionTimer ( const cMessage *  message) const
protectedvirtual
522 {
523  return !strcmp(message->getName(), "receptionTimer");
524 }

Referenced by handleMessageWhenDown(), and handleSelfMessage().

◆ isTransmitterMode()

bool inet::physicallayer::Radio::isTransmitterMode ( IRadio::RadioMode  radioMode) const
protectedvirtual

◆ parseRadioModeSwitchingTimes()

void inet::physicallayer::Radio::parseRadioModeSwitchingTimes ( )
private
117 {
118  const char *times = par("switchingTimes");
119 
120  char prefix[3];
121  unsigned int count = sscanf(times, "%s", prefix);
122 
123  if (count > 2)
124  throw cRuntimeError("Metric prefix should be no more than two characters long");
125 
126  double metric = 1;
127 
128  if (strcmp("s", prefix) == 0)
129  metric = 1;
130  else if (strcmp("ms", prefix) == 0)
131  metric = 0.001;
132  else if (strcmp("ns", prefix) == 0)
133  metric = 0.000000001;
134  else
135  throw cRuntimeError("Undefined or missed metric prefix for switchingTimes parameter");
136 
137  cStringTokenizer tok(times + count + 1);
138  unsigned int idx = 0;
139  while (tok.hasMoreTokens()) {
140  switchingTimes[idx / RADIO_MODE_SWITCHING][idx % RADIO_MODE_SWITCHING] = atof(tok.nextToken()) * metric;
141  idx++;
142  }
144  throw cRuntimeError("Check your switchingTimes parameter! Some parameters may be missed");
145 }

Referenced by initialize().

◆ printToStream()

std::ostream & inet::physicallayer::Radio::printToStream ( std::ostream &  stream,
int  level,
int  evFlags = 0 
) const
overridevirtual

Prints this object to the provided output stream.

Reimplemented from inet::IPrintableObject.

89 {
90  stream << static_cast<const cSimpleModule *>(this);
91  if (level <= PRINT_LEVEL_TRACE)
92  stream << EV_FIELD(antenna, printFieldToString(antenna, level + 1, evFlags))
95  return stream;
96 }

◆ sendUp()

void inet::physicallayer::Radio::sendUp ( Packet macFrame)
protectedvirtual

Reimplemented in inet::physicallayer::ApskRadio.

508 {
509  EV_INFO << "Sending up " << macFrame << endl;
510  emit(packetSentToUpperSignal, macFrame);
511  send(macFrame, upperLayerOut);
512 }

Referenced by endReception(), and inet::physicallayer::ApskRadio::sendUp().

◆ setRadioMode()

void inet::physicallayer::Radio::setRadioMode ( RadioMode  radioMode)
overridevirtual

Changes the current radio mode.

The actual change may take zero or more time. The new radio mode will be emitted with a radioModeChangedSignal.

Implements inet::physicallayer::IRadio.

99 {
100  Enter_Method("setRadioMode");
101  if (newRadioMode < RADIO_MODE_OFF || newRadioMode > RADIO_MODE_SWITCHING)
102  throw cRuntimeError("Unknown radio mode: %d", newRadioMode);
103  else if (newRadioMode == RADIO_MODE_SWITCHING)
104  throw cRuntimeError("Cannot switch manually to RADIO_MODE_SWITCHING");
105  else if (radioMode == RADIO_MODE_SWITCHING || switchTimer->isScheduled())
106  throw cRuntimeError("Cannot switch to a new radio mode while another switch is in progress");
107  else if (newRadioMode != radioMode && newRadioMode != nextRadioMode) {
108  simtime_t switchingTime = switchingTimes[radioMode][newRadioMode];
109  if (switchingTime != 0)
110  startRadioModeSwitch(newRadioMode, switchingTime);
111  else
112  completeRadioModeSwitch(newRadioMode);
113  }
114 }

Referenced by handleUpperCommand().

◆ startRadioModeSwitch()

void inet::physicallayer::Radio::startRadioModeSwitch ( RadioMode  newRadioMode,
simtime_t  switchingTime 
)
private
148 {
149  EV_DETAIL << "Starting to change radio mode from \x1b[1m" << getRadioModeName(radioMode) << "\x1b[0m to \x1b[1m" << getRadioModeName(newRadioMode) << "\x1b[0m." << endl;
152  nextRadioMode = newRadioMode;
154  scheduleAfter(switchingTime, switchTimer);
155 }

Referenced by setRadioMode().

◆ startReception()

void inet::physicallayer::Radio::startReception ( cMessage *  timer,
IRadioSignal::SignalPart  part 
)
protectedvirtual
407 {
408  auto signal = static_cast<WirelessSignal *>(timer->getControlInfo());
409  auto arrival = signal->getArrival();
410  auto reception = signal->getReception();
411  // TODO should be this, but it breaks fingerprints: if (receptionTimer == nullptr && isReceiverMode(radioMode) && arrival->getStartTime(part) == simTime()) {
412  if (isReceiverMode(radioMode) && arrival->getStartTime(part) == simTime()) {
413  auto transmission = signal->getTransmission();
414  auto isReceptionAttempted = medium->isReceptionAttempted(this, transmission, part);
415  EV_INFO << "Reception started: " << (isReceptionAttempted ? "\x1b[1mattempting\x1b[0m" : "\x1b[1mnot attempting\x1b[0m") << " " << (IWirelessSignal *)signal << " " << IRadioSignal::getSignalPartName(part) << " as " << reception << endl;
416  if (isReceptionAttempted) {
417  receptionTimer = timer;
418  emit(receptionStartedSignal, check_and_cast<const cObject *>(reception));
419  }
420  }
421  else
422  EV_INFO << "Reception started: \x1b[1mignoring\x1b[0m " << (IWirelessSignal *)signal << " " << IRadioSignal::getSignalPartName(part) << " as " << reception << endl;
423  timer->setKind(part);
424  scheduleAt(arrival->getEndTime(part), timer);
427  // TODO move to radio medium
428  check_and_cast<RadioMedium *>(medium.get())->emit(IRadioMedium::signalArrivalStartedSignal, check_and_cast<const cObject *>(reception));
429 }

Referenced by handleSignal().

◆ startTransmission()

void inet::physicallayer::Radio::startTransmission ( Packet macFrame,
IRadioSignal::SignalPart  part 
)
protectedvirtual
316 {
317  auto signal = createSignal(macFrame);
318  auto transmission = signal->getTransmission();
319  transmissionTimer->setKind(part);
320  transmissionTimer->setContextPointer(const_cast<WirelessSignal *>(signal));
321 
322 #ifdef NS3_VALIDATION
323  auto *df = dynamic_cast<inet::ieee80211::Ieee80211DataHeader *>(macFrame);
324  const char *ac = "NA";
325  if (df != nullptr && df->getType() == inet::ieee80211::ST_DATA_WITH_QOS) {
326  switch (df->getTid()) {
327  case 1: case 2: ac = "AC_BK"; break;
328  case 0: case 3: ac = "AC_BE"; break;
329  case 4: case 5: ac = "AC_VI"; break;
330  case 6: case 7: ac = "AC_VO"; break;
331  default: ac = "???"; break;
332  }
333  }
334  const char *lastSeq = strchr(macFrame->getName(), '-');
335  if (lastSeq == nullptr)
336  lastSeq = "-1";
337  else
338  lastSeq++;
339  std::cout << "TX: node = " << getId() << ", ac = " << ac << ", seq = " << lastSeq << ", start = " << simTime().inUnit(SIMTIME_PS) << ", duration = " << signal->getDuration().inUnit(SIMTIME_PS) << std::endl;
340 #endif
341 
342  scheduleAt(transmission->getEndTime(part), transmissionTimer);
343  EV_INFO << "Transmission started: " << (IWirelessSignal *)signal << " " << IRadioSignal::getSignalPartName(part) << " as " << transmission << endl;
346  emit(transmissionStartedSignal, check_and_cast<const cObject *>(transmission));
347  // TODO move to radio medium
348  check_and_cast<RadioMedium *>(medium.get())->emit(IRadioMedium::signalDepartureStartedSignal, check_and_cast<const cObject *>(transmission));
349 }

Referenced by handleUpperPacket().

◆ updateTransceiverPart()

void inet::physicallayer::Radio::updateTransceiverPart ( )
protectedvirtual
582 {
584  if (receivedSignalPart != newReceivedPart) {
585  EV_INFO << "Changing radio received signal part from \x1b[1m" << IRadioSignal::getSignalPartName(receivedSignalPart) << "\x1b[0m to \x1b[1m" << IRadioSignal::getSignalPartName(newReceivedPart) << "\x1b[0m." << endl;
586  receivedSignalPart = newReceivedPart;
588  }
590  if (transmittedSignalPart != newTransmittedPart) {
591  EV_INFO << "Changing radio transmitted signal part from \x1b[1m" << IRadioSignal::getSignalPartName(transmittedSignalPart) << "\x1b[0m to \x1b[1m" << IRadioSignal::getSignalPartName(newTransmittedPart) << "\x1b[0m." << endl;
592  transmittedSignalPart = newTransmittedPart;
594  }
595 }

Referenced by abortReception(), abortTransmission(), completeRadioModeSwitch(), continueReception(), continueTransmission(), endReception(), endTransmission(), startReception(), and startTransmission().

◆ updateTransceiverState()

void inet::physicallayer::Radio::updateTransceiverState ( )
protectedvirtual
550 {
551  // reception state
552  ReceptionState newRadioReceptionState;
554  newRadioReceptionState = RECEPTION_STATE_UNDEFINED;
555  else if (receptionTimer && receptionTimer->isScheduled())
556  newRadioReceptionState = RECEPTION_STATE_RECEIVING;
557  else if (isListeningPossible())
558  newRadioReceptionState = RECEPTION_STATE_BUSY;
559  else
560  newRadioReceptionState = RECEPTION_STATE_IDLE;
561  if (receptionState != newRadioReceptionState) {
562  EV_INFO << "Changing radio reception state from \x1b[1m" << getRadioReceptionStateName(receptionState) << "\x1b[0m to \x1b[1m" << getRadioReceptionStateName(newRadioReceptionState) << "\x1b[0m." << endl;
563  receptionState = newRadioReceptionState;
564  emit(receptionStateChangedSignal, newRadioReceptionState);
565  }
566  // transmission state
567  TransmissionState newRadioTransmissionState;
569  newRadioTransmissionState = TRANSMISSION_STATE_UNDEFINED;
570  else if (transmissionTimer->isScheduled())
571  newRadioTransmissionState = TRANSMISSION_STATE_TRANSMITTING;
572  else
573  newRadioTransmissionState = TRANSMISSION_STATE_IDLE;
574  if (transmissionState != newRadioTransmissionState) {
575  EV_INFO << "Changing radio transmission state from \x1b[1m" << getRadioTransmissionStateName(transmissionState) << "\x1b[0m to \x1b[1m" << getRadioTransmissionStateName(newRadioTransmissionState) << "\x1b[0m." << endl;
576  transmissionState = newRadioTransmissionState;
577  emit(transmissionStateChangedSignal, newRadioTransmissionState);
578  }
579 }

Referenced by abortReception(), abortTransmission(), completeRadioModeSwitch(), continueReception(), continueTransmission(), endReception(), endTransmission(), startReception(), and startTransmission().

Member Data Documentation

◆ antenna

const IAntenna* inet::physicallayer::Radio::antenna = nullptr
protected

The radio antenna model is never nullptr.

Referenced by initialize(), isListeningPossible(), and printToStream().

◆ id

const int inet::physicallayer::Radio::id = nextId++
protected

An identifier which is globally unique for the whole lifetime of the simulation among all radios.

◆ medium

ModuleRefByPar<IRadioMedium> inet::physicallayer::Radio::medium
protected

◆ mediumModuleId

int inet::physicallayer::Radio::mediumModuleId = -1
protected

The module id of the medim model.

Referenced by initialize(), and ~Radio().

◆ nextRadioMode

RadioMode inet::physicallayer::Radio::nextRadioMode = RADIO_MODE_OFF
protected

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.

Referenced by completeRadioModeSwitch(), handleSwitchTimer(), setRadioMode(), and startRadioModeSwitch().

◆ previousRadioMode

RadioMode inet::physicallayer::Radio::previousRadioMode = RADIO_MODE_OFF
protected

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.

Referenced by completeRadioModeSwitch(), and startRadioModeSwitch().

◆ radioIn

cGate* inet::physicallayer::Radio::radioIn = nullptr
protected

◆ radioMode

◆ receivedSignalPart

IRadioSignal::SignalPart inet::physicallayer::Radio::receivedSignalPart = IRadioSignal::SIGNAL_PART_NONE
protected

The current received signal part.

Referenced by getReceivedSignalPart(), initialize(), and updateTransceiverPart().

◆ receiver

◆ receptionState

ReceptionState inet::physicallayer::Radio::receptionState = RECEPTION_STATE_UNDEFINED
protected

The current reception state.

Referenced by initialize(), and updateTransceiverState().

◆ receptionTimer

◆ sendRawBytes

bool inet::physicallayer::Radio::sendRawBytes = false
protected

When true packets are serialized into a sequence of bytes before sending out.

Referenced by createSignal(), and initialize().

◆ separateReceptionParts

bool inet::physicallayer::Radio::separateReceptionParts = false
protected

Determines whether the reception of the preamble, header and data part are simulated separately or not.

Referenced by handleSignal(), and initialize().

◆ separateTransmissionParts

bool inet::physicallayer::Radio::separateTransmissionParts = false
protected

Determines whether the transmission of the preamble, header and data part are simulated separately or not.

Referenced by handleUpperPacket(), and initialize().

◆ switchingTimes

simtime_t inet::physicallayer::Radio::switchingTimes[RADIO_MODE_SWITCHING][RADIO_MODE_SWITCHING]
protected

Simulation time required to switch from one radio mode to another.

Referenced by parseRadioModeSwitchingTimes(), and setRadioMode().

◆ switchTimer

cMessage* inet::physicallayer::Radio::switchTimer = nullptr
protected

The timer that is scheduled to the end of the radio mode switch.

Referenced by handleCrashOperation(), handleSelfMessage(), handleStopOperation(), initialize(), setRadioMode(), startRadioModeSwitch(), and ~Radio().

◆ transmissionState

TransmissionState inet::physicallayer::Radio::transmissionState = TRANSMISSION_STATE_UNDEFINED
protected

The current transmission state.

Referenced by initialize(), and updateTransceiverState().

◆ transmissionTimer

cMessage* inet::physicallayer::Radio::transmissionTimer = nullptr
protected

◆ transmittedSignalPart

IRadioSignal::SignalPart inet::physicallayer::Radio::transmittedSignalPart = IRadioSignal::SIGNAL_PART_NONE
protected

The current transmitted signal part.

Referenced by getTransmittedSignalPart(), initialize(), and updateTransceiverPart().

◆ transmitter

◆ upperLayerIn

cGate* inet::physicallayer::Radio::upperLayerIn = nullptr
protected

Referenced by initialize().

◆ upperLayerOut

cGate* inet::physicallayer::Radio::upperLayerOut = nullptr
protected

Gates.

Referenced by initialize(), and sendUp().


The documentation for this class was generated from the following files:
inet::physicallayer::IRadioSignal::SIGNAL_PART_WHOLE
@ SIGNAL_PART_WHOLE
Definition: IRadioSignal.h:26
inet::INITSTAGE_LAST
INET_API InitStage INITSTAGE_LAST
Operations that no other initializations can depend on, e.g.
inet::physicallayer::IRadio::RECEPTION_STATE_IDLE
@ RECEPTION_STATE_IDLE
The radio medium is free, no signal is detected.
Definition: IRadio.h:136
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::physicallayer::Radio::transmissionTimer
cMessage * transmissionTimer
The timer that is scheduled to the end of the current transmission.
Definition: Radio.h:146
inet::physicallayer::Radio::encapsulate
virtual void encapsulate(Packet *packet) const
Definition: Radio.h:232
inet::physicallayer::IRadioSignal::SIGNAL_PART_NONE
@ SIGNAL_PART_NONE
Definition: IRadioSignal.h:25
inet::physicallayer::Radio::decapsulate
virtual void decapsulate(Packet *packet) const
Definition: Radio.h:233
inet::physicallayer::Radio::handleReceptionTimer
virtual void handleReceptionTimer(cMessage *message)
Definition: Radio.cc:235
inet::physicallayer::Radio::id
const int id
An identifier which is globally unique for the whole lifetime of the simulation among all radios.
Definition: Radio.h:55
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::packetReceivedFromUpperSignal
simsignal_t packetReceivedFromUpperSignal
Definition: Simsignals.cc:88
inet::count
int count(const std::vector< T > &v, const Tk &a)
Definition: stlutils.h:54
inet::physicallayer::Radio::mediumModuleId
int mediumModuleId
The module id of the medim model.
Definition: Radio.h:78
inet::physicallayer::IRadio::RADIO_MODE_SWITCHING
@ RADIO_MODE_SWITCHING
The radio is switching from one mode to another, frame reception or transmission is not possible,...
Definition: IRadio.h:117
inet::physicallayer::Radio::updateTransceiverPart
virtual void updateTransceiverPart()
Definition: Radio.cc:581
inet::physicallayer::Radio::previousRadioMode
RadioMode previousRadioMode
The radio is switching from this radio mode to another if a switch is in progress,...
Definition: Radio.h:121
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::physicallayer::Radio::medium
ModuleRefByPar< IRadioMedium > medium
The radio medium model is never nullptr.
Definition: Radio.h:74
inet::physicallayer::IRadio::RECEPTION_STATE_RECEIVING
@ RECEPTION_STATE_RECEIVING
The radio medium is busy, a signal strong enough to receive is detected.
Definition: IRadio.h:149
inet::physicallayer::Radio::transmittedSignalPart
IRadioSignal::SignalPart transmittedSignalPart
The current transmitted signal part.
Definition: Radio.h:137
inet::physicallayer::Radio::sendRawBytes
bool sendRawBytes
When true packets are serialized into a sequence of bytes before sending out.
Definition: Radio.h:86
inet::physicallayer::Radio::radioIn
cGate * radioIn
Definition: Radio.h:103
inet::physicallayer::IRadioMedium::signalDepartureEndedSignal
static simsignal_t signalDepartureEndedSignal
This simsignal is emitted when a signal departure is ended on the medium.
Definition: IRadioMedium.h:75
inet::physicallayer::IRadio::RECEPTION_STATE_UNDEFINED
@ RECEPTION_STATE_UNDEFINED
The radio medium state is unknown, reception state is meaningless, signal detection is not possible.
Definition: IRadio.h:130
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::receptionStartedSignal
simsignal_t receptionStartedSignal
Definition: Simsignals.cc:118
inet::physicallayer::Radio::startTransmission
virtual void startTransmission(Packet *macFrame, IRadioSignal::SignalPart part)
Definition: Radio.cc:315
inet::physicallayer::IRadio::getRadioModeName
static const char * getRadioModeName(RadioMode radioMode)
Returns the name of the provided radio mode.
Definition: IRadio.cc:46
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::physicallayer::IRadio::ReceptionState
ReceptionState
This enumeration specifies the reception state of the radio.
Definition: IRadio.h:124
inet::physicallayer::Radio::switchTimer
cMessage * switchTimer
The timer that is scheduled to the end of the radio mode switch.
Definition: Radio.h:156
inet::physicallayer::Radio::updateTransceiverState
virtual void updateTransceiverState()
Definition: Radio.cc:549
inet::physicallayer::IRadioMedium::signalArrivalEndedSignal
static simsignal_t signalArrivalEndedSignal
This simsignal is emitted when a signal arrival is ended on the medium.
Definition: IRadioMedium.h:87
inet::physicallayer::IRadioMedium::signalDepartureStartedSignal
static simsignal_t signalDepartureStartedSignal
This simsignal is emitted when a signal departure is started on the medium.
Definition: IRadioMedium.h:69
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::physicallayer::IRadio::transmittedSignalPartChangedSignal
static simsignal_t transmittedSignalPartChangedSignal
This signal is emitted when the transmitted part is changed by the radio.
Definition: IRadio.h:72
inet::physicallayer::Radio::receivedSignalPart
IRadioSignal::SignalPart receivedSignalPart
The current received signal part.
Definition: Radio.h:133
inet::printFieldToString
std::string printFieldToString(const IPrintableObject *object, int level, int evFlags=0)
Definition: IPrintableObject.h:98
inet::physicallayer::IRadioSignal::SIGNAL_PART_HEADER
@ SIGNAL_PART_HEADER
Definition: IRadioSignal.h:28
inet::IPrintableObject::getCompleteStringRepresentation
virtual std::string getCompleteStringRepresentation(int evFlags=0) const
Definition: IPrintableObject.h:78
inet::physicallayer::Radio::isReceptionTimer
virtual bool isReceptionTimer(const cMessage *message) const
Definition: Radio.cc:521
inet::transmissionEndedSignal
simsignal_t transmissionEndedSignal
Definition: Simsignals.cc:117
inet::physicallayer::IRadioSignal::SIGNAL_PART_PREAMBLE
@ SIGNAL_PART_PREAMBLE
Definition: IRadioSignal.h:27
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::receptionEndedSignal
simsignal_t receptionEndedSignal
Definition: Simsignals.cc:119
inet::physicallayer::Radio::abortReception
virtual void abortReception(cMessage *timer)
Definition: Radio.cc:489
inet::physicallayer::Radio::startRadioModeSwitch
void startRadioModeSwitch(RadioMode newRadioMode, simtime_t switchingTime)
Definition: Radio.cc:147
EV_FIELD
#define EV_FIELD(...)
Definition: INETDefs.h:112
inet::transmissionStartedSignal
simsignal_t transmissionStartedSignal
Definition: Simsignals.cc:116
inet::physicallayer::Radio::parseRadioModeSwitchingTimes
void parseRadioModeSwitchingTimes()
Definition: Radio.cc:116
inet::physicallayer::Radio::receiver
const IReceiver * receiver
The receiver model is never nullptr.
Definition: Radio.h:70
inet::physicallayer::Radio::separateTransmissionParts
bool separateTransmissionParts
Determines whether the transmission of the preamble, header and data part are simulated separately or...
Definition: Radio.h:91
inet::physicallayer::Radio::receptionTimer
cMessage * receptionTimer
The timer that is scheduled to the end of the current reception.
Definition: Radio.h:152
inet::physicallayer::IRadioMedium::signalArrivalStartedSignal
static simsignal_t signalArrivalStartedSignal
This simsignal is emitted when a signal arrival is started on the medium.
Definition: IRadioMedium.h:81
inet::physicallayer::Radio::startReception
virtual void startReception(cMessage *timer, IRadioSignal::SignalPart part)
Definition: Radio.cc:406
inet::physicallayer::PhysicalLayerBase::initialize
virtual void initialize(int stage) override
Definition: PhysicalLayerBase.cc:16
inet::physicallayer::Radio::abortTransmission
virtual void abortTransmission()
Definition: Radio.cc:379
inet::physicallayer::Radio::isListeningPossible
virtual bool isListeningPossible() const
Definition: Radio.cc:536
inet::physicallayer::IAntenna::getMobility
virtual IMobility * getMobility() const =0
Returns the mobility of this antenna that describes its position and orientation over time.
inet::physicallayer::Radio::sendUp
virtual void sendUp(Packet *macFrame)
Definition: Radio.cc:507
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::IPrintableObject::PRINT_LEVEL_TRACE
@ PRINT_LEVEL_TRACE
Definition: IPrintableObject.h:22
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::physicallayer::IRadioSignal::SignalPart
SignalPart
This enumeration specifies a part of a radio signal.
Definition: IRadioSignal.h:24
inet::physicallayer::Radio::createSignal
virtual WirelessSignal * createSignal(Packet *packet) const
Definition: Radio.cc:392
inet::physicallayer::Radio::receptionState
ReceptionState receptionState
The current reception state.
Definition: Radio.h:125
inet::physicallayer::IRadioSignal::getSignalPartName
static const char * getSignalPartName(SignalPart signalPart)
Returns the name of the provided signal part.
Definition: IRadioSignal.cc:23
inet::physicallayer::Radio::separateReceptionParts
bool separateReceptionParts
Determines whether the reception of the preamble, header and data part are simulated separately or no...
Definition: Radio.h:96
inet::physicallayer::Radio::createReceptionTimer
virtual cMessage * createReceptionTimer(WirelessSignal *signal) const
Definition: Radio.cc:514
inet::physicallayer::Radio::endReception
virtual void endReception(cMessage *timer)
Definition: Radio.cc:460
inet::physicallayer::IRadioSignal::SIGNAL_PART_DATA
@ SIGNAL_PART_DATA
Definition: IRadioSignal.h:29
inet::ieee80211::ST_DATA_WITH_QOS
@ ST_DATA_WITH_QOS
Definition: Ieee80211Frame_m.h:169
inet::physicallayer::Radio::continueReception
virtual void continueReception(cMessage *timer)
Definition: Radio.cc:431
inet::ieee80211::Ieee80211DataHeader
Class generated from inet/linklayer/ieee80211/mac/Ieee80211Frame.msg:199 by opp_msgtool.
Definition: Ieee80211Frame_m.h:627
inet::physicallayer::IRadio::RECEPTION_STATE_BUSY
@ RECEPTION_STATE_BUSY
The radio medium is busy, a signal is detected but it is not strong enough to receive.
Definition: IRadio.h:143
inet::evFlags
int evFlags
Definition: INETDefs.cc:12
inet::physicallayer::Radio::transmissionState
TransmissionState transmissionState
The current transmission state.
Definition: Radio.h:129
inet::physicallayer::IReceiver::createListening
virtual const IListening * createListening(const IRadio *radio, const simtime_t startTime, const simtime_t endTime, const Coord &startPosition, const Coord &endPosition) const =0
Returns a description of how the receiver is listening on the medium.
inet::physicallayer::RADIO_C_CONFIGURE
@ RADIO_C_CONFIGURE
Definition: RadioControlInfo_m.h:62
inet::physicallayer::Radio::nextRadioMode
RadioMode nextRadioMode
The radio is switching to this radio radio mode if a switch is in progress, otherwise this is the sam...
Definition: Radio.h:116
inet::physicallayer::Radio::antenna
const IAntenna * antenna
The radio antenna model is never nullptr.
Definition: Radio.h:62
inet::physicallayer::Radio::upperLayerIn
cGate * upperLayerIn
Definition: Radio.h:102
inet::physicallayer::Radio::upperLayerOut
cGate * upperLayerOut
Gates.
Definition: Radio.h:101
inet::physicallayer::IRadio::getRadioReceptionStateName
static const char * getRadioReceptionStateName(ReceptionState receptionState)
Returns the name of the provided radio reception state.
Definition: IRadio.cc:53
Enter_Method
#define Enter_Method(...)
Definition: SelfDoc.h:71
inet::physicallayer::IRadio::TransmissionState
TransmissionState
This enumeration specifies the transmission state of the radio.
Definition: IRadio.h:155
inet::physicallayer::Radio::isTransmitterMode
virtual bool isTransmitterMode(IRadio::RadioMode radioMode) const
Definition: Radio.cc:531
inet::physicallayer::Radio::initializeRadioMode
virtual void initializeRadioMode()
Definition: Radio.cc:72
inet::physicallayer::IRadio::RadioMode
RadioMode
This enumeration specifies the requested operational mode of the radio.
Definition: IRadio.h:79
inet::physicallayer::Radio::setRadioMode
virtual void setRadioMode(RadioMode newRadioMode) override
Changes the current radio mode.
Definition: Radio.cc:98
inet::physicallayer::Radio::endTransmission
virtual void endTransmission()
Definition: Radio.cc:365
inet::physicallayer::IRadio::getRadioTransmissionStateName
static const char * getRadioTransmissionStateName(TransmissionState transmissionState)
Returns the name of the provided radio transmission state.
Definition: IRadio.cc:60
inet::packetSentToUpperSignal
simsignal_t packetSentToUpperSignal
Definition: Simsignals.cc:87
inet::IMobility::getCurrentPosition
virtual const Coord & getCurrentPosition()=0
Returns the position at the current simulation time.
inet::physicallayer::IRadio::TRANSMISSION_STATE_UNDEFINED
@ TRANSMISSION_STATE_UNDEFINED
The transmission state is undefined or meaningless.
Definition: IRadio.h:160
inet::physicallayer::Radio::handleTransmissionTimer
virtual void handleTransmissionTimer(cMessage *message)
Definition: Radio.cc:221
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::OperationalMixin< cSimpleModule >::handleMessageWhenDown
virtual void handleMessageWhenDown(cMessage *msg)
Definition: OperationalMixinImpl.h:71
inet::physicallayer::Radio::continueTransmission
virtual void continueTransmission()
Definition: Radio.cc:351
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::physicallayer::Radio::radioMode
RadioMode radioMode
State.
Definition: Radio.h:111
inet::physicallayer::Radio::completeRadioModeSwitch
void completeRadioModeSwitch(RadioMode newRadioMode)
Definition: Radio.cc:157
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::Radio::isReceiverMode
virtual bool isReceiverMode(IRadio::RadioMode radioMode) const
Definition: Radio.cc:526
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
inet::physicallayer::Radio::handleSwitchTimer
virtual void handleSwitchTimer(cMessage *message)
Definition: Radio.cc:216
inet::physicallayer::Radio::switchingTimes
simtime_t switchingTimes[RADIO_MODE_SWITCHING][RADIO_MODE_SWITCHING]
Simulation time required to switch from one radio mode to another.
Definition: Radio.h:82