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

#include <EthernetFragmentFcsChecker.h>

Inheritance diagram for inet::EthernetFragmentFcsChecker:
inet::FcsCheckerBase inet::queueing::PacketFilterBase inet::queueing::PacketProcessorBase inet::queueing::IPacketFilter inet::queueing::IPacketProcessor inet::StringFormat::IDirectiveResolver inet::queueing::IPacketFlow inet::queueing::IPacketSink inet::queueing::IPacketSource inet::queueing::IPassivePacketSink inet::queueing::IActivePacketSink inet::queueing::IPassivePacketSource inet::queueing::IActivePacketSource

Public Member Functions

virtual bool matchesPacket (const Packet *packet) const override
 Returns true if the filter matches the given packet. More...
 
- Public Member Functions inherited from inet::queueing::PacketFilterBase
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 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 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 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...
 
- 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...
 
- 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 bool checkComputedFcs (const Packet *packet, uint32_t fcs) const override
 
virtual bool checkFcs (const Packet *packet, FcsMode fcsMode, uint32_t fcs) const override
 
virtual void processPacket (Packet *packet) override
 
virtual void dropPacket (Packet *packet) override
 
- Protected Member Functions inherited from inet::FcsCheckerBase
virtual bool checkDisabledFcs (const Packet *packet, uint32_t fcs) const
 
virtual bool checkDeclaredCorrectFcs (const Packet *packet, uint32_t fcs) const
 
virtual bool checkDeclaredIncorrectFcs (const Packet *packet, uint32_t fcs) const
 
- Protected Member Functions inherited from inet::queueing::PacketFilterBase
virtual void initialize (int stage) override
 
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)
 
virtual void dropPacket (Packet *packet, PacketDropReason reason, int limit=-1) override
 
virtual const char * resolveDirective (char directive) const override
 
- 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 updateDisplayString () const
 

Protected Attributes

uint32_t lastFragmentCompleteFcs = 0
 
uint32_t currentFragmentCompleteFcs = 0
 
- Protected Attributes inherited from inet::queueing::PacketFilterBase
bool backpressure = false
 
cGate * inputGate = nullptr
 
ModuleRef< IActivePacketSourceproducer
 
ModuleRef< IPassivePacketSourceprovider
 
cGate * outputGate = nullptr
 
ModuleRef< IPassivePacketSinkconsumer
 
ModuleRef< IActivePacketSinkcollector
 
int inProgressStreamId = -1
 
int numDroppedPackets = 0
 
b droppedTotalLength = b(-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

◆ checkComputedFcs()

bool inet::EthernetFragmentFcsChecker::checkComputedFcs ( const Packet packet,
uint32_t  fcs 
) const
overrideprotectedvirtual

Reimplemented from inet::FcsCheckerBase.

20 {
21  auto data = packet->peekDataAsBytes();
22  auto bytes = data->getBytes();
23  uint32_t fragmentFcs = ethernetCRC(bytes.data(), packet->getByteLength() - 4);
24  auto& fragmentTag = packet->getTag<FragmentTag>();
25  currentFragmentCompleteFcs = ethernetCRC(bytes.data(), packet->getByteLength() - 4, fragmentTag->getFirstFragment() ? 0 : lastFragmentCompleteFcs);
26  bool lastFragment = receivedFcs != (fragmentFcs ^ 0xFFFF0000);
27  return !lastFragment || receivedFcs == currentFragmentCompleteFcs;
28 }

Referenced by checkFcs().

◆ checkFcs()

bool inet::EthernetFragmentFcsChecker::checkFcs ( const Packet packet,
FcsMode  fcsMode,
uint32_t  fcs 
) const
overrideprotectedvirtual

Reimplemented from inet::FcsCheckerBase.

31 {
32  switch (fcsMode) {
34  return checkDeclaredCorrectFcs(packet, fcs);
36  return checkDeclaredIncorrectFcs(packet, fcs);
37  case FCS_COMPUTED:
38  return checkComputedFcs(packet, fcs);
39  default:
40  throw cRuntimeError("Unknown FCS mode");
41  }
42 }

Referenced by matchesPacket().

◆ dropPacket()

void inet::EthernetFragmentFcsChecker::dropPacket ( Packet packet)
overrideprotectedvirtual

◆ matchesPacket()

bool inet::EthernetFragmentFcsChecker::matchesPacket ( const Packet packet) const
overridevirtual

Returns true if the filter matches the given packet.

Implements inet::queueing::IPacketFilter.

55 {
56  const auto& trailer = packet->peekAtBack<EthernetFragmentFcs>(B(4));
57  auto fcsMode = trailer->getFcsMode();
58  auto fcs = trailer->getFcs();
59  return checkFcs(packet, fcsMode, fcs);
60 }

◆ processPacket()

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

Reimplemented from inet::queueing::PacketFilterBase.

45 {
46  const auto& trailer = packet->popAtBack<EthernetFragmentFcs>(B(4));
47  auto& fragmentTag = packet->getTagForUpdate<FragmentTag>();
48  fragmentTag->setLastFragment(!trailer->getMCrc());
49  auto packetProtocolTag = packet->getTagForUpdate<PacketProtocolTag>();
50  packetProtocolTag->setBackOffset(packetProtocolTag->getBackOffset() + trailer->getChunkLength());
52 }

Member Data Documentation

◆ currentFragmentCompleteFcs

uint32_t inet::EthernetFragmentFcsChecker::currentFragmentCompleteFcs = 0
mutableprotected

Referenced by checkComputedFcs(), and processPacket().

◆ lastFragmentCompleteFcs

uint32_t inet::EthernetFragmentFcsChecker::lastFragmentCompleteFcs = 0
protected

Referenced by checkComputedFcs(), and processPacket().


The documentation for this class was generated from the following files:
inet::FcsCheckerBase::checkDeclaredIncorrectFcs
virtual bool checkDeclaredIncorrectFcs(const Packet *packet, uint32_t fcs) const
Definition: FcsCheckerBase.cc:29
inet::queueing::PacketFilterBase::dropPacket
virtual void dropPacket(Packet *packet)
Definition: PacketFilterBase.cc:259
inet::INCORRECTLY_RECEIVED
@ INCORRECTLY_RECEIVED
Definition: Simsignals_m.h:71
inet::FCS_COMPUTED
@ FCS_COMPUTED
Definition: FcsMode_m.h:59
inet::FCS_DECLARED_CORRECT
@ FCS_DECLARED_CORRECT
Definition: FcsMode_m.h:57
PacketProtocolTag
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down PacketProtocolTag
Definition: IUdp-gates.txt:25
inet::EthernetFragmentFcsChecker::lastFragmentCompleteFcs
uint32_t lastFragmentCompleteFcs
Definition: EthernetFragmentFcsChecker.h:20
inet::units::units::B
intscale< b, 1, 8 > B
Definition: Units.h:1168
inet::EthernetFragmentFcsChecker::checkComputedFcs
virtual bool checkComputedFcs(const Packet *packet, uint32_t fcs) const override
Definition: EthernetFragmentFcsChecker.cc:19
inet::ethernetCRC
uint32_t ethernetCRC(const unsigned char *buf, unsigned int bufsize, uint32_t crc)
Definition: EthernetCRC.cc:58
inet::EthernetFragmentFcsChecker::currentFragmentCompleteFcs
uint32_t currentFragmentCompleteFcs
Definition: EthernetFragmentFcsChecker.h:21
inet::FCS_DECLARED_INCORRECT
@ FCS_DECLARED_INCORRECT
Definition: FcsMode_m.h:58
inet::EthernetFragmentFcsChecker::checkFcs
virtual bool checkFcs(const Packet *packet, FcsMode fcsMode, uint32_t fcs) const override
Definition: EthernetFragmentFcsChecker.cc:30
inet::FcsCheckerBase::checkDeclaredCorrectFcs
virtual bool checkDeclaredCorrectFcs(const Packet *packet, uint32_t fcs) const
Definition: FcsCheckerBase.cc:21