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

#include <EthernetCutthroughSource.h>

Inheritance diagram for inet::EthernetCutthroughSource:
inet::PacketDestreamer inet::queueing::PacketProcessorBase inet::queueing::IPacketFlow 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 ~EthernetCutthroughSource ()
 
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...
 
- Public Member Functions inherited from inet::PacketDestreamer
virtual ~PacketDestreamer ()
 
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 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 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 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 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 handleMessage (cMessage *message) override
 
- Protected Member Functions inherited from inet::PacketDestreamer
virtual bool isStreaming () 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

cGate * cutthroughOutputGate = nullptr
 
ModuleRef< IPassivePacketSinkcutthroughConsumer
 
NetworkInterfacenetworkInterface = nullptr
 
ModuleRefByPar< IMacForwardingTablemacForwardingTable
 
bool cutthroughInProgress = false
 
cMessage * cutthroughTimer = nullptr
 
- Protected Attributes inherited from inet::PacketDestreamer
bps datarate
 
cGate * inputGate = nullptr
 
IActivePacketSourceproducer = nullptr
 
IPassivePacketSourceprovider = nullptr
 
cGate * outputGate = nullptr
 
IPassivePacketSinkconsumer = nullptr
 
IActivePacketSinkcollector = nullptr
 
bps streamDatarate = bps(NaN)
 
PacketstreamedPacket = 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

◆ ~EthernetCutthroughSource()

virtual inet::EthernetCutthroughSource::~EthernetCutthroughSource ( )
inlinevirtual
38 { cancelAndDelete(cutthroughTimer); }

Member Function Documentation

◆ handleMessage()

void inet::EthernetCutthroughSource::handleMessage ( cMessage *  message)
overrideprotectedvirtual

Reimplemented from inet::PacketDestreamer.

34 {
35  if (message == cutthroughTimer) {
36  const auto& header = streamedPacket->peekAtFront<EthernetMacAddressFields>();
37  auto sourceAddress = header->getSrc();
38  auto destinationAddress = header->getDest();
39  if (!sourceAddress.isMulticast())
40  macForwardingTable->learnUnicastAddressForwardingInterface(networkInterface->getInterfaceId(), sourceAddress);
41  int interfaceId = destinationAddress.isMulticast() ? -1 : macForwardingTable->getUnicastAddressForwardingInterface(destinationAddress);
42  if (interfaceId != -1 && cutthroughConsumer->canPushPacket(streamedPacket, cutthroughOutputGate)) {
44  streamedPacket->addTag<InterfaceReq>()->setInterfaceId(interfaceId);
45  streamedPacket->addTagIfAbsent<DirectionTag>()->setDirection(DIRECTION_OUTBOUND);
47  EV_INFO << "Starting streaming packet " << streamedPacket->getName() << "." << std::endl;
49  streamedPacket = nullptr;
50  cutthroughInProgress = true;
52  }
53  else
55  }
56  else
58 }

◆ initialize()

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

Reimplemented from inet::PacketDestreamer.

22 {
24  if (stage == INITSTAGE_LOCAL) {
25  cutthroughOutputGate = gate("cutthroughOut");
26  cutthroughConsumer.reference(cutthroughOutputGate, false);
28  macForwardingTable.reference(this, "macTableModule", true);
29  cutthroughTimer = new cMessage("CutthroughTimer");
30  }
31 }

◆ pushPacketEnd()

void inet::EthernetCutthroughSource::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::PacketDestreamer.

74 {
76  Enter_Method("pushPacketEnd");
77  take(packet);
78  const auto& header = packet->peekAtFront<EthernetMacAddressFields>();
79  auto sourceAddress = header->getSrc();
80  auto destinationAddress = header->getDest();
81  if (!sourceAddress.isMulticast())
82  macForwardingTable->learnUnicastAddressForwardingInterface(networkInterface->getInterfaceId(), sourceAddress);
83  packet->trim();
84  int interfaceId = destinationAddress.isMulticast() ? -1 : macForwardingTable->getUnicastAddressForwardingInterface(destinationAddress);
85  if (interfaceId != -1)
86  packet->addTag<InterfaceReq>()->setInterfaceId(interfaceId);
87  packet->addTagIfAbsent<DirectionTag>()->setDirection(DIRECTION_OUTBOUND);
88  packet->removeTagIfPresent<DispatchProtocolReq>();
89  delete streamedPacket;
90  streamedPacket = packet;
92  EV_INFO << "Ending streaming packet " << streamedPacket->getName() << "." << std::endl;
94  streamedPacket = nullptr;
95  cutthroughInProgress = false;
97  }
98  else
99  PacketDestreamer::pushPacketEnd(packet, gate);
100 }

◆ pushPacketStart()

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

Reimplemented from inet::PacketDestreamer.

61 {
62  Enter_Method("pushPacketStart");
63  take(packet);
64  b cutthroughPosition = PREAMBLE_BYTES + SFD_BYTES + ETHER_MAC_HEADER_BYTES;
65  simtime_t delay = s(cutthroughPosition / datarate).get();
66  scheduleAt(simTime() + delay, cutthroughTimer);
67  delete streamedPacket;
68  streamedPacket = packet;
71 }

Member Data Documentation

◆ cutthroughConsumer

ModuleRef<IPassivePacketSink> inet::EthernetCutthroughSource::cutthroughConsumer
protected

◆ cutthroughInProgress

bool inet::EthernetCutthroughSource::cutthroughInProgress = false
protected

Referenced by handleMessage(), and pushPacketEnd().

◆ cutthroughOutputGate

cGate* inet::EthernetCutthroughSource::cutthroughOutputGate = nullptr
protected

◆ cutthroughTimer

cMessage* inet::EthernetCutthroughSource::cutthroughTimer = nullptr
protected

◆ macForwardingTable

ModuleRefByPar<IMacForwardingTable> inet::EthernetCutthroughSource::macForwardingTable
protected

◆ networkInterface

NetworkInterface* inet::EthernetCutthroughSource::networkInterface = nullptr
protected

The documentation for this class was generated from the following files:
inet::Packet::addTagIfAbsent
const Ptr< T > addTagIfAbsent()
Returns a newly added packet tag for the provided type if absent, or returns the packet tag that is a...
Definition: Packet.h:1317
inet::DIRECTION_OUTBOUND
@ DIRECTION_OUTBOUND
Definition: DirectionTag_m.h:58
inet::Packet::addTag
const Ptr< T > addTag()
Returns a newly added packet tag for the provided type, or throws an exception if such a packet tag i...
Definition: Packet.h:1310
inet::EthernetCutthroughSource::cutthroughConsumer
ModuleRef< IPassivePacketSink > cutthroughConsumer
Definition: EthernetCutthroughSource.h:25
inet::PacketDestreamer::pushPacketStart
virtual void pushPacketStart(Packet *packet, cGate *gate, bps datarate) override
Starts pushing the packet into the packet sink at the given gate.
Definition: PacketDestreamer.cc:56
inet::Packet::peekAtFront
const Ptr< const Chunk > peekAtFront(b length=b(-1), int flags=0) const
Returns the designated part from the beginning of the data part of the packet as an immutable chunk i...
Definition: Packet.h:245
InterfaceReq
removed InterfaceReq
Definition: IUdp-gates.txt:11
DispatchProtocolReq
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down DispatchProtocolReq
Definition: IUdp-gates.txt:25
inet::PacketDestreamer::pushPacketEnd
virtual void pushPacketEnd(Packet *packet, cGate *gate) override
Ends pushing the packet into the packet sink at the given gate.
Definition: PacketDestreamer.cc:65
inet::EthernetCutthroughSource::cutthroughOutputGate
cGate * cutthroughOutputGate
Definition: EthernetCutthroughSource.h:24
inet::getContainingNicModule
NetworkInterface * getContainingNicModule(const cModule *from)
Find the nic module (inside the networkNode) containing the given module.
Definition: NetworkInterface.cc:691
inet::PacketDestreamer::initialize
virtual void initialize(int stage) override
Definition: PacketDestreamer.cc:22
inet::EthernetCutthroughSource::macForwardingTable
ModuleRefByPar< IMacForwardingTable > macForwardingTable
Definition: EthernetCutthroughSource.h:28
inet::PacketDestreamer::handleMessage
virtual void handleMessage(cMessage *message) override
Definition: PacketDestreamer.cc:40
inet::PacketDestreamer::streamDatarate
bps streamDatarate
Definition: PacketDestreamer.h:31
inet::EthernetCutthroughSource::cutthroughTimer
cMessage * cutthroughTimer
Definition: EthernetCutthroughSource.h:31
inet::PacketDestreamer::datarate
bps datarate
Definition: PacketDestreamer.h:21
inet::ETHER_MAC_HEADER_BYTES
const B ETHER_MAC_HEADER_BYTES
Definition: Ethernet.h:60
inet::units::values::s
value< double, units::s > s
Definition: Units.h:1235
inet::NetworkInterface::getInterfaceId
int getInterfaceId() const
Definition: NetworkInterface.h:232
inet::Packet::removeTagIfPresent
const Ptr< T > removeTagIfPresent()
Removes the packet tag for the provided type if present, or returns nullptr if no such packet tag is ...
Definition: Packet.h:1331
inet::PacketDestreamer::streamedPacket
Packet * streamedPacket
Definition: PacketDestreamer.h:32
inet::EthernetCutthroughSource::cutthroughInProgress
bool cutthroughInProgress
Definition: EthernetCutthroughSource.h:30
inet::PacketDestreamer::outputGate
cGate * outputGate
Definition: PacketDestreamer.h:27
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
inet::queueing::PacketProcessorBase::pushOrSendPacketEnd
virtual void pushOrSendPacketEnd(Packet *packet, cGate *gate, IPassivePacketSink *consumer, int transmissionId)
Definition: PacketProcessorBase.cc:154
inet::units::values::b
value< int64_t, units::b > b
Definition: Units.h:1241
inet::queueing::PacketProcessorBase::updateDisplayString
virtual void updateDisplayString() const
Definition: PacketProcessorBase.cc:399
inet::EthernetCutthroughSource::networkInterface
NetworkInterface * networkInterface
Definition: EthernetCutthroughSource.h:27
Enter_Method
#define Enter_Method(...)
Definition: SelfDoc.h:71
inet::queueing::PacketProcessorBase::pushOrSendPacketStart
virtual void pushOrSendPacketStart(Packet *packet, cGate *gate, IPassivePacketSink *consumer, bps datarate, int transmissionId)
Definition: PacketProcessorBase.cc:136
inet::SFD_BYTES
const B SFD_BYTES
Definition: Ethernet.h:42
inet::PREAMBLE_BYTES
const B PREAMBLE_BYTES
Definition: Ethernet.h:41
inet::Packet::trim
void trim()
Erases both the front and the back popped parts of the packet and sets both the front and the back of...
Definition: Packet.cc:281