INET Framework for OMNeT++/OMNEST
inet::queueing::PacketClassifierBase Class Referenceabstract

#include <PacketClassifierBase.h>

Inheritance diagram for inet::queueing::PacketClassifierBase:
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 inet::ClockUserModuleMixin< PacketClassifierBase > inet::BehaviorAggregateClassifier inet::EthernetFrameClassifier inet::MultiFieldClassifier inet::PcpClassifier inet::PcpTrafficClassClassifier inet::queueing::ContentBasedClassifier inet::queueing::LabelClassifier inet::queueing::PacketClassifier inet::queueing::PriorityClassifier inet::queueing::WrrClassifier inet::StreamClassifier inet::queueing::MultiTokenBucketMixin< PacketClassifierBase > inet::queueing::TokenBucketMixin< PacketClassifierBase >

Public Member Functions

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...
 
virtual const char * resolveDirective (char directive) const override
 
- 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 ()
 

Protected Member Functions

virtual void initialize (int stage) override
 
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 classifyPacket (Packet *packet)=0
 
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
 

Protected Attributes

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)
 

Additional Inherited Members

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

Member Function Documentation

◆ callClassifyPacket()

int inet::queueing::PacketClassifierBase::callClassifyPacket ( Packet packet) const
protectedvirtual
58 {
59  // KLUDGE
60  int index = const_cast<PacketClassifierBase *>(this)->classifyPacket(packet);
61  if (index < 0 || static_cast<unsigned int>(index) >= outputGates.size())
62  throw cRuntimeError("Classified packet to invalid output gate: %d", index);
63  return index;
64 }

Referenced by canPullPacket(), handleCanPullPacketChanged(), pullPacket(), pushPacket(), and startPacketStreaming().

◆ canPullPacket()

Packet * inet::queueing::PacketClassifierBase::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.

Reimplemented in inet::queueing::MarkovClassifier.

172 {
173  auto packet = provider->canPullPacket(inputGate->getPathStartGate());
174  if (packet == nullptr)
175  return nullptr;
176  else {
177  int index = callClassifyPacket(packet);
178  return index == gate->getIndex() ? packet : nullptr;
179  }
180 }

Referenced by canPullSomePacket().

◆ canPullSomePacket()

bool inet::queueing::PacketClassifierBase::canPullSomePacket ( cGate *  gate) const
overridevirtual

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.

Implements inet::queueing::IPassivePacketSource.

Reimplemented in inet::queueing::MarkovClassifier.

167 {
168  return canPullPacket(gate) != nullptr;
169 }

◆ canPushPacket()

bool inet::queueing::PacketClassifierBase::canPushPacket ( Packet packet,
cGate *  gate 
) const
overridevirtual

Returns true if the given packet can be pushed at the given gate into the packet sink without raising an error.

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

Implements inet::queueing::IPassivePacketSink.

Reimplemented in inet::queueing::PriorityClassifier.

96 {
97  return canPushSomePacket(gate);
98 }

◆ canPushSomePacket()

bool inet::queueing::PacketClassifierBase::canPushSomePacket ( cGate *  gate) const
overridevirtual

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.

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

Implements inet::queueing::IPassivePacketSink.

Reimplemented in inet::queueing::PriorityClassifier.

88 {
89  for (int i = 0; i < (int)outputGates.size(); i++)
90  if (!consumers[i]->canPushSomePacket(outputGates[i]->getPathEndGate()))
91  return false;
92  return true;
93 }

Referenced by canPushPacket(), and inet::queueing::WrrClassifier::classifyPacket().

◆ checkPacketStreaming()

void inet::queueing::PacketClassifierBase::checkPacketStreaming ( Packet packet)
protectedvirtual
67 {
68  if (inProgressStreamId != -1 && (packet == nullptr || packet->getTreeId() != inProgressStreamId))
69  throw cRuntimeError("Another packet streaming operation is already in progress");
70 }

Referenced by pushPacket(), pushPacketEnd(), pushPacketProgress(), and pushPacketStart().

◆ classifyPacket()

◆ endPacketStreaming()

void inet::queueing::PacketClassifierBase::endPacketStreaming ( Packet packet)
protectedvirtual
80 {
81  emit(packetPushedSignal, packet);
82  handlePacketProcessed(packet);
83  inProgressStreamId = -1;
85 }

Referenced by pushPacketEnd(), and pushPacketProgress().

◆ getConsumer()

virtual IPassivePacketSink* inet::queueing::PacketClassifierBase::getConsumer ( cGate *  gate)
inlineoverridevirtual

Returns the passive packet sink where packets are pushed or nullptr if the connected module doesn't implement the interface.

The gate parameter must be a valid gate of this module.

Implements inet::queueing::IActivePacketSource.

52 { return consumers[gate->getIndex()]; }

◆ getOutputGateIndex()

virtual size_t inet::queueing::PacketClassifierBase::getOutputGateIndex ( size_t  i) const
inlineprotectedvirtual

◆ getProvider()

virtual IPassivePacketSource* inet::queueing::PacketClassifierBase::getProvider ( cGate *  gate)
inlineoverridevirtual

Returns the passive packet source from where packets are pulled or nullptr if the connected module doesn't implement the interface.

The gate parameter must be a valid gate of this module.

Implements inet::queueing::IActivePacketSink.

Reimplemented in inet::queueing::MarkovClassifier.

51 { return provider; }

◆ handleCanPullPacketChanged()

void inet::queueing::PacketClassifierBase::handleCanPullPacketChanged ( cGate *  gate)
overridevirtual

Notifies about a change in the possibility of pulling some packet from the passive packet source at the given gate.

This method is called, for example, when a new packet is inserted into a queue. It allows the sink to pull a new packet from the queue.

The gate parameter must be a valid gate of this module.

Implements inet::queueing::IActivePacketSink.

Reimplemented in inet::queueing::MarkovClassifier.

192 {
193  auto packet = provider->canPullPacket(inputGate->getPathStartGate());
194  if (packet != nullptr) {
195  int index = callClassifyPacket(packet);
196  auto collector = collectors[index];
197  if (collector != nullptr)
198  collector->handleCanPullPacketChanged(outputGates[index]->getPathEndGate());
199  }
200 }

◆ handleCanPushPacketChanged()

void inet::queueing::PacketClassifierBase::handleCanPushPacketChanged ( cGate *  gate)
overridevirtual

Notifies about a change in the possibility of pushing some packet into the passive packet sink at the given gate.

This method is called, for example, when a new packet can be inserted into a queue. It allows the source to push a new packet into the queue.

The gate parameter must be a valid gate of this module.

Implements inet::queueing::IActivePacketSource.

155 {
156  Enter_Method("handleCanPushPacketChanged");
157  if (producer != nullptr)
158  producer->handleCanPushPacketChanged(inputGate->getPathStartGate());
159 }

◆ handleMessage()

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

Reimplemented in inet::queueing::TokenBucketMixin< PacketClassifierBase >, and inet::queueing::MarkovClassifier.

40 {
41  auto packet = check_and_cast<Packet *>(message);
42  pushPacket(packet, packet->getArrivalGate());
43 }

◆ handlePullPacketProcessed()

virtual void inet::queueing::PacketClassifierBase::handlePullPacketProcessed ( Packet packet,
cGate *  gate,
bool  successful 
)
inlineoverridevirtual

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

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

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

Implements inet::queueing::IActivePacketSink.

Reimplemented in inet::queueing::MarkovClassifier.

78 { throw cRuntimeError("TODO"); }

◆ handlePushPacketProcessed()

void inet::queueing::PacketClassifierBase::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.

Implements inet::queueing::IActivePacketSource.

162 {
163  producer->handlePushPacketProcessed(packet, inputGate->getPathStartGate(), successful);
164 }

◆ initialize()

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

Reimplemented from inet::queueing::PacketProcessorBase.

Reimplemented in inet::MultiFieldClassifier, inet::BehaviorAggregateClassifier, inet::queueing::MultiTokenBucketMixin< PacketClassifierBase >, inet::queueing::MarkovClassifier, inet::queueing::WrrClassifier, inet::queueing::TokenBucketMixin< PacketClassifierBase >, inet::queueing::DynamicClassifier, inet::StreamClassifier, inet::queueing::ContentBasedClassifier, inet::queueing::TokenBucketClassifierMixin< TokenBucketMixin< PacketClassifierBase > >, inet::queueing::TokenBucketClassifierMixin< MultiTokenBucketMixin< PacketClassifierBase > >, inet::PcpClassifier, inet::PcpTrafficClassClassifier, inet::queueing::LabelClassifier, inet::queueing::PacketClassifier, inet::queueing::MultiTokenBucketClassifier, and inet::queueing::TokenBucketClassifier.

16 {
18  if (stage == INITSTAGE_LOCAL) {
19  reverseOrder = par("reverseOrder");
20  inputGate = gate("in");
21  producer = findConnectedModule<IActivePacketSource>(inputGate);
22  provider = findConnectedModule<IPassivePacketSource>(inputGate);
23  for (int i = 0; i < gateSize("out"); i++) {
24  auto outputGate = gate("out", i);
25  outputGates.push_back(outputGate);
26  auto consumer = findConnectedModule<IPassivePacketSink>(outputGate);
27  consumers.push_back(consumer);
28  auto collector = findConnectedModule<IActivePacketSink>(outputGate);
29  collectors.push_back(collector);
30  }
31  }
32  else if (stage == INITSTAGE_QUEUEING) {
33  for (int i = 0; i < gateSize("out"); i++)
36  }
37 }

Referenced by inet::queueing::LabelClassifier::initialize(), inet::queueing::PacketClassifier::initialize(), inet::PcpClassifier::initialize(), inet::PcpTrafficClassClassifier::initialize(), inet::StreamClassifier::initialize(), inet::queueing::ContentBasedClassifier::initialize(), inet::queueing::WrrClassifier::initialize(), inet::BehaviorAggregateClassifier::initialize(), and inet::MultiFieldClassifier::initialize().

◆ isStreamingPacket()

virtual bool inet::queueing::PacketClassifierBase::isStreamingPacket ( ) const
inlineprotectedvirtual
45 { return inProgressStreamId != -1; }

Referenced by pushPacketEnd(), and pushPacketProgress().

◆ mapRegistrationForwardingGates()

void inet::queueing::PacketClassifierBase::mapRegistrationForwardingGates ( cGate *  gate,
std::function< void(cGate *)>  f 
)
overrideprotectedvirtual

Reimplemented from inet::TransparentProtocolRegistrationListener.

Reimplemented in inet::MultiFieldClassifier.

46 {
47  if (gate == inputGate) {
48  for (auto outputGate : outputGates)
49  f(outputGate);
50  }
51  else if (std::find(outputGates.begin(), outputGates.end(), gate) != outputGates.end())
52  f(inputGate);
53  else
54  throw cRuntimeError("Unknown gate");
55 }

Referenced by inet::MultiFieldClassifier::mapRegistrationForwardingGates().

◆ pullPacket()

Packet * inet::queueing::PacketClassifierBase::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.

Reimplemented in inet::queueing::MarkovClassifier.

183 {
184  auto packet = provider->pullPacket(inputGate->getPathStartGate());
185  int index = callClassifyPacket(packet);
186  if (index != gate->getIndex())
187  throw cRuntimeError("Classified packet to wrong output gate");
188  return packet;
189 }

◆ pullPacketEnd()

virtual Packet* inet::queueing::PacketClassifierBase::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.

Implements inet::queueing::IPassivePacketSource.

Reimplemented in inet::queueing::MarkovClassifier.

74 { throw cRuntimeError("TODO"); }

◆ pullPacketProgress()

virtual Packet* inet::queueing::PacketClassifierBase::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.

Implements inet::queueing::IPassivePacketSource.

Reimplemented in inet::queueing::MarkovClassifier.

75 { throw cRuntimeError("TODO"); }

◆ pullPacketStart()

virtual Packet* inet::queueing::PacketClassifierBase::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.

Implements inet::queueing::IPassivePacketSource.

Reimplemented in inet::queueing::MarkovClassifier.

73 { throw cRuntimeError("TODO"); }

◆ pushPacket()

void inet::queueing::PacketClassifierBase::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.

Implements inet::queueing::IPassivePacketSink.

Reimplemented in inet::MultiFieldClassifier, and inet::BehaviorAggregateClassifier.

101 {
102  Enter_Method("pushPacket");
103  take(packet);
104  checkPacketStreaming(nullptr);
105  EV_INFO << "Classifying packet" << EV_FIELD(packet) << EV_ENDL;
106  int index = callClassifyPacket(packet);
107  handlePacketProcessed(packet);
108  emit(packetPushedSignal, packet);
109  pushOrSendPacket(packet, outputGates[index], consumers[index]);
111 }

Referenced by handleMessage().

◆ pushPacketEnd()

void inet::queueing::PacketClassifierBase::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.

Implements inet::queueing::IPassivePacketSink.

124 {
125  Enter_Method("pushPacketEnd");
126  take(packet);
127  if (!isStreamingPacket())
128  startPacketStreaming(packet);
129  else
130  checkPacketStreaming(packet);
131  auto outputGate = outputGates[inProgressGateIndex];
132  auto consumer = consumers[inProgressGateIndex];
133  endPacketStreaming(packet);
134  pushOrSendPacketEnd(packet, outputGate, consumer, packet->getTransmissionId());
136 }

◆ pushPacketProgress()

void inet::queueing::PacketClassifierBase::pushPacketProgress ( Packet packet,
cGate *  gate,
bps  datarate,
b  position,
b  extraProcessableLength = b(0) 
)
overridevirtual

Progresses pushing the packet into the packet sink 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 sink about a change in the packet data when a preemption occurs.

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.

Implements inet::queueing::IPassivePacketSink.

139 {
140  Enter_Method("pushPacketProgress");
141  take(packet);
142  if (!isStreamingPacket())
143  startPacketStreaming(packet);
144  else
145  checkPacketStreaming(packet);
146  auto outputGate = outputGates[inProgressGateIndex];
147  auto consumer = consumers[inProgressGateIndex];
148  if (packet->getTotalLength() == position + extraProcessableLength)
149  endPacketStreaming(packet);
150  pushOrSendPacketProgress(packet, outputGate, consumer, datarate, position, extraProcessableLength, packet->getTransmissionId());
152 }

◆ pushPacketStart()

void inet::queueing::PacketClassifierBase::pushPacketStart ( Packet packet,
cGate *  gate,
bps  datarate 
)
overridevirtual

Starts 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 starts 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.

Implements inet::queueing::IPassivePacketSink.

114 {
115  Enter_Method("pushPacketStart");
116  take(packet);
117  checkPacketStreaming(packet);
118  startPacketStreaming(packet);
119  pushOrSendPacketStart(packet, outputGates[inProgressGateIndex], consumers[inProgressGateIndex], datarate, packet->getTransmissionId());
121 }

◆ startPacketStreaming()

void inet::queueing::PacketClassifierBase::startPacketStreaming ( Packet packet)
protectedvirtual
73 {
74  EV_INFO << "Classifying packet" << EV_FIELD(packet) << EV_ENDL;
75  inProgressStreamId = packet->getTreeId();
77 }

Referenced by pushPacketEnd(), pushPacketProgress(), and pushPacketStart().

◆ supportsPacketPulling()

virtual bool inet::queueing::PacketClassifierBase::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.

Implements inet::queueing::IPacketProcessor.

Reimplemented in inet::queueing::MarkovClassifier.

55 { return true; }

◆ supportsPacketPushing()

virtual bool inet::queueing::PacketClassifierBase::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.

Implements inet::queueing::IPacketProcessor.

Reimplemented in inet::queueing::MarkovClassifier.

54 { return true; }

◆ supportsPacketStreaming()

virtual bool inet::queueing::PacketClassifierBase::supportsPacketStreaming ( cGate *  gate) const
inlineoverridevirtual

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

A streamed packet is handed over from one module to another using several method calls and potentially exending to a non-zero simulation duration.

For example, packets are streamed to a preemptable signal transmitter 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(stream) in the NED file.

Reimplemented from inet::queueing::PacketProcessorBase.

56 { return true; }

Member Data Documentation

◆ collectors

std::vector<IActivePacketSink *> inet::queueing::PacketClassifierBase::collectors
protected

◆ consumers

◆ inProgressGateIndex

int inet::queueing::PacketClassifierBase::inProgressGateIndex = -1
protected

◆ inProgressStreamId

int inet::queueing::PacketClassifierBase::inProgressStreamId = -1
protected

◆ inputGate

◆ outputGates

◆ producer

IActivePacketSource* inet::queueing::PacketClassifierBase::producer = nullptr
protected

◆ provider

IPassivePacketSource* inet::queueing::PacketClassifierBase::provider = nullptr
protected

◆ reverseOrder

bool inet::queueing::PacketClassifierBase::reverseOrder = false
protected

Referenced by initialize().


The documentation for this class was generated from the following files:
inet::queueing::PacketProcessorBase::initialize
virtual void initialize(int stage) override
Definition: PacketProcessorBase.cc:16
inet::queueing::PacketProcessorBase::pushOrSendPacket
virtual void pushOrSendPacket(Packet *packet, cGate *gate, IPassivePacketSink *consumer)
Definition: PacketProcessorBase.cc:126
inet::queueing::PacketClassifierBase::pushPacket
virtual void pushPacket(Packet *packet, cGate *gate) override
Pushes the packet into the packet sink at the given gate.
Definition: PacketClassifierBase.cc:100
inet::queueing::PacketClassifierBase::canPullPacket
virtual Packet * canPullPacket(cGate *gate) const override
Returns the packet that can be pulled at the given gate.
Definition: PacketClassifierBase.cc:171
inet::queueing::PacketProcessorBase::pushOrSendPacketProgress
virtual void pushOrSendPacketProgress(Packet *packet, cGate *gate, IPassivePacketSink *consumer, bps datarate, b position, b extraProcessableLength, int transmissionId)
Definition: PacketProcessorBase.cc:171
inet::INITSTAGE_QUEUEING
INET_API InitStage INITSTAGE_QUEUEING
Initialization of queueing modules.
inet::queueing::PacketClassifierBase::canPushSomePacket
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 ...
Definition: PacketClassifierBase.cc:87
inet::find
std::vector< T >::iterator find(std::vector< T > &v, const Tk &a)
Definition: stlutils.h:44
inet::queueing::IPassivePacketSource::canPullPacket
virtual Packet * canPullPacket(cGate *gate) const =0
Returns the packet that can be pulled at the given gate.
inet::queueing::PacketClassifierBase::isStreamingPacket
virtual bool isStreamingPacket() const
Definition: PacketClassifierBase.h:45
inet::queueing::PacketClassifierBase::inputGate
cGate * inputGate
Definition: PacketClassifierBase.h:24
inet::queueing::PacketClassifierBase::classifyPacket
virtual int classifyPacket(Packet *packet)=0
inet::queueing::PacketProcessorBase::handlePacketProcessed
virtual void handlePacketProcessed(Packet *packet)
Definition: PacketProcessorBase.cc:34
inet::packetPushedSignal
simsignal_t packetPushedSignal
Definition: Simsignals.cc:99
inet::queueing::PacketClassifierBase::provider
IPassivePacketSource * provider
Definition: PacketClassifierBase.h:26
EV_FIELD
#define EV_FIELD(...)
Definition: INETDefs.h:112
inet::queueing::PacketClassifierBase::checkPacketStreaming
virtual void checkPacketStreaming(Packet *packet)
Definition: PacketClassifierBase.cc:66
inet::queueing::PacketClassifierBase::endPacketStreaming
virtual void endPacketStreaming(Packet *packet)
Definition: PacketClassifierBase.cc:79
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
inet::queueing::IActivePacketSource::handleCanPushPacketChanged
virtual void handleCanPushPacketChanged(cGate *gate)=0
Notifies about a change in the possibility of pushing some packet into the passive packet sink at the...
inet::queueing::PacketProcessorBase::pushOrSendPacketEnd
virtual void pushOrSendPacketEnd(Packet *packet, cGate *gate, IPassivePacketSink *consumer, int transmissionId)
Definition: PacketProcessorBase.cc:154
inet::queueing::PacketClassifierBase::collectors
std::vector< IActivePacketSink * > collectors
Definition: PacketClassifierBase.h:30
inet::queueing::IActivePacketSource::handlePushPacketProcessed
virtual void handlePushPacketProcessed(Packet *packet, cGate *gate, bool successful)=0
Notifies about the completion of the packet processing for a packet that was pushed earlier independe...
inet::queueing::PacketProcessorBase::updateDisplayString
virtual void updateDisplayString() const
Definition: PacketProcessorBase.cc:399
inet::queueing::PacketClassifierBase::producer
IActivePacketSource * producer
Definition: PacketClassifierBase.h:25
inet::queueing::PacketClassifierBase::reverseOrder
bool reverseOrder
Definition: PacketClassifierBase.h:22
inet::queueing::PacketProcessorBase::checkPacketOperationSupport
virtual void checkPacketOperationSupport(cGate *gate) const
Definition: PacketProcessorBase.cc:40
inet::queueing::PacketClassifierBase::consumers
std::vector< IPassivePacketSink * > consumers
Definition: PacketClassifierBase.h:29
Enter_Method
#define Enter_Method(...)
Definition: SelfDoc.h:71
inet::queueing::PacketClassifierBase::outputGates
std::vector< cGate * > outputGates
Definition: PacketClassifierBase.h:28
inet::queueing::PacketProcessorBase::pushOrSendPacketStart
virtual void pushOrSendPacketStart(Packet *packet, cGate *gate, IPassivePacketSink *consumer, bps datarate, int transmissionId)
Definition: PacketProcessorBase.cc:136
inet::queueing::PacketClassifierBase::startPacketStreaming
virtual void startPacketStreaming(Packet *packet)
Definition: PacketClassifierBase.cc:72
EV_ENDL
#define EV_ENDL
Definition: INETDefs.h:114
inet::queueing::PacketClassifierBase::callClassifyPacket
virtual int callClassifyPacket(Packet *packet) const
Definition: PacketClassifierBase.cc:57
inet::queueing::IPassivePacketSource::pullPacket
virtual Packet * pullPacket(cGate *gate)=0
Pulls the packet from the packet source at the given gate.
inet::queueing::PacketClassifierBase::inProgressStreamId
int inProgressStreamId
Definition: PacketClassifierBase.h:32
inet::queueing::PacketClassifierBase::inProgressGateIndex
int inProgressGateIndex
Definition: PacketClassifierBase.h:33