INET Framework for OMNeT++/OMNEST
inet::OrdinalBasedDuplicator Class Reference

Ordinal Based Duplicator module. More...

#include <OrdinalBasedDuplicator.h>

Inheritance diagram for inet::OrdinalBasedDuplicator:

Protected Member Functions

virtual void initialize () override
 
virtual void handleMessage (cMessage *msg) override
 
virtual void parseVector (const char *vector)
 
virtual void finish () override
 

Protected Attributes

unsigned int numPackets
 
unsigned int numDuplicated
 
bool generateFurtherDuplicates
 
std::vector< unsigned int > duplicatesVector
 

Static Protected Attributes

static simsignal_t rcvdPkSignal = registerSignal("rcvdPk")
 
static simsignal_t sentPkSignal = registerSignal("sentPk")
 
static simsignal_t duplPkSignal = registerSignal("duplPk")
 

Detailed Description

Ordinal Based Duplicator module.

Member Function Documentation

void inet::OrdinalBasedDuplicator::finish ( )
overrideprotectedvirtual
109 {
110 }
void inet::OrdinalBasedDuplicator::handleMessage ( cMessage *  msg)
overrideprotectedvirtual
53 {
54  numPackets++;
55 
56  emit(rcvdPkSignal, msg);
57 
59  if (numPackets == duplicatesVector[0]) {
60  EV << "DuplicatesGenerator: Duplicating packet number " << numPackets << " " << msg << endl;
61  cMessage *dupmsg = utils::dupPacketAndControlInfo(msg);
62  emit(duplPkSignal, dupmsg);
63  emit(sentPkSignal, dupmsg);
64  send(dupmsg, "out");
65  numDuplicated++;
66  duplicatesVector.erase(duplicatesVector.begin());
67  if (duplicatesVector.size() == 0) {
68  EV << "DuplicatesGenerator: End of duplicatesVector reached." << endl;
70  }
71  }
72  }
73  emit(sentPkSignal, msg);
74  send(msg, "out");
75 }
static simsignal_t sentPkSignal
Definition: OrdinalBasedDuplicator.h:38
bool generateFurtherDuplicates
Definition: OrdinalBasedDuplicator.h:35
unsigned int numPackets
Definition: OrdinalBasedDuplicator.h:33
static simsignal_t rcvdPkSignal
Definition: OrdinalBasedDuplicator.h:37
std::vector< unsigned int > duplicatesVector
Definition: OrdinalBasedDuplicator.h:41
unsigned int numDuplicated
Definition: OrdinalBasedDuplicator.h:34
static simsignal_t duplPkSignal
Definition: OrdinalBasedDuplicator.h:39
T * dupPacketAndControlInfo(T *packet)
Duplicate a packet together with its control info.
Definition: INETUtils.h:86
void inet::OrdinalBasedDuplicator::initialize ( )
overrideprotectedvirtual
31 {
32  numPackets = 0;
33  numDuplicated = 0;
35 
36  WATCH(numPackets);
37  WATCH(numDuplicated);
39 
40  const char *vector = par("duplicatesVector");
41  parseVector(vector);
42 
43  if (duplicatesVector.size() == 0) {
44  EV << "DuplicatesGenerator: Empty duplicatesVector" << endl;
45  }
46  else {
47  EV << "DuplicatesGenerator: duplicatesVector=" << vector << endl;
49  }
50 }
bool generateFurtherDuplicates
Definition: OrdinalBasedDuplicator.h:35
unsigned int numPackets
Definition: OrdinalBasedDuplicator.h:33
std::vector< unsigned int > duplicatesVector
Definition: OrdinalBasedDuplicator.h:41
unsigned int numDuplicated
Definition: OrdinalBasedDuplicator.h:34
virtual void parseVector(const char *vector)
Definition: OrdinalBasedDuplicator.cc:77
void inet::OrdinalBasedDuplicator::parseVector ( const char *  vector)
protectedvirtual

Referenced by initialize().

78 {
79  const char *v = vector;
80  while (*v) {
81  // parse packet numbers
82  while (isspace(*v))
83  v++;
84  if (!*v || *v == ';')
85  break;
86  if (!isdigit(*v))
87  throw cRuntimeError("Syntax error in duplicatesVector: packet number expected");
88  if (duplicatesVector.size() > 0 && duplicatesVector.back() >= (unsigned int)atoi(v))
89  throw cRuntimeError("Syntax error in duplicatesVector: packet numbers in ascending order expected");
90 
91  duplicatesVector.push_back(atoi(v));
92  while (isdigit(*v))
93  v++;
94 
95  // skip delimiter
96  while (isspace(*v))
97  v++;
98  if (!*v)
99  break;
100  if (*v != ';')
101  throw cRuntimeError("Syntax error in duplicatesVector: separator ';' missing");
102  v++;
103  while (isspace(*v))
104  v++;
105  }
106 }
std::vector< unsigned int > duplicatesVector
Definition: OrdinalBasedDuplicator.h:41

Member Data Documentation

std::vector<unsigned int> inet::OrdinalBasedDuplicator::duplicatesVector
protected
simsignal_t inet::OrdinalBasedDuplicator::duplPkSignal = registerSignal("duplPk")
staticprotected

Referenced by handleMessage().

bool inet::OrdinalBasedDuplicator::generateFurtherDuplicates
protected

Referenced by handleMessage(), and initialize().

unsigned int inet::OrdinalBasedDuplicator::numDuplicated
protected

Referenced by handleMessage(), and initialize().

unsigned int inet::OrdinalBasedDuplicator::numPackets
protected

Referenced by handleMessage(), and initialize().

simsignal_t inet::OrdinalBasedDuplicator::rcvdPkSignal = registerSignal("rcvdPk")
staticprotected

Referenced by handleMessage().

simsignal_t inet::OrdinalBasedDuplicator::sentPkSignal = registerSignal("sentPk")
staticprotected

Referenced by handleMessage().


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