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

#include <PcapFilePacketProducer.h>

Inheritance diagram for inet::queueing::PcapFilePacketProducer:
inet::queueing::ActivePacketSourceBase inet::queueing::PacketSourceBase inet::queueing::IActivePacketSource inet::queueing::PacketProcessorBase inet::queueing::IPacketProcessor inet::StringFormat::IDirectiveResolver

Public Member Functions

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...
 
- Public Member Functions inherited from inet::queueing::ActivePacketSourceBase
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...
 
- 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::IActivePacketSource
virtual ~IActivePacketSource ()
 

Protected Member Functions

virtual void initialize (int stage) override
 
virtual void finish () override
 
virtual void handleMessage (cMessage *message) override
 
virtual void schedulePacket ()
 
- 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

PcapReader pcapReader
 
- Protected Attributes inherited from inet::queueing::ActivePacketSourceBase
cGate * outputGate = nullptr
 
IPassivePacketSinkconsumer = 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 }
 

Member Function Documentation

◆ finish()

void inet::queueing::PcapFilePacketProducer::finish ( )
overrideprotectedvirtual
28 {
29  if (pcapReader.isOpen())
31 }

◆ handleCanPushPacketChanged()

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

61 {
62  Enter_Method("handleCanPushPacketChanged");
63  if (gate == outputGate)
65 }

◆ handleMessage()

void inet::queueing::PcapFilePacketProducer::handleMessage ( cMessage *  message)
overrideprotectedvirtual
34 {
35  if (message->isPacket()) {
36  auto packet = check_and_cast<Packet *>(message);
37  if (consumer == nullptr || consumer->canPushPacket(packet, outputGate->getPathEndGate())) {
38  emit(packetPushedSignal, packet);
41  }
42  }
43  else
44  throw cRuntimeError("Unknown message: %s", message->getFullName());
45 }

◆ handlePushPacketProcessed()

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

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.

31 {}

◆ initialize()

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

Reimplemented from inet::queueing::ActivePacketSourceBase.

19 {
21  if (stage == INITSTAGE_LOCAL)
22  pcapReader.openPcap(par("filename"), par("packetNameFormat"));
23  else if (stage == INITSTAGE_QUEUEING)
25 }

◆ schedulePacket()

void inet::queueing::PcapFilePacketProducer::schedulePacket ( )
protectedvirtual
48 {
49  auto pair = pcapReader.readPacket();
50  auto packet = pair.second;
51  emit(packetCreatedSignal, packet);
52  if (packet != nullptr) {
53  EV << "Scheduling packet from PCAP file" << EV_FIELD(packet) << EV_ENDL;
54  scheduleAt(pair.first, packet);
55  }
56  else
57  EV << "End of PCAP file reached" << EV_ENDL;
58 }

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

Member Data Documentation

◆ pcapReader

PcapReader inet::queueing::PcapFilePacketProducer::pcapReader
protected

Referenced by finish(), initialize(), and schedulePacket().


The documentation for this class was generated from the following files:
inet::queueing::PcapFilePacketProducer::schedulePacket
virtual void schedulePacket()
Definition: PcapFilePacketProducer.cc:47
inet::queueing::PacketProcessorBase::pushOrSendPacket
virtual void pushOrSendPacket(Packet *packet, cGate *gate, IPassivePacketSink *consumer)
Definition: PacketProcessorBase.cc:126
inet::queueing::IPassivePacketSink::canPushPacket
virtual bool canPushPacket(Packet *packet, cGate *gate) const =0
Returns true if the given packet can be pushed at the given gate into the packet sink without raising...
inet::PcapReader::isOpen
virtual bool isOpen()
Definition: PcapReader.h:49
inet::PcapReader::readPacket
virtual std::pair< simtime_t, Packet * > readPacket()
Definition: PcapReader.cc:56
inet::INITSTAGE_QUEUEING
INET_API InitStage INITSTAGE_QUEUEING
Initialization of queueing modules.
inet::queueing::ActivePacketSourceBase::initialize
virtual void initialize(int stage) override
Definition: ActivePacketSourceBase.cc:15
inet::packetPushedSignal
simsignal_t packetPushedSignal
Definition: Simsignals.cc:99
EV_FIELD
#define EV_FIELD(...)
Definition: INETDefs.h:112
inet::PcapReader::openPcap
virtual void openPcap(const char *filename, const char *packetNameFormat)
Definition: PcapReader.cc:27
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
inet::queueing::PcapFilePacketProducer::pcapReader
PcapReader pcapReader
Definition: PcapFilePacketProducer.h:20
inet::queueing::ActivePacketSourceBase::consumer
IPassivePacketSink * consumer
Definition: ActivePacketSourceBase.h:21
inet::queueing::ActivePacketSourceBase::outputGate
cGate * outputGate
Definition: ActivePacketSourceBase.h:20
inet::packetCreatedSignal
simsignal_t packetCreatedSignal
Definition: Simsignals.cc:82
Enter_Method
#define Enter_Method(...)
Definition: SelfDoc.h:71
EV_ENDL
#define EV_ENDL
Definition: INETDefs.h:114
inet::PcapReader::closePcap
virtual void closePcap()
Definition: PcapReader.cc:108