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

#include <LayeredErrorModelBase.h>

Inheritance diagram for inet::physicallayer::LayeredErrorModelBase:
inet::physicallayer::ILayeredErrorModel inet::IPrintableObject inet::physicallayer::ApskLayeredErrorModel inet::physicallayer::StochasticLayeredErrorModel

Protected Member Functions

virtual const IReceptionPacketModelcomputePacketModel (const LayeredTransmission *transmission, double packetErrorRate) const
 
virtual const IReceptionBitModelcomputeBitModel (const LayeredTransmission *transmission, double bitErrorRate) const
 
virtual const IReceptionSymbolModelcomputeSymbolModel (const LayeredTransmission *transmission, double symbolErrorRate) const
 

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) }
 
- Public Member Functions inherited from inet::physicallayer::ILayeredErrorModel
virtual const IReceptionPacketModelcomputePacketModel (const LayeredTransmission *transmission, const ISnir *snir) const =0
 Computes the packet domain representation at the receiver using a simplified model for the underlying domains. More...
 
virtual const IReceptionBitModelcomputeBitModel (const LayeredTransmission *transmission, const ISnir *snir) const =0
 Computes the bit domain representation at the receiver using a simplified model for the underlying domains. More...
 
virtual const IReceptionSymbolModelcomputeSymbolModel (const LayeredTransmission *transmission, const ISnir *snir) const =0
 Computes the symbol domain representation at the receiver using a simplified model for the underlying domains. More...
 
virtual const IReceptionSampleModelcomputeSampleModel (const LayeredTransmission *transmission, const ISnir *snir) const =0
 Computes the sample domain representation at the receiver using a simplified model for the underlying domains. 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
 

Member Function Documentation

◆ computeBitModel()

const IReceptionBitModel * inet::physicallayer::LayeredErrorModelBase::computeBitModel ( const LayeredTransmission transmission,
double  bitErrorRate 
) const
protectedvirtual
33 {
34  const TransmissionBitModel *transmissionBitModel = check_and_cast<const TransmissionBitModel *>(transmission->getBitModel());
35  if (bitErrorRate == 0)
36  return new ReceptionBitModel(transmissionBitModel->getHeaderLength(), transmissionBitModel->getHeaderBitRate(), transmissionBitModel->getDataLength(), transmissionBitModel->getDataBitRate(), new BitVector(*transmissionBitModel->getBits()), bitErrorRate);
37  else {
38  BitVector *receivedBits = new BitVector(*transmissionBitModel->getBits());
39  for (unsigned int i = 0; i < receivedBits->getSize(); i++) {
40  if (uniform(0, 1) < bitErrorRate)
41  receivedBits->toggleBit(i);
42  }
43  return new ReceptionBitModel(transmissionBitModel->getHeaderLength(), transmissionBitModel->getHeaderBitRate(), transmissionBitModel->getDataLength(), transmissionBitModel->getDataBitRate(), receivedBits, bitErrorRate);
44  }
45 }

Referenced by inet::physicallayer::ApskLayeredErrorModel::computeBitModel(), and inet::physicallayer::StochasticLayeredErrorModel::computeBitModel().

◆ computePacketModel()

const IReceptionPacketModel * inet::physicallayer::LayeredErrorModelBase::computePacketModel ( const LayeredTransmission transmission,
double  packetErrorRate 
) const
protectedvirtual
22 {
23  auto transmissionPacketModel = check_and_cast<const TransmissionPacketModel *>(transmission->getPacketModel());
24  auto transmittedPacket = transmissionPacketModel->getPacket();
25  auto receivedPacket = transmittedPacket->dup();
26  if (packetErrorRate != 0 && uniform(0, 1) < packetErrorRate)
27  receivedPacket->setBitError(true);
28  receivedPacket->addTagIfAbsent<ErrorRateInd>()->setPacketErrorRate(packetErrorRate);
29  return new ReceptionPacketModel(receivedPacket, transmissionPacketModel->getBitrate(), packetErrorRate);
30 }

Referenced by inet::physicallayer::ApskLayeredErrorModel::computePacketModel().

◆ computeSymbolModel()

const IReceptionSymbolModel * inet::physicallayer::LayeredErrorModelBase::computeSymbolModel ( const LayeredTransmission transmission,
double  symbolErrorRate 
) const
protectedvirtual
48 {
49  if (symbolErrorRate == 0) {
50  const TransmissionSymbolModel *transmissionSymbolModel = check_and_cast<const TransmissionSymbolModel *>(transmission->getSymbolModel());
51  return new ReceptionSymbolModel(transmissionSymbolModel->getHeaderSymbolLength(), transmissionSymbolModel->getHeaderSymbolRate(), transmissionSymbolModel->getPayloadSymbolLength(), transmissionSymbolModel->getPayloadSymbolRate(), new std::vector<const ISymbol *>(*transmissionSymbolModel->getSymbols()), symbolErrorRate);
52  }
53  else {
54  const TransmissionSymbolModel *transmissionSymbolModel = check_and_cast<const TransmissionSymbolModel *>(transmission->getSymbolModel());
55  const ApskModulationBase *modulation = check_and_cast<const ApskModulationBase *>(transmissionSymbolModel->getPayloadModulation());
56  const std::vector<const ISymbol *> *transmittedSymbols = transmissionSymbolModel->getSymbols();
57  std::vector<const ISymbol *> *receivedSymbols = new std::vector<const ISymbol *>();
58  for (auto& transmittedSymbols_i : *transmittedSymbols) {
59  if (uniform(0, 1) < symbolErrorRate) {
60  const ApskSymbol *transmittedSymbol = check_and_cast<const ApskSymbol *>(transmittedSymbols_i);
61  ShortBitVector bits = modulation->demapToBitRepresentation(transmittedSymbol);
62  int errorIndex = intuniform(0, bits.getSize() - 1);
63  bits.setBit(errorIndex, !bits.getBit(errorIndex));
64  const ApskSymbol *receivedSymbol = modulation->mapToConstellationDiagram(bits);
65  receivedSymbols->push_back(receivedSymbol);
66  }
67  else
68  receivedSymbols->push_back(transmittedSymbols_i);
69  }
70  return new ReceptionSymbolModel(transmissionSymbolModel->getHeaderSymbolLength(), transmissionSymbolModel->getHeaderSymbolRate(), transmissionSymbolModel->getPayloadSymbolLength(), transmissionSymbolModel->getPayloadSymbolRate(), receivedSymbols, symbolErrorRate);
71  }
72 }

Referenced by inet::physicallayer::ApskLayeredErrorModel::computeSymbolModel(), and inet::physicallayer::StochasticLayeredErrorModel::computeSymbolModel().


The documentation for this class was generated from the following files: