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

#include <PacketEmitter.h>

Inheritance diagram for inet::PacketEmitter:
inet::queueing::PacketFlowBase inet::queueing::PacketProcessorBase inet::queueing::IPacketFlow inet::queueing::IPacketCollection 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 ~PacketEmitter ()
 
virtual void pushPacket (Packet *packet, cGate *gate) override
 Pushes 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 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::PacketFlowBase
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 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 pushPacketStart (Packet *packet, cGate *gate, bps datarate) override
 Starts 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 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...
 
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 ()
 

Protected Member Functions

virtual void initialize (int stage) override
 
virtual void processPacket (Packet *packet) override
 
virtual void emitPacket (Packet *packet)
 
- Protected Member Functions inherited from inet::queueing::PacketFlowBase
virtual void handleMessage (cMessage *message) override
 
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
 

Protected Attributes

simsignal_t signal
 
PacketFilter packetFilter
 
Direction direction = DIRECTION_UNDEFINED
 
PacketprocessedPacket = nullptr
 
- 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

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

Constructor & Destructor Documentation

◆ ~PacketEmitter()

virtual inet::PacketEmitter::~PacketEmitter ( )
inlinevirtual
35 { delete processedPacket; }

Member Function Documentation

◆ emitPacket()

void inet::PacketEmitter::emitPacket ( Packet packet)
protectedvirtual
67 {
68  if (packetFilter.matches(packet))
69  emit(signal, packet);
70 }

Referenced by pushPacket(), and pushPacketEnd().

◆ handlePushPacketProcessed()

void inet::PacketEmitter::handlePushPacketProcessed ( Packet packet,
cGate *  gate,
bool  successful 
)
overridevirtual

Notifies about the completion of the packet processing for a packet that was pushed earlier independently whether the packet is passed or streamed.

This method is called, for example, when a previously pushed packet is failed to be processed successfully. It allows the source to retry the operation.

The gate parameter must be a valid gate of this module. The packet must not be nullptr.

Reimplemented from inet::queueing::PacketFlowBase.

61 {
62 // emitPacket(processedPacket);
63  PacketFlowBase::handlePushPacketProcessed(packet, gate, successful);
64 }

◆ initialize()

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

Reimplemented from inet::queueing::PacketFlowBase.

18 {
20  if (stage == INITSTAGE_LOCAL) {
21  signal = registerSignal(par("signalName"));
22  packetFilter.setExpression(par("packetFilter").objectValue());
23  const char *directionString = par("direction");
24  if (!strcmp(directionString, "inbound"))
26  else if (!strcmp(directionString, "outbound"))
28  else if (!strcmp(directionString, "undefined"))
30  else
31  throw cRuntimeError("Unknown direction parameter value");
32  }
33 }

◆ processPacket()

void inet::PacketEmitter::processPacket ( Packet packet)
overrideprotectedvirtual

Implements inet::queueing::PacketFlowBase.

36 {
38  const auto& directionTag = packet->addTagIfAbsent<DirectionTag>();
39  if (directionTag->getDirection() == DIRECTION_UNDEFINED)
40  directionTag->setDirection(direction);
41  else if (directionTag->getDirection() != direction)
42  throw cRuntimeError("Packet direction tag doesn't match direction parameter");
43  }
44  delete processedPacket;
45  processedPacket = packet->dup();
46 }

◆ pushPacket()

void inet::PacketEmitter::pushPacket ( Packet packet,
cGate *  gate 
)
overridevirtual

Pushes the packet into the packet sink at the given gate.

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

This method is called, for example, when a packet source module pushes a packet into a queue module.

The sink must not be full at the gate. The packet must not be nullptr. The gate must be a valid gate of this module and it must support pushing and passing packets.

Reimplemented from inet::queueing::PacketFlowBase.

49 {
50  emitPacket(packet);
51  PacketFlowBase::pushPacket(packet, gate);
52 }

◆ pushPacketEnd()

void inet::PacketEmitter::pushPacketEnd ( Packet packet,
cGate *  gate 
)
overridevirtual

Ends pushing the packet into the packet sink 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 to the sink.

The sink must not be full at the gate and no other packet streaming can be in progress. The packet must not be nullptr. The gate must be a valid gate of this module and it must support pushing and streaming packets.

Reimplemented from inet::queueing::PacketFlowBase.

55 {
56  emitPacket(packet);
57  PacketFlowBase::pushPacketEnd(packet, gate);
58 }

Member Data Documentation

◆ direction

Direction inet::PacketEmitter::direction = DIRECTION_UNDEFINED
protected

Referenced by initialize(), and processPacket().

◆ packetFilter

PacketFilter inet::PacketEmitter::packetFilter
protected

Referenced by emitPacket(), and initialize().

◆ processedPacket

Packet* inet::PacketEmitter::processedPacket = nullptr
protected

Referenced by processPacket().

◆ signal

simsignal_t inet::PacketEmitter::signal
protected

Referenced by emitPacket(), and initialize().


The documentation for this class was generated from the following files:
inet::DIRECTION_INBOUND
@ DIRECTION_INBOUND
Definition: DirectionTag_m.h:57
inet::DIRECTION_OUTBOUND
@ DIRECTION_OUTBOUND
Definition: DirectionTag_m.h:58
inet::PacketFilter::setExpression
void setExpression(const char *expression)
Definition: common/packet/PacketFilter.cc:39
inet::PacketEmitter::signal
simsignal_t signal
Definition: PacketEmitter.h:23
inet::PacketEmitter::direction
Direction direction
Definition: PacketEmitter.h:25
inet::queueing::PacketFlowBase::pushPacket
virtual void pushPacket(Packet *packet, cGate *gate) override
Pushes the packet into the packet sink at the given gate.
Definition: PacketFlowBase.cc:66
inet::PacketEmitter::packetFilter
PacketFilter packetFilter
Definition: PacketEmitter.h:24
inet::queueing::PacketFlowBase::pushPacketEnd
virtual void pushPacketEnd(Packet *packet, cGate *gate) override
Ends pushing the packet into the packet sink at the given gate.
Definition: PacketFlowBase.cc:91
inet::PacketFilter::matches
bool matches(const cPacket *packet) const
Definition: common/packet/PacketFilter.cc:92
inet::PacketEmitter::emitPacket
virtual void emitPacket(Packet *packet)
Definition: PacketEmitter.cc:66
inet::queueing::PacketFlowBase::handlePushPacketProcessed
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 independe...
Definition: PacketFlowBase.cc:133
inet::Packet::dup
virtual Packet * dup() const override
Definition: Packet.h:171
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
inet::DIRECTION_UNDEFINED
@ DIRECTION_UNDEFINED
Definition: DirectionTag_m.h:56
inet::queueing::PacketFlowBase::initialize
virtual void initialize(int stage) override
Definition: PacketFlowBase.cc:15
inet::PacketEmitter::processedPacket
Packet * processedPacket
Definition: PacketEmitter.h:27