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

This class extends ProbabilisticBroadcast by adding an algorithm which adapts broadcasting parameters according to network conditions. More...

#include <AdaptiveProbabilisticBroadcast.h>

Inheritance diagram for inet::AdaptiveProbabilisticBroadcast:
inet::ProbabilisticBroadcast inet::NetworkProtocolBase inet::INetworkProtocol inet::LayeredProtocolBase inet::DefaultProtocolRegistrationListener inet::OperationalBase inet::IProtocolRegistrationListener inet::OperationalMixin< cSimpleModule > inet::ILifecycle

Public Member Functions

 AdaptiveProbabilisticBroadcast ()
 
virtual void initialize (int) override
 Initialization of the module and some variables. More...
 
- Public Member Functions inherited from inet::ProbabilisticBroadcast
 ProbabilisticBroadcast ()
 
virtual int numInitStages () const override
 Initialization of the module and some variables. More...
 
virtual void finish () override
 
const ProtocolgetProtocol () const override
 
- Public Member Functions inherited from inet::NetworkProtocolBase
virtual void handleRegisterService (const Protocol &protocol, cGate *gate, ServicePrimitive servicePrimitive) override
 
virtual void handleRegisterProtocol (const Protocol &protocol, cGate *gate, ServicePrimitive servicePrimitive) override
 
- Public Member Functions inherited from inet::OperationalMixin< cSimpleModule >
virtual ~OperationalMixin ()
 }@ More...
 
- Public Member Functions inherited from inet::ILifecycle
virtual ~ILifecycle ()
 
- Public Member Functions inherited from inet::DefaultProtocolRegistrationListener
virtual void handleRegisterServiceGroup (const ProtocolGroup &protocolGroup, cGate *gate, ServicePrimitive servicePrimitive) override
 
virtual void handleRegisterProtocolGroup (const ProtocolGroup &protocolGroup, cGate *gate, ServicePrimitive servicePrimitive) override
 
virtual void handleRegisterAnyService (cGate *gate, ServicePrimitive servicePrimitive) override
 
virtual void handleRegisterAnyProtocol (cGate *gate, ServicePrimitive servicePrimitive) override
 
- Public Member Functions inherited from inet::INetworkProtocol
virtual ~INetworkProtocol ()
 

Protected Types

typedef std::map< L3Address, cMessage * > NeighborMap
 
- Protected Types inherited from inet::ProbabilisticBroadcast
enum  messagesTypes { UNKNOWN = 0, BROADCAST_TIMER, NEIGHBOR_TIMER, BETA_TIMER }
 
typedef struct inet::ProbabilisticBroadcast::tMsgDesc tMsgDesc
 Store messages in a structure so that we can keep some information needed by the protocol. More...
 
typedef std::set< unsigned int > MsgIdSet
 
typedef std::multimap< simtime_t, tMsgDesc * > TimeMsgMap
 
- Protected Types inherited from inet::OperationalMixin< cSimpleModule >
enum  State
 

Protected Member Functions

virtual void handleLowerPacket (Packet *packet) override
 Handle messages from lower layer. More...
 
virtual void handleSelfMessage (cMessage *msg) override
 Handle self messages. More...
 
void updateNeighMap (const ProbabilisticBroadcastHeader *m)
 
void updateBeta ()
 
- Protected Member Functions inherited from inet::ProbabilisticBroadcast
virtual void handleUpperPacket (Packet *packet) override
 Handle messages from upper layer. More...
 
virtual bool messageKnown (unsigned int msgId)
 Checks whether a message is known (= kept in memory) or not. More...
 
virtual bool debugMessageKnown (unsigned int msgId)
 Checks whether a message is known (= kept in memory) or not. More...
 
virtual void insertMessage (simtime_t_cref bcastDelay, tMsgDesc *msgDesc)
 Insert a message in both known ID list and message queue. More...
 
virtual tMsgDescpopFirstMessageUpdateQueue (void)
 Returns the descriptor of the first message in the queue, then remove its pointer from the queue and its id from the known IDs list. More...
 
virtual void encapsulate (Packet *packet)
 Returns a network layer packet which encapsulates the upper layer packet passed to the function. More...
 
virtual void decapsulate (Packet *packet)
 extracts and returns the application layer packet which is encapsulated in the network layer packet given in argument, delete network layer packet. More...
 
virtual void insertNewMessage (Packet *packet, bool iAmInitialSender=false)
 Insert a new message in both known ID list and message queue. More...
 
virtual void setDownControlInfo (Packet *const pMsg, const MacAddress &pDestAddr)
 Attaches a "control info" (NetwToMac) structure (object) to the message pMsg. More...
 
virtual void handleStartOperation (LifecycleOperation *operation) override
 
virtual void handleStopOperation (LifecycleOperation *operation) override
 
virtual void handleCrashOperation (LifecycleOperation *operation) override
 
- Protected Member Functions inherited from inet::NetworkProtocolBase
 NetworkProtocolBase ()
 
virtual ~NetworkProtocolBase ()
 
virtual void sendUp (cMessage *message)
 
virtual void sendDown (cMessage *message, int interfaceId=-1)
 
virtual bool isUpperMessage (cMessage *message) const override
 
virtual bool isLowerMessage (cMessage *message) const override
 
virtual bool isInitializeStage (int stage) const override
 
virtual bool isModuleStartStage (int stage) const override
 
virtual bool isModuleStopStage (int stage) const override
 
virtual void handleUpperCommand (cMessage *msg) override
 
- Protected Member Functions inherited from inet::LayeredProtocolBase
virtual void handleMessageWhenUp (cMessage *message) override
 
virtual void handleUpperMessage (cMessage *message)
 
virtual void handleLowerMessage (cMessage *message)
 
virtual void handleLowerCommand (cMessage *message)
 
- Protected Member Functions inherited from inet::OperationalMixin< cSimpleModule >
virtual int numInitStages () const override
 
virtual void refreshDisplay () const override
 
virtual void handleMessage (cMessage *msg) override
 
virtual void handleMessageWhenDown (cMessage *msg)
 
virtual bool handleOperationStage (LifecycleOperation *operation, IDoneCallback *doneCallback) override
 Perform one stage of a lifecycle operation. More...
 
virtual State getInitialOperationalState () const
 Returns initial operational state: OPERATING or NOT_OPERATING. More...
 
virtual void handleActiveOperationTimeout (cMessage *message)
 
virtual bool isUp () const
 utility functions More...
 
virtual bool isDown () const
 
virtual void setOperationalState (State newState)
 
virtual void scheduleOperationTimeout (simtime_t timeout)
 
virtual void setupActiveOperation (LifecycleOperation *operation, IDoneCallback *doneCallback, State)
 
virtual void delayActiveOperationFinish (simtime_t timeout)
 
virtual void startActiveOperationExtraTime (simtime_t delay=SIMTIME_ZERO)
 
virtual void startActiveOperationExtraTimeOrFinish (simtime_t extraTime)
 
virtual void finishActiveOperation ()
 

Protected Attributes

simtime_t timeInNeighboursTable
 Default ttl for NeighborTable entries in seconds. More...
 
cOutVector bvec
 
NeighborMap neighMap
 
- Protected Attributes inherited from inet::ProbabilisticBroadcast
simtime_t broadcastPeriod
 Period (in sim time) between two broadcast attempts. More...
 
double beta = 0.0
 Probability of each broadcast attempt. More...
 
simtime_t timeToLive
 
int maxNbBcast = 0
 Maximal number of broadcast attempts for each packet. More...
 
simtime_t maxFirstBcastBackoff
 Maximal back-off before first broadcast attempt [seconds]. More...
 
simtime_t timeInQueueAfterDeath
 How long the message should be kept in queue after its died. More...
 
int headerLength = 0
 Length of the NetwPkt header Read from omnetpp.ini. More...
 
cMessage * broadcastTimer = nullptr
 
MsgIdSet knownMsgIds
 
TimeMsgMap msgQueue
 
MsgIdSet debugMsgIdSet
 
long nbDataPacketsReceived = 0
 
long nbDataPacketsSent = 0
 
long nbHops = 0
 
int debugNbMessageKnown = 0
 
long nbDataPacketsForwarded = 0
 
cOutVector oneHopLatencies
 
L3Address myNetwAddr
 
- Protected Attributes inherited from inet::NetworkProtocolBase
ModuleRefByPar< IInterfaceTableinterfaceTable
 
std::set< const Protocol * > upperProtocols
 
std::map< int, SocketDescriptor * > socketIdToSocketDescriptor
 
- Protected Attributes inherited from inet::OperationalMixin< cSimpleModule >
State operationalState
 
simtime_t lastChange
 
Operation activeOperation
 
cMessage * activeOperationTimeout
 
cMessage * activeOperationExtraTimer
 

Additional Inherited Members

- Static Protected Member Functions inherited from inet::ProbabilisticBroadcast
static long getNextID ()
 
- Static Protected Attributes inherited from inet::ProbabilisticBroadcast
static long id_counter = 0
 

Detailed Description

This class extends ProbabilisticBroadcast by adding an algorithm which adapts broadcasting parameters according to network conditions.

Author
Dimitris Kotsakos, George Alyfantis, Damien Piguet

Member Typedef Documentation

◆ NeighborMap

typedef std::map<L3Address, cMessage *> inet::AdaptiveProbabilisticBroadcast::NeighborMap
protected

Constructor & Destructor Documentation

◆ AdaptiveProbabilisticBroadcast()

inet::AdaptiveProbabilisticBroadcast::AdaptiveProbabilisticBroadcast ( )
inline
29 {}

Member Function Documentation

◆ handleLowerPacket()

void inet::AdaptiveProbabilisticBroadcast::handleLowerPacket ( Packet packet)
overrideprotectedvirtual

Handle messages from lower layer.

Reimplemented from inet::ProbabilisticBroadcast.

33 {
34  const auto& macHeader = packet->peekAtFront<ProbabilisticBroadcastHeader>();
35  // Update neighbors table before calling the method of the super class
36  // because it may delete the message.
37  updateNeighMap(macHeader.get());
39 }

◆ handleSelfMessage()

void inet::AdaptiveProbabilisticBroadcast::handleSelfMessage ( cMessage *  msg)
overrideprotectedvirtual

Handle self messages.

Reimplemented from inet::ProbabilisticBroadcast.

81 {
82  if (msg->getKind() == NEIGHBOR_TIMER) {
83  const NeighborMap::key_type& node = *static_cast<NeighborMap::key_type *>(msg->getContextPointer());
84  EV << "handleSelfMsg(): Remove node " << node << " from NeighMap!" << endl;
85  auto it = neighMap.find(node);
86  ASSERT(it != neighMap.end());
87  cancelAndDelete(it->second);
88  neighMap.erase(it);
89  updateBeta();
90  }
91  else {
93  }
94 }

◆ initialize()

void inet::AdaptiveProbabilisticBroadcast::initialize ( int  stage)
overridevirtual

Initialization of the module and some variables.

Reimplemented from inet::ProbabilisticBroadcast.

20 {
22 
23  if (stage == INITSTAGE_LOCAL) {
24  beta = 1.0;
25 
26  bvec.setName("Beta Vector");
27 
28  timeInNeighboursTable = par("timeInNeighboursTable");
29  }
30 }

◆ updateBeta()

void inet::AdaptiveProbabilisticBroadcast::updateBeta ( )
protected
97 {
98  int k = neighMap.size();
99 
100  // those values are derived from the simulations
101  // with the non-adaptive protocol.
102  if (k < 4)
103  beta = 1.0;
104  else if (k < 6)
105  beta = 0.9;
106  else if (k < 8)
107  beta = 0.8;
108  else if (k < 10)
109  beta = 0.7;
110  else if (k < 12)
111  beta = 0.6;
112  else if (k < 14)
113  beta = 0.5;
114  else if (k < 16)
115  beta = 0.4;
116  else if (k < 18)
117  beta = 0.3;
118  else if (k < 20)
119  beta = 0.2;
120  else
121  beta = 0.1;
122  bvec.record(beta);
123 }

Referenced by handleSelfMessage(), and updateNeighMap().

◆ updateNeighMap()

void inet::AdaptiveProbabilisticBroadcast::updateNeighMap ( const ProbabilisticBroadcastHeader m)
protected
42 {
43  // find the network address of the node who sent the msg
44  NeighborMap::key_type nodeAddress = m->getSrcAddr();
45 // EV << "updateNeighMap(): neighAddress: " << nodeAddress << endl;
46 
47  // search for it in the "already-neighbors" map
48  auto it = neighMap.find(nodeAddress);
49 
50  // if the node is a "new" neighbor
51  if (it == neighMap.end()) {
52  EV << "updateNeighMap(): The message came from a new neighbor! " << endl;
53 
54  // insert key value pair <node address, event> in neighborhood map.
55  cMessage *removeEvent = new cMessage("removeEvent", NEIGHBOR_TIMER);
56 
57  // schedule the event to remove the entry after initT seconds
58  scheduleAfter(timeInNeighboursTable, removeEvent);
59 
60  NeighborMap::value_type pairToInsert = make_pair(nodeAddress, removeEvent);
61  pair<NeighborMap::iterator, bool> ret = neighMap.insert(pairToInsert);
62 
63  // set the context pointer to point to the integer that resembles to the address of
64  // the node to be removed when the corresponding event occurs
65  (ret.first)->second->setContextPointer((void *)(&(ret.first)->first));
66  }
67  // if the node is NOT a "new" neighbor update its timer
68  else {
69  EV << "updateNeighMap(): The message came from an already known neighbor! " << endl;
70  // Cancel the event that was scheduled to remove the entry for this neighbor.
71  // Define a new event in order to remove the entry after initT seconds
72  // Set the context pointer to point to the integer that resembles to the address of
73  // the node to be removed when the corresponding event occurs
74  it->second->setContextPointer((void *)(&it->first));
75  rescheduleAfter(timeInNeighboursTable, it->second);
76  }
77  updateBeta();
78 }

Referenced by handleLowerPacket().

Member Data Documentation

◆ bvec

cOutVector inet::AdaptiveProbabilisticBroadcast::bvec
protected

Referenced by initialize(), and updateBeta().

◆ neighMap

NeighborMap inet::AdaptiveProbabilisticBroadcast::neighMap
protected

◆ timeInNeighboursTable

simtime_t inet::AdaptiveProbabilisticBroadcast::timeInNeighboursTable
protected

Default ttl for NeighborTable entries in seconds.

Referenced by initialize(), and updateNeighMap().


The documentation for this class was generated from the following files:
inet::ProbabilisticBroadcast::NEIGHBOR_TIMER
@ NEIGHBOR_TIMER
Definition: ProbabilisticBroadcast.h:57
inet::ProbabilisticBroadcast::initialize
virtual void initialize(int) override
Definition: ProbabilisticBroadcast.cc:29
inet::ProbabilisticBroadcast::handleSelfMessage
virtual void handleSelfMessage(cMessage *msg) override
Handle self messages.
Definition: ProbabilisticBroadcast.cc:120
inet::ProbabilisticBroadcast::beta
double beta
Probability of each broadcast attempt.
Definition: ProbabilisticBroadcast.h:157
inet::AdaptiveProbabilisticBroadcast::neighMap
NeighborMap neighMap
Definition: AdaptiveProbabilisticBroadcast.h:50
inet::ProbabilisticBroadcast::handleLowerPacket
virtual void handleLowerPacket(Packet *packet) override
Handle messages from lower layer.
Definition: ProbabilisticBroadcast.cc:71
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
inet::AdaptiveProbabilisticBroadcast::updateNeighMap
void updateNeighMap(const ProbabilisticBroadcastHeader *m)
Definition: AdaptiveProbabilisticBroadcast.cc:41
inet::physicallayer::k
const double k
Definition: Qam1024Modulation.cc:14
inet::AdaptiveProbabilisticBroadcast::timeInNeighboursTable
simtime_t timeInNeighboursTable
Default ttl for NeighborTable entries in seconds.
Definition: AdaptiveProbabilisticBroadcast.h:48
inet::AdaptiveProbabilisticBroadcast::updateBeta
void updateBeta()
Definition: AdaptiveProbabilisticBroadcast.cc:96
inet::units::values::m
value< double, units::m > m
Definition: Units.h:1233
inet::AdaptiveProbabilisticBroadcast::bvec
cOutVector bvec
Definition: AdaptiveProbabilisticBroadcast.h:49