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

#include <APSKEncoder.h>

Inheritance diagram for inet::physicallayer::APSKEncoder:
inet::physicallayer::IEncoder inet::physicallayer::IPrintableObject

Public Member Functions

 APSKEncoder ()
 
virtual ~APSKEncoder ()
 
virtual std::ostream & printToStream (std::ostream &stream, int level) const override
 Prints this object to the provided output stream. More...
 
virtual const APSKCodegetCode () const override
 
virtual const ITransmissionBitModelencode (const ITransmissionPacketModel *packetModel) const override
 
- 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 int numInitStages () const override
 
virtual void initialize (int stage) override
 

Protected Attributes

const APSKCodecode
 
const IScramblerscrambler
 
const IFECCoderfecEncoder
 
const IInterleaverinterleaver
 

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
}
 

Constructor & Destructor Documentation

inet::physicallayer::APSKEncoder::APSKEncoder ( )
27  :
28  code(nullptr),
29  scrambler(nullptr),
30  fecEncoder(nullptr),
31  interleaver(nullptr)
32 {
33 }
const IInterleaver * interleaver
Definition: APSKEncoder.h:40
const IScrambler * scrambler
Definition: APSKEncoder.h:38
const APSKCode * code
Definition: APSKEncoder.h:37
const IFECCoder * fecEncoder
Definition: APSKEncoder.h:39
inet::physicallayer::APSKEncoder::~APSKEncoder ( )
virtual
36 {
37  delete code;
38 }
const APSKCode * code
Definition: APSKEncoder.h:37

Member Function Documentation

const ITransmissionBitModel * inet::physicallayer::APSKEncoder::encode ( const ITransmissionPacketModel packetModel) const
overridevirtual

Implements inet::physicallayer::IEncoder.

68 {
69  const BitVector *serializedBits = packetModel->getSerializedPacket();
70  BitVector *encodedBits = new BitVector(*serializedBits);
71  const IScrambling *scrambling = nullptr;
72  if (scrambler) {
73  *encodedBits = scrambler->scramble(*encodedBits);
74  scrambling = scrambler->getScrambling();
75  EV_DEBUG << "Scrambled bits are: " << *encodedBits << endl;
76  }
77  const IForwardErrorCorrection *forwardErrorCorrection = nullptr;
78  if (fecEncoder) {
79  *encodedBits = fecEncoder->encode(*encodedBits);
80  forwardErrorCorrection = fecEncoder->getForwardErrorCorrection();
81  EV_DEBUG << "FEC encoded bits are: " << *encodedBits << endl;
82  }
83  const IInterleaving *interleaving = nullptr;
84  if (interleaver) {
85  *encodedBits = interleaver->interleave(*encodedBits);
86  interleaving = interleaver->getInterleaving();
87  EV_DEBUG << "Interleaved bits are: " << *encodedBits << endl;
88  }
89  int netHeaderBitLength = APSK_PHY_FRAME_HEADER_BYTE_LENGTH * 8;
90  if (forwardErrorCorrection == nullptr)
91  return new TransmissionBitModel(netHeaderBitLength, packetModel->getBitrate(), serializedBits->getSize() - netHeaderBitLength, packetModel->getBitrate(), encodedBits, forwardErrorCorrection, scrambling, interleaving);
92  else {
93  int grossHeaderBitLength = forwardErrorCorrection->getEncodedLength(netHeaderBitLength);
94  bps grossBitrate = packetModel->getBitrate() / forwardErrorCorrection->getCodeRate();
95  return new TransmissionBitModel(grossHeaderBitLength, grossBitrate, serializedBits->getSize() - grossHeaderBitLength, grossBitrate, encodedBits, forwardErrorCorrection, scrambling, interleaving);
96  }
97 }
const IInterleaver * interleaver
Definition: APSKEncoder.h:40
virtual const IInterleaving * getInterleaving() const =0
virtual BitVector encode(const BitVector &informationBits) const =0
const IScrambler * scrambler
Definition: APSKEncoder.h:38
virtual BitVector scramble(const BitVector &bits) const =0
virtual const IScrambling * getScrambling() const =0
compose< b, pow< s,-1 > > bps
Definition: Units.h:985
virtual const IForwardErrorCorrection * getForwardErrorCorrection() const =0
virtual BitVector interleave(const BitVector &bits) const =0
const IFECCoder * fecEncoder
Definition: APSKEncoder.h:39
#define APSK_PHY_FRAME_HEADER_BYTE_LENGTH
Definition: APSKPhyFrameSerializer.h:28
virtual const APSKCode* inet::physicallayer::APSKEncoder::getCode ( ) const
inlineoverridevirtual
void inet::physicallayer::APSKEncoder::initialize ( int  stage)
overrideprotectedvirtual
41 {
42  if (stage == INITSTAGE_LOCAL) {
43  scrambler = dynamic_cast<IScrambler *>(getSubmodule("scrambler"));
44  fecEncoder = dynamic_cast<IFECCoder *>(getSubmodule("fecEncoder"));
45  interleaver = dynamic_cast<IInterleaver *>(getSubmodule("interleaver"));
46  }
47  else if (stage == INITSTAGE_PHYSICAL_LAYER) {
48  const IScrambling *scrambling = scrambler != nullptr ? scrambler->getScrambling() : nullptr;
49  const ConvolutionalCode *forwardErrorCorrection = fecEncoder != nullptr ? check_and_cast<const ConvolutionalCode *>(fecEncoder->getForwardErrorCorrection()) : nullptr;
50  const IInterleaving *interleaving = interleaver != nullptr ? interleaver->getInterleaving() : nullptr;
51  code = new APSKCode(forwardErrorCorrection, interleaving, scrambling);
52  }
53 }
const IInterleaver * interleaver
Definition: APSKEncoder.h:40
Initialization of the physical layer of protocol stacks.
Definition: InitStages.h:53
virtual const IInterleaving * getInterleaving() const =0
const IScrambler * scrambler
Definition: APSKEncoder.h:38
virtual const IScrambling * getScrambling() const =0
Local initializations.
Definition: InitStages.h:35
virtual const IForwardErrorCorrection * getForwardErrorCorrection() const =0
const APSKCode * code
Definition: APSKEncoder.h:37
const IFECCoder * fecEncoder
Definition: APSKEncoder.h:39
virtual int inet::physicallayer::APSKEncoder::numInitStages ( ) const
inlineoverrideprotectedvirtual
43 { return NUM_INIT_STAGES; }
The number of initialization stages.
Definition: InitStages.h:116
std::ostream & inet::physicallayer::APSKEncoder::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.

56 {
57  stream << "APSKEncoder";
58  if (level <= PRINT_LEVEL_DETAIL)
59  stream << ", code = " << printObjectToString(code, level + 1);
60  if (level <= PRINT_LEVEL_TRACE)
61  stream << ", scrambler = " << printObjectToString(scrambler, level + 1)
62  << ", fecEncoder = " << printObjectToString(fecEncoder, level + 1)
63  << ", interleaver = " << printObjectToString(interleaver, level + 1);
64  return stream;
65 }
const IInterleaver * interleaver
Definition: APSKEncoder.h:40
std::string printObjectToString(const IPrintableObject *object, int level)
Definition: IPrintableObject.h:73
const IScrambler * scrambler
Definition: APSKEncoder.h:38
const APSKCode * code
Definition: APSKEncoder.h:37
const IFECCoder * fecEncoder
Definition: APSKEncoder.h:39

Member Data Documentation

const APSKCode* inet::physicallayer::APSKEncoder::code
protected
const IFECCoder* inet::physicallayer::APSKEncoder::fecEncoder
protected

Referenced by encode(), initialize(), and printToStream().

const IInterleaver* inet::physicallayer::APSKEncoder::interleaver
protected

Referenced by encode(), initialize(), and printToStream().

const IScrambler* inet::physicallayer::APSKEncoder::scrambler
protected

Referenced by encode(), initialize(), and printToStream().


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