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

#include <EligibilityTimeMeter.h>

Inheritance diagram for inet::EligibilityTimeMeter:
inet::ClockUserModuleMixin< PacketMeterBase > inet::PacketMeterBase inet::queueing::PacketProcessorBase inet::queueing::IPassivePacketSink inet::queueing::IActivePacketSource inet::queueing::IPacketProcessor inet::StringFormat::IDirectiveResolver

Protected Member Functions

virtual void initialize (int stage) override
 
virtual void meterPacket (Packet *packet) override
 
virtual void emitNumTokenChangedSignal ()
 
- Protected Member Functions inherited from inet::PacketMeterBase
virtual int numInitStages () const override
 
virtual void handleMessage (cMessage *message) override
 
- Protected Member Functions inherited from inet::queueing::PacketProcessorBase
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

b packetOverheadLength = b(-1)
 
bps committedInformationRate = bps(NaN)
 
b committedBurstSize = b(-1)
 
clocktime_t maxResidenceTime
 
clocktime_t groupEligibilityTime
 
clocktime_t bucketEmptyTime
 
double numTokens = 0
 
- Protected Attributes inherited from inet::PacketMeterBase
cGate * inputGate = nullptr
 
IActivePacketSourceproducer = 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::ClockUserModuleMixin< PacketMeterBase >
virtual void scheduleClockEventAt (clocktime_t time, ClockEvent *msg)
 
virtual void scheduleClockEventAfter (clocktime_t delay, ClockEvent *msg)
 
virtual cMessage * cancelClockEvent (ClockEvent *msg)
 
virtual void cancelAndDeleteClockEvent (ClockEvent *msg)
 
virtual void rescheduleClockEventAt (clocktime_t time, ClockEvent *msg)
 
virtual void rescheduleClockEventAfter (clocktime_t time, ClockEvent *msg)
 
virtual clocktime_t computeClockTimeFromSimTime (simtime_t time) const
 
virtual simtime_t computeSimTimeFromClockTime (clocktime_t time) const
 
virtual clocktime_t getClockTime () const
 
virtual clocktime_t getArrivalClockTime (ClockEvent *msg) const
 
- Public Member Functions inherited from inet::PacketMeterBase
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 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 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...
 
- 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 ()
 
virtual void pushPacket (Packet *packet, cGate *gate)=0
 Pushes the packet into the packet sink at the given gate. More...
 
- Public Member Functions inherited from inet::queueing::IActivePacketSource
virtual ~IActivePacketSource ()
 
- Protected Types inherited from inet::queueing::PacketProcessorBase
enum  Action { PUSH, PULL }
 

Member Function Documentation

◆ emitNumTokenChangedSignal()

void inet::EligibilityTimeMeter::emitNumTokenChangedSignal ( )
protectedvirtual
54 {
55  clocktime_t emptyToFullDuration = s(committedBurstSize / committedInformationRate).get();
56  double alpha = (getClockTime() - bucketEmptyTime).dbl() / emptyToFullDuration.dbl();
57  if (alpha > 1.0) {
59  cTimestampedValue value(CLOCKTIME_AS_SIMTIME(bucketEmptyTime + emptyToFullDuration), numTokens);
60  emit(tokensChangedSignal, &value);
62  }
63  else {
66  }
67 }

Referenced by initialize(), and meterPacket().

◆ initialize()

void inet::EligibilityTimeMeter::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::PacketMeterBase.

17 {
18  ClockUserModuleMixin::initialize(stage);
19  if (stage == INITSTAGE_LOCAL) {
20  packetOverheadLength = b(par("packetOverheadLength"));
21  committedInformationRate = bps(par("committedInformationRate"));
22  committedBurstSize = b(par("committedBurstSize"));
23  maxResidenceTime = par("maxResidenceTime");
26  WATCH(groupEligibilityTime);
27  WATCH(bucketEmptyTime);
28  WATCH(maxResidenceTime);
29  WATCH(numTokens);
30  }
31  else if (stage == INITSTAGE_QUEUEING)
33 }

◆ meterPacket()

void inet::EligibilityTimeMeter::meterPacket ( Packet packet)
overrideprotectedvirtual

Implements inet::PacketMeterBase.

36 {
38  clocktime_t arrivalTime = getClockTime();
39  clocktime_t lengthRecoveryDuration = s((packet->getDataLength() + packetOverheadLength) / committedInformationRate).get();
40  clocktime_t emptyToFullDuration = s(committedBurstSize / committedInformationRate).get();
41  clocktime_t schedulerEligibilityTime = bucketEmptyTime + lengthRecoveryDuration;
42  clocktime_t bucketFullTime = bucketEmptyTime + emptyToFullDuration;
43  clocktime_t eligibilityTime;
44  eligibilityTime.setRaw(std::max(std::max(arrivalTime.raw(), groupEligibilityTime.raw()), schedulerEligibilityTime.raw()));
45  if (maxResidenceTime == -1 || eligibilityTime <= arrivalTime + maxResidenceTime) {
46  groupEligibilityTime = eligibilityTime;
47  bucketEmptyTime = eligibilityTime < bucketFullTime ? schedulerEligibilityTime : schedulerEligibilityTime + eligibilityTime - bucketFullTime;
48  packet->addTagIfAbsent<EligibilityTimeTag>()->setEligibilityTime(eligibilityTime);
50  }
51 }

Member Data Documentation

◆ bucketEmptyTime

clocktime_t inet::EligibilityTimeMeter::bucketEmptyTime
protected

◆ committedBurstSize

b inet::EligibilityTimeMeter::committedBurstSize = b(-1)
protected

◆ committedInformationRate

bps inet::EligibilityTimeMeter::committedInformationRate = bps(NaN)
protected

◆ groupEligibilityTime

clocktime_t inet::EligibilityTimeMeter::groupEligibilityTime
protected

Referenced by initialize(), and meterPacket().

◆ maxResidenceTime

clocktime_t inet::EligibilityTimeMeter::maxResidenceTime
protected

Referenced by initialize(), and meterPacket().

◆ numTokens

double inet::EligibilityTimeMeter::numTokens = 0
protected

◆ packetOverheadLength

b inet::EligibilityTimeMeter::packetOverheadLength = b(-1)
protected

Referenced by initialize(), and meterPacket().


The documentation for this class was generated from the following files:
inet::EligibilityTimeMeter::packetOverheadLength
b packetOverheadLength
Definition: EligibilityTimeMeter.h:21
inet::clocktime_t
ClockTime clocktime_t
Definition: contract/ClockTime.h:25
inet::tokensChangedSignal
simsignal_t tokensChangedSignal
Definition: Simsignals.cc:121
CLOCKTIME_AS_SIMTIME
#define CLOCKTIME_AS_SIMTIME(x)
Definition: contract/ClockTime.h:19
inet::units::units::bps
compose< b, pow< s, -1 > > bps
Definition: Units.h:1169
inet::INITSTAGE_QUEUEING
INET_API InitStage INITSTAGE_QUEUEING
Initialization of queueing modules.
inet::ClockTime::raw
int64_t raw() const
Returns the underlying 64-bit integer.
Definition: common/ClockTime.h:285
inet::EligibilityTimeMeter::numTokens
double numTokens
Definition: EligibilityTimeMeter.h:29
inet::ClockUserModuleMixin< PacketMeterBase >::getClockTime
virtual clocktime_t getClockTime() const
Definition: ClockUserModuleMixin.h:72
inet::EligibilityTimeMeter::emitNumTokenChangedSignal
virtual void emitNumTokenChangedSignal()
Definition: EligibilityTimeMeter.cc:53
inet::units::values::s
value< double, units::s > s
Definition: Units.h:1235
inet::EligibilityTimeMeter::bucketEmptyTime
clocktime_t bucketEmptyTime
Definition: EligibilityTimeMeter.h:27
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
inet::units::values::b
value< int64_t, units::b > b
Definition: Units.h:1241
inet::sctp::max
double max(const double a, const double b)
Returns the maximum of a and b.
Definition: SctpAssociation.h:266
inet::units::constants::alpha
const value< double, units::unit > alpha(7.2973525376e-3)
inet::EligibilityTimeMeter::committedBurstSize
b committedBurstSize
Definition: EligibilityTimeMeter.h:23
inet::ClockTime::setRaw
const ClockTime & setRaw(int64_t l)
Directly sets the underlying 64-bit integer.
Definition: common/ClockTime.h:290
inet::EligibilityTimeMeter::committedInformationRate
bps committedInformationRate
Definition: EligibilityTimeMeter.h:22
inet::EligibilityTimeMeter::groupEligibilityTime
clocktime_t groupEligibilityTime
Definition: EligibilityTimeMeter.h:26
inet::EligibilityTimeMeter::maxResidenceTime
clocktime_t maxResidenceTime
Definition: EligibilityTimeMeter.h:24