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

#include <MultiTokenBucketClassifier.h>

Inheritance diagram for inet::queueing::MultiTokenBucketClassifier:
inet::queueing::TokenBucketClassifierMixin< MultiTokenBucketMixin< PacketClassifierBase > > inet::queueing::MultiTokenBucketMixin< PacketClassifierBase > inet::queueing::PacketClassifierBase inet::queueing::ITokenStorage inet::queueing::PacketProcessorBase inet::TransparentProtocolRegistrationListener inet::queueing::IPacketSink inet::queueing::IPacketSource inet::queueing::IActivePacketSource inet::queueing::IPassivePacketSource inet::queueing::IActivePacketSink inet::queueing::IPassivePacketSink inet::IProtocolRegistrationListener inet::StringFormat::IDirectiveResolver inet::queueing::IPacketProcessor

Protected Member Functions

virtual void initialize (int stage) override
 
virtual int classifyPacket (Packet *packet) override
 
- Protected Member Functions inherited from inet::queueing::TokenBucketClassifierMixin< MultiTokenBucketMixin< PacketClassifierBase > >
virtual double getNumPacketTokens (Packet *packet) const
 
- Protected Member Functions inherited from inet::queueing::MultiTokenBucketMixin< PacketClassifierBase >
virtual void finish () override
 
virtual ITokenStoragegetExcessTokenStorage (const char *designator)
 
const virtual char * resolveDirective (char directive) const override
 
- Protected Member Functions inherited from inet::queueing::PacketClassifierBase
virtual void handleMessage (cMessage *message) override
 
virtual void mapRegistrationForwardingGates (cGate *gate, std::function< void(cGate *)> f) override
 
virtual size_t getOutputGateIndex (size_t i) const
 
virtual int callClassifyPacket (Packet *packet) const
 
virtual bool isStreamingPacket () const
 
virtual void startPacketStreaming (Packet *packet)
 
virtual void endPacketStreaming (Packet *packet)
 
virtual void checkPacketStreaming (Packet *packet)
 
- 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
 

Additional Inherited Members

- Public Member Functions inherited from inet::queueing::MultiTokenBucketMixin< PacketClassifierBase >
virtual double getNumTokens () const override
 
virtual void addTokens (double numTokens) override
 
virtual void removeTokens (double numTokens) override
 
virtual void addTokenProductionRate (double tokenRate) override
 
virtual void removeTokenProductionRate (double tokenRate) override
 
- Public Member Functions inherited from inet::queueing::PacketClassifierBase
virtual IPassivePacketSourcegetProvider (cGate *gate) override
 Returns the passive packet source from where packets are pulled or nullptr if the connected module doesn't implement the interface. More...
 
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 supportsPacketStreaming (cGate *gate) const override
 Returns true if the processor supports streaming 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...
 
virtual bool canPullSomePacket (cGate *gate) const override
 Returns false if the packet source is empty at the given gate and no more packets can be pulled from it without raising an error. More...
 
virtual PacketcanPullPacket (cGate *gate) const override
 Returns the packet that can be pulled at the given gate. More...
 
virtual PacketpullPacket (cGate *gate) override
 Pulls the packet from the packet source at the given gate. More...
 
virtual PacketpullPacketStart (cGate *gate, bps datarate) override
 Starts pulling the packet from the packet source at the given gate. More...
 
virtual PacketpullPacketEnd (cGate *gate) override
 Ends pulling the packet from the packet source at the given gate. More...
 
virtual PacketpullPacketProgress (cGate *gate, bps datarate, b position, b extraProcessableLength) override
 Progresses pulling the packet from the packet source at the given gate. More...
 
virtual void handleCanPullPacketChanged (cGate *gate) override
 Notifies about a change in the possibility of pulling some packet from the passive packet source at the given gate. More...
 
virtual void handlePullPacketProcessed (Packet *packet, cGate *gate, bool successful) override
 Notifies about the completion of the packet processing for a packet that was pulled 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...
 
- Public Member Functions inherited from inet::queueing::IPacketProcessor
virtual ~IPacketProcessor ()
 
- Public Member Functions inherited from inet::TransparentProtocolRegistrationListener
virtual cGate * getRegistrationForwardingGate (cGate *gate)
 
virtual bool isForwardingProtocol (const Protocol &protocol, cGate *gate, ServicePrimitive servicePrimitive) const
 
virtual bool isForwardingProtocolGroup (const ProtocolGroup &protocolGroup, cGate *gate, ServicePrimitive servicePrimitive) const
 
virtual bool isForwardingAnyProtocol (cGate *gate, ServicePrimitive servicePrimitive) const
 
virtual bool isForwardingProtocol (cGate *gate, ServicePrimitive servicePrimitive) const
 
virtual bool isForwardingService (const Protocol &protocol, cGate *gate, ServicePrimitive servicePrimitive) const
 
virtual bool isForwardingServiceGroup (const ProtocolGroup &protocolGroup, cGate *gate, ServicePrimitive servicePrimitive) const
 
virtual bool isForwardingAnyService (cGate *gate, ServicePrimitive servicePrimitive) const
 
virtual bool isForwardingService (cGate *gate, ServicePrimitive servicePrimitive) const
 
virtual void handleRegisterService (const Protocol &protocol, cGate *gate, ServicePrimitive servicePrimitive) override
 
virtual void handleRegisterProtocol (const Protocol &protocol, cGate *gate, ServicePrimitive servicePrimitive) override
 
virtual void handleRegisterServiceGroup (const ProtocolGroup &protocolGroup, cGate *gate, ServicePrimitive servicePrimitive) override
 
virtual void handleRegisterProtocolGroup (const ProtocolGroup &protocolGroup, cGate *gate, ServicePrimitive servicePrimitive) override
 
virtual void handleRegisterAnyService (cGate *gate, ServicePrimitive servicePrimitive) override
 
virtual void handleRegisterAnyProtocol (cGate *gate, ServicePrimitive servicePrimitive) override
 
- Public Member Functions inherited from inet::queueing::IPassivePacketSink
virtual ~IPassivePacketSink ()
 
- Public Member Functions inherited from inet::queueing::IActivePacketSink
virtual ~IActivePacketSink ()
 
- Public Member Functions inherited from inet::queueing::IPassivePacketSource
virtual ~IPassivePacketSource ()
 
- Public Member Functions inherited from inet::queueing::IActivePacketSource
virtual ~IActivePacketSource ()
 
- Public Member Functions inherited from inet::queueing::ITokenStorage
virtual ~ITokenStorage ()
 
virtual double getNumTokens () const =0
 
- Protected Types inherited from inet::queueing::PacketProcessorBase
enum  Action { PUSH, PULL }
 
- Protected Attributes inherited from inet::queueing::TokenBucketClassifierMixin< MultiTokenBucketMixin< PacketClassifierBase > >
double tokenConsumptionPerPacket
 
double tokenConsumptionPerBit
 
- Protected Attributes inherited from inet::queueing::MultiTokenBucketMixin< PacketClassifierBase >
std::vector< TokenBuckettokenBuckets
 
- Protected Attributes inherited from inet::queueing::PacketClassifierBase
bool reverseOrder = false
 
cGate * inputGate = nullptr
 
IActivePacketSourceproducer = nullptr
 
IPassivePacketSourceprovider = nullptr
 
std::vector< cGate * > outputGates
 
std::vector< IPassivePacketSink * > consumers
 
std::vector< IActivePacketSink * > collectors
 
int inProgressStreamId = -1
 
int inProgressGateIndex = -1
 
- Protected Attributes inherited from inet::queueing::PacketProcessorBase
const char * displayStringTextFormat = nullptr
 
int numProcessedPackets = -1
 
b processedTotalLength = b(-1)
 

Member Function Documentation

◆ classifyPacket()

int inet::queueing::MultiTokenBucketClassifier::classifyPacket ( Packet packet)
overrideprotectedvirtual

Implements inet::queueing::PacketClassifierBase.

27 {
29  auto numTokens = getNumPacketTokens(packet);
30  for (int i = 0; i < tokenBuckets.size(); i++) {
31  auto& tokenBucket = tokenBuckets[i];
32  EV_DEBUG << "Checking tokens for packet" << EV_FIELD(numTokens) << EV_FIELD(tokenBucket) << EV_FIELD(packet) << EV_ENDL;
33  if (tokenBucket.getNumTokens() > numTokens) {
34  tokenBucket.removeTokens(numTokens);
35  EV_INFO << "Removed tokens from ith bucket for packet" << EV_FIELD(numTokens) << EV_FIELD(i) << EV_FIELD(tokenBucket) << EV_FIELD(packet) << EV_ENDL;
37  return i;
38  }
39  }
40  EV_INFO << "Insufficient number of tokens for packet" << EV_FIELD(numTokens) << EV_FIELD(packet) << EV_ENDL;
41  return outputGates.size() - 1;
42 }

◆ initialize()

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

Reimplemented from inet::queueing::TokenBucketClassifierMixin< MultiTokenBucketMixin< PacketClassifierBase > >.

18 {
19  TokenBucketClassifierMixin<MultiTokenBucketMixin<PacketClassifierBase>>::initialize(stage);
20  if (stage == INITSTAGE_QUEUEING) {
21  if (tokenBuckets.size() != outputGates.size() - 1)
22  throw cRuntimeError("Number of buckets must be 1 less than the number of output gates");
23  }
24 }

The documentation for this class was generated from the following files:
inet::tokensChangedSignal
simsignal_t tokensChangedSignal
Definition: Simsignals.cc:121
inet::queueing::MultiTokenBucketClassifier::initialize
virtual void initialize(int stage) override
Definition: MultiTokenBucketClassifier.cc:17
inet::INITSTAGE_QUEUEING
INET_API InitStage INITSTAGE_QUEUEING
Initialization of queueing modules.
inet::queueing::MultiTokenBucketMixin< PacketClassifierBase >::getNumTokens
virtual double getNumTokens() const override
Definition: MultiTokenBucketMixin.h:102
inet::queueing::MultiTokenBucketMixin< PacketClassifierBase >::tokenBuckets
std::vector< TokenBucket > tokenBuckets
Definition: MultiTokenBucketMixin.h:35
EV_FIELD
#define EV_FIELD(...)
Definition: INETDefs.h:112
inet::queueing::PacketClassifierBase::outputGates
std::vector< cGate * > outputGates
Definition: PacketClassifierBase.h:28
EV_ENDL
#define EV_ENDL
Definition: INETDefs.h:114
inet::queueing::TokenBucketClassifierMixin< MultiTokenBucketMixin< PacketClassifierBase > >::getNumPacketTokens
virtual double getNumPacketTokens(Packet *packet) const
Definition: TokenBucketClassifierMixin.h:33