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

#include <CloudDelayerBase.h>

Inheritance diagram for inet::CloudDelayerBase:
inet::INetfilter::IHook inet::MatrixCloudDelayer

Public Member Functions

 CloudDelayerBase ()
 
 ~CloudDelayerBase ()
 
- Public Member Functions inherited from inet::INetfilter::IHook
virtual ~IHook ()
 

Protected Member Functions

virtual void initialize (int stage) override
 
virtual int numInitStages () const override
 
virtual void finish () override
 
virtual void handleMessage (cMessage *msg) override
 
virtual void calculateDropAndDelay (const cMessage *msg, int srcID, int destID, bool &outDrop, simtime_t &outDelay)
 Returns true in outDrop if the msg is dropped in cloud, otherwise returns calculated delay in outDelay. More...
 
virtual INetfilter::IHook::Result datagramPreRoutingHook (INetworkDatagram *datagram, const InterfaceEntry *inputInterfaceEntry, const InterfaceEntry *&outputInterfaceEntry, L3Address &nextHopAddress) override
 This is the first hook called by the network protocol before it routes a datagram that was received from the lower layer. More...
 
virtual INetfilter::IHook::Result datagramForwardHook (INetworkDatagram *datagram, const InterfaceEntry *inputInterfaceEntry, const InterfaceEntry *&outputInterfaceEntry, L3Address &nextHopAddress) override
 This is the second hook called by the network protocol before it sends a datagram to the lower layer. More...
 
virtual INetfilter::IHook::Result datagramPostRoutingHook (INetworkDatagram *datagram, const InterfaceEntry *inputInterfaceEntry, const InterfaceEntry *&outputInterfaceEntry, L3Address &nextHopAddress) override
 This is the last hook called by the network protocol before it sends a datagram to the lower layer. More...
 
virtual INetfilter::IHook::Result datagramLocalInHook (INetworkDatagram *datagram, const InterfaceEntry *inputInterfaceEntry) override
 This is the last hook called by the network protocol before it sends a datagram to the upper layer. More...
 
virtual INetfilter::IHook::Result datagramLocalOutHook (INetworkDatagram *datagram, const InterfaceEntry *&outputInterfaceEntry, L3Address &nextHopAddress) override
 This is the first hook called by the network protocol before it routes a datagram that was received from the upper layer. More...
 

Protected Attributes

IPv4ipv4Layer
 

Additional Inherited Members

- Public Types inherited from inet::INetfilter::IHook
enum  Type {
  PREROUTING, LOCALIN, FORWARD, POSTROUTING,
  LOCALOUT
}
 
enum  Result { ACCEPT, DROP, QUEUE, STOLEN }
 

Constructor & Destructor Documentation

inet::CloudDelayerBase::CloudDelayerBase ( )
31 {
32  ipv4Layer = nullptr;
33 }
IPv4 * ipv4Layer
Definition: CloudDelayerBase.h:57
inet::CloudDelayerBase::~CloudDelayerBase ( )
36 {
37  //TODO unregister hook if ipv4Layer exists
38  ipv4Layer = check_and_cast_nullable<IPv4 *>(getModuleByPath("^.ip"));
39  if (ipv4Layer)
40  ipv4Layer->unregisterHook(0, this);
41 }
IPv4 * ipv4Layer
Definition: CloudDelayerBase.h:57
virtual void unregisterHook(int priority, IHook *hook) override
unregisters a Hook to be executed during datagram processing
Definition: IPv4.cc:918

Member Function Documentation

void inet::CloudDelayerBase::calculateDropAndDelay ( const cMessage *  msg,
int  srcID,
int  destID,
bool &  outDrop,
simtime_t &  outDelay 
)
protectedvirtual

Returns true in outDrop if the msg is dropped in cloud, otherwise returns calculated delay in outDelay.

Reimplemented in inet::MatrixCloudDelayer.

Referenced by datagramForwardHook().

70 {
71  outDrop = false;
72  outDelay = SIMTIME_ZERO;
73 }
INetfilter::IHook::Result inet::CloudDelayerBase::datagramForwardHook ( INetworkDatagram datagram,
const InterfaceEntry inputInterfaceEntry,
const InterfaceEntry *&  outputInterfaceEntry,
L3Address nextHopAddress 
)
overrideprotectedvirtual

This is the second hook called by the network protocol before it sends a datagram to the lower layer.

This is done after the datagramPreRoutingHook or the datagramLocalInHook is called and the datagram is routed.

Implements inet::INetfilter::IHook.

81 {
82  Enter_Method_Silent();
83 
84  int srcID = inputInterfaceEntry ? inputInterfaceEntry->getInterfaceId() : -1;
85  int destID = outputInterfaceEntry->getInterfaceId();
86 
87  cMessage *msg = check_and_cast<cMessage *>(datagram);
88  simtime_t propDelay;
89  bool isDrop;
90  calculateDropAndDelay(msg, srcID, destID, isDrop, propDelay);
91  if (isDrop) {
92  //TODO emit?
93  EV_INFO << "Message " << msg->str() << " dropped in cloud.\n";
95  }
96 
97  if (propDelay > SIMTIME_ZERO) {
98  //TODO emit?
99  EV_INFO << "Message " << msg->str() << " delayed with " << propDelay * 1000.0 << "ms in cloud.\n";
100  cMessage *selfmsg = new cMessage("Delay");
101  selfmsg->setContextPointer(datagram);
102  scheduleAt(simTime() + propDelay, selfmsg);
104  }
106 }
doesn&#39;t allow the datagram to pass to the next hook, will be deleted
Definition: INetfilter.h:51
allows the datagram to pass to the next hook
Definition: INetfilter.h:50
virtual void calculateDropAndDelay(const cMessage *msg, int srcID, int destID, bool &outDrop, simtime_t &outDelay)
Returns true in outDrop if the msg is dropped in cloud, otherwise returns calculated delay in outDela...
Definition: CloudDelayerBase.cc:69
queues the datagram for later re-injection (e.g. when route discovery completes)
Definition: INetfilter.h:52
INetfilter::IHook::Result inet::CloudDelayerBase::datagramLocalInHook ( INetworkDatagram datagram,
const InterfaceEntry inputInterfaceEntry 
)
overrideprotectedvirtual

This is the last hook called by the network protocol before it sends a datagram to the upper layer.

This is done after the datagramPreRoutingHook is called and the datagram is routed.

Implements inet::INetfilter::IHook.

114 {
116 }
allows the datagram to pass to the next hook
Definition: INetfilter.h:50
INetfilter::IHook::Result inet::CloudDelayerBase::datagramLocalOutHook ( INetworkDatagram datagram,
const InterfaceEntry *&  outputInterfaceEntry,
L3Address nextHopAddress 
)
overrideprotectedvirtual

This is the first hook called by the network protocol before it routes a datagram that was received from the upper layer.

The nextHopAddress is ignored when the outputInterfaceEntry is a nullptr. After this is done

Implements inet::INetfilter::IHook.

119 {
121 }
allows the datagram to pass to the next hook
Definition: INetfilter.h:50
INetfilter::IHook::Result inet::CloudDelayerBase::datagramPostRoutingHook ( INetworkDatagram datagram,
const InterfaceEntry inputInterfaceEntry,
const InterfaceEntry *&  outputInterfaceEntry,
L3Address nextHopAddress 
)
overrideprotectedvirtual

This is the last hook called by the network protocol before it sends a datagram to the lower layer.

Implements inet::INetfilter::IHook.

109 {
111 }
allows the datagram to pass to the next hook
Definition: INetfilter.h:50
INetfilter::IHook::Result inet::CloudDelayerBase::datagramPreRoutingHook ( INetworkDatagram datagram,
const InterfaceEntry inputInterfaceEntry,
const InterfaceEntry *&  outputInterfaceEntry,
L3Address nextHopAddress 
)
overrideprotectedvirtual

This is the first hook called by the network protocol before it routes a datagram that was received from the lower layer.

The nextHopAddress is ignored when the outputInterfaceEntry is nullptr.

Implements inet::INetfilter::IHook.

76 {
78 }
allows the datagram to pass to the next hook
Definition: INetfilter.h:50
void inet::CloudDelayerBase::finish ( )
overrideprotectedvirtual
54 {
55  if (ipv4Layer)
56  ipv4Layer->unregisterHook(0, this);
57  ipv4Layer = nullptr;
58 }
IPv4 * ipv4Layer
Definition: CloudDelayerBase.h:57
virtual void unregisterHook(int priority, IHook *hook) override
unregisters a Hook to be executed during datagram processing
Definition: IPv4.cc:918
void inet::CloudDelayerBase::handleMessage ( cMessage *  msg)
overrideprotectedvirtual
61 {
62  if (msg->isSelfMessage()) {
63  INetworkDatagram *context = (INetworkDatagram *)msg->getContextPointer();
64  delete msg;
66  }
67 }
IPv4 * ipv4Layer
Definition: CloudDelayerBase.h:57
void reinjectQueuedDatagram(const INetworkDatagram *datagram) override
re-injects a previously queued datagram
Definition: IPv4.cc:941
void inet::CloudDelayerBase::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented in inet::MatrixCloudDelayer.

Referenced by inet::MatrixCloudDelayer::initialize().

44 {
45  cSimpleModule::initialize(stage);
46 
47  if (stage == INITSTAGE_NETWORK_LAYER) {
48  ipv4Layer = check_and_cast<IPv4 *>(getModuleByPath("^.ip"));
49  ipv4Layer->registerHook(0, this);
50  }
51 }
IPv4 * ipv4Layer
Definition: CloudDelayerBase.h:57
virtual void registerHook(int priority, IHook *hook) override
registers a Hook to be executed during datagram processing
Definition: IPv4.cc:912
Initialization of network-layer protocols, stage 1.
Definition: InitStages.h:72
virtual int inet::CloudDelayerBase::numInitStages ( ) const
inlineoverrideprotectedvirtual

Reimplemented in inet::MatrixCloudDelayer.

40 { return NUM_INIT_STAGES; }
The number of initialization stages.
Definition: InitStages.h:116

Member Data Documentation

IPv4* inet::CloudDelayerBase::ipv4Layer
protected

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