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

#include <APSKLayeredTransmitter.h>

Inheritance diagram for inet::physicallayer::APSKLayeredTransmitter:
inet::physicallayer::TransmitterBase inet::physicallayer::ITransmitter inet::physicallayer::IPrintableObject

Public Types

enum  LevelOfDetail { PACKET_DOMAIN, BIT_DOMAIN, SYMBOL_DOMAIN, SAMPLE_DOMAIN }
 
- 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

 APSKLayeredTransmitter ()
 
virtual std::ostream & printToStream (std::ostream &stream, int level) const override
 Prints this object to the provided output stream. More...
 
virtual const IEncodergetEncoder () const
 
virtual const IModulatorgetModulator () const
 
virtual const IPulseShapergetPulseShaper () const
 
virtual const IDigitalAnalogConvertergetDigitalAnalogConverter () const
 
virtual W getPower () const
 
virtual bps getBitrate () const
 
virtual const Hz getBandwidth () const
 
virtual const Hz getCarrierFrequency () const
 
virtual W getMaxPower () const override
 Returns the maximum transmission power above which no transmission is ever transmitted. More...
 
virtual m getMaxCommunicationRange () const override
 Returns the maximum transmission range. More...
 
virtual m getMaxInterferenceRange () const override
 Returns the maximum interference range. More...
 
virtual const ITransmissioncreateTransmission (const IRadio *radio, const cPacket *packet, const simtime_t startTime) const override
 Returns a transmission which describes the radio signal corresponding to the provided mac frame. 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
 

Protected Member Functions

virtual void initialize (int stage) override
 
virtual int computePaddingLength (BitVector *bits) const
 
virtual const APSKPhyFramecreatePhyFrame (const cPacket *macFrame) const
 
virtual const ITransmissionPacketModelcreatePacketModel (const APSKPhyFrame *phyFrame) const
 
virtual const ITransmissionBitModelcreateBitModel (const ITransmissionPacketModel *packetModel) const
 
virtual const ITransmissionSymbolModelcreateSymbolModel (const ITransmissionBitModel *bitModel) const
 
virtual const ITransmissionSampleModelcreateSampleModel (const ITransmissionSymbolModel *symbolModel) const
 
virtual const ITransmissionAnalogModelcreateAnalogModel (const ITransmissionPacketModel *packetModel, const ITransmissionBitModel *bitModel, const ITransmissionSampleModel *sampleModel) const
 
- Protected Member Functions inherited from inet::physicallayer::TransmitterBase
virtual int numInitStages () const override
 

Protected Attributes

LevelOfDetail levelOfDetail
 
const IEncoderencoder
 
const IModulatormodulator
 
const IPulseShaperpulseShaper
 
const IDigitalAnalogConverterdigitalAnalogConverter
 
W power
 
bps bitrate
 
Hz bandwidth
 
Hz carrierFrequency
 

Member Enumeration Documentation

Enumerator
PACKET_DOMAIN 
BIT_DOMAIN 
SYMBOL_DOMAIN 
SAMPLE_DOMAIN 
37  {
39  BIT_DOMAIN,
42  };
Definition: APSKLayeredTransmitter.h:39
Definition: APSKLayeredTransmitter.h:38
Definition: APSKLayeredTransmitter.h:40
Definition: APSKLayeredTransmitter.h:41

Constructor & Destructor Documentation

inet::physicallayer::APSKLayeredTransmitter::APSKLayeredTransmitter ( )
34  :
36  encoder(nullptr),
37  modulator(nullptr),
38  pulseShaper(nullptr),
39  digitalAnalogConverter(nullptr),
40  power(W(NaN)),
41  bitrate(bps(NaN)),
42  bandwidth(Hz(NaN)),
44 {
45 }
const IEncoder * encoder
Definition: APSKLayeredTransmitter.h:46
pow< s,-1 > Hz
Definition: Units.h:766
Hz bandwidth
Definition: APSKLayeredTransmitter.h:52
LevelOfDetail levelOfDetail
Definition: APSKLayeredTransmitter.h:45
W power
Definition: APSKLayeredTransmitter.h:50
compose< J, pow< s,-1 > > W
Definition: Units.h:770
LevelOfDetail
Definition: APSKLayeredTransmitter.h:37
compose< b, pow< s,-1 > > bps
Definition: Units.h:985
const IPulseShaper * pulseShaper
Definition: APSKLayeredTransmitter.h:48
bps bitrate
Definition: APSKLayeredTransmitter.h:51
#define NaN
Definition: INETMath.h:103
const IModulator * modulator
Definition: APSKLayeredTransmitter.h:47
const IDigitalAnalogConverter * digitalAnalogConverter
Definition: APSKLayeredTransmitter.h:49
Hz carrierFrequency
Definition: APSKLayeredTransmitter.h:53

Member Function Documentation

int inet::physicallayer::APSKLayeredTransmitter::computePaddingLength ( BitVector bits) const
protectedvirtual

Referenced by createPacketModel().

96 {
97  const ConvolutionalCode *forwardErrorCorrection = nullptr;
98  if (encoder) {
99  const APSKEncoder *apskEncoder = check_and_cast<const APSKEncoder *>(encoder);
100  forwardErrorCorrection = apskEncoder->getCode()->getConvolutionalCode();
101  }
102  int modulationCodeWordSize = check_and_cast<const APSKModulationBase *>(modulator->getModulation())->getCodeWordSize();
103  int encodedCodeWordSize = forwardErrorCorrection == nullptr ? modulationCodeWordSize : modulationCodeWordSize *forwardErrorCorrection->getCodeRatePuncturingK();
104  return (encodedCodeWordSize - bits->getSize() % encodedCodeWordSize) % encodedCodeWordSize;
105 }
const IEncoder * encoder
Definition: APSKLayeredTransmitter.h:46
const IModulator * modulator
Definition: APSKLayeredTransmitter.h:47
virtual const IModulation * getModulation() const =0
const ITransmissionAnalogModel * inet::physicallayer::APSKLayeredTransmitter::createAnalogModel ( const ITransmissionPacketModel packetModel,
const ITransmissionBitModel bitModel,
const ITransmissionSampleModel sampleModel 
) const
protectedvirtual

Referenced by createTransmission().

167 {
169  if (sampleModel == nullptr)
170  throw cRuntimeError("Digital analog converter needs sample domain representation");
171  else
172  return digitalAnalogConverter->convertDigitalToAnalog(sampleModel);
173  }
174  else {
175  simtime_t duration = packetModel->getPacket()->getBitLength() / bitrate.get();
176  return new ScalarTransmissionSignalAnalogModel(duration, carrierFrequency, bandwidth, power);
177  }
178 }
Hz bandwidth
Definition: APSKLayeredTransmitter.h:52
W power
Definition: APSKLayeredTransmitter.h:50
const value_type & get() const
Definition: Units.h:89
virtual const ITransmissionAnalogModel * convertDigitalToAnalog(const ITransmissionSampleModel *sampleModel) const =0
bps bitrate
Definition: APSKLayeredTransmitter.h:51
const IDigitalAnalogConverter * digitalAnalogConverter
Definition: APSKLayeredTransmitter.h:49
Hz carrierFrequency
Definition: APSKLayeredTransmitter.h:53
const ITransmissionBitModel * inet::physicallayer::APSKLayeredTransmitter::createBitModel ( const ITransmissionPacketModel packetModel) const
protectedvirtual

Referenced by createTransmission().

127 {
128  if (levelOfDetail >= BIT_DOMAIN)
129  return encoder->encode(packetModel);
130  else {
131  int netHeaderBitLength = APSK_PHY_FRAME_HEADER_BYTE_LENGTH * 8;
132  int netPayloadBitLength = packetModel->getSerializedPacket()->getSize() - netHeaderBitLength;
133  if (encoder) {
134  const APSKEncoder *apskEncoder = check_and_cast<const APSKEncoder *>(encoder);
135  const ConvolutionalCode *forwardErrorCorrection = apskEncoder->getCode()->getConvolutionalCode();
136  if (forwardErrorCorrection == nullptr)
137  return new TransmissionBitModel(netHeaderBitLength, bitrate, netPayloadBitLength, bitrate, nullptr, forwardErrorCorrection, nullptr, nullptr);
138  else {
139  int grossHeaderBitLength = forwardErrorCorrection->getEncodedLength(netHeaderBitLength);
140  int grossPayloadBitLength = forwardErrorCorrection->getEncodedLength(netPayloadBitLength);
141  bps grossBitrate = bitrate / forwardErrorCorrection->getCodeRate();
142  return new TransmissionBitModel(grossHeaderBitLength, grossBitrate, grossPayloadBitLength, grossBitrate, nullptr, forwardErrorCorrection, nullptr, nullptr);
143  }
144  }
145  else
146  return new TransmissionBitModel(netHeaderBitLength, bitrate, netPayloadBitLength, bitrate, nullptr, nullptr, nullptr, nullptr);
147  }
148 }
const IEncoder * encoder
Definition: APSKLayeredTransmitter.h:46
LevelOfDetail levelOfDetail
Definition: APSKLayeredTransmitter.h:45
Definition: APSKLayeredTransmitter.h:39
compose< b, pow< s,-1 > > bps
Definition: Units.h:985
virtual const ITransmissionBitModel * encode(const ITransmissionPacketModel *packetModel) const =0
bps bitrate
Definition: APSKLayeredTransmitter.h:51
#define APSK_PHY_FRAME_HEADER_BYTE_LENGTH
Definition: APSKPhyFrameSerializer.h:28
const ITransmissionPacketModel * inet::physicallayer::APSKLayeredTransmitter::createPacketModel ( const APSKPhyFrame phyFrame) const
protectedvirtual

Referenced by createTransmission().

116 {
117  if (levelOfDetail >= PACKET_DOMAIN) {
118  BitVector *bits = APSKPhyFrameSerializer().serialize(phyFrame);
119  bits->appendBit(0, computePaddingLength(bits));
120  return new TransmissionPacketModel(phyFrame, bits, bitrate);
121  }
122  else
123  return new TransmissionPacketModel(phyFrame, nullptr, bitrate);
124 }
LevelOfDetail levelOfDetail
Definition: APSKLayeredTransmitter.h:45
virtual int computePaddingLength(BitVector *bits) const
Definition: APSKLayeredTransmitter.cc:95
bps bitrate
Definition: APSKLayeredTransmitter.h:51
Definition: APSKLayeredTransmitter.h:38
const APSKPhyFrame * inet::physicallayer::APSKLayeredTransmitter::createPhyFrame ( const cPacket *  macFrame) const
protectedvirtual

Referenced by createTransmission().

108 {
109  APSKPhyFrame *phyFrame = new APSKPhyFrame();
110  phyFrame->setByteLength(APSK_PHY_FRAME_HEADER_BYTE_LENGTH);
111  phyFrame->encapsulate(const_cast<cPacket *>(macFrame));
112  return phyFrame;
113 }
#define APSK_PHY_FRAME_HEADER_BYTE_LENGTH
Definition: APSKPhyFrameSerializer.h:28
const ITransmissionSampleModel * inet::physicallayer::APSKLayeredTransmitter::createSampleModel ( const ITransmissionSymbolModel symbolModel) const
protectedvirtual

Referenced by createTransmission().

159 {
161  return pulseShaper->shape(symbolModel);
162  else
163  return nullptr;
164 }
LevelOfDetail levelOfDetail
Definition: APSKLayeredTransmitter.h:45
virtual const ITransmissionSampleModel * shape(const ITransmissionSymbolModel *symbolModel) const =0
const IPulseShaper * pulseShaper
Definition: APSKLayeredTransmitter.h:48
Definition: APSKLayeredTransmitter.h:41
const ITransmissionSymbolModel * inet::physicallayer::APSKLayeredTransmitter::createSymbolModel ( const ITransmissionBitModel bitModel) const
protectedvirtual

Referenced by createTransmission().

151 {
153  return modulator->modulate(bitModel);
154  else
155  return new TransmissionSymbolModel(-1, NaN, -1, NaN, nullptr, modulator->getModulation(), modulator->getModulation());
156 }
LevelOfDetail levelOfDetail
Definition: APSKLayeredTransmitter.h:45
#define NaN
Definition: INETMath.h:103
const IModulator * modulator
Definition: APSKLayeredTransmitter.h:47
virtual const ITransmissionSymbolModel * modulate(const ITransmissionBitModel *bitModel) const =0
Definition: APSKLayeredTransmitter.h:40
virtual const IModulation * getModulation() const =0
const ITransmission * inet::physicallayer::APSKLayeredTransmitter::createTransmission ( const IRadio transmitter,
const cPacket *  macFrame,
const simtime_t  startTime 
) const
overridevirtual

Returns a transmission which describes the radio signal corresponding to the provided mac frame.

This function never returns nullptr.

Implements inet::physicallayer::ITransmitter.

181 {
182  const APSKPhyFrame *phyFrame = createPhyFrame(macFrame);
183  const ITransmissionPacketModel *packetModel = createPacketModel(phyFrame);
184  const ITransmissionBitModel *bitModel = createBitModel(packetModel);
185  const ITransmissionSymbolModel *symbolModel = createSymbolModel(bitModel);
186  const ITransmissionSampleModel *sampleModel = createSampleModel(symbolModel);
187  const ITransmissionAnalogModel *analogModel = createAnalogModel(packetModel, bitModel, sampleModel);
188  // assuming movement and rotation during transmission is negligible
189  IMobility *mobility = transmitter->getAntenna()->getMobility();
190  const simtime_t endTime = startTime + analogModel->getDuration();
191  const Coord startPosition = mobility->getCurrentPosition();
192  const Coord endPosition = mobility->getCurrentPosition();
193  const EulerAngles startOrientation = mobility->getCurrentAngularPosition();
194  const EulerAngles endOrientation = mobility->getCurrentAngularPosition();
195  return new LayeredTransmission(packetModel, bitModel, symbolModel, sampleModel, analogModel, transmitter, macFrame, startTime, endTime, -1, -1, -1, startPosition, endPosition, startOrientation, endOrientation);
196 }
virtual const ITransmissionPacketModel * createPacketModel(const APSKPhyFrame *phyFrame) const
Definition: APSKLayeredTransmitter.cc:115
virtual const ITransmissionSampleModel * createSampleModel(const ITransmissionSymbolModel *symbolModel) const
Definition: APSKLayeredTransmitter.cc:158
virtual const ITransmissionAnalogModel * createAnalogModel(const ITransmissionPacketModel *packetModel, const ITransmissionBitModel *bitModel, const ITransmissionSampleModel *sampleModel) const
Definition: APSKLayeredTransmitter.cc:166
virtual const APSKPhyFrame * createPhyFrame(const cPacket *macFrame) const
Definition: APSKLayeredTransmitter.cc:107
virtual const ITransmissionBitModel * createBitModel(const ITransmissionPacketModel *packetModel) const
Definition: APSKLayeredTransmitter.cc:126
virtual const ITransmissionSymbolModel * createSymbolModel(const ITransmissionBitModel *bitModel) const
Definition: APSKLayeredTransmitter.cc:150
virtual const Hz inet::physicallayer::APSKLayeredTransmitter::getBandwidth ( ) const
inlinevirtual
76 { return bandwidth; }
Hz bandwidth
Definition: APSKLayeredTransmitter.h:52
virtual bps inet::physicallayer::APSKLayeredTransmitter::getBitrate ( ) const
inlinevirtual
75 { return bitrate; }
bps bitrate
Definition: APSKLayeredTransmitter.h:51
virtual const Hz inet::physicallayer::APSKLayeredTransmitter::getCarrierFrequency ( ) const
inlinevirtual
77 { return carrierFrequency; }
Hz carrierFrequency
Definition: APSKLayeredTransmitter.h:53
virtual const IDigitalAnalogConverter* inet::physicallayer::APSKLayeredTransmitter::getDigitalAnalogConverter ( ) const
inlinevirtual
73 { return digitalAnalogConverter; }
const IDigitalAnalogConverter * digitalAnalogConverter
Definition: APSKLayeredTransmitter.h:49
virtual const IEncoder* inet::physicallayer::APSKLayeredTransmitter::getEncoder ( ) const
inlinevirtual
70 { return encoder; }
const IEncoder * encoder
Definition: APSKLayeredTransmitter.h:46
virtual m inet::physicallayer::APSKLayeredTransmitter::getMaxCommunicationRange ( ) const
inlineoverridevirtual

Returns the maximum transmission range.

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

Reimplemented from inet::physicallayer::TransmitterBase.

79 { return m(NaN); }
#define NaN
Definition: INETMath.h:103
value< double, units::m > m
Definition: Units.h:1047
virtual m inet::physicallayer::APSKLayeredTransmitter::getMaxInterferenceRange ( ) const
inlineoverridevirtual

Returns the maximum interference range.

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

Reimplemented from inet::physicallayer::TransmitterBase.

80 { return m(NaN); }
#define NaN
Definition: INETMath.h:103
value< double, units::m > m
Definition: Units.h:1047
virtual W inet::physicallayer::APSKLayeredTransmitter::getMaxPower ( ) const
inlineoverridevirtual

Returns the maximum transmission power above which no transmission is ever transmitted.

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

Reimplemented from inet::physicallayer::TransmitterBase.

78 { return power; }
W power
Definition: APSKLayeredTransmitter.h:50
virtual const IModulator* inet::physicallayer::APSKLayeredTransmitter::getModulator ( ) const
inlinevirtual
71 { return modulator; }
const IModulator * modulator
Definition: APSKLayeredTransmitter.h:47
virtual W inet::physicallayer::APSKLayeredTransmitter::getPower ( ) const
inlinevirtual
74 { return power; }
W power
Definition: APSKLayeredTransmitter.h:50
virtual const IPulseShaper* inet::physicallayer::APSKLayeredTransmitter::getPulseShaper ( ) const
inlinevirtual
72 { return pulseShaper; }
const IPulseShaper * pulseShaper
Definition: APSKLayeredTransmitter.h:48
void inet::physicallayer::APSKLayeredTransmitter::initialize ( int  stage)
overrideprotectedvirtual
48 {
49  if (stage == INITSTAGE_LOCAL) {
50  encoder = dynamic_cast<const IEncoder *>(getSubmodule("encoder"));
51  modulator = dynamic_cast<const IModulator *>(getSubmodule("modulator"));
52  pulseShaper = dynamic_cast<const IPulseShaper *>(getSubmodule("pulseShaper"));
53  digitalAnalogConverter = dynamic_cast<const IDigitalAnalogConverter *>(getSubmodule("digitalAnalogConverter"));
54  power = W(par("power"));
55  bitrate = bps(par("bitrate"));
56  bandwidth = Hz(par("bandwidth"));
57  carrierFrequency = Hz(par("carrierFrequency"));
58  const char *levelOfDetailStr = par("levelOfDetail").stringValue();
59  if (strcmp("packet", levelOfDetailStr) == 0)
61  else if (strcmp("bit", levelOfDetailStr) == 0)
63  else if (strcmp("symbol", levelOfDetailStr) == 0)
65  else if (strcmp("sample", levelOfDetailStr) == 0)
67  else
68  throw cRuntimeError("Unknown level of detail='%s'", levelOfDetailStr);
69  if (levelOfDetail >= BIT_DOMAIN && !encoder)
70  throw cRuntimeError("Encoder not configured");
72  throw cRuntimeError("Modulator not configured");
74  throw cRuntimeError("Pulse shaper not configured");
75  }
76 }
const IEncoder * encoder
Definition: APSKLayeredTransmitter.h:46
pow< s,-1 > Hz
Definition: Units.h:766
Hz bandwidth
Definition: APSKLayeredTransmitter.h:52
LevelOfDetail levelOfDetail
Definition: APSKLayeredTransmitter.h:45
W power
Definition: APSKLayeredTransmitter.h:50
Definition: APSKLayeredTransmitter.h:39
compose< J, pow< s,-1 > > W
Definition: Units.h:770
compose< b, pow< s,-1 > > bps
Definition: Units.h:985
const IPulseShaper * pulseShaper
Definition: APSKLayeredTransmitter.h:48
Local initializations.
Definition: InitStages.h:35
bps bitrate
Definition: APSKLayeredTransmitter.h:51
const IModulator * modulator
Definition: APSKLayeredTransmitter.h:47
const IDigitalAnalogConverter * digitalAnalogConverter
Definition: APSKLayeredTransmitter.h:49
Definition: APSKLayeredTransmitter.h:38
Hz carrierFrequency
Definition: APSKLayeredTransmitter.h:53
Definition: APSKLayeredTransmitter.h:40
Definition: APSKLayeredTransmitter.h:41
std::ostream & inet::physicallayer::APSKLayeredTransmitter::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.

79 {
80  stream << "APSKLayeredTransmitter";
81  if (level <= PRINT_LEVEL_DETAIL)
82  stream << ", levelOfDetail = " << levelOfDetail
83  << ", carrierFrequency = " << carrierFrequency;
84  if (level <= PRINT_LEVEL_TRACE)
85  stream << ", encoder = " << printObjectToString(encoder, level + 1)
86  << ", modulator = " << printObjectToString(modulator, level + 1)
87  << ", pulseShaper = " << printObjectToString(pulseShaper, level + 1)
88  << ", digitalAnalogConverter = " << printObjectToString(digitalAnalogConverter, level + 1)
89  << ", power = " << power
90  << ", bitrate = " << bitrate
91  << ", bandwidth = " << bandwidth;
92  return stream;
93 }
const IEncoder * encoder
Definition: APSKLayeredTransmitter.h:46
Hz bandwidth
Definition: APSKLayeredTransmitter.h:52
LevelOfDetail levelOfDetail
Definition: APSKLayeredTransmitter.h:45
std::string printObjectToString(const IPrintableObject *object, int level)
Definition: IPrintableObject.h:73
W power
Definition: APSKLayeredTransmitter.h:50
const IPulseShaper * pulseShaper
Definition: APSKLayeredTransmitter.h:48
bps bitrate
Definition: APSKLayeredTransmitter.h:51
const IModulator * modulator
Definition: APSKLayeredTransmitter.h:47
const IDigitalAnalogConverter * digitalAnalogConverter
Definition: APSKLayeredTransmitter.h:49
Hz carrierFrequency
Definition: APSKLayeredTransmitter.h:53

Member Data Documentation

Hz inet::physicallayer::APSKLayeredTransmitter::bandwidth
protected
bps inet::physicallayer::APSKLayeredTransmitter::bitrate
protected
Hz inet::physicallayer::APSKLayeredTransmitter::carrierFrequency
protected
const IDigitalAnalogConverter* inet::physicallayer::APSKLayeredTransmitter::digitalAnalogConverter
protected
const IEncoder* inet::physicallayer::APSKLayeredTransmitter::encoder
protected
LevelOfDetail inet::physicallayer::APSKLayeredTransmitter::levelOfDetail
protected
const IModulator* inet::physicallayer::APSKLayeredTransmitter::modulator
protected
W inet::physicallayer::APSKLayeredTransmitter::power
protected
const IPulseShaper* inet::physicallayer::APSKLayeredTransmitter::pulseShaper
protected

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