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

#include <AdditiveScrambler.h>

Inheritance diagram for inet::physicallayer::AdditiveScrambler:
inet::physicallayer::IScrambler inet::physicallayer::IPrintableObject

Public Member Functions

 AdditiveScrambler (const AdditiveScrambling *scrambling)
 
virtual std::ostream & printToStream (std::ostream &stream, int level) const override
 Prints this object to the provided output stream. More...
 
BitVector scramble (const BitVector &bits) const override
 
BitVector descramble (const BitVector &bits) const override
 
const AdditiveScramblinggetScrambling () const override
 
const BitVectorgetScramblingSequcene () const
 
- 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

bool eXOR (bool alpha, bool beta) const
 
BitVector generateScramblingSequence (const ShortBitVector &generatorPolynomial, const ShortBitVector &seed) const
 

Protected Attributes

BitVector scramblingSequence
 
const AdditiveScramblingscrambling
 

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::AdditiveScrambler::AdditiveScrambler ( const AdditiveScrambling scrambling)
66 {
67  ShortBitVector generatorPolynomial = scrambling->getGeneratorPolynomial();
68  ShortBitVector seed = scrambling->getSeed();
69  scramblingSequence = generateScramblingSequence(generatorPolynomial, seed);
70 }
BitVector scramblingSequence
Definition: AdditiveScrambler.h:39
const AdditiveScrambling * scrambling
Definition: AdditiveScrambler.h:40
const ShortBitVector & getGeneratorPolynomial() const
Definition: AdditiveScrambling.h:39
const ShortBitVector & getSeed() const
Definition: AdditiveScrambling.h:40
BitVector generateScramblingSequence(const ShortBitVector &generatorPolynomial, const ShortBitVector &seed) const
Definition: AdditiveScrambler.cc:47

Member Function Documentation

BitVector inet::physicallayer::AdditiveScrambler::descramble ( const BitVector bits) const
inlineoverridevirtual

Implements inet::physicallayer::IScrambler.

Referenced by inet::physicallayer::AdditiveScramblerModule::descramble().

51 { return scramble(bits); }
BitVector scramble(const BitVector &bits) const override
Definition: AdditiveScrambler.cc:33
bool inet::physicallayer::AdditiveScrambler::eXOR ( bool  alpha,
bool  beta 
) const
inlineprotected

Referenced by generateScramblingSequence(), and scramble().

43 { return alpha != beta; }
const value< double, units::unit > alpha(7.2973525376e-3)
BitVector inet::physicallayer::AdditiveScrambler::generateScramblingSequence ( const ShortBitVector generatorPolynomial,
const ShortBitVector seed 
) const
protected

Referenced by AdditiveScrambler().

48 {
49  BitVector scramblingSequence;
50  int sequenceLength = (int)pow(2, seed.getSize()) - 1;
51  ShortBitVector shiftRegisters = seed;
52  for (int i = 0; i < sequenceLength; i++) {
53  bool registerSum = false;
54  for (unsigned int j = 0; j < generatorPolynomial.getSize(); j++) {
55  if (generatorPolynomial.getBit(j))
56  registerSum = eXOR(shiftRegisters.getBit(j), registerSum);
57  }
58  shiftRegisters.leftShift(1);
59  shiftRegisters.setBit(0, registerSum);
60  scramblingSequence.appendBit(registerSum);
61  }
62  return scramblingSequence;
63 }
bool eXOR(bool alpha, bool beta) const
Definition: AdditiveScrambler.h:43
BitVector scramblingSequence
Definition: AdditiveScrambler.h:39
const AdditiveScrambling* inet::physicallayer::AdditiveScrambler::getScrambling ( ) const
inlineoverridevirtual

Implements inet::physicallayer::IScrambler.

Referenced by inet::physicallayer::AdditiveScramblerModule::getScrambling().

52 { return scrambling; }
const AdditiveScrambling * scrambling
Definition: AdditiveScrambler.h:40
const BitVector& inet::physicallayer::AdditiveScrambler::getScramblingSequcene ( ) const
inline
53 { return scramblingSequence; }
BitVector scramblingSequence
Definition: AdditiveScrambler.h:39
std::ostream & inet::physicallayer::AdditiveScrambler::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.

Referenced by inet::physicallayer::AdditiveScramblerModule::printToStream().

26 {
27  stream << "AdditiveScrambler";
28  if (level <= PRINT_LEVEL_TRACE)
29  stream<< ", scrambling = " << printObjectToString(scrambling, level + 1);
30  return stream;
31 }
std::string printObjectToString(const IPrintableObject *object, int level)
Definition: IPrintableObject.h:73
const AdditiveScrambling * scrambling
Definition: AdditiveScrambler.h:40
BitVector inet::physicallayer::AdditiveScrambler::scramble ( const BitVector bits) const
overridevirtual

Implements inet::physicallayer::IScrambler.

Referenced by inet::physicallayer::AdditiveScramblerModule::scramble().

34 {
35  EV_DEBUG << "Scrambling the following bits: " << bits << endl;
36  BitVector scrambledBits;
37  int sequenceLength = scramblingSequence.getSize();
38  for (unsigned int i = 0; i < bits.getSize(); i++) {
39  int scramblingIndex = i % sequenceLength;
40  bool scrambledBit = eXOR(bits.getBit(i), scramblingSequence.getBit(scramblingIndex));
41  scrambledBits.appendBit(scrambledBit);
42  }
43  EV_DEBUG << "The scrambled bits are: " << scrambledBits << endl;
44  return scrambledBits;
45 }
unsigned int getSize() const
Definition: BitVector.h:53
bool eXOR(bool alpha, bool beta) const
Definition: AdditiveScrambler.h:43
BitVector scramblingSequence
Definition: AdditiveScrambler.h:39
bool getBit(int pos) const
Definition: BitVector.cc:82

Member Data Documentation

const AdditiveScrambling* inet::physicallayer::AdditiveScrambler::scrambling
protected

Referenced by printToStream().

BitVector inet::physicallayer::AdditiveScrambler::scramblingSequence
protected

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