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

#include <ShortcutRadio.h>

Inheritance diagram for inet::physicallayer::ShortcutRadio:
inet::physicallayer::PhysicalLayerBase inet::physicallayer::IRadio inet::LayeredProtocolBase inet::IPhysicalLayer inet::IPhysicalLayer inet::IPrintableObject inet::OperationalBase inet::OperationalMixin< cSimpleModule > inet::ILifecycle

Public Member Functions

virtual void handleMessageWhenUp (cMessage *message) override
 
virtual void handleUpperPacket (Packet *packet) override
 
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 radioMode) override
 
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 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 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 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 handleStartOperation (LifecycleOperation *operation) override
 
virtual void handleStopOperation (LifecycleOperation *operation) override
 
virtual void handleCrashOperation (LifecycleOperation *operation) override
 
- 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::physicallayer::IRadio
virtual void setRadioMode (RadioMode radioMode)=0
 Changes the current radio mode. More...
 
- Public Member Functions inherited from inet::IPrintableObject
virtual ~IPrintableObject ()
 
virtual std::ostream & printToStream (std::ostream &stream, int level, int evFlags=0) const
 Prints this object to the provided output stream. More...
 
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 ShortcutRadiofindPeer (MacAddress address)
 
virtual void sendToPeer (Packet *packet, ShortcutRadio *peer)
 
virtual void receiveFromPeer (Packet *packet)
 
- Protected Member Functions inherited from inet::physicallayer::PhysicalLayerBase
virtual void handleSignal (WirelessSignal *signal)
 
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 handleSelfMessage (cMessage *message)
 
virtual void handleUpperMessage (cMessage *message)
 
virtual void handleUpperCommand (cMessage *message)
 
virtual void handleLowerCommand (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 void handleMessageWhenDown (cMessage *msg)
 
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

RadioMode radioMode = RADIO_MODE_OFF
 
double bitrate = NaN
 
cPar * lengthOverhead = nullptr
 
cPar * durationOverhead = nullptr
 
cPar * propagationDelay = nullptr
 
cPar * packetLoss = nullptr
 
TransmissionState transmissionState = TRANSMISSION_STATE_UNDEFINED
 
- 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
 

Static Protected Attributes

static std::map< MacAddress, ShortcutRadio * > shortcutRadios
 
- 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...
 

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
 

Member Function Documentation

◆ findPeer()

ShortcutRadio * inet::physicallayer::ShortcutRadio::findPeer ( MacAddress  address)
protectedvirtual
77 {
78  auto it = shortcutRadios.find(address);
79  return (it == shortcutRadios.end()) ? nullptr : it->second;
80 }

Referenced by handleUpperPacket().

◆ getAntenna()

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

Returns the antenna used by the transceiver of this radio.

This function never returns nullptr.

Implements inet::physicallayer::IRadio.

51 { return nullptr; }

◆ getId()

virtual int inet::physicallayer::ShortcutRadio::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.

50 { return -1; }

◆ getMedium()

virtual const IRadioMedium* inet::physicallayer::ShortcutRadio::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.

54 { return nullptr; }

◆ getRadioGate()

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

Returns the gate of the radio that receives incoming signals.

Implements inet::physicallayer::IRadio.

45 { return gate("radioIn"); }

◆ getRadioMode()

virtual RadioMode inet::physicallayer::ShortcutRadio::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.

46 { return radioMode; }

◆ getReceivedSignalPart()

virtual IRadioSignal::SignalPart inet::physicallayer::ShortcutRadio::getReceivedSignalPart ( ) const
inlineoverridevirtual

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.

◆ getReceiver()

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

Returns the receiver part of this radio.

This function never returns nullptr.

Implements inet::physicallayer::IRadio.

53 { return nullptr; }

◆ getReceptionInProgress()

virtual const ITransmission* inet::physicallayer::ShortcutRadio::getReceptionInProgress ( ) const
inlineoverridevirtual

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

Implements inet::physicallayer::IRadio.

56 { return nullptr; }

◆ getReceptionState()

virtual ReceptionState inet::physicallayer::ShortcutRadio::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.

48 { return RECEPTION_STATE_UNDEFINED; }

◆ getTransmissionInProgress()

virtual const ITransmission* inet::physicallayer::ShortcutRadio::getTransmissionInProgress ( ) const
inlineoverridevirtual

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

Implements inet::physicallayer::IRadio.

55 { return nullptr; }

◆ getTransmissionState()

virtual TransmissionState inet::physicallayer::ShortcutRadio::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.

49 { return transmissionState; }

◆ getTransmittedSignalPart()

virtual IRadioSignal::SignalPart inet::physicallayer::ShortcutRadio::getTransmittedSignalPart ( ) const
inlineoverridevirtual

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.

◆ getTransmitter()

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

Returns the transmitter part of this radio.

This function never returns nullptr.

Implements inet::physicallayer::IRadio.

52 { return nullptr; }

◆ handleCrashOperation()

virtual void inet::physicallayer::ShortcutRadio::handleCrashOperation ( LifecycleOperation operation)
inlineoverridevirtual

Implements inet::OperationalMixin< cSimpleModule >.

63 {} // TODO implementation

◆ handleMessageWhenUp()

void inet::physicallayer::ShortcutRadio::handleMessageWhenUp ( cMessage *  message)
overridevirtual

Reimplemented from inet::LayeredProtocolBase.

47 {
48  if (message->getArrivalGate() == gate("radioIn"))
49  receiveFromPeer(check_and_cast<Packet *>(message));
50  else
52 }

◆ handleStartOperation()

virtual void inet::physicallayer::ShortcutRadio::handleStartOperation ( LifecycleOperation operation)
inlineoverridevirtual

Implements inet::OperationalMixin< cSimpleModule >.

61 {} // TODO implementation

◆ handleStopOperation()

virtual void inet::physicallayer::ShortcutRadio::handleStopOperation ( LifecycleOperation operation)
inlineoverridevirtual

Implements inet::OperationalMixin< cSimpleModule >.

62 {} // TODO implementation

◆ handleUpperPacket()

void inet::physicallayer::ShortcutRadio::handleUpperPacket ( Packet packet)
overridevirtual

Reimplemented from inet::LayeredProtocolBase.

55 {
56  auto destination = packet->getTag<MacAddressReq>()->getDestAddress();
59  if (destination.isBroadcast()) {
60  for (auto it : shortcutRadios)
61  if (it.second != this)
62  sendToPeer(packet->dup(), it.second);
63  delete packet;
64  }
65  else {
66  auto peer = findPeer(destination);
67  if (peer != nullptr)
68  sendToPeer(packet, peer);
69  else
70  throw cRuntimeError("ShortcutRadio not found");
71  }
72  transmissionState = IRadio::TRANSMISSION_STATE_IDLE; // TODO zero time transmission simulated
74 }

◆ initialize()

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

Reimplemented from inet::physicallayer::PhysicalLayerBase.

27 {
29  if (stage == INITSTAGE_LOCAL) {
30  bitrate = par("bitrate");
31  lengthOverhead = &par("lengthOverhead");
32  durationOverhead = &par("durationOverhead");
33  propagationDelay = &par("propagationDelay");
34  packetLoss = &par("packetLoss");
35  gate("radioIn")->setDeliverImmediately(true);
36  }
37  // TODO INITSTAGE
38  else if (stage == INITSTAGE_LINK_LAYER) {
39  auto interfaceTable = getModuleFromPar<IInterfaceTable>(par("interfaceTableModule"), this);
40  auto networkInterface = CHK(interfaceTable->findInterfaceByInterfaceModule(this));
41  auto address = networkInterface->getMacAddress();
42  shortcutRadios[address] = this;
43  }
44 }

◆ receiveFromPeer()

void inet::physicallayer::ShortcutRadio::receiveFromPeer ( Packet packet)
protectedvirtual
107 {
108  auto& packetProtocolTag = packet->getTagForUpdate<PacketProtocolTag>();
109  if (packetProtocolTag->getProtocol() == &Protocol::shortcutPhy) {
110  const auto& header = packet->popAtFront<ShortcutPhyHeader>();
111  packetProtocolTag->setProtocol(header->getPayloadProtocol());
112  }
113  emit(packetSentToUpperSignal, packet);
114  send(packet, gate("upperLayerOut"));
115 }

Referenced by handleMessageWhenUp().

◆ sendToPeer()

void inet::physicallayer::ShortcutRadio::sendToPeer ( Packet packet,
ShortcutRadio peer 
)
protectedvirtual
83 {
84  if (dblrand() < packetLoss->doubleValue()) {
85  EV_WARN << "Packet " << packet << " lost.";
86  delete packet;
87  }
88  else {
89  auto length = b(lengthOverhead->intValue());
90  if (length < b(0))
91  throw cRuntimeError("invalid lengthOverhead value: %li bit", length.get());
92  if (length > b(0)) {
93  auto& protocolTag = packet->getTagForUpdate<PacketProtocolTag>();
94  auto header = makeShared<ShortcutPhyHeader>();
95  header->setChunkLength(length);
96  header->setPayloadProtocol(protocolTag->getProtocol());
97  packet->insertAtFront(header);
98  protocolTag->setProtocol(&Protocol::shortcutPhy);
99  }
100  simtime_t transmissionDuration = packet->getBitLength() / bitrate + durationOverhead->doubleValue();
101  packet->setDuration(transmissionDuration);
102  sendDirect(packet, propagationDelay->doubleValue(), transmissionDuration, peer->gate("radioIn")->getPathStartGate());
103  }
104 }

Referenced by handleUpperPacket().

◆ setRadioMode()

virtual void inet::physicallayer::ShortcutRadio::setRadioMode ( RadioMode  radioMode)
inlineoverridevirtual
47 { this->radioMode = radioMode; }

Member Data Documentation

◆ bitrate

double inet::physicallayer::ShortcutRadio::bitrate = NaN
protected

Referenced by initialize(), and sendToPeer().

◆ durationOverhead

cPar* inet::physicallayer::ShortcutRadio::durationOverhead = nullptr
protected

Referenced by initialize(), and sendToPeer().

◆ lengthOverhead

cPar* inet::physicallayer::ShortcutRadio::lengthOverhead = nullptr
protected

Referenced by initialize(), and sendToPeer().

◆ packetLoss

cPar* inet::physicallayer::ShortcutRadio::packetLoss = nullptr
protected

Referenced by initialize(), and sendToPeer().

◆ propagationDelay

cPar* inet::physicallayer::ShortcutRadio::propagationDelay = nullptr
protected

Referenced by initialize(), and sendToPeer().

◆ radioMode

RadioMode inet::physicallayer::ShortcutRadio::radioMode = RADIO_MODE_OFF
protected

◆ shortcutRadios

std::map< MacAddress, ShortcutRadio * > inet::physicallayer::ShortcutRadio::shortcutRadios
staticprotected

◆ transmissionState

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

Referenced by handleUpperPacket().


The documentation for this class was generated from the following files:
CHK
#define CHK(x)
Definition: INETDefs.h:87
inet::physicallayer::ShortcutRadio::durationOverhead
cPar * durationOverhead
Definition: ShortcutRadio.h:29
inet::physicallayer::IRadioSignal::SIGNAL_PART_WHOLE
@ SIGNAL_PART_WHOLE
Definition: IRadioSignal.h:26
inet::LayeredProtocolBase::handleMessageWhenUp
virtual void handleMessageWhenUp(cMessage *message) override
Definition: LayeredProtocolBase.cc:14
inet::physicallayer::ShortcutRadio::transmissionState
TransmissionState transmissionState
Definition: ShortcutRadio.h:32
inet::physicallayer::ShortcutRadio::shortcutRadios
static std::map< MacAddress, ShortcutRadio * > shortcutRadios
Definition: ShortcutRadio.h:23
inet::physicallayer::ShortcutRadio::packetLoss
cPar * packetLoss
Definition: ShortcutRadio.h:31
inet::physicallayer::ShortcutRadio::receiveFromPeer
virtual void receiveFromPeer(Packet *packet)
Definition: ShortcutRadio.cc:106
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::physicallayer::ShortcutRadio::propagationDelay
cPar * propagationDelay
Definition: ShortcutRadio.h:30
inet::physicallayer::ShortcutRadio::findPeer
virtual ShortcutRadio * findPeer(MacAddress address)
Definition: ShortcutRadio.cc:76
PacketProtocolTag
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down PacketProtocolTag
Definition: IUdp-gates.txt:25
inet::physicallayer::ShortcutRadio::radioMode
RadioMode radioMode
Definition: ShortcutRadio.h:26
inet::physicallayer::PhysicalLayerBase::initialize
virtual void initialize(int stage) override
Definition: PhysicalLayerBase.cc:16
inet::physicallayer::ShortcutRadio::lengthOverhead
cPar * lengthOverhead
Definition: ShortcutRadio.h:28
inet::physicallayer::ShortcutRadio::sendToPeer
virtual void sendToPeer(Packet *packet, ShortcutRadio *peer)
Definition: ShortcutRadio.cc:82
inet::physicallayer::ShortcutRadio::bitrate
double bitrate
Definition: ShortcutRadio.h:27
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::Protocol::shortcutPhy
static const Protocol shortcutPhy
Definition: Protocol.h:131
inet::units::values::b
value< int64_t, units::b > b
Definition: Units.h:1241
inet::packetSentToUpperSignal
simsignal_t packetSentToUpperSignal
Definition: Simsignals.cc:87
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::INITSTAGE_LINK_LAYER
INET_API InitStage INITSTAGE_LINK_LAYER
Initialization of link-layer protocols.