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

#include <ApskRadio.h>

Inheritance diagram for inet::physicallayer::ApskRadio:
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

 ApskRadio ()
 
- 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
 

Protected Member Functions

virtual void initialize (int stage) override
 
virtual b computePaddingLength (b length, const ConvolutionalCode *forwardErrorCorrection, const ApskModulationBase *modulation) const
 
virtual const ApskModulationBasegetModulation () const
 
virtual void handleUpperPacket (Packet *packet) override
 
virtual void sendUp (Packet *packet) override
 
virtual void encapsulate (Packet *packet) const override
 
virtual void decapsulate (Packet *packet) const override
 
- Protected Member Functions inherited from inet::physicallayer::FlatRadioBase
void handleUpperCommand (cMessage *message) override
 
- Protected Member Functions inherited from inet::physicallayer::NarrowbandRadioBase
void handleUpperCommand (cMessage *message) 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 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 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

const Protocolprotocol = nullptr
 
- 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) }
 
- 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
 
- 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

◆ ApskRadio()

inet::physicallayer::ApskRadio::ApskRadio ( )
24  :
26 {
27 }

Member Function Documentation

◆ computePaddingLength()

b inet::physicallayer::ApskRadio::computePaddingLength ( b  length,
const ConvolutionalCode forwardErrorCorrection,
const ApskModulationBase modulation 
) const
protectedvirtual
60 {
61  int modulationCodeWordSize = modulation->getCodeWordSize();
62  int encodedCodeWordSize = forwardErrorCorrection == nullptr ? modulationCodeWordSize : modulationCodeWordSize *forwardErrorCorrection->getCodeRatePuncturingK();
63  return b((encodedCodeWordSize - b(length).get() % encodedCodeWordSize) % encodedCodeWordSize);
64 }

Referenced by decapsulate(), and encapsulate().

◆ decapsulate()

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

Reimplemented from inet::physicallayer::Radio.

115 {
116  const auto& phyHeader = packet->popAtFront<ApskPhyHeader>(b(-1), Chunk::PF_ALLOW_INCORRECT | Chunk::PF_ALLOW_INCOMPLETE | Chunk::PF_ALLOW_IMPROPERLY_REPRESENTED);
117  if (phyHeader->isIncorrect() || phyHeader->isIncomplete() || phyHeader->isImproperlyRepresented())
118  packet->setBitError(true);
119  b headerLength = phyHeader->getChunkLength();
120 
121 #if 0
122  if (auto flatTransmitter = dynamic_cast<const FlatTransmitterBase *>(transmitter)) {
123  b definedHeaderLength = flatTransmitter->getHeaderLength();
124  if (headerLength != definedHeaderLength)
125  throw cRuntimeError("Incoming header length is incorrect");
126  }
127 #endif
128 
129  auto paddingLength = computePaddingLength(headerLength + phyHeader->getPayloadLengthField(), nullptr, getModulation());
130  if (paddingLength > b(0)) {
131  if (paddingLength <= packet->getDataLength())
132  packet->popAtBack(paddingLength, Chunk::PF_ALLOW_INCORRECT);
133  else
134  packet->setBitError(true);
135  }
136 
137  // KLUDGE? higher layers accepts only byte length packets started on byte position
138  if (packet->getBitLength() % 8 != 0 || headerLength.get() % 8 != 0)
139  packet->setBitError(true);
140 
141  if (phyHeader->getPayloadLengthField() > packet->getDataLength())
142  packet->setBitError(true);
143 
144  packet->addTagIfAbsent<PacketProtocolTag>()->setProtocol(phyHeader->getPayloadProtocol());
145 }

◆ encapsulate()

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

Reimplemented from inet::physicallayer::Radio.

93 {
94  auto phyHeader = makeShared<ApskPhyHeader>();
95  phyHeader->setCrc(0);
96  phyHeader->setCrcMode(CRC_DISABLED);
97  phyHeader->setPayloadLengthField(packet->getDataLength());
98  phyHeader->setPayloadProtocol(packet->getTag<PacketProtocolTag>()->getProtocol());
99  b headerLength = phyHeader->getChunkLength();
100  if (auto flatTransmitter = dynamic_cast<const FlatTransmitterBase *>(transmitter)) {
101  headerLength = flatTransmitter->getHeaderLength();
102  phyHeader->setChunkLength(headerLength);
103  }
104  phyHeader->setHeaderLengthField(headerLength);
105  packet->insertAtFront(phyHeader);
106 
107  auto paddingLength = computePaddingLength(headerLength + phyHeader->getPayloadLengthField(), nullptr, getModulation());
108  if (paddingLength != b(0))
109  packet->insertAtBack(makeShared<BitCountChunk>(paddingLength));
110  EV_DEBUG << "ApskRadio::encapsulate: packetLength=" << packet->getDataLength() << ", headerLength=" << headerLength << ", paddingLength=" << paddingLength << endl;
111  packet->getTagForUpdate<PacketProtocolTag>()->setProtocol(&Protocol::apskPhy);
112 }

◆ getModulation()

const ApskModulationBase * inet::physicallayer::ApskRadio::getModulation ( ) const
protectedvirtual
67 {
68  const ApskModulationBase *modulation = nullptr;
69 // const ConvolutionalCode *forwardErrorCorrection = nullptr; // TODO
70  auto phyHeader = makeShared<ApskPhyHeader>();
71  b headerLength = phyHeader->getChunkLength();
72 
73  // KLUDGE
74  if (auto flatTransmitter = dynamic_cast<const FlatTransmitterBase *>(transmitter)) {
75  headerLength = flatTransmitter->getHeaderLength();
76  modulation = check_and_cast<const ApskModulationBase *>(flatTransmitter->getModulation());
77  }
78  // KLUDGE
79  else if (auto layeredTransmitter = dynamic_cast<const ApskLayeredTransmitter *>(transmitter)) {
80  auto encoder = layeredTransmitter->getEncoder();
81  if (encoder != nullptr) {
82 // const ApskEncoder *apskEncoder = check_and_cast<const ApskEncoder *>(encoder);
83 // forwardErrorCorrection = apskEncoder->getCode()->getConvolutionalCode(); // TODO
84  }
85  modulation = check_and_cast<const ApskModulationBase *>(layeredTransmitter->getModulator()->getModulation());
86  }
87  // FIXME when uses OFDM, ofdm modulator can not cast to apsk modulator, see /examples/wireless/layered80211/ -f omnetpp.ini -c LayeredCompliant80211Ping
88  ASSERT(modulation != nullptr);
89  return modulation;
90 }

Referenced by decapsulate(), and encapsulate().

◆ handleUpperPacket()

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

Reimplemented from inet::physicallayer::Radio.

40 {
41  if (protocol != nullptr && protocol != packet->getTag<PacketProtocolTag>()->getProtocol())
42  throw cRuntimeError("Packet received with incorrect protocol");
43  else
45 }

◆ initialize()

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

Reimplemented from inet::physicallayer::Radio.

30 {
31  Radio::initialize(stage);
32  if (stage == INITSTAGE_LOCAL) {
33  const char *protocolName = par("protocol");
34  if (*protocolName != '\0')
35  protocol = Protocol::getProtocol(protocolName);
36  }
37 }

◆ sendUp()

void inet::physicallayer::ApskRadio::sendUp ( Packet packet)
overrideprotectedvirtual

Reimplemented from inet::physicallayer::Radio.

48 {
49  if (protocol != nullptr && protocol != packet->getTag<PacketProtocolTag>()->getProtocol()) {
50  PacketDropDetails details;
51  details.setReason(PacketDropReason::OTHER_PACKET_DROP);
52  emit(packetDroppedSignal, packet, &details);
53  delete packet;
54  }
55  else
56  FlatRadioBase::sendUp(packet);
57 }

Member Data Documentation

◆ protocol

const Protocol* inet::physicallayer::ApskRadio::protocol = nullptr
protected

The documentation for this class was generated from the following files:
inet::physicallayer::ApskRadio::getModulation
virtual const ApskModulationBase * getModulation() const
Definition: ApskRadio.cc:66
inet::Protocol::apskPhy
static const Protocol apskPhy
Definition: Protocol.h:123
inet::physicallayer::FlatRadioBase::FlatRadioBase
FlatRadioBase()
Definition: FlatRadioBase.cc:20
inet::Protocol::getProtocol
static const Protocol * getProtocol(int id)
Definition: Protocol.cc:50
inet::Chunk::PF_ALLOW_IMPROPERLY_REPRESENTED
@ PF_ALLOW_IMPROPERLY_REPRESENTED
Definition: Chunk.h:282
inet::CRC_DISABLED
@ CRC_DISABLED
Definition: CrcMode_m.h:56
inet::packetDroppedSignal
simsignal_t packetDroppedSignal
Definition: Simsignals.cc:85
PacketProtocolTag
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down PacketProtocolTag
Definition: IUdp-gates.txt:25
inet::Chunk::PF_ALLOW_INCOMPLETE
@ PF_ALLOW_INCOMPLETE
Definition: Chunk.h:280
inet::physicallayer::Radio::handleUpperPacket
virtual void handleUpperPacket(Packet *packet) override
Definition: Radio.cc:266
inet::physicallayer::ApskRadio::computePaddingLength
virtual b computePaddingLength(b length, const ConvolutionalCode *forwardErrorCorrection, const ApskModulationBase *modulation) const
Definition: ApskRadio.cc:59
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::Radio::transmitter
const ITransmitter * transmitter
The transmitter model is never nullptr.
Definition: Radio.h:66
inet::OTHER_PACKET_DROP
@ OTHER_PACKET_DROP
Definition: Simsignals_m.h:84
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::Radio::initialize
virtual void initialize(int stage) override
Definition: Radio.cc:36
inet::physicallayer::ApskRadio::protocol
const Protocol * protocol
Definition: ApskRadio.h:23