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

#include <FlatReceiverBase.h>

Inheritance diagram for inet::physicallayer::FlatReceiverBase:
inet::physicallayer::NarrowbandReceiverBase inet::physicallayer::SnirReceiverBase inet::physicallayer::ReceiverBase inet::physicallayer::IReceiver inet::IPrintableObject inet::physicallayer::ApskDimensionalReceiver inet::physicallayer::ApskScalarReceiver inet::physicallayer::Ieee80211ReceiverBase inet::physicallayer::Ieee802154NarrowbandDimensionalReceiver inet::physicallayer::Ieee802154NarrowbandScalarReceiver inet::physicallayer::Ieee80211DimensionalReceiver inet::physicallayer::Ieee80211ScalarReceiver

Public Member Functions

 FlatReceiverBase ()
 
virtual std::ostream & printToStream (std::ostream &stream, int level, int evFlags=0) const override
 Prints this object to the provided output stream. More...
 
virtual W getMinReceptionPower () const override
 Returns the minimum reception power below which successful reception is definitely not possible. More...
 
virtual const IListeningDecisioncomputeListeningDecision (const IListening *listening, const IInterference *interference) const override
 Returns the result of the listening process specifying the reception state of the receiver. More...
 
virtual const IReceptionResultcomputeReceptionResult (const IListening *listening, const IReception *reception, const IInterference *interference, const ISnir *snir, const std::vector< const IReceptionDecision * > *decisions) const override
 Returns the complete result of the reception process for the provided reception. More...
 
virtual const IErrorModelgetErrorModel () const
 
virtual W getEnergyDetection () const
 
virtual void setEnergyDetection (W energyDetection)
 
virtual W getSensitivity () const
 
virtual void setSensitivity (W sensitivity)
 
- Public Member Functions inherited from inet::physicallayer::NarrowbandReceiverBase
 NarrowbandReceiverBase ()
 
virtual const IListeningcreateListening (const IRadio *radio, const simtime_t startTime, const simtime_t endTime, const Coord &startPosition, const Coord &endPosition) const override
 Returns a description of how the receiver is listening on the medium. More...
 
virtual bool computeIsReceptionPossible (const IListening *listening, const ITransmission *transmission) const override
 Returns whether the reception of the provided transmission is possible or not independently of the reception conditions. More...
 
virtual const IReceptionDecisioncomputeReceptionDecision (const IListening *listening, const IReception *reception, IRadioSignal::SignalPart part, const IInterference *interference, const ISnir *snir) const override
 Returns the reception decision for the transmission part that specifies whether the reception is possible, attempted, and successful. More...
 
virtual const IModulationgetModulation () const
 
virtual void setModulation (const IModulation *modulation)
 
virtual Hz getCenterFrequency () const
 
virtual void setCenterFrequency (Hz centerFrequency)
 
virtual Hz getBandwidth () const
 
virtual void setBandwidth (Hz bandwidth)
 
- Public Member Functions inherited from inet::physicallayer::SnirReceiverBase
virtual double getSNIRThreshold () const
 
- Public Member Functions inherited from inet::physicallayer::ReceiverBase
 ReceiverBase ()
 
virtual W getMinInterferencePower () const override
 Returns the minimum interference power below which receptions are to be ignored while computing the interference. More...
 
virtual bool computeIsReceptionAttempted (const IListening *listening, const IReception *reception, IRadioSignal::SignalPart part, const IInterference *interference) const override
 Returns whether the reception of the provided part is actually attempted or ignored by the receiver. More...
 
- 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 bool computeIsReceptionPossible (const IListening *listening, const IReception *reception, IRadioSignal::SignalPart part) const override
 Returns whether the reception of the provided part is possible or not. More...
 
virtual bool computeIsReceptionSuccessful (const IListening *listening, const IReception *reception, IRadioSignal::SignalPart part, const IInterference *interference, const ISnir *snir) const override
 Returns whether the reception of the provided part is actually successful or failed by the receiver. More...
 
virtual PacketcomputeReceivedPacket (const ISnir *snir, bool isReceptionSuccessful) const override
 
virtual bool computeIsReceptionPossible (const IListening *listening, const ITransmission *transmission) const override
 
virtual bool computeIsReceptionPossible (const IListening *listening, const IReception *reception, IRadioSignal::SignalPart part) const override
 
- Protected Member Functions inherited from inet::physicallayer::ReceiverBase
virtual int numInitStages () const override
 
virtual W computeSignalPower (const IListening *listening, const ISnir *snir, const IInterference *interference) const
 

Protected Attributes

const IErrorModelerrorModel
 
W energyDetection
 
W sensitivity
 
- Protected Attributes inherited from inet::physicallayer::NarrowbandReceiverBase
const IModulationmodulation
 
Hz centerFrequency
 
Hz bandwidth
 
- Protected Attributes inherited from inet::physicallayer::SnirReceiverBase
double snirThreshold = NaN
 
SnirThresholdMode snirThresholdMode = SnirThresholdMode::STM_UNDEFINED
 

Additional Inherited Members

- Public Types inherited from inet::IPrintableObject
enum  PrintLevel {
  PRINT_LEVEL_TRACE, PRINT_LEVEL_DEBUG, PRINT_LEVEL_DETAIL, PRINT_LEVEL_INFO,
  PRINT_LEVEL_COMPLETE = INT_MIN
}
 
enum  PrintFlag { PRINT_FLAG_FORMATTED = (1 << 0), PRINT_FLAG_MULTILINE = (1 << 1) }
 
- Protected Types inherited from inet::physicallayer::SnirReceiverBase
enum  SnirThresholdMode { SnirThresholdMode::STM_UNDEFINED = -1, SnirThresholdMode::STM_MIN, SnirThresholdMode::STM_MEAN }
 

Constructor & Destructor Documentation

◆ FlatReceiverBase()

inet::physicallayer::FlatReceiverBase::FlatReceiverBase ( )
22  :
24  errorModel(nullptr),
26  sensitivity(W(NaN))
27 {
28 }

Member Function Documentation

◆ computeIsReceptionPossible() [1/3]

bool inet::physicallayer::NarrowbandReceiverBase::computeIsReceptionPossible
overrideprotected
64 {
65  const BandListening *bandListening = check_and_cast<const BandListening *>(listening);
66  const NarrowbandReceptionBase *narrowbandReception = check_and_cast<const NarrowbandReceptionBase *>(reception);
67  if (bandListening->getCenterFrequency() != narrowbandReception->getCenterFrequency() || bandListening->getBandwidth() < narrowbandReception->getBandwidth()) {
68  EV_DEBUG << "Computing whether reception is possible: listening and reception bands are different -> reception is impossible" << endl;
69  return false;
70  }
71  else
72  return true;
73 }

◆ computeIsReceptionPossible() [2/3]

bool inet::physicallayer::FlatReceiverBase::computeIsReceptionPossible ( const IListening listening,
const IReception reception,
IRadioSignal::SignalPart  part 
) const
overrideprotectedvirtual

Returns whether the reception of the provided part is possible or not.

For example, it might check if the reception power is above sensitivity.

This function may be called before the reception actually starts at the receiver, thus it must be purely functional and support optimistic parallel computation.

Reimplemented from inet::physicallayer::NarrowbandReceiverBase.

Reimplemented in inet::physicallayer::ApskDimensionalReceiver, inet::physicallayer::ApskScalarReceiver, inet::physicallayer::Ieee80211DimensionalReceiver, and inet::physicallayer::Ieee80211ScalarReceiver.

66 {
67  if (!NarrowbandReceiverBase::computeIsReceptionPossible(listening, reception, part))
68  return false;
69  else {
70  const FlatReceptionBase *flatReception = check_and_cast<const FlatReceptionBase *>(reception);
71  W minReceptionPower = flatReception->computeMinPower(reception->getStartTime(part), reception->getEndTime(part));
72  ASSERT(W(0.0) <= minReceptionPower);
73  bool isReceptionPossible = minReceptionPower >= sensitivity;
74  EV_DEBUG << "Computing whether reception is possible" << EV_FIELD(minReceptionPower) << EV_FIELD(sensitivity) << " -> reception is " << (isReceptionPossible ? "possible" : "impossible") << endl;
75  return isReceptionPossible;
76  }
77 }

Referenced by inet::physicallayer::Ieee80211DimensionalReceiver::computeIsReceptionPossible(), inet::physicallayer::Ieee80211ScalarReceiver::computeIsReceptionPossible(), inet::physicallayer::ApskDimensionalReceiver::computeIsReceptionPossible(), and inet::physicallayer::ApskScalarReceiver::computeIsReceptionPossible().

◆ computeIsReceptionPossible() [3/3]

bool inet::physicallayer::NarrowbandReceiverBase::computeIsReceptionPossible
overrideprotected
56 {
57  // TODO check if modulation matches?
58  const NarrowbandTransmissionBase *narrowbandTransmission = check_and_cast<const NarrowbandTransmissionBase *>(transmission);
59  return centerFrequency == narrowbandTransmission->getCenterFrequency() && bandwidth >= narrowbandTransmission->getBandwidth();
60 }

◆ computeIsReceptionSuccessful()

bool inet::physicallayer::FlatReceiverBase::computeIsReceptionSuccessful ( const IListening listening,
const IReception reception,
IRadioSignal::SignalPart  part,
const IInterference interference,
const ISnir snir 
) const
overrideprotectedvirtual

Returns whether the reception of the provided part is actually successful or failed by the receiver.

For example, it might compute the error rate and draw a random number to make the decision.

This function may be called before the reception actually starts at the receiver, thus it must be purely functional and support optimistic parallel computation.

Reimplemented from inet::physicallayer::SnirReceiverBase.

80 {
81  if (!SnirReceiverBase::computeIsReceptionSuccessful(listening, reception, part, interference, snir))
82  return false;
83  else if (!errorModel)
84  return true;
85  else {
86  double packetErrorRate = errorModel->computePacketErrorRate(snir, part);
87  if (packetErrorRate == 0.0)
88  return true;
89  else if (packetErrorRate == 1.0)
90  return false;
91  else {
92  ASSERT(0.0 < packetErrorRate && packetErrorRate <= 1.0);
93  return dblrand() > packetErrorRate;
94  }
95  }
96 }

◆ computeListeningDecision()

const IListeningDecision * inet::physicallayer::FlatReceiverBase::computeListeningDecision ( const IListening listening,
const IInterference interference 
) const
overridevirtual

Returns the result of the listening process specifying the reception state of the receiver.

This function must be purely functional and support optimistic parallel computation.

Implements inet::physicallayer::IReceiver.

51 {
52  const IRadio *receiver = listening->getReceiver();
53  const IRadioMedium *radioMedium = receiver->getMedium();
54  const IAnalogModel *analogModel = radioMedium->getAnalogModel();
55  const INoise *noise = analogModel->computeNoise(listening, interference);
56  const NarrowbandNoiseBase *narrowbandNoise = check_and_cast<const NarrowbandNoiseBase *>(noise);
57  W maxPower = narrowbandNoise->computeMaxPower(listening->getStartTime(), listening->getEndTime());
58  bool isListeningPossible = maxPower >= energyDetection;
59  delete noise;
60  EV_DEBUG << "Computing whether listening is possible: maximum power = " << maxPower << ", energy detection = " << energyDetection << " -> listening is " << (isListeningPossible ? "possible" : "impossible") << endl;
61  return new ListeningDecision(listening, isListeningPossible);
62 }

◆ computeReceivedPacket()

Packet * inet::physicallayer::FlatReceiverBase::computeReceivedPacket ( const ISnir snir,
bool  isReceptionSuccessful 
) const
overrideprotectedvirtual

Reimplemented from inet::physicallayer::ReceiverBase.

109 {
110  if (errorModel == nullptr || isReceptionSuccessful)
111  return ReceiverBase::computeReceivedPacket(snir, isReceptionSuccessful);
112  else
113  return errorModel->computeCorruptedPacket(snir);
114 }

◆ computeReceptionResult()

const IReceptionResult * inet::physicallayer::FlatReceiverBase::computeReceptionResult ( const IListening listening,
const IReception reception,
const IInterference interference,
const ISnir snir,
const std::vector< const IReceptionDecision * > *  decisions 
) const
overridevirtual

Returns the complete result of the reception process for the provided reception.

This function may be called before the reception actually starts at the receiver, thus it must be purely functional and support optimistic parallel computation.

Reimplemented from inet::physicallayer::ReceiverBase.

Reimplemented in inet::physicallayer::Ieee80211ReceiverBase.

99 {
100  auto receptionResult = NarrowbandReceiverBase::computeReceptionResult(listening, reception, interference, snir, decisions);
101  auto errorRateInd = const_cast<Packet *>(receptionResult->getPacket())->addTagIfAbsent<ErrorRateInd>();
102  errorRateInd->setPacketErrorRate(errorModel ? errorModel->computePacketErrorRate(snir, IRadioSignal::SIGNAL_PART_WHOLE) : 0.0);
103  errorRateInd->setBitErrorRate(errorModel ? errorModel->computeBitErrorRate(snir, IRadioSignal::SIGNAL_PART_WHOLE) : 0.0);
104  errorRateInd->setSymbolErrorRate(errorModel ? errorModel->computeSymbolErrorRate(snir, IRadioSignal::SIGNAL_PART_WHOLE) : 0.0);
105  return receptionResult;
106 }

Referenced by inet::physicallayer::Ieee80211ReceiverBase::computeReceptionResult().

◆ getEnergyDetection()

virtual W inet::physicallayer::FlatReceiverBase::getEnergyDetection ( ) const
inlinevirtual
46 { return energyDetection; }

◆ getErrorModel()

virtual const IErrorModel* inet::physicallayer::FlatReceiverBase::getErrorModel ( ) const
inlinevirtual
44 { return errorModel; }

◆ getMinReceptionPower()

virtual W inet::physicallayer::FlatReceiverBase::getMinReceptionPower ( ) const
inlineoverridevirtual

Returns the minimum reception power below which successful reception is definitely not possible.

Returns a value in the range [0, +infinity) or NaN if unspecified.

Reimplemented from inet::physicallayer::ReceiverBase.

39 { return sensitivity; }

◆ getSensitivity()

virtual W inet::physicallayer::FlatReceiverBase::getSensitivity ( ) const
inlinevirtual
49 { return sensitivity; }

◆ initialize()

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

◆ printToStream()

◆ setEnergyDetection()

virtual void inet::physicallayer::FlatReceiverBase::setEnergyDetection ( W  energyDetection)
inlinevirtual

◆ setSensitivity()

virtual void inet::physicallayer::FlatReceiverBase::setSensitivity ( W  sensitivity)
inlinevirtual
50 { this->sensitivity = sensitivity; }

Member Data Documentation

◆ energyDetection

W inet::physicallayer::FlatReceiverBase::energyDetection
protected

◆ errorModel

const IErrorModel* inet::physicallayer::FlatReceiverBase::errorModel
protected

◆ sensitivity

W inet::physicallayer::FlatReceiverBase::sensitivity
protected

The documentation for this class was generated from the following files:
inet::physicallayer::FlatReceiverBase::errorModel
const IErrorModel * errorModel
Definition: FlatReceiverBase.h:21
inet::physicallayer::NarrowbandReceiverBase::centerFrequency
Hz centerFrequency
Definition: NarrowbandReceiverBase.h:23
inet::physicallayer::IErrorModel::computeBitErrorRate
virtual double computeBitErrorRate(const ISnir *snir, IRadioSignal::SignalPart part) const =0
Returns the bit error rate based on SNIR, modulation, FEC encoding and any other physical layer chara...
inet::physicallayer::IRadioSignal::SIGNAL_PART_WHOLE
@ SIGNAL_PART_WHOLE
Definition: IRadioSignal.h:26
inet::physicallayer::IErrorModel::computePacketErrorRate
virtual double computePacketErrorRate(const ISnir *snir, IRadioSignal::SignalPart part) const =0
Returns the packet error rate based on SNIR, modulation, FEC encoding and any other physical layer ch...
inet::physicallayer::NarrowbandReceiverBase::NarrowbandReceiverBase
NarrowbandReceiverBase()
Definition: NarrowbandReceiverBase.cc:23
inet::IPrintableObject::PRINT_LEVEL_INFO
@ PRINT_LEVEL_INFO
Definition: IPrintableObject.h:25
inet::physicallayer::SnirReceiverBase::computeIsReceptionSuccessful
virtual bool computeIsReceptionSuccessful(const IListening *listening, const IReception *reception, IRadioSignal::SignalPart part, const IInterference *interference, const ISnir *snir) const override
Returns whether the reception of the provided part is actually successful or failed by the receiver.
Definition: SnirReceiverBase.cc:39
inet::math::dBmW2mW
double dBmW2mW(double dBm)
Converts a dBmW value to mW.
Definition: INETMath.h:163
inet::physicallayer::NarrowbandReceiverBase::bandwidth
Hz bandwidth
Definition: NarrowbandReceiverBase.h:24
inet::units::units::W
compose< J, pow< s, -1 > > W
Definition: Units.h:939
inet::physicallayer::NarrowbandReceiverBase::computeIsReceptionPossible
virtual bool computeIsReceptionPossible(const IListening *listening, const ITransmission *transmission) const override
Returns whether the reception of the provided transmission is possible or not independently of the re...
Definition: NarrowbandReceiverBase.cc:55
inet::units::units::mW
milli< W >::type mW
Definition: Units.h:1080
inet::printFieldToString
std::string printFieldToString(const IPrintableObject *object, int level, int evFlags=0)
Definition: IPrintableObject.h:98
inet::physicallayer::IErrorModel::computeSymbolErrorRate
virtual double computeSymbolErrorRate(const ISnir *snir, IRadioSignal::SignalPart part) const =0
Returns the symbol error rate based on SNIR, modulation, and any other physical layer characteristics...
inet::physicallayer::ReceiverBase::computeReceptionResult
virtual const IReceptionResult * computeReceptionResult(const IListening *listening, const IReception *reception, const IInterference *interference, const ISnir *snir, const std::vector< const IReceptionDecision * > *decisions) const override
Returns the complete result of the reception process for the provided reception.
Definition: ReceiverBase.cc:72
EV_FIELD
#define EV_FIELD(...)
Definition: INETDefs.h:112
inet::physicallayer::ReceiverBase::computeReceivedPacket
virtual Packet * computeReceivedPacket(const ISnir *snir, bool isReceptionSuccessful) const
Definition: ReceiverBase.cc:106
inet::physicallayer::FlatReceiverBase::energyDetection
W energyDetection
Definition: FlatReceiverBase.h:22
NaN
#define NaN
Definition: INETMath.h:91
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
inet::IPrintableObject::PRINT_LEVEL_TRACE
@ PRINT_LEVEL_TRACE
Definition: IPrintableObject.h:22
inet::evFlags
int evFlags
Definition: INETDefs.cc:12
inet::physicallayer::NarrowbandReceiverBase::initialize
virtual void initialize(int stage) override
Definition: NarrowbandReceiverBase.cc:31
inet::physicallayer::NarrowbandReceiverBase::printToStream
virtual std::ostream & printToStream(std::ostream &stream, int level, int evFlags=0) const override
Prints this object to the provided output stream.
Definition: NarrowbandReceiverBase.cc:41
inet::physicallayer::FlatReceiverBase::sensitivity
W sensitivity
Definition: FlatReceiverBase.h:23
inet::physicallayer::IErrorModel::computeCorruptedPacket
virtual Packet * computeCorruptedPacket(const ISnir *snir) const =0