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

Implements the StochasticErrorModel model, see the NED file for details. More...

#include <StochasticErrorModel.h>

Inheritance diagram for inet::physicallayer::StochasticErrorModel:
inet::physicallayer::ErrorModelBase inet::physicallayer::IErrorModel inet::IPrintableObject

Public Member Functions

 StochasticErrorModel ()
 
virtual std::ostream & printToStream (std::ostream &stream, int level, int evFlags=0) const override
 Prints this object to the provided output stream. More...
 
virtual double computePacketErrorRate (const ISnir *snir, IRadioSignal::SignalPart part) const override
 Returns the packet error rate based on SNIR, modulation, FEC encoding and any other physical layer characteristics. More...
 
virtual double computeBitErrorRate (const ISnir *snir, IRadioSignal::SignalPart part) const override
 Returns the bit error rate based on SNIR, modulation, FEC encoding and any other physical layer characteristics. More...
 
virtual double computeSymbolErrorRate (const ISnir *snir, IRadioSignal::SignalPart part) const override
 Returns the symbol error rate based on SNIR, modulation, and any other physical layer characteristics. 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
 
- Protected Member Functions inherited from inet::physicallayer::ErrorModelBase
virtual double getScalarSnir (const ISnir *snir) const
 
virtual bool hasProbabilisticError (b length, double ber) const
 
virtual PacketcorruptBits (const Packet *packet, double ber, bool &isCorrupted) const
 
virtual PacketcorruptBytes (const Packet *packet, double ber, bool &isCorrupted) const
 
virtual PacketcorruptChunks (const Packet *packet, double ber, bool &isCorrupted) const
 
virtual PacketcorruptPacket (const Packet *packet, bool &isCorrupted) const
 
virtual PacketcomputeCorruptedPacket (const Packet *packet, double ber) const
 
virtual PacketcomputeCorruptedPacket (const ISnir *snir) const override
 

Protected Attributes

double packetErrorRate
 
double bitErrorRate
 
double symbolErrorRate
 
- Protected Attributes inherited from inet::physicallayer::ErrorModelBase
CorruptionMode corruptionMode = CorruptionMode::CM_UNDEFINED
 
SnirMode snirMode = SnirMode::SM_UNDEFINED
 
double snirOffset = NaN
 

Additional Inherited Members

- Public Types inherited from inet::physicallayer::ErrorModelBase
enum  CorruptionMode {
  CorruptionMode::CM_UNDEFINED = -1, CorruptionMode::CM_PACKET, CorruptionMode::CM_CHUNK, CorruptionMode::CM_BYTE,
  CorruptionMode::CM_BIT
}
 
enum  SnirMode { SnirMode::SM_UNDEFINED = -1, SnirMode::SM_MIN, SnirMode::SM_MEAN }
 
- 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) }
 

Detailed Description

Implements the StochasticErrorModel model, see the NED file for details.

Constructor & Destructor Documentation

◆ StochasticErrorModel()

inet::physicallayer::StochasticErrorModel::StochasticErrorModel ( )
18  :
22 {
23 }

Member Function Documentation

◆ computeBitErrorRate()

double inet::physicallayer::StochasticErrorModel::computeBitErrorRate ( const ISnir snir,
IRadioSignal::SignalPart  part 
) const
overridevirtual

Returns the bit error rate based on SNIR, modulation, FEC encoding and any other physical layer characteristics.

Implements inet::physicallayer::IErrorModel.

73 {
74  Enter_Method("computeBitErrorRate");
75  if (!std::isnan(bitErrorRate)) {
76  return bitErrorRate;
77  }
78  else {
79  // TODO compute bit error rate based on symbol error rate and modulation
80 // const IReception *reception = snir->getReception();
81 // const NarrowbandTransmissionBase *narrowbandTransmission = check_and_cast<const NarrowbandTransmissionBase *>(reception->getTransmission());
82 // const IModulation *modulation = narrowbandTransmission->getModulation();
83 // double symbolErrorRate = computeSymbolErrorRate(snir);
84  throw cRuntimeError("Not yet implemented");
85  }
86 }

Referenced by computePacketErrorRate().

◆ computePacketErrorRate()

double inet::physicallayer::StochasticErrorModel::computePacketErrorRate ( const ISnir snir,
IRadioSignal::SignalPart  part 
) const
overridevirtual

Returns the packet error rate based on SNIR, modulation, FEC encoding and any other physical layer characteristics.

Implements inet::physicallayer::IErrorModel.

45 {
46  Enter_Method("computePacketErrorRate");
47  const IReception *reception = snir->getReception();
48  if (!std::isnan(packetErrorRate)) {
49  double factor = reception->getDuration(part) / reception->getDuration();
50  return pow(packetErrorRate, factor);
51  }
52  else {
53  const FlatTransmissionBase *flatTransmission = check_and_cast<const FlatTransmissionBase *>(reception->getTransmission());
54  double bitErrorRate = computeBitErrorRate(snir, part);
55  double headerSuccessRate = pow(1.0 - bitErrorRate, b(flatTransmission->getHeaderLength()).get());
56  double dataSuccessRate = pow(1.0 - bitErrorRate, b(flatTransmission->getDataLength()).get());
57  switch (part) {
59  return 1.0 - headerSuccessRate * dataSuccessRate;
61  return 0;
63  return 1.0 - headerSuccessRate;
65  return 1.0 - dataSuccessRate;
66  default:
67  throw cRuntimeError("Unknown signal part: '%s'", IRadioSignal::getSignalPartName(part));
68  }
69  }
70 }

◆ computeSymbolErrorRate()

double inet::physicallayer::StochasticErrorModel::computeSymbolErrorRate ( const ISnir snir,
IRadioSignal::SignalPart  part 
) const
overridevirtual

Returns the symbol error rate based on SNIR, modulation, and any other physical layer characteristics.

Implements inet::physicallayer::IErrorModel.

89 {
90  Enter_Method("computeSymbolErrorRate");
91  return symbolErrorRate;
92 }

◆ initialize()

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

Reimplemented from inet::physicallayer::ErrorModelBase.

26 {
27  if (stage == INITSTAGE_LOCAL) {
28  packetErrorRate = par("packetErrorRate");
29  bitErrorRate = par("bitErrorRate");
30  symbolErrorRate = par("symbolErrorRate");
31  }
32 }

◆ printToStream()

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

Prints this object to the provided output stream.

Reimplemented from inet::IPrintableObject.

35 {
36  if (level <= PRINT_LEVEL_TRACE)
37  stream << "StochasticErrorModel"
38  << "packetErrorRate = " << packetErrorRate
39  << "bitErrorRate = " << bitErrorRate
40  << "symbolErrorRate = " << symbolErrorRate;
41  return stream;
42 }

Member Data Documentation

◆ bitErrorRate

double inet::physicallayer::StochasticErrorModel::bitErrorRate
protected

◆ packetErrorRate

double inet::physicallayer::StochasticErrorModel::packetErrorRate
protected

◆ symbolErrorRate

double inet::physicallayer::StochasticErrorModel::symbolErrorRate
protected

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::physicallayer::StochasticErrorModel::packetErrorRate
double packetErrorRate
Definition: StochasticErrorModel.h:23
inet::physicallayer::IRadioSignal::SIGNAL_PART_HEADER
@ SIGNAL_PART_HEADER
Definition: IRadioSignal.h:28
inet::physicallayer::IRadioSignal::SIGNAL_PART_PREAMBLE
@ SIGNAL_PART_PREAMBLE
Definition: IRadioSignal.h:27
inet::physicallayer::StochasticErrorModel::bitErrorRate
double bitErrorRate
Definition: StochasticErrorModel.h:24
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::physicallayer::IRadioSignal::getSignalPartName
static const char * getSignalPartName(SignalPart signalPart)
Returns the name of the provided signal part.
Definition: IRadioSignal.cc:23
inet::units::values::b
value< int64_t, units::b > b
Definition: Units.h:1241
inet::physicallayer::IRadioSignal::SIGNAL_PART_DATA
@ SIGNAL_PART_DATA
Definition: IRadioSignal.h:29
inet::physicallayer::StochasticErrorModel::computeBitErrorRate
virtual double computeBitErrorRate(const ISnir *snir, IRadioSignal::SignalPart part) const override
Returns the bit error rate based on SNIR, modulation, FEC encoding and any other physical layer chara...
Definition: StochasticErrorModel.cc:72
Enter_Method
#define Enter_Method(...)
Definition: SelfDoc.h:71
inet::physicallayer::StochasticErrorModel::symbolErrorRate
double symbolErrorRate
Definition: StochasticErrorModel.h:25