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

Loopback interface implementation. More...

#include <Loopback.h>

Inheritance diagram for inet::Loopback:
inet::MACBase inet::ILifecycle

Public Member Functions

 Loopback ()
 
virtual ~Loopback ()
 
- Public Member Functions inherited from inet::MACBase
 MACBase ()
 
virtual ~MACBase ()
 
- Public Member Functions inherited from inet::ILifecycle
virtual ~ILifecycle ()
 

Protected Member Functions

virtual InterfaceEntrycreateInterfaceEntry () override
 should create InterfaceEntry More...
 
virtual void flushQueue () override
 should clear queue and emit signal "dropPkFromHLIfaceDown" with entire packets More...
 
virtual void clearQueue () override
 should clear queue silently More...
 
virtual bool isUpperMsg (cMessage *msg) override
 should return true if the msg arrived from upper layer, else return false More...
 
virtual int numInitStages () const override
 
virtual void initialize (int stage) override
 
virtual void handleMessage (cMessage *msg) override
 
virtual void refreshDisplay () const override
 
- Protected Member Functions inherited from inet::MACBase
void registerInterface ()
 
virtual void receiveSignal (cComponent *source, simsignal_t signalID, cObject *obj, cObject *details) override
 
virtual bool handleOperationStage (LifecycleOperation *operation, int stage, IDoneCallback *doneCallback) override
 Perform one stage of a lifecycle operation. More...
 
virtual void updateOperationalFlag (bool isNodeUp)
 
virtual bool isNodeUp ()
 
virtual void handleMessageWhenDown (cMessage *msg)
 

Protected Attributes

long numSent = 0
 
long numRcvdOK = 0
 
- Protected Attributes inherited from inet::MACBase
cModule * hostModule = nullptr
 
bool isOperational = false
 
InterfaceEntryinterfaceEntry = nullptr
 

Static Protected Attributes

static simsignal_t packetSentToUpperSignal = registerSignal("packetSentToUpper")
 
static simsignal_t packetReceivedFromUpperSignal = registerSignal("packetReceivedFromUpper")
 

Detailed Description

Loopback interface implementation.

Constructor & Destructor Documentation

inet::Loopback::Loopback ( )
inline
53 {}
inet::Loopback::~Loopback ( )
virtual
38 {
39 }

Member Function Documentation

void inet::Loopback::clearQueue ( )
overrideprotectedvirtual

should clear queue silently

Implements inet::MACBase.

96 {
97  // do nothing, lo interface doesn't have any queue
98 }
InterfaceEntry * inet::Loopback::createInterfaceEntry ( )
overrideprotectedvirtual

should create InterfaceEntry

Implements inet::MACBase.

58 {
59  InterfaceEntry *ie = new InterfaceEntry(this);
60 
61 // // generate a link-layer address to be used as interface token for IPv6
62 // InterfaceToken token(0, getSimulation()->getUniqueNumber(), 64);
63 // ie->setInterfaceToken(token);
64 
65  // capabilities
66  ie->setMtu(par("mtu").longValue());
67  ie->setLoopback(true);
68 
69  return ie;
70 }
void inet::Loopback::flushQueue ( )
overrideprotectedvirtual

should clear queue and emit signal "dropPkFromHLIfaceDown" with entire packets

Implements inet::MACBase.

91 {
92  // do nothing, lo interface doesn't have any queue
93 }
void inet::Loopback::handleMessage ( cMessage *  msg)
overrideprotectedvirtual
73 {
74  if (!isOperational) {
76  return;
77  }
78 
80  EV << "Received " << msg << " for transmission\n";
81  ASSERT(PK(msg)->hasBitError() == false);
82 
83  // pass up payload
84  numRcvdOK++;
85  emit(packetSentToUpperSignal, msg);
86  numSent++;
87  send(msg, "netwOut");
88 }
static simsignal_t packetSentToUpperSignal
Definition: Loopback.h:43
bool isOperational
Definition: MACBase.h:37
virtual void handleMessageWhenDown(cMessage *msg)
Definition: MACBase.cc:108
#define PK(msg)
Definition: INETDefs.h:92
long numRcvdOK
Definition: Loopback.h:41
long numSent
Definition: Loopback.h:40
static simsignal_t packetReceivedFromUpperSignal
Definition: Loopback.h:44
void inet::Loopback::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::MACBase.

42 {
43  MACBase::initialize(stage);
44 
45  // all initialization is done in the first stage
46  if (stage == INITSTAGE_LOCAL) {
47  numSent = numRcvdOK = 0;
48  WATCH(numSent);
49  WATCH(numRcvdOK);
50  }
51  else if (stage == INITSTAGE_LINK_LAYER) {
52  // register our interface entry in IInterfaceTable
54  }
55 }
virtual void initialize(int stage) override
Definition: MACBase.cc:37
Local initializations.
Definition: InitStages.h:35
Initialization of link-layer protocols.
Definition: InitStages.h:59
long numRcvdOK
Definition: Loopback.h:41
long numSent
Definition: Loopback.h:40
void registerInterface()
Definition: MACBase.cc:98
bool inet::Loopback::isUpperMsg ( cMessage *  msg)
overrideprotectedvirtual

should return true if the msg arrived from upper layer, else return false

Implements inet::MACBase.

101 {
102  return true;
103 }
virtual int inet::Loopback::numInitStages ( ) const
inlineoverrideprotectedvirtual

Reimplemented from inet::MACBase.

57 { return NUM_INIT_STAGES; }
The number of initialization stages.
Definition: InitStages.h:116
void inet::Loopback::refreshDisplay ( ) const
overrideprotectedvirtual
106 {
107  /* TBD find solution for displaying IPv4 address without dependence on IPv4 or IPv6
108  IPv4Address addr = interfaceEntry->ipv4Data()->getIPAddress();
109  sprintf(buf, "%s / %s\nrcv:%ld snt:%ld", addr.isUnspecified()?"-":addr.str().c_str(), datarateText, numRcvdOK, numSent);
110  */
111  char buf[80];
112  sprintf(buf, "rcv:%ld snt:%ld", numRcvdOK, numSent);
113 
114  getDisplayString().setTagArg("t", 0, buf);
115 }
long numRcvdOK
Definition: Loopback.h:41
long numSent
Definition: Loopback.h:40

Member Data Documentation

long inet::Loopback::numRcvdOK = 0
protected
long inet::Loopback::numSent = 0
protected
simsignal_t inet::Loopback::packetReceivedFromUpperSignal = registerSignal("packetReceivedFromUpper")
staticprotected

Referenced by handleMessage().

simsignal_t inet::Loopback::packetSentToUpperSignal = registerSignal("packetSentToUpper")
staticprotected

Referenced by handleMessage().


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