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

#include <PacketServer.h>

Inheritance diagram for inet::queueing::PacketServer:
inet::ClockUserModuleMixin< PacketServerBase > inet::queueing::PacketServerBase inet::queueing::PacketProcessorBase inet::queueing::IActivePacketSink inet::queueing::IActivePacketSource inet::queueing::IPacketProcessor inet::StringFormat::IDirectiveResolver

Public Member Functions

virtual ~PacketServer ()
 
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...
 
virtual const char * resolveDirective (char directive) const override
 
- Public Member Functions inherited from inet::ClockUserModuleMixin< PacketServerBase >
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::PacketServerBase
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 void handlePushPacketProcessed (Packet *packet, cGate *gate, bool successful) override
 Notifies about the completion of the packet processing for a packet that was pushed earlier independently whether the packet is passed or streamed. More...
 
virtual void 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 bool supportsPacketStreaming (cGate *gate) const override
 Returns true if the processor supports streaming packets at the given gate. More...
 
- Public Member Functions inherited from inet::queueing::IPacketProcessor
virtual ~IPacketProcessor ()
 
- Public Member Functions inherited from inet::queueing::IActivePacketSink
virtual ~IActivePacketSink ()
 
- 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 scheduleProcessingTimer ()
 
virtual bool canStartProcessingPacket ()
 
virtual void startProcessingPacket ()
 
virtual void endProcessingPacket ()
 
- 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

ClockEventprocessingTimer = nullptr
 
Packetpacket = nullptr
 
- Protected Attributes inherited from inet::queueing::PacketServerBase
cGate * inputGate = nullptr
 
IPassivePacketSourceprovider = nullptr
 
cGate * outputGate = nullptr
 
IPassivePacketSinkconsumer = nullptr
 
- 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

◆ ~PacketServer()

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

Member Function Documentation

◆ canStartProcessingPacket()

bool inet::queueing::PacketServer::canStartProcessingPacket ( )
protectedvirtual
49 {
50  return provider->canPullSomePacket(inputGate->getPathStartGate()) &&
51  consumer->canPushSomePacket(outputGate->getPathEndGate());
52 }

Referenced by handleCanPullPacketChanged(), handleCanPushPacketChanged(), and handleMessage().

◆ endProcessingPacket()

void inet::queueing::PacketServer::endProcessingPacket ( )
protectedvirtual
63 {
64  EV_INFO << "Processing packet ended" << EV_FIELD(packet) << EV_ENDL;
65  simtime_t packetProcessingTime = simTime() - processingTimer->getSendingTime();
66  simtime_t bitProcessingTime = packetProcessingTime / packet->getBitLength();
67  insertPacketEvent(this, packet, PEK_PROCESSED, bitProcessingTime);
68  increaseTimeTag<ProcessingTimeTag>(packet, bitProcessingTime, packetProcessingTime);
73  packet = nullptr;
74 }

Referenced by handleMessage().

◆ handleCanPullPacketChanged()

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

86 {
87  Enter_Method("handleCanPullPacketChanged");
88  if (!processingTimer->isScheduled() && canStartProcessingPacket()) {
91  }
92 }

◆ handleCanPushPacketChanged()

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

77 {
78  Enter_Method("handleCanPushPacketChanged");
79  if (!processingTimer->isScheduled() && canStartProcessingPacket()) {
82  }
83 }

◆ handleMessage()

void inet::queueing::PacketServer::handleMessage ( cMessage *  message)
overrideprotectedvirtual
27 {
28  if (message == processingTimer) {
33  }
35  }
36  else
37  throw cRuntimeError("Unknown message");
38 }

◆ initialize()

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

Reimplemented from inet::queueing::PacketServerBase.

20 {
21  ClockUserModuleMixin::initialize(stage);
22  if (stage == INITSTAGE_LOCAL)
23  processingTimer = new ClockEvent("ProcessingTimer");
24 }

◆ resolveDirective()

const char * inet::queueing::PacketServer::resolveDirective ( char  directive) const
overridevirtual

Reimplemented from inet::queueing::PacketProcessorBase.

95 {
96  static std::string result;
97  switch (directive) {
98  case 's':
99  result = processingTimer->isScheduled() ? "processing" : "";
100  break;
101  default:
102  return PacketServerBase::resolveDirective(directive);
103  }
104  return result.c_str();
105 }

◆ scheduleProcessingTimer()

void inet::queueing::PacketServer::scheduleProcessingTimer ( )
protectedvirtual
41 {
42  clocktime_t processingTime = par("processingTime");
43  auto processingBitrate = bps(par("processingBitrate"));
44  processingTime += s(packet->getTotalLength() / processingBitrate).get();
46 }

Referenced by handleCanPullPacketChanged(), handleCanPushPacketChanged(), and handleMessage().

◆ startProcessingPacket()

void inet::queueing::PacketServer::startProcessingPacket ( )
protectedvirtual
55 {
56  packet = provider->pullPacket(inputGate->getPathStartGate());
57  take(packet);
59  EV_INFO << "Processing packet started" << EV_FIELD(packet) << EV_ENDL;
60 }

Referenced by handleCanPullPacketChanged(), handleCanPushPacketChanged(), and handleMessage().

Member Data Documentation

◆ packet

Packet* inet::queueing::PacketServer::packet = nullptr
protected

◆ processingTimer


The documentation for this class was generated from the following files:
inet::queueing::PacketServer::endProcessingPacket
virtual void endProcessingPacket()
Definition: PacketServer.cc:62
inet::clocktime_t
ClockTime clocktime_t
Definition: contract/ClockTime.h:25
inet::queueing::PacketProcessorBase::pushOrSendPacket
virtual void pushOrSendPacket(Packet *packet, cGate *gate, IPassivePacketSink *consumer)
Definition: PacketProcessorBase.cc:126
inet::queueing::PacketServerBase::consumer
IPassivePacketSink * consumer
Definition: PacketServerBase.h:25
inet::queueing::PacketServer::processingTimer
ClockEvent * processingTimer
Definition: PacketServer.h:20
inet::Packet::getDataLength
b getDataLength() const
Returns the current length of the data part of the packet.
Definition: Packet.h:206
inet::units::units::bps
compose< b, pow< s, -1 > > bps
Definition: Units.h:1169
inet::ClockUserModuleMixin< PacketServerBase >::scheduleClockEventAfter
virtual void scheduleClockEventAfter(clocktime_t delay, ClockEvent *msg)
Definition: ClockUserModuleMixin.h:65
inet::queueing::PacketServer::startProcessingPacket
virtual void startProcessingPacket()
Definition: PacketServer.cc:54
inet::queueing::PacketServer::packet
Packet * packet
Definition: PacketServer.h:21
inet::packetPulledSignal
simsignal_t packetPulledSignal
Definition: Simsignals.cc:105
inet::queueing::IPassivePacketSink::canPushSomePacket
virtual bool canPushSomePacket(cGate *gate) const =0
Returns false if the packet sink is full at the given gate and no more packets can be pushed into it ...
inet::queueing::PacketProcessorBase::processedTotalLength
b processedTotalLength
Definition: PacketProcessorBase.h:31
inet::ClockEvent
cMessage ClockEvent
Definition: contract/ClockEvent.h:18
inet::queueing::PacketServer::scheduleProcessingTimer
virtual void scheduleProcessingTimer()
Definition: PacketServer.cc:40
inet::queueing::PacketServerBase::provider
IPassivePacketSource * provider
Definition: PacketServerBase.h:22
inet::packetPushedSignal
simsignal_t packetPushedSignal
Definition: Simsignals.cc:99
inet::queueing::PacketProcessorBase::resolveDirective
virtual const char * resolveDirective(char directive) const override
Definition: PacketProcessorBase.cc:407
inet::units::values::s
value< double, units::s > s
Definition: Units.h:1235
EV_FIELD
#define EV_FIELD(...)
Definition: INETDefs.h:112
inet::queueing::PacketServer::canStartProcessingPacket
virtual bool canStartProcessingPacket()
Definition: PacketServer.cc:48
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
inet::queueing::PacketProcessorBase::numProcessedPackets
int numProcessedPackets
Definition: PacketProcessorBase.h:30
inet::Packet::getTotalLength
b getTotalLength() const
Returns the total packet length ignoring front and back offsets.
Definition: Packet.h:193
inet::ClockUserModuleMixin< PacketServerBase >::cancelAndDeleteClockEvent
virtual void cancelAndDeleteClockEvent(ClockEvent *msg)
Definition: ClockUserModuleMixin.h:67
inet::queueing::PacketProcessorBase::updateDisplayString
virtual void updateDisplayString() const
Definition: PacketProcessorBase.cc:399
inet::Packet::getBitLength
virtual int64_t getBitLength() const override
Returns the length in bits between the front and back offsets.
Definition: Packet.h:199
Enter_Method
#define Enter_Method(...)
Definition: SelfDoc.h:71
inet::queueing::PacketServerBase::outputGate
cGate * outputGate
Definition: PacketServerBase.h:24
inet::queueing::IPassivePacketSource::canPullSomePacket
virtual bool canPullSomePacket(cGate *gate) const =0
Returns false if the packet source is empty at the given gate and no more packets can be pulled from ...
EV_ENDL
#define EV_ENDL
Definition: INETDefs.h:114
inet::insertPacketEvent
void insertPacketEvent(const cModule *module, Packet *packet, int kind, simtime_t duration, PacketEvent *packetEvent)
Definition: PacketEventTag.cc:12
inet::PEK_PROCESSED
@ PEK_PROCESSED
Definition: PacketEventTag_m.h:67
inet::queueing::IPassivePacketSource::pullPacket
virtual Packet * pullPacket(cGate *gate)=0
Pulls the packet from the packet source at the given gate.
inet::queueing::PacketServerBase::inputGate
cGate * inputGate
Definition: PacketServerBase.h:21