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

#include <NetworkProtocolBase.h>

Inheritance diagram for inet::NetworkProtocolBase:
inet::LayeredProtocolBase inet::OperationalBase inet::ILifecycle inet::Flood inet::ProbabilisticBroadcast inet::WiseRoute inet::AdaptiveProbabilisticBroadcast

Protected Member Functions

 NetworkProtocolBase ()
 
virtual void initialize (int stage) override
 
virtual void handleUpperCommand (cMessage *message) override
 
virtual void sendUp (cMessage *message, int transportProtocol)
 
virtual void sendDown (cMessage *message, int interfaceId=-1)
 
virtual bool isUpperMessage (cMessage *message) override
 
virtual bool isLowerMessage (cMessage *message) override
 
virtual bool isInitializeStage (int stage) override
 
virtual bool isNodeStartStage (int stage) override
 
virtual bool isNodeShutdownStage (int stage) override
 
- Protected Member Functions inherited from inet::LayeredProtocolBase
virtual void handleMessageWhenUp (cMessage *message) override
 
virtual void handleSelfMessage (cMessage *message)
 
virtual void handleLowerCommand (cMessage *message)
 
virtual void handleUpperPacket (cPacket *packet)=0
 
virtual void handleLowerPacket (cPacket *packet)=0
 
- Protected Member Functions inherited from inet::OperationalBase
virtual int numInitStages () const override
 
virtual void handleMessage (cMessage *msg) override
 
virtual void handleMessageWhenDown (cMessage *msg)
 
virtual bool handleOperationStage (LifecycleOperation *operation, int stage, IDoneCallback *doneCallback) override
 Perform one stage of a lifecycle operation. More...
 
virtual bool handleNodeStart (IDoneCallback *doneCallback)
 
virtual bool handleNodeShutdown (IDoneCallback *doneCallback)
 
virtual void handleNodeCrash ()
 
virtual void setOperational (bool isOperational)
 

Protected Attributes

ProtocolMapping protocolMapping
 
IInterfaceTableinterfaceTable
 
- Protected Attributes inherited from inet::OperationalBase
bool isOperational
 
simtime_t lastChange
 

Additional Inherited Members

- Public Member Functions inherited from inet::OperationalBase
 OperationalBase ()
 
- Public Member Functions inherited from inet::ILifecycle
virtual ~ILifecycle ()
 
- Static Public Attributes inherited from inet::LayeredProtocolBase
static simsignal_t packetSentToUpperSignal = registerSignal("packetSentToUpper")
 
static simsignal_t packetReceivedFromUpperSignal = registerSignal("packetReceivedFromUpper")
 
static simsignal_t packetFromUpperDroppedSignal = registerSignal("packetFromUpperDropped")
 
static simsignal_t packetSentToLowerSignal = registerSignal("packetSentToLower")
 
static simsignal_t packetReceivedFromLowerSignal = registerSignal("packetReceivedFromLower")
 
static simsignal_t packetFromLowerDroppedSignal = registerSignal("packetFromLowerDropped")
 

Constructor & Destructor Documentation

inet::NetworkProtocolBase::NetworkProtocolBase ( )
protected
23  :
24  interfaceTable(nullptr)
25 {
26 }
IInterfaceTable * interfaceTable
Definition: NetworkProtocolBase.h:32

Member Function Documentation

void inet::NetworkProtocolBase::handleUpperCommand ( cMessage *  message)
overrideprotectedvirtual

Reimplemented from inet::LayeredProtocolBase.

36 {
37  if (dynamic_cast<RegisterTransportProtocolCommand *>(message)) {
38  RegisterTransportProtocolCommand *command = check_and_cast<RegisterTransportProtocolCommand *>(message);
39  protocolMapping.addProtocolMapping(command->getProtocol(), message->getArrivalGate()->getIndex());
40  delete message;
41  }
42  else
44 }
void addProtocolMapping(int protocol, int gateIndex)
Definition: ProtocolMap.cc:82
virtual void handleUpperCommand(cMessage *message)
Definition: LayeredProtocolBase.cc:58
ProtocolMapping protocolMapping
Definition: NetworkProtocolBase.h:31
void inet::NetworkProtocolBase::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::OperationalBase.

Reimplemented in inet::Flood, inet::WiseRoute, inet::ProbabilisticBroadcast, and inet::AdaptiveProbabilisticBroadcast.

Referenced by inet::ProbabilisticBroadcast::initialize(), inet::WiseRoute::initialize(), and inet::Flood::initialize().

29 {
31  if (stage == INITSTAGE_LOCAL)
32  interfaceTable = getModuleFromPar<IInterfaceTable>(par("interfaceTableModule"), this);
33 }
Local initializations.
Definition: InitStages.h:35
IInterfaceTable * interfaceTable
Definition: NetworkProtocolBase.h:32
virtual void initialize(int stage) override
Definition: OperationalBase.cc:32
virtual bool inet::NetworkProtocolBase::isInitializeStage ( int  stage)
inlineoverrideprotectedvirtual

Implements inet::OperationalBase.

47 { return stage == INITSTAGE_NETWORK_LAYER; }
Initialization of network-layer protocols, stage 1.
Definition: InitStages.h:72
bool inet::NetworkProtocolBase::isLowerMessage ( cMessage *  message)
overrideprotectedvirtual

Implements inet::LayeredProtocolBase.

80 {
81  return message->getArrivalGate()->isName("lowerLayerIn");
82 }
virtual bool inet::NetworkProtocolBase::isNodeShutdownStage ( int  stage)
inlineoverrideprotectedvirtual
virtual bool inet::NetworkProtocolBase::isNodeStartStage ( int  stage)
inlineoverrideprotectedvirtual

Implements inet::OperationalBase.

48 { return stage == NodeStartOperation::STAGE_NETWORK_LAYER; }
Definition: NodeOperations.h:50
bool inet::NetworkProtocolBase::isUpperMessage ( cMessage *  message)
overrideprotectedvirtual

Implements inet::LayeredProtocolBase.

75 {
76  return message->getArrivalGate()->isName("upperLayerIn");
77 }
void inet::NetworkProtocolBase::sendDown ( cMessage *  message,
int  interfaceId = -1 
)
protectedvirtual

Referenced by inet::Flood::handleLowerPacket(), inet::WiseRoute::handleLowerPacket(), inet::ProbabilisticBroadcast::handleSelfMessage(), inet::WiseRoute::handleSelfMessage(), inet::Flood::handleUpperPacket(), and inet::WiseRoute::handleUpperPacket().

54 {
55  if (message->isPacket())
56  emit(packetSentToLowerSignal, message);
57  if (interfaceId != -1) {
58  InterfaceEntry *interfaceEntry = interfaceTable->getInterfaceById(interfaceId);
59  send(message, "lowerLayerOut", interfaceEntry->getNetworkLayerGateIndex());
60  }
61  else {
62  for (int i = 0; i < interfaceTable->getNumInterfaces(); i++) {
63  InterfaceEntry *interfaceEntry = interfaceTable->getInterface(i);
64  if (interfaceEntry && !interfaceEntry->isLoopback()) {
65  cMessage *duplicate = message->dup();
66  duplicate->setControlInfo(message->getControlInfo()->dup());
67  send(duplicate, "lowerLayerOut", interfaceEntry->getNetworkLayerGateIndex());
68  }
69  }
70  delete message;
71  }
72 }
virtual InterfaceEntry * getInterfaceById(int id) const =0
Returns an interface by its Id.
static simsignal_t packetSentToLowerSignal
Definition: LayeredProtocolBase.h:32
IInterfaceTable * interfaceTable
Definition: NetworkProtocolBase.h:32
virtual int getNumInterfaces() const =0
Returns the number of interfaces.
virtual InterfaceEntry * getInterface(int pos) const =0
Returns the InterfaceEntry specified by an index 0..numInterfaces-1.
void inet::NetworkProtocolBase::sendUp ( cMessage *  message,
int  transportProtocol 
)
protectedvirtual

Referenced by inet::ProbabilisticBroadcast::handleLowerPacket(), inet::Flood::handleLowerPacket(), and inet::WiseRoute::handleLowerPacket().

47 {
48  if (message->isPacket())
49  emit(packetSentToUpperSignal, message);
50  send(message, "upperLayerOut", protocolMapping.getOutputGateForProtocol(transportProtocol));
51 }
int getOutputGateForProtocol(int protocol) const
find output gate index for protocol ID and returns it.
Definition: ProtocolMap.cc:74
static simsignal_t packetSentToUpperSignal
Definition: LayeredProtocolBase.h:28
ProtocolMapping protocolMapping
Definition: NetworkProtocolBase.h:31

Member Data Documentation

ProtocolMapping inet::NetworkProtocolBase::protocolMapping
protected

Referenced by handleUpperCommand(), and sendUp().


The documentation for this class was generated from the following files: