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

#include <PassivePacketSource.h>

Inheritance diagram for inet::queueing::PassivePacketSource:
inet::ClockUserModuleMixin< PassivePacketSourceBase > inet::queueing::PassivePacketSourceBase inet::queueing::PacketSourceBase inet::queueing::IPassivePacketSource inet::queueing::PacketProcessorBase inet::queueing::IPacketProcessor inet::StringFormat::IDirectiveResolver

Public Member Functions

virtual ~PassivePacketSource ()
 
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 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...
 
- Public Member Functions inherited from inet::ClockUserModuleMixin< PassivePacketSourceBase >
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::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::IPassivePacketSource
virtual ~IPassivePacketSource ()
 

Protected Member Functions

virtual void initialize (int stage) override
 
virtual void handleMessage (cMessage *message) override
 
virtual void scheduleProvidingTimer ()
 
virtual PacketprovidePacket (cGate *gate)
 
- Protected Member Functions inherited from inet::queueing::PacketSourceBase
virtual const char * createPacketName (const Ptr< const Chunk > &data) const
 
virtual Ptr< ChunkcreatePacketContent () const
 
virtual PacketcreatePacket ()
 
virtual const cModule * findContainingApplication () const
 
virtual const cModule * getContainingApplication () const
 
- 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

cPar * providingIntervalParameter = nullptr
 
ClockEventprovidingTimer = nullptr
 
bool scheduleForAbsoluteTime = false
 
PacketnextPacket = nullptr
 
- Protected Attributes inherited from inet::queueing::PassivePacketSourceBase
cGate * outputGate = nullptr
 
IActivePacketSinkcollector = nullptr
 
- Protected Attributes inherited from inet::queueing::PacketSourceBase
const char * packetNameFormat = nullptr
 
const char * packetRepresentation = nullptr
 
cPar * packetLengthParameter = nullptr
 
cPar * packetDataParameter = nullptr
 
bool attachCreationTimeTag = false
 
bool attachIdentityTag = false
 
bool attachDirectionTag = false
 
- Protected Attributes inherited from inet::queueing::PacketProcessorBase
const char * displayStringTextFormat = nullptr
 
int numProcessedPackets = -1
 
b processedTotalLength = b(-1)
 

Additional Inherited Members

- Protected Types inherited from inet::queueing::PacketProcessorBase
enum  Action { PUSH, PULL }
 

Constructor & Destructor Documentation

◆ ~PassivePacketSource()

virtual inet::queueing::PassivePacketSource::~PassivePacketSource ( )
inlinevirtual

Member Function Documentation

◆ canPullPacket()

Packet * inet::queueing::PassivePacketSource::canPullPacket ( cGate *  gate) const
overridevirtual

Returns the packet that can be pulled at the given gate.

The returned value is nullptr if there is no such packet.

The gate must be a valid gate of this module and it must support pushing packets.

Implements inet::queueing::IPassivePacketSource.

54 {
55  Enter_Method("canPullPacket");
56  if (providingTimer->isScheduled())
57  return nullptr;
58  else {
59  if (nextPacket == nullptr)
60  // KLUDGE
61  nextPacket = const_cast<PassivePacketSource *>(this)->createPacket();
62  return nextPacket;
63  }
64 }

◆ canPullSomePacket()

virtual bool inet::queueing::PassivePacketSource::canPullSomePacket ( cGate *  gate) const
inlineoverridevirtual

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.

The gate must be a valid gate of this module and it must support pulling packets.

Reimplemented from inet::queueing::PassivePacketSourceBase.

39 { return !providingTimer->isScheduled(); }

◆ handleMessage()

void inet::queueing::PassivePacketSource::handleMessage ( cMessage *  message)
overrideprotectedvirtual
33 {
34  if (message == providingTimer) {
35  if (collector != nullptr)
37  }
38  else
39  throw cRuntimeError("Unknown message");
40 }

◆ initialize()

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

Reimplemented from inet::queueing::PassivePacketSourceBase.

18 {
19  ClockUserModuleMixin::initialize(stage);
20  if (stage == INITSTAGE_LOCAL) {
21  providingIntervalParameter = &par("providingInterval");
22  providingTimer = new ClockEvent("ProvidingTimer");
23  scheduleForAbsoluteTime = par("scheduleForAbsoluteTime");
24  WATCH_PTR(nextPacket);
25  }
26  else if (stage == INITSTAGE_QUEUEING) {
27  if (collector != nullptr)
29  }
30 }

◆ providePacket()

Packet * inet::queueing::PassivePacketSource::providePacket ( cGate *  gate)
protectedvirtual
82 {
83  Packet *packet;
84  if (nextPacket == nullptr)
85  packet = createPacket();
86  else {
87  packet = nextPacket;
88  nextPacket = nullptr;
89  }
90  EV_INFO << "Providing packet" << EV_FIELD(packet) << EV_ENDL;
92  return packet;
93 }

Referenced by pullPacket().

◆ pullPacket()

Packet * inet::queueing::PassivePacketSource::pullPacket ( cGate *  gate)
overridevirtual

Pulls the packet from the packet source at the given gate.

This operation pulls the packet as a whole. The onwership of the packet is transferred to the sink.

The source must not be empty at the given gate. The returned packet must not be nullptr. The gate must be a valid gate of this module and it must support pulling and passing packets.

Implements inet::queueing::IPassivePacketSource.

67 {
68  Enter_Method("pullPacket");
69  if (providingTimer->isScheduled() && providingTimer->getArrivalTime() > simTime())
70  throw cRuntimeError("Another packet is already being provided");
71  else {
72  auto packet = providePacket(gate);
74  emit(packetPulledSignal, packet);
77  return packet;
78  }
79 }

◆ pullPacketEnd()

virtual Packet* inet::queueing::PassivePacketSource::pullPacketEnd ( cGate *  gate)
inlineoverridevirtual

Ends pulling the packet from the packet source at the given gate.

This is a packet streaming operation. The onwership of the packet is transferred to the sink.

Packet streaming can be started with any of the streaming operations, and ends when the streaming position plus the extra processable packet length equals to the total packet length.

This method is called, for example, when a preemption supporting server module ends streaming a packet from the the source.

The source must not be empty at the gate and no other packet streaming can be in progress. The gate must be a valid gate of this module and it must support pulling and streaming packets. The returned packet must not be nullptr.

Reimplemented from inet::queueing::PassivePacketSourceBase.

44 { throw cRuntimeError("Invalid operation"); }

◆ pullPacketProgress()

virtual Packet* inet::queueing::PassivePacketSource::pullPacketProgress ( cGate *  gate,
bps  datarate,
b  position,
b  extraProcessableLength 
)
inlineoverridevirtual

Progresses pulling the packet from the packet source at the given gate.

This is a packet streaming operation. The position specifies where the packet streaming is at the moment. The extra length parameter partially fixes the future of the packet streaming operation. The onwership of the packet is transferred to the sink.

Packet streaming can be started with any of the streaming operations, and ends when the streaming position plus the extra processable packet length equals to the total packet length.

This method is called, for example, to notify the source about a change in the packet data when a preemption occurs.

The source must not be empty at the gate and no other packet streaming can be in progress. The gate must be a valid gate of this module and it must support pulling and streaming packets. The returned packet must not be nullptr.

Reimplemented from inet::queueing::PassivePacketSourceBase.

45 { throw cRuntimeError("Invalid operation"); }

◆ pullPacketStart()

virtual Packet* inet::queueing::PassivePacketSource::pullPacketStart ( cGate *  gate,
bps  datarate 
)
inlineoverridevirtual

Starts pulling the packet from the packet source at the given gate.

This is a packet streaming operation. The onwership of the packet is transferred to the sink.

Packet streaming can be started with any of the streaming operations, and ends when the streaming position plus the extra processable packet length equals to the total packet length.

This method is called, for example, when a preemption supporting server module starts streaming a packet from the source.

The source must not be empty at the gate and no other packet streaming can be in progress. The gate must be a valid gate of this module and it must support pulling and streaming packets. The returned packet must not be nullptr.

Reimplemented from inet::queueing::PassivePacketSourceBase.

43 { throw cRuntimeError("Invalid operation"); }

◆ scheduleProvidingTimer()

void inet::queueing::PassivePacketSource::scheduleProvidingTimer ( )
protectedvirtual
43 {
44  clocktime_t interval = providingIntervalParameter->doubleValue();
45  if (interval != 0 || providingTimer->getArrivalModule() == nullptr) {
48  else
50  }
51 }

Referenced by pullPacket().

◆ supportsPacketPulling()

virtual bool inet::queueing::PassivePacketSource::supportsPacketPulling ( cGate *  gate) const
inlineoverridevirtual

Returns true if the processor supports pulling packets at the given gate.

Pulling a packet is a synchronous operation that is initiated by the sink module. A pulled packet can be passed as a whole using pullPacket(), or it can be streamed from the source to the sink using pullPacketStart(), pullPacketEnd(), and pullPacketProgress().

For output gates, true means that the connected module can pull packets from this module. For input gates, true means that this module can pull packets from the connected module. For example, a packet server module can pull packets from a queue module.

Connecting incompatible gates raises an error during initialize. The gate parameter must be a valid gate of this module. The gate should be marked with @labels(pull) in the NED file.

Reimplemented from inet::queueing::PassivePacketSourceBase.

37 { return outputGate == gate; }

◆ supportsPacketPushing()

virtual bool inet::queueing::PassivePacketSource::supportsPacketPushing ( cGate *  gate) const
inlineoverridevirtual

Returns true if the processor supports pushing packets at the given gate.

Pushing a packet is a synchronous operation that is initiated by the source module. A pushed packet can be passed as a whole using pushPacket(), or it can be streamed from the source to the sink using pushPacketStart(), pushPacketEnd(), and pushPacketProgress().

For output gates, true means that this module can push packets into the connected module. For input gates, true means that the connected module can push packets into this module. For example, a packet generator module can push packets into a queue module.

Connecting incompatible gates raises an error during initialize. The gate parameter must be a valid gate of this module. The gate should be marked with @labels(push) in the NED file.

Reimplemented from inet::queueing::PassivePacketSourceBase.

36 { return false; }

Member Data Documentation

◆ nextPacket

Packet* inet::queueing::PassivePacketSource::nextPacket = nullptr
mutableprotected

◆ providingIntervalParameter

cPar* inet::queueing::PassivePacketSource::providingIntervalParameter = nullptr
protected

◆ providingTimer

ClockEvent* inet::queueing::PassivePacketSource::providingTimer = nullptr
protected

◆ scheduleForAbsoluteTime

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

The documentation for this class was generated from the following files:
inet::clocktime_t
ClockTime clocktime_t
Definition: contract/ClockTime.h:25
inet::queueing::PassivePacketSource::providingIntervalParameter
cPar * providingIntervalParameter
Definition: PassivePacketSource.h:20
inet::queueing::PacketProcessorBase::animatePullPacket
virtual void animatePullPacket(Packet *packet, cGate *gate) const
Definition: PacketProcessorBase.cc:355
inet::queueing::PassivePacketSourceBase::collector
IActivePacketSink * collector
Definition: PassivePacketSourceBase.h:22
inet::queueing::PacketSourceBase::createPacket
virtual Packet * createPacket()
Definition: PacketSourceBase.cc:146
inet::queueing::PassivePacketSource::providePacket
virtual Packet * providePacket(cGate *gate)
Definition: PassivePacketSource.cc:81
inet::INITSTAGE_QUEUEING
INET_API InitStage INITSTAGE_QUEUEING
Initialization of queueing modules.
inet::queueing::PassivePacketSourceBase::outputGate
cGate * outputGate
Definition: PassivePacketSourceBase.h:21
inet::ClockUserModuleMixin< PassivePacketSourceBase >::scheduleClockEventAfter
virtual void scheduleClockEventAfter(clocktime_t delay, ClockEvent *msg)
Definition: ClockUserModuleMixin.h:65
inet::ClockUserModuleMixin< PassivePacketSourceBase >::scheduleClockEventAt
virtual void scheduleClockEventAt(clocktime_t time, ClockEvent *msg)
Definition: ClockUserModuleMixin.h:64
inet::queueing::PassivePacketSource::nextPacket
Packet * nextPacket
Definition: PassivePacketSource.h:24
inet::packetPulledSignal
simsignal_t packetPulledSignal
Definition: Simsignals.cc:105
inet::ClockUserModuleMixin< PassivePacketSourceBase >::getClockTime
virtual clocktime_t getClockTime() const
Definition: ClockUserModuleMixin.h:72
inet::ClockEvent
cMessage ClockEvent
Definition: contract/ClockEvent.h:18
inet::queueing::PassivePacketSource::scheduleProvidingTimer
virtual void scheduleProvidingTimer()
Definition: PassivePacketSource.cc:42
EV_FIELD
#define EV_FIELD(...)
Definition: INETDefs.h:112
inet::queueing::PassivePacketSource::scheduleForAbsoluteTime
bool scheduleForAbsoluteTime
Definition: PassivePacketSource.h:22
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
inet::ClockUserModuleMixin< PassivePacketSourceBase >::cancelAndDeleteClockEvent
virtual void cancelAndDeleteClockEvent(ClockEvent *msg)
Definition: ClockUserModuleMixin.h:67
inet::queueing::PassivePacketSource::providingTimer
ClockEvent * providingTimer
Definition: PassivePacketSource.h:21
inet::queueing::PacketProcessorBase::updateDisplayString
virtual void updateDisplayString() const
Definition: PacketProcessorBase.cc:399
Enter_Method
#define Enter_Method(...)
Definition: SelfDoc.h:71
EV_ENDL
#define EV_ENDL
Definition: INETDefs.h:114
inet::queueing::IActivePacketSink::handleCanPullPacketChanged
virtual void handleCanPullPacketChanged(cGate *gate)=0
Notifies about a change in the possibility of pulling some packet from the passive packet source at t...