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

#include <PeriodicGate.h>

Inheritance diagram for inet::queueing::PeriodicGate:
inet::ClockUserModuleMixin< PacketGateBase > inet::queueing::PacketGateBase inet::queueing::PacketFlowBase inet::TransparentProtocolRegistrationListener inet::queueing::IPacketGate inet::queueing::PacketProcessorBase inet::queueing::IPacketFlow inet::queueing::IPacketCollection inet::IProtocolRegistrationListener inet::queueing::IPacketProcessor inet::StringFormat::IDirectiveResolver inet::queueing::IPacketSink inet::queueing::IPacketSource inet::queueing::IPassivePacketSink inet::queueing::IActivePacketSink inet::queueing::IPassivePacketSource inet::queueing::IActivePacketSource

Public Member Functions

virtual ~PeriodicGate ()
 
virtual clocktime_t getInitialOffset () const
 
virtual bool getInitiallyOpen () const
 
virtual const cValueArray * getDurations () const
 
- Public Member Functions inherited from inet::ClockUserModuleMixin< PacketGateBase >
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::queueing::PacketGateBase
virtual bool isOpen () const override
 Returns true if the gate is open. More...
 
virtual bool isClosed () const
 
virtual void open () override
 Opens the gate and starts traffic go through. More...
 
virtual void close () override
 Closes the gate and stops traffic. 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 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 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 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 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 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...
 
- Public Member Functions inherited from inet::queueing::PacketFlowBase
virtual bool supportsPacketStreaming (cGate *gate) const override
 Returns true if the processor supports streaming packets at the given gate. 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 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 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 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...
 
virtual int getMaxNumPackets () const override
 Returns maximum allowed number of packets in the collection. More...
 
virtual int getNumPackets () const override
 Returns the number of available packets in the collection in the range [0, inf). More...
 
virtual b getMaxTotalLength () const override
 Returns maximum allowed total length of all packets in the collection. More...
 
virtual b getTotalLength () const override
 Returns the total length of all packets in the collection in the range [0, inf). More...
 
virtual PacketgetPacket (int index) const override
 Returns the packet at the given index. More...
 
virtual bool isEmpty () const override
 Returns true if there are no packets available in the collection. More...
 
virtual void removePacket (Packet *packet) override
 Removes a packet from the collection. More...
 
virtual void removeAllPackets () override
 Removes all packets from the collection. 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 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::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::TransparentProtocolRegistrationListener
virtual void mapRegistrationForwardingGates (cGate *gate, std::function< void(cGate *)> f)
 
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
 

Protected Member Functions

virtual void initialize (int stage) override
 
virtual void handleMessage (cMessage *message) override
 
virtual void handleParameterChange (const char *name) override
 
virtual bool canPacketFlowThrough (Packet *packet) const override
 
virtual void initializeGating ()
 
virtual void scheduleChangeTimer ()
 
virtual void processChangeTimer ()
 
- Protected Member Functions inherited from inet::queueing::PacketGateBase
virtual cGate * getRegistrationForwardingGate (cGate *gate) override
 
virtual void processPacket (Packet *packet) override
 
virtual void updateDisplayString () const override
 
- Protected Member Functions inherited from inet::queueing::PacketFlowBase
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)
 

Protected Attributes

int index = 0
 
clocktime_t initialOffset
 
clocktime_t offset
 
cValueArray * durations = nullptr
 
bool scheduleForAbsoluteTime = false
 
ClockEventchangeTimer = nullptr
 
- Protected Attributes inherited from inet::queueing::PacketGateBase
bps bitrate = bps(NaN)
 
b extraLength = b(-1)
 
simtime_t extraDuration
 
bool isOpen_ = false
 
- Protected Attributes inherited from inet::queueing::PacketFlowBase
cGate * inputGate = nullptr
 
ModuleRef< IActivePacketSourceproducer
 
ModuleRef< IPassivePacketSourceprovider
 
ModuleRef< IPacketCollectioncollection
 
cGate * outputGate = nullptr
 
ModuleRef< IPassivePacketSinkconsumer
 
ModuleRef< IActivePacketSinkcollector
 
int inProgressStreamId = -1
 
- Protected Attributes inherited from inet::queueing::PacketProcessorBase
const char * displayStringTextFormat = nullptr
 
int numProcessedPackets = -1
 
b processedTotalLength = b(-1)
 

Additional Inherited Members

- Static Public Attributes inherited from inet::queueing::PacketGateBase
static simsignal_t gateStateChangedSignal = registerSignal("gateStateChanged")
 
- Protected Types inherited from inet::queueing::PacketProcessorBase
enum  Action { PUSH, PULL }
 

Constructor & Destructor Documentation

◆ ~PeriodicGate()

virtual inet::queueing::PeriodicGate::~PeriodicGate ( )
inlinevirtual
39 { cancelAndDelete(changeTimer); }

Member Function Documentation

◆ canPacketFlowThrough()

bool inet::queueing::PeriodicGate::canPacketFlowThrough ( Packet packet) const
overrideprotectedvirtual

Reimplemented from inet::queueing::PacketGateBase.

106 {
107  if (std::isnan(bitrate.get()))
109  else if (packet == nullptr)
110  return false;
111  else {
112  clocktime_t flowEndTime = getClockTime() + s((packet->getDataLength() + extraLength) / bitrate).get() + SIMTIME_AS_CLOCKTIME(extraDuration);
113  return !changeTimer->isScheduled() || flowEndTime <= getArrivalClockTime(changeTimer);
114  }
115 }

◆ getDurations()

virtual const cValueArray* inet::queueing::PeriodicGate::getDurations ( ) const
inlinevirtual
43 { return durations; }

◆ getInitiallyOpen()

virtual bool inet::queueing::PeriodicGate::getInitiallyOpen ( ) const
inlinevirtual
42 { return par("initiallyOpen"); }

◆ getInitialOffset()

virtual clocktime_t inet::queueing::PeriodicGate::getInitialOffset ( ) const
inlinevirtual
41 { return initialOffset; }

◆ handleMessage()

void inet::queueing::PeriodicGate::handleMessage ( cMessage *  message)
overrideprotectedvirtual

Reimplemented from inet::queueing::PacketFlowBase.

46 {
47  if (message == changeTimer) {
50  }
51  else
52  throw cRuntimeError("Unknown message");
53 }

◆ handleParameterChange()

void inet::queueing::PeriodicGate::handleParameterChange ( const char *  name)
overrideprotectedvirtual
32 {
33  if (name != nullptr) {
34  if (!strcmp(name, "offset"))
35  initialOffset = par("offset");
36  else if (!strcmp(name, "initiallyOpen"))
37  isOpen_ = par("initiallyOpen");
38  else if (!strcmp(name, "durations")) {
39  durations = check_and_cast<cValueArray *>(par("durations").objectValue());
41  }
42  }
43 }

◆ initialize()

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

Reimplemented from inet::queueing::PacketGateBase.

18 {
19  ClockUserModuleMixin::initialize(stage);
20  if (stage == INITSTAGE_LOCAL) {
21  isOpen_ = par("initiallyOpen");
22  initialOffset = par("offset");
23  durations = check_and_cast<cValueArray *>(par("durations").objectValue());
24  scheduleForAbsoluteTime = par("scheduleForAbsoluteTime");
25  changeTimer = new ClockEvent("ChangeTimer");
26  }
27  else if (stage == INITSTAGE_QUEUEING)
29 }

◆ initializeGating()

void inet::queueing::PeriodicGate::initializeGating ( )
protectedvirtual
56 {
57  if (durations->size() % 2 != 0)
58  throw cRuntimeError("The duration parameter must contain an even number of values");
59  index = 0;
61  while (offset > 0) {
62  clocktime_t duration = durations->get(index).doubleValueInUnit("s");
63  if (offset > duration) {
64  isOpen_ = !isOpen_;
65  offset -= duration;
66  index = (index + 1) % durations->size();
67  }
68  else
69  break;
70  }
71  if (index < (int)durations->size()) {
72  if (changeTimer->isScheduled())
75  }
76 }

Referenced by handleParameterChange(), and initialize().

◆ processChangeTimer()

void inet::queueing::PeriodicGate::processChangeTimer ( )
protectedvirtual
98 {
99  if (isOpen_)
100  close();
101  else
102  open();
103 }

Referenced by handleMessage().

◆ scheduleChangeTimer()

void inet::queueing::PeriodicGate::scheduleChangeTimer ( )
protectedvirtual
79 {
80  ASSERT(0 <= index && index < (int)durations->size());
81  clocktime_t duration = durations->get(index).doubleValueInUnit("s");
82  index = (index + 1) % durations->size();
83  // skip trailing zero for wrap around, length is divisible by 2 so the expected state is the same
84  if (durations->get(index).doubleValueInUnit("s") == 0) {
85  index = (index + 1) % durations->size();
86  duration += durations->get(index).doubleValueInUnit("s");
87  index = (index + 1) % durations->size();
88  }
89  //std::cout << getFullPath() << " " << duration << std::endl;
92  else
94  offset = 0;
95 }

Referenced by handleMessage(), and initializeGating().

Member Data Documentation

◆ changeTimer

ClockEvent* inet::queueing::PeriodicGate::changeTimer = nullptr
protected

◆ durations

cValueArray* inet::queueing::PeriodicGate::durations = nullptr
protected

◆ index

int inet::queueing::PeriodicGate::index = 0
protected

◆ initialOffset

clocktime_t inet::queueing::PeriodicGate::initialOffset
protected

◆ offset

clocktime_t inet::queueing::PeriodicGate::offset
protected

◆ scheduleForAbsoluteTime

bool inet::queueing::PeriodicGate::scheduleForAbsoluteTime = false
protected

Referenced by initialize(), and scheduleChangeTimer().


The documentation for this class was generated from the following files:
inet::queueing::PeriodicGate::initialOffset
clocktime_t initialOffset
Definition: PeriodicGate.h:21
inet::clocktime_t
ClockTime clocktime_t
Definition: contract/ClockTime.h:25
inet::queueing::PacketGateBase::close
virtual void close() override
Closes the gate and stops traffic.
Definition: PacketGateBase.cc:52
inet::queueing::PeriodicGate::durations
cValueArray * durations
Definition: PeriodicGate.h:23
inet::queueing::PeriodicGate::offset
clocktime_t offset
Definition: PeriodicGate.h:22
inet::queueing::PeriodicGate::scheduleChangeTimer
virtual void scheduleChangeTimer()
Definition: PeriodicGate.cc:78
inet::INITSTAGE_QUEUEING
INET_API InitStage INITSTAGE_QUEUEING
Initialization of queueing modules.
inet::ClockUserModuleMixin< PacketGateBase >::getArrivalClockTime
virtual clocktime_t getArrivalClockTime(ClockEvent *msg) const
Definition: ClockUserModuleMixin.h:73
inet::ClockUserModuleMixin< PacketGateBase >::scheduleClockEventAfter
virtual void scheduleClockEventAfter(clocktime_t delay, ClockEvent *msg)
Definition: ClockUserModuleMixin.h:65
inet::queueing::PacketGateBase::isOpen_
bool isOpen_
Definition: PacketGateBase.h:31
inet::queueing::PacketGateBase::extraLength
b extraLength
Definition: PacketGateBase.h:28
inet::ClockUserModuleMixin< PacketGateBase >::scheduleClockEventAt
virtual void scheduleClockEventAt(clocktime_t time, ClockEvent *msg)
Definition: ClockUserModuleMixin.h:64
inet::queueing::PeriodicGate::index
int index
Definition: PeriodicGate.h:20
inet::ClockUserModuleMixin< PacketGateBase >::getClockTime
virtual clocktime_t getClockTime() const
Definition: ClockUserModuleMixin.h:72
inet::ClockEvent
cMessage ClockEvent
Definition: contract/ClockEvent.h:18
SIMTIME_AS_CLOCKTIME
#define SIMTIME_AS_CLOCKTIME(x)
Definition: contract/ClockTime.h:20
inet::queueing::PeriodicGate::changeTimer
ClockEvent * changeTimer
Definition: PeriodicGate.h:26
inet::units::values::s
value< double, units::s > s
Definition: Units.h:1235
inet::queueing::PacketGateBase::bitrate
bps bitrate
Definition: PacketGateBase.h:27
inet::queueing::PacketGateBase::open
virtual void open() override
Opens the gate and starts traffic go through.
Definition: PacketGateBase.cc:39
inet::queueing::PeriodicGate::processChangeTimer
virtual void processChangeTimer()
Definition: PeriodicGate.cc:97
inet::queueing::PeriodicGate::initializeGating
virtual void initializeGating()
Definition: PeriodicGate.cc:55
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
inet::queueing::PacketGateBase::canPacketFlowThrough
virtual bool canPacketFlowThrough(Packet *packet) const
Definition: PacketGateBase.cc:106
inet::queueing::PeriodicGate::scheduleForAbsoluteTime
bool scheduleForAbsoluteTime
Definition: PeriodicGate.h:24
inet::units::value::get
const value_type & get() const
Definition: Units.h:108
inet::ClockUserModuleMixin< PacketGateBase >::cancelClockEvent
virtual cMessage * cancelClockEvent(ClockEvent *msg)
Definition: ClockUserModuleMixin.h:66
inet::queueing::PacketGateBase::extraDuration
simtime_t extraDuration
Definition: PacketGateBase.h:29