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

PimSplitter register itself for PIM protocol (103) in the network layer, and dispatches the received packets either to PimDm or PimSm according to the PIM mode of the incoming interface. More...

#include <PimSplitter.h>

Inheritance diagram for inet::PimSplitter:

Protected Member Functions

virtual int numInitStages () const override
 
virtual void initialize (int stage) override
 
virtual void handleMessage (cMessage *msg) override
 
virtual void processPIMPacket (Packet *pkt)
 

Private Attributes

ModuleRefByPar< IInterfaceTableift
 
ModuleRefByPar< PimInterfaceTablepimIft
 
cGate * ipIn = nullptr
 
cGate * ipOut = nullptr
 
cGate * pimDMIn = nullptr
 
cGate * pimDMOut = nullptr
 
cGate * pimSMIn = nullptr
 
cGate * pimSMOut = nullptr
 

Detailed Description

PimSplitter register itself for PIM protocol (103) in the network layer, and dispatches the received packets either to PimDm or PimSm according to the PIM mode of the incoming interface.

Packets received from the PIM modules are simply forwarded to the network layer.

Member Function Documentation

◆ handleMessage()

void inet::PimSplitter::handleMessage ( cMessage *  msg)
overrideprotectedvirtual
41 {
42  cGate *arrivalGate = msg->getArrivalGate();
43 
44  if (arrivalGate == ipIn) {
45  Packet *packet = check_and_cast<Packet *>(msg);
46  auto protocol = packet->getTag<PacketProtocolTag>()->getProtocol();
47  if (protocol == &Protocol::icmpv4) {
48  EV_WARN << "Received ICMP error " << msg->getName() << ", ignored\n";
49  delete msg;
50  }
51  else if (protocol == &Protocol::pim) {
52  processPIMPacket(packet);
53  }
54  else
55  throw cRuntimeError("PimSplitter: received unknown packet '%s (%s)' from the network layer.", msg->getName(), msg->getClassName());
56  }
57  else if (arrivalGate == pimSMIn || arrivalGate == pimDMIn) {
58  // Send other packets to the network layer
59  EV_INFO << "Received packet from PIM module, sending it to the network." << endl;
60  check_and_cast<Packet *>(msg)->addTagIfAbsent<DispatchProtocolReq>()->setProtocol(&Protocol::ipv4);
61  send(msg, ipOut);
62  }
63  else
64  throw cRuntimeError("PimSplitter: received packet on the unknown gate: %s.", arrivalGate ? arrivalGate->getBaseName() : "nullptr");
65 }

◆ initialize()

void inet::PimSplitter::initialize ( int  stage)
overrideprotectedvirtual
24 {
25  cSimpleModule::initialize(stage);
26 
27  if (stage == INITSTAGE_LOCAL) {
28  ift.reference(this, "interfaceTableModule", true);
29  pimIft.reference(this, "pimInterfaceTableModule", true);
30 
31  ipIn = gate("ipIn");
32  ipOut = gate("ipOut");
33  pimDMIn = gate("pimDMIn");
34  pimDMOut = gate("pimDMOut");
35  pimSMIn = gate("pimSMIn");
36  pimSMOut = gate("pimSMOut");
37  }
38 }

◆ numInitStages()

virtual int inet::PimSplitter::numInitStages ( ) const
inlineoverrideprotectedvirtual
42 { return NUM_INIT_STAGES; }

◆ processPIMPacket()

void inet::PimSplitter::processPIMPacket ( Packet pkt)
protectedvirtual
68 {
69  const auto& pimPkt = pkt->peekAtFront<PimPacket>();
70  (void)pimPkt; // unused variable
71  NetworkInterface *ie = ift->getInterfaceById(pkt->getTag<InterfaceInd>()->getInterfaceId());
72  ASSERT(ie);
73 
74  EV_INFO << "Received packet on interface '" << ie->getInterfaceName() << "'" << endl;
75 
76  PimInterface *pimInt = pimIft->getInterfaceById(ie->getInterfaceId());
77  if (!pimInt) {
78  EV_WARN << "PIM is not enabled on interface '" << ie->getInterfaceName() << "', dropping packet." << endl;
79  delete pkt;
80  return;
81  }
82 
83  switch (pimInt->getMode()) {
85  EV_INFO << "Sending packet to PimDm.\n";
86  send(pkt, pimDMOut);
87  break;
88 
90  EV_INFO << "Sending packet to PimSm.\n";
91  send(pkt, pimSMOut);
92  break;
93 
94  default:
95  throw cRuntimeError("PimSplitter: PIM mode of interface '%s' is invalid.", ie->getInterfaceName());
96  }
97 }

Referenced by handleMessage().

Member Data Documentation

◆ ift

ModuleRefByPar<IInterfaceTable> inet::PimSplitter::ift
private

Referenced by initialize(), and processPIMPacket().

◆ ipIn

cGate* inet::PimSplitter::ipIn = nullptr
private

Referenced by handleMessage(), and initialize().

◆ ipOut

cGate* inet::PimSplitter::ipOut = nullptr
private

Referenced by handleMessage(), and initialize().

◆ pimDMIn

cGate* inet::PimSplitter::pimDMIn = nullptr
private

Referenced by handleMessage(), and initialize().

◆ pimDMOut

cGate* inet::PimSplitter::pimDMOut = nullptr
private

Referenced by initialize(), and processPIMPacket().

◆ pimIft

ModuleRefByPar<PimInterfaceTable> inet::PimSplitter::pimIft
private

Referenced by initialize(), and processPIMPacket().

◆ pimSMIn

cGate* inet::PimSplitter::pimSMIn = nullptr
private

Referenced by handleMessage(), and initialize().

◆ pimSMOut

cGate* inet::PimSplitter::pimSMOut = nullptr
private

Referenced by initialize(), and processPIMPacket().


The documentation for this class was generated from the following files:
protocol
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down protocol
Definition: IUdp-gates.txt:25
inet::Protocol::ipv4
static const Protocol ipv4
Definition: Protocol.h:93
inet::PimSplitter::ipIn
cGate * ipIn
Definition: PimSplitter.h:34
inet::PimInterface::DenseMode
@ DenseMode
Definition: PimInterfaceTable.h:25
inet::Protocol::icmpv4
static const Protocol icmpv4
Definition: Protocol.h:71
inet::PimSplitter::pimDMOut
cGate * pimDMOut
Definition: PimSplitter.h:37
DispatchProtocolReq
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down DispatchProtocolReq
Definition: IUdp-gates.txt:25
inet::PimSplitter::ift
ModuleRefByPar< IInterfaceTable > ift
Definition: PimSplitter.h:31
PacketProtocolTag
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down PacketProtocolTag
Definition: IUdp-gates.txt:25
inet::Protocol::pim
static const Protocol pim
Definition: Protocol.h:103
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
inet::PimSplitter::ipOut
cGate * ipOut
Definition: PimSplitter.h:35
NUM_INIT_STAGES
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
inet::PimSplitter::pimIft
ModuleRefByPar< PimInterfaceTable > pimIft
Definition: PimSplitter.h:32
inet::PimSplitter::pimSMIn
cGate * pimSMIn
Definition: PimSplitter.h:38
inet::PimInterface::SparseMode
@ SparseMode
Definition: PimInterfaceTable.h:26
inet::PimSplitter::processPIMPacket
virtual void processPIMPacket(Packet *pkt)
Definition: PimSplitter.cc:67
inet::PimSplitter::pimSMOut
cGate * pimSMOut
Definition: PimSplitter.h:39
inet::PimSplitter::pimDMIn
cGate * pimDMIn
Definition: PimSplitter.h:36