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

Base class for modulations using various amplitude and phase-shift keying. More...

#include <APSKModulationBase.h>

Inheritance diagram for inet::physicallayer::APSKModulationBase:
inet::physicallayer::IAPSKModulation inet::physicallayer::IModulation inet::physicallayer::IPrintableObject inet::physicallayer::DSSSOQPSK16Modulation inet::physicallayer::MASKModulation inet::physicallayer::MPSKModulation inet::physicallayer::MQAMModulationBase inet::physicallayer::BPSKModulation inet::physicallayer::MQAMModulation inet::physicallayer::QAM16Modulation inet::physicallayer::QAM256Modulation inet::physicallayer::QAM64Modulation inet::physicallayer::QBPSKModulation inet::physicallayer::QPSKModulation

Public Member Functions

 APSKModulationBase (const std::vector< APSKSymbol > *constellation)
 
virtual std::ostream & printToStream (std::ostream &stream, int level) const override
 Prints this object to the provided output stream. More...
 
virtual const std::vector< APSKSymbol > * getConstellation () const
 
virtual unsigned int getConstellationSize () const override
 
virtual unsigned int getCodeWordSize () const override
 
virtual const APSKSymbolmapToConstellationDiagram (const ShortBitVector &symbol) const
 
virtual ShortBitVector demapToBitRepresentation (const APSKSymbol *symbol) const
 
- Public Member Functions inherited from inet::physicallayer::IModulation
virtual double calculateBER (double snir, Hz bandwidth, bps bitrate) const =0
 Returns the bit error rate as a function of the signal to noise and interference ratio, the bandwidth, and the gross (physical) bitrate. More...
 
virtual double calculateSER (double snir, Hz bandwidth, bps bitrate) const =0
 Returns the symbol error rate as a function of the signal to noise and interference ratio, the bandwidth, and the gross (physical) bitrate. More...
 
- Public Member Functions inherited from inet::physicallayer::IPrintableObject
virtual ~IPrintableObject ()
 
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
 

Static Public Member Functions

static const APSKModulationBasefindModulation (const char *name)
 

Protected Attributes

const std::vector< APSKSymbol > * constellation
 
const unsigned int codeWordSize
 
const unsigned int constellationSize
 

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
}
 

Detailed Description

Base class for modulations using various amplitude and phase-shift keying.

Constructor & Destructor Documentation

inet::physicallayer::APSKModulationBase::APSKModulationBase ( const std::vector< APSKSymbol > *  constellation)
32  :
34  codeWordSize(log2(constellation->size())),
36 {
37 }
const unsigned int codeWordSize
Definition: APSKModulationBase.h:36
const std::vector< APSKSymbol > * constellation
Definition: APSKModulationBase.h:35
const unsigned int constellationSize
Definition: APSKModulationBase.h:37

Member Function Documentation

ShortBitVector inet::physicallayer::APSKModulationBase::demapToBitRepresentation ( const APSKSymbol symbol) const
virtual

Referenced by inet::physicallayer::APSKDemodulator::demodulate(), and inet::physicallayer::Ieee80211OFDMDemodulator::demodulateSymbol().

78 {
79  // TODO: Complete implementation: http://eprints.soton.ac.uk/354719/1/tvt-hanzo-2272640-proof.pdf
80  double symbolQ = symbol->real();
81  double symbolI = symbol->imag();
82  double minDist = DBL_MAX;
83  int nearestNeighborIndex = -1;
84  for (unsigned int i = 0; i < constellationSize; i++) {
85  const APSKSymbol *constellationSymbol = &constellation->at(i);
86  double cQ = constellationSymbol->real();
87  double cI = constellationSymbol->imag();
88  double dist = (symbolQ - cQ) * (symbolQ - cQ) + (symbolI - cI) * (symbolI - cI);
89  if (dist < minDist) {
90  minDist = dist;
91  nearestNeighborIndex = i;
92  }
93  }
94  ASSERT(nearestNeighborIndex != -1);
95  return ShortBitVector(nearestNeighborIndex, codeWordSize);
96 }
const unsigned int codeWordSize
Definition: APSKModulationBase.h:36
const std::vector< APSKSymbol > * constellation
Definition: APSKModulationBase.h:35
const unsigned int constellationSize
Definition: APSKModulationBase.h:37
const APSKModulationBase * inet::physicallayer::APSKModulationBase::findModulation ( const char *  name)
static

Referenced by inet::physicallayer::Ieee80211OFDMModulatorModule::initialize(), inet::physicallayer::Ieee80211OFDMDemodulatorModule::initialize(), inet::physicallayer::NarrowbandTransmitterBase::initialize(), inet::physicallayer::NarrowbandReceiverBase::initialize(), inet::physicallayer::APSKModulator::initialize(), and inet::physicallayer::APSKDemodulator::initialize().

48 {
49  if (!strcmp("BPSK", modulation))
51  else if (!strcmp("QPSK", modulation))
53  else if (!strcmp("QAM-16", modulation))
55  else if (!strcmp("QAM-64", modulation))
57  else if (!strcmp("QAM-256", modulation))
59  else if (!strncmp("MQAM-", modulation, 5))
60  return new MQAMModulation(atoi(modulation + 5));
61  else if (!strncmp("MPSK-", modulation, 5))
62  return new MPSKModulation(atoi(modulation + 5));
63  else if (!strcmp(modulation, "DSSS-OQPSK-16"))
64  return new DSSSOQPSK16Modulation();
65  else
66  throw cRuntimeError("Unknown modulation = %s", modulation);
67 }
static const QPSKModulation singleton
Definition: QPSKModulation.h:35
static const QAM16Modulation singleton
Definition: QAM16Modulation.h:36
static const BPSKModulation singleton
Definition: BPSKModulation.h:35
static const QAM256Modulation singleton
Definition: QAM256Modulation.h:36
static const QAM64Modulation singleton
Definition: QAM64Modulation.h:36
virtual const std::vector<APSKSymbol>* inet::physicallayer::APSKModulationBase::getConstellation ( ) const
inlinevirtual

Referenced by inet::physicallayer::Ieee80211OFDMErrorModel::computeSymbolModel().

45 { return constellation; }
const std::vector< APSKSymbol > * constellation
Definition: APSKModulationBase.h:35
virtual unsigned int inet::physicallayer::APSKModulationBase::getConstellationSize ( ) const
inlineoverridevirtual

Implements inet::physicallayer::IAPSKModulation.

Referenced by inet::physicallayer::Ieee80211OFDMErrorModel::computeSymbolModel().

46 { return constellationSize; }
const unsigned int constellationSize
Definition: APSKModulationBase.h:37
const APSKSymbol * inet::physicallayer::APSKModulationBase::mapToConstellationDiagram ( const ShortBitVector symbol) const
virtual

Referenced by inet::physicallayer::APSKModulator::modulate().

70 {
71  unsigned int decimalSymbol = symbol.toDecimal();
72  if (decimalSymbol >= constellationSize)
73  throw cRuntimeError("Unknown input: %d", decimalSymbol);
74  return &constellation->at(decimalSymbol);
75 }
const std::vector< APSKSymbol > * constellation
Definition: APSKModulationBase.h:35
const unsigned int constellationSize
Definition: APSKModulationBase.h:37
std::ostream & inet::physicallayer::APSKModulationBase::printToStream ( std::ostream &  stream,
int  level 
) const
overridevirtual

Prints this object to the provided output stream.

Function calls to operator<< with pointers or references either const or not are all forwarded to this function.

Reimplemented from inet::physicallayer::IPrintableObject.

Reimplemented in inet::physicallayer::QAM16Modulation, inet::physicallayer::QAM256Modulation, inet::physicallayer::QAM64Modulation, inet::physicallayer::BPSKModulation, inet::physicallayer::QPSKModulation, inet::physicallayer::MASKModulation, inet::physicallayer::MPSKModulation, and inet::physicallayer::MQAMModulation.

Referenced by inet::physicallayer::MASKModulation::printToStream(), inet::physicallayer::MQAMModulation::printToStream(), and inet::physicallayer::MPSKModulation::printToStream().

40 {
41  if (level <= PRINT_LEVEL_TRACE)
42  stream << ", constellationSize = " << constellationSize
43  << ", codeWordSize = " << codeWordSize;
44  return stream;
45 }
const unsigned int codeWordSize
Definition: APSKModulationBase.h:36
const unsigned int constellationSize
Definition: APSKModulationBase.h:37

Member Data Documentation

const unsigned int inet::physicallayer::APSKModulationBase::codeWordSize
protected

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