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

Ordinal Based Duplicator module. More...

#include <OrdinalBasedDuplicator.h>

Inheritance diagram for inet::queueing::OrdinalBasedDuplicator:
inet::queueing::PacketDuplicatorBase inet::queueing::PacketProcessorBase inet::queueing::IPacketDuplicator inet::queueing::IPacketProcessor inet::StringFormat::IDirectiveResolver inet::queueing::IPassivePacketSink inet::queueing::IActivePacketSource

Protected Member Functions

virtual void initialize (int stage) override
 
virtual void parseVector (const char *vector)
 
int getNumPacketDuplicates (Packet *packet) override
 Returns the number of duplicates to be generated. More...
 
- Protected Member Functions inherited from inet::queueing::PacketProcessorBase
virtual int numInitStages () const override
 
virtual void refreshDisplay () const override
 
virtual void handlePacketProcessed (Packet *packet)
 
virtual void checkPacketOperationSupport (cGate *gate) const
 
virtual void checkPacketOperationSupport (cGate *startGate, cGate *endGate) const
 
virtual void animate (Packet *packet, cGate *gate, const SendOptions &sendOptions, Action action) const
 
virtual void animatePacket (Packet *packet, cGate *gate, Action action) const
 
virtual void animatePacketStart (Packet *packet, cGate *gate, bps datarate, long transmissionId, Action action) const
 
virtual void animatePacketStart (Packet *packet, cGate *gate, bps datarate, const SendOptions &sendOptions, Action action) const
 
virtual void animatePacketEnd (Packet *packet, cGate *gate, long transmissionId, Action action) const
 
virtual void animatePacketEnd (Packet *packet, cGate *gate, const SendOptions &sendOptions, Action action) const
 
virtual void animatePacketProgress (Packet *packet, cGate *gate, bps datarate, b position, b extraProcessableLength, long transmissionId, Action action) const
 
virtual void animatePacketProgress (Packet *packet, cGate *gate, bps datarate, b position, b extraProcessableLength, const SendOptions &sendOptions, Action action) const
 
virtual void pushOrSendPacket (Packet *packet, cGate *gate, IPassivePacketSink *consumer)
 
virtual void pushOrSendPacketStart (Packet *packet, cGate *gate, IPassivePacketSink *consumer, bps datarate, int transmissionId)
 
virtual void pushOrSendPacketEnd (Packet *packet, cGate *gate, IPassivePacketSink *consumer, int transmissionId)
 
virtual void pushOrSendPacketProgress (Packet *packet, cGate *gate, IPassivePacketSink *consumer, bps datarate, b position, b extraProcessableLength, int transmissionId)
 
virtual void animatePush (Packet *packet, cGate *gate, const SendOptions &sendOptions) const
 
virtual void animatePushPacket (Packet *packet, cGate *gate) const
 
virtual void animatePushPacketStart (Packet *packet, cGate *gate, bps datarate, long transmissionId) const
 
virtual void animatePushPacketStart (Packet *packet, cGate *gate, bps datarate, const SendOptions &sendOptions) const
 
virtual void animatePushPacketEnd (Packet *packet, cGate *gate, long transmissionId) const
 
virtual void animatePushPacketEnd (Packet *packet, cGate *gate, const SendOptions &sendOptions) const
 
virtual void animatePushPacketProgress (Packet *packet, cGate *gate, bps datarate, b position, b extraProcessableLength, long transmissionId) const
 
virtual void animatePushPacketProgress (Packet *packet, cGate *gate, bps datarate, b position, b extraProcessableLength, const SendOptions &sendOptions) const
 
virtual void animatePull (Packet *packet, cGate *gate, const SendOptions &sendOptions) const
 
virtual void animatePullPacket (Packet *packet, cGate *gate) const
 
virtual void animatePullPacketStart (Packet *packet, cGate *gate, bps datarate, long transmissionId) const
 
virtual void animatePullPacketStart (Packet *packet, cGate *gate, bps datarate, const SendOptions &sendOptions) const
 
virtual void animatePullPacketEnd (Packet *packet, cGate *gate, long transmissionId) const
 
virtual void animatePullPacketEnd (Packet *packet, cGate *gate, const SendOptions &sendOptions) const
 
virtual void animatePullPacketProgress (Packet *packet, cGate *gate, bps datarate, b position, b extraProcessableLength, long transmissionId) const
 
virtual void animatePullPacketProgress (Packet *packet, cGate *gate, bps datarate, b position, b extraProcessableLength, const SendOptions &sendOptions) const
 
virtual void dropPacket (Packet *packet, PacketDropReason reason, int limit=-1)
 
virtual void updateDisplayString () const
 

Protected Attributes

unsigned int numPackets
 
unsigned int numDuplicated
 
bool generateFurtherDuplicates
 
std::vector< unsigned int > duplicatesVector
 
- Protected Attributes inherited from inet::queueing::PacketDuplicatorBase
cGate * inputGate = nullptr
 
IActivePacketSourceproducer = nullptr
 
cGate * outputGate = nullptr
 
IPassivePacketSinkconsumer = nullptr
 
- Protected Attributes inherited from inet::queueing::PacketProcessorBase
const char * displayStringTextFormat = nullptr
 
int numProcessedPackets = -1
 
b processedTotalLength = b(-1)
 

Additional Inherited Members

- Public Member Functions inherited from inet::queueing::PacketDuplicatorBase
virtual IPassivePacketSinkgetConsumer (cGate *gate) override
 Returns the passive packet sink where packets are pushed or nullptr if the connected module doesn't implement the interface. More...
 
virtual bool supportsPacketPushing (cGate *gate) const override
 Returns true if the processor supports pushing packets at the given gate. More...
 
virtual bool supportsPacketPulling (cGate *gate) const override
 Returns true if the processor supports pulling packets at the given gate. More...
 
virtual bool canPushSomePacket (cGate *gate) const override
 Returns false if the packet sink is full at the given gate and no more packets can be pushed into it without raising an error. More...
 
virtual bool canPushPacket (Packet *packet, cGate *gate) const override
 Returns true if the given packet can be pushed at the given gate into the packet sink without raising an error. More...
 
virtual void pushPacket (Packet *packet, cGate *gate) override
 Pushes the packet into the packet sink at the given gate. More...
 
virtual void pushPacketStart (Packet *packet, cGate *gate, bps datarate) override
 Starts pushing the packet into the packet sink at the given gate. More...
 
virtual void pushPacketEnd (Packet *packet, cGate *gate) override
 Ends pushing the packet into the packet sink at the given gate. More...
 
virtual void pushPacketProgress (Packet *packet, cGate *gate, bps datarate, b position, b extraProcessableLength=b(0)) override
 Progresses pushing the packet into the packet sink at the given gate. More...
 
virtual void handleCanPushPacketChanged (cGate *gate) override
 Notifies about a change in the possibility of pushing some packet into the passive packet sink at the given gate. More...
 
virtual void handlePushPacketProcessed (Packet *packet, cGate *gate, bool successful) override
 Notifies about the completion of the packet processing for a packet that was pushed earlier independently whether the packet is passed or streamed. More...
 
- Public Member Functions inherited from inet::queueing::PacketProcessorBase
virtual bool supportsPacketSending (cGate *gate) const override
 Returns true if the processor supports sending packets at the given gate. More...
 
virtual bool supportsPacketPassing (cGate *gate) const override
 Returns true if the processor supports passing packets as a whole at the given gate. More...
 
virtual bool supportsPacketStreaming (cGate *gate) const override
 Returns true if the processor supports streaming packets at the given gate. More...
 
virtual const char * resolveDirective (char directive) const override
 
- Public Member Functions inherited from inet::queueing::IPacketProcessor
virtual ~IPacketProcessor ()
 
- Public Member Functions inherited from inet::queueing::IPassivePacketSink
virtual ~IPassivePacketSink ()
 
- Public Member Functions inherited from inet::queueing::IActivePacketSource
virtual ~IActivePacketSource ()
 
- Protected Types inherited from inet::queueing::PacketProcessorBase
enum  Action { PUSH, PULL }
 

Detailed Description

Ordinal Based Duplicator module.

Member Function Documentation

◆ getNumPacketDuplicates()

int inet::queueing::OrdinalBasedDuplicator::getNumPacketDuplicates ( Packet packet)
overrideprotectedvirtual

Returns the number of duplicates to be generated.

Implements inet::queueing::IPacketDuplicator.

43 {
45  if (numPackets == duplicatesVector[0]) {
46  EV_DEBUG << "Duplicating packet" << EV_FIELD(ordinalNumber, numPackets) << EV_FIELD(packet) << EV_ENDL;
47  numDuplicated++;
48  duplicatesVector.erase(duplicatesVector.begin());
49  if (duplicatesVector.size() == 0) {
50  EV_DEBUG << "End of duplicatesVector reached" << EV_ENDL;
52  }
53  numPackets++;
54  return 1;
55  }
56  }
57  numPackets++;
58  return 0;
59 }

◆ initialize()

void inet::queueing::OrdinalBasedDuplicator::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::queueing::PacketDuplicatorBase.

19 {
21  if (stage == INITSTAGE_LOCAL) {
22  numPackets = 0;
23  numDuplicated = 0;
25 
26  WATCH(numPackets);
27  WATCH(numDuplicated);
29 
30  const char *vector = par("duplicatesVector");
31  parseVector(vector);
32 
33  if (duplicatesVector.size() == 0)
34  EV_WARN << "Empty duplicatesVector" << EV_ENDL;
35  else {
36  EV_DEBUG << EV_FIELD(duplicatesVector, vector) << EV_ENDL;
38  }
39  }
40 }

◆ parseVector()

void inet::queueing::OrdinalBasedDuplicator::parseVector ( const char *  vector)
protectedvirtual
62 {
63  const char *v = vector;
64  while (*v) {
65  // parse packet numbers
66  while (isspace(*v))
67  v++;
68  if (!*v || *v == ';')
69  break;
70  if (!isdigit(*v))
71  throw cRuntimeError("Syntax error in duplicatesVector: packet number expected");
72  if (duplicatesVector.size() > 0 && duplicatesVector.back() >= (unsigned int)atoi(v))
73  throw cRuntimeError("Syntax error in duplicatesVector: packet numbers in ascending order expected");
74 
75  duplicatesVector.push_back(atoi(v));
76  while (isdigit(*v))
77  v++;
78 
79  // skip delimiter
80  while (isspace(*v))
81  v++;
82  if (!*v)
83  break;
84  if (*v != ';')
85  throw cRuntimeError("Syntax error in duplicatesVector: separator ';' missing");
86  v++;
87  while (isspace(*v))
88  v++;
89  }
90 }

Referenced by initialize().

Member Data Documentation

◆ duplicatesVector

std::vector<unsigned int> inet::queueing::OrdinalBasedDuplicator::duplicatesVector
protected

◆ generateFurtherDuplicates

bool inet::queueing::OrdinalBasedDuplicator::generateFurtherDuplicates
protected

◆ numDuplicated

unsigned int inet::queueing::OrdinalBasedDuplicator::numDuplicated
protected

◆ numPackets

unsigned int inet::queueing::OrdinalBasedDuplicator::numPackets
protected

The documentation for this class was generated from the following files:
inet::queueing::OrdinalBasedDuplicator::parseVector
virtual void parseVector(const char *vector)
Definition: OrdinalBasedDuplicator.cc:61
inet::queueing::PacketDuplicatorBase::initialize
virtual void initialize(int stage) override
Definition: PacketDuplicatorBase.cc:16
inet::queueing::OrdinalBasedDuplicator::duplicatesVector
std::vector< unsigned int > duplicatesVector
Definition: OrdinalBasedDuplicator.h:28
EV_FIELD
#define EV_FIELD(...)
Definition: INETDefs.h:112
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
inet::queueing::OrdinalBasedDuplicator::generateFurtherDuplicates
bool generateFurtherDuplicates
Definition: OrdinalBasedDuplicator.h:26
inet::queueing::OrdinalBasedDuplicator::numPackets
unsigned int numPackets
Definition: OrdinalBasedDuplicator.h:24
EV_ENDL
#define EV_ENDL
Definition: INETDefs.h:114
inet::queueing::OrdinalBasedDuplicator::numDuplicated
unsigned int numDuplicated
Definition: OrdinalBasedDuplicator.h:25