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

#include <LayeredErrorModelBase.h>

Inheritance diagram for inet::physicallayer::LayeredErrorModelBase:
inet::physicallayer::ILayeredErrorModel inet::physicallayer::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::physicallayer::IPrintableObject
enum  PrintLevel {
  PRINT_LEVEL_TRACE, PRINT_LEVEL_DEBUG, PRINT_LEVEL_DETAIL, PRINT_LEVEL_INFO,
  PRINT_LEVEL_COMPLETE = INT_MIN
}
 
- 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::physicallayer::IPrintableObject
virtual ~IPrintableObject ()
 
virtual std::ostream & printToStream (std::ostream &stream, int level) const
 Prints this object to the provided output stream. More...
 
virtual std::string getInfoStringRepresentation () const
 
virtual std::string getDetailStringRepresentation () const
 
virtual std::string getDebugStringRepresentation () const
 
virtual std::string getTraceStringRepresentation () const
 
virtual std::string getCompleteStringRepresentation () const
 

Member Function Documentation

const IReceptionBitModel * inet::physicallayer::LayeredErrorModelBase::computeBitModel ( const LayeredTransmission transmission,
double  bitErrorRate 
) const
protectedvirtual

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

45 {
46  const TransmissionBitModel *transmissionBitModel = check_and_cast<const TransmissionBitModel *>(transmission->getBitModel());
47  if (bitErrorRate == 0)
48  return new const ReceptionBitModel(transmissionBitModel->getHeaderBitLength(), transmissionBitModel->getHeaderBitRate(), transmissionBitModel->getPayloadBitLength(), transmissionBitModel->getPayloadBitRate(), new BitVector(*transmissionBitModel->getBits()));
49  else {
50  BitVector *receivedBits = new BitVector(*transmissionBitModel->getBits());
51  for (unsigned int i = 0; i < receivedBits->getSize(); i++) {
52  if (uniform(0, 1) < bitErrorRate)
53  receivedBits->toggleBit(i);
54  }
55  return new const ReceptionBitModel(transmissionBitModel->getHeaderBitLength(), transmissionBitModel->getHeaderBitRate(), transmissionBitModel->getPayloadBitLength(), transmissionBitModel->getPayloadBitRate(), receivedBits);
56  }
57 }
const IReceptionPacketModel * inet::physicallayer::LayeredErrorModelBase::computePacketModel ( const LayeredTransmission transmission,
double  packetErrorRate 
) const
protectedvirtual

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

31 {
32  const TransmissionPacketModel *transmissionPacketModel = check_and_cast<const TransmissionPacketModel *>(transmission->getPacketModel());
33  const cPacket* packet = transmissionPacketModel->getPacket();
34  if (packetErrorRate == 0)
35  return new ReceptionPacketModel(packet, new BitVector(*transmissionPacketModel->getSerializedPacket()), transmissionPacketModel->getBitrate(), packetErrorRate, true);
36  else {
37  if (uniform(0, 1) < packetErrorRate)
38  return new const ReceptionPacketModel(packet, new BitVector(), transmissionPacketModel->getBitrate(), packetErrorRate, false);
39  else
40  return new const ReceptionPacketModel(packet, new BitVector(*transmissionPacketModel->getSerializedPacket()), transmissionPacketModel->getBitrate(), packetErrorRate, true);
41  }
42 }
const IReceptionSymbolModel * inet::physicallayer::LayeredErrorModelBase::computeSymbolModel ( const LayeredTransmission transmission,
double  symbolErrorRate 
) const
protectedvirtual

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

60 {
61  if (symbolErrorRate == 0) {
62  const TransmissionSymbolModel *transmissionSymbolModel = check_and_cast<const TransmissionSymbolModel *>(transmission->getSymbolModel());
63  return new ReceptionSymbolModel(transmissionSymbolModel->getHeaderSymbolLength(), transmissionSymbolModel->getHeaderSymbolRate(), transmissionSymbolModel->getPayloadSymbolLength(), transmissionSymbolModel->getPayloadSymbolRate(), new std::vector<const ISymbol*>(*transmissionSymbolModel->getSymbols()));
64  }
65  else {
66  const TransmissionSymbolModel *transmissionSymbolModel = check_and_cast<const TransmissionSymbolModel *>(transmission->getSymbolModel());
67  const APSKModulationBase *modulation = check_and_cast<const APSKModulationBase *>(transmissionSymbolModel->getPayloadModulation());
68  const std::vector<const ISymbol*> *transmittedSymbols = transmissionSymbolModel->getSymbols();
69  std::vector<const ISymbol*> *receivedSymbols = new std::vector<const ISymbol *>();
70  for (auto & transmittedSymbols_i : *transmittedSymbols) {
71  if (uniform(0, 1) < symbolErrorRate) {
72  const APSKSymbol *transmittedSymbol = check_and_cast<const APSKSymbol *>(transmittedSymbols_i);
73  ShortBitVector bits = modulation->demapToBitRepresentation(transmittedSymbol);
74  int errorIndex = intuniform(0, bits.getSize() - 1);
75  bits.setBit(errorIndex, !bits.getBit(errorIndex));
76  const APSKSymbol *receivedSymbol = modulation->mapToConstellationDiagram(bits);
77  receivedSymbols->push_back(receivedSymbol);
78  }
79  else
80  receivedSymbols->push_back(transmittedSymbols_i);
81  }
82  return new ReceptionSymbolModel(transmissionSymbolModel->getHeaderSymbolLength(), transmissionSymbolModel->getHeaderSymbolRate(), transmissionSymbolModel->getPayloadSymbolLength(), transmissionSymbolModel->getPayloadSymbolRate(), receivedSymbols);
83  }
84 }

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