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::OperationalBase 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
 
- Public Member Functions inherited from inet::OperationalBase
 OperationalBase ()
 
- Public Member Functions inherited from inet::ILifecycle
virtual ~ILifecycle ()
 
- 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 Member Functions

virtual void handleLowerPacket (cPacket *msg) override
 Handle messages from lower layer. More...
 
virtual void handleSelfMessage (cMessage *msg) override
 Handle self messages. More...
 
void updateNeighMap (ProbabilisticBroadcastDatagram *m)
 
void updateBeta ()
 
- Protected Member Functions inherited from inet::ProbabilisticBroadcast
virtual void handleUpperPacket (cPacket *msg) 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 cPacket * encapsMsg (cPacket *msg)
 Returns a network layer packet which encapsulates the upper layer packet passed to the function. More...
 
virtual cPacket * decapsMsg (ProbabilisticBroadcastDatagram *msg)
 extracts and returns the application layer packet which is encapsulated in the network layer packet given in argument. More...
 
virtual void insertNewMessage (ProbabilisticBroadcastDatagram *pkt, bool iAmInitialSender=false)
 Insert a new message in both known ID list and message queue. More...
 
virtual cObject * setDownControlInfo (cMessage *const pMsg, const MACAddress &pDestAddr)
 Attaches a "control info" (NetwToMac) structure (object) to the message pMsg. More...
 
- Protected Member Functions inherited from inet::NetworkProtocolBase
 NetworkProtocolBase ()
 
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 handleLowerCommand (cMessage *message)
 
- Protected Member Functions inherited from inet::OperationalBase
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

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
 Probability of each broadcast attempt. More...
 
simtime_t timeToLive
 
int maxNbBcast
 Maximal number of broadcast attempts for each packet. More...
 
int 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
 Length of the NetwPkt header Read from omnetpp.ini. More...
 
cMessage * broadcastTimer
 
MsgIdSet knownMsgIds
 
TimeMsgMap msgQueue
 
MsgIdSet debugMsgIdSet
 
long nbDataPacketsReceived
 
long nbDataPacketsSent
 
long nbHops
 
int debugNbMessageKnown
 
long nbDataPacketsForwarded
 
cOutVector oneHopLatencies
 
L3Address myNetwAddr
 
- Protected Attributes inherited from inet::NetworkProtocolBase
ProtocolMapping protocolMapping
 
IInterfaceTableinterfaceTable
 
- Protected Attributes inherited from inet::OperationalBase
bool isOperational
 
simtime_t lastChange
 

Additional Inherited Members

- 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")
 
- 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

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

Constructor & Destructor Documentation

inet::AdaptiveProbabilisticBroadcast::AdaptiveProbabilisticBroadcast ( )
inline
32  , bvec()
33  , neighMap()
34  {}
simtime_t timeInNeighboursTable
Default ttl for NeighborTable entries in seconds.
Definition: AdaptiveProbabilisticBroadcast.h:53
ProbabilisticBroadcast()
Definition: ProbabilisticBroadcast.h:40
NeighborMap neighMap
Definition: AdaptiveProbabilisticBroadcast.h:55
cOutVector bvec
Definition: AdaptiveProbabilisticBroadcast.h:54

Member Function Documentation

void inet::AdaptiveProbabilisticBroadcast::handleLowerPacket ( cPacket *  msg)
overrideprotectedvirtual

Handle messages from lower layer.

Reimplemented from inet::ProbabilisticBroadcast.

33 {
34  ProbabilisticBroadcastDatagram *m = check_and_cast<ProbabilisticBroadcastDatagram *>(msg);
35  // Update neighbors table before calling the method of the super class
36  // because it may delete the message.
37  updateNeighMap(m);
39 }
void updateNeighMap(ProbabilisticBroadcastDatagram *m)
Definition: AdaptiveProbabilisticBroadcast.cc:41
virtual void handleLowerPacket(cPacket *msg) override
Handle messages from lower layer.
Definition: ProbabilisticBroadcast.cc:61
value< double, units::m > m
Definition: Units.h:1047
void inet::AdaptiveProbabilisticBroadcast::handleSelfMessage ( cMessage *  msg)
overrideprotectedvirtual

Handle self messages.

Reimplemented from inet::ProbabilisticBroadcast.

83 {
84  if (msg->getKind() == NEIGHBOR_TIMER) {
85  const NeighborMap::key_type& node = *static_cast<NeighborMap::key_type *>(msg->getContextPointer());
86  EV << "handleSelfMsg(): Remove node " << node << " from NeighMap!" << endl;
87  auto it = neighMap.find(node);
88  cancelAndDelete(neighMap.find(it->first)->second);
89  neighMap.erase(it);
90  updateBeta();
91  }
92  else {
94  }
95 }
Definition: ProbabilisticBroadcast.h:72
virtual void handleSelfMessage(cMessage *msg) override
Handle self messages.
Definition: ProbabilisticBroadcast.cc:108
NeighborMap neighMap
Definition: AdaptiveProbabilisticBroadcast.h:55
void updateBeta()
Definition: AdaptiveProbabilisticBroadcast.cc:97
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 }
simtime_t timeInNeighboursTable
Default ttl for NeighborTable entries in seconds.
Definition: AdaptiveProbabilisticBroadcast.h:53
virtual void initialize(int) override
Definition: ProbabilisticBroadcast.cc:25
Local initializations.
Definition: InitStages.h:35
double beta
Probability of each broadcast attempt.
Definition: ProbabilisticBroadcast.h:168
cOutVector bvec
Definition: AdaptiveProbabilisticBroadcast.h:54
void inet::AdaptiveProbabilisticBroadcast::updateBeta ( )
protected

Referenced by handleSelfMessage(), and updateNeighMap().

98 {
99  int k = neighMap.size();
100 
101  // those values are derived from the simulations
102  // with the non-adaptive protocol.
103  if (k < 4)
104  beta = 1.0;
105  else if (k < 6)
106  beta = 0.9;
107  else if (k < 8)
108  beta = 0.8;
109  else if (k < 10)
110  beta = 0.7;
111  else if (k < 12)
112  beta = 0.6;
113  else if (k < 14)
114  beta = 0.5;
115  else if (k < 16)
116  beta = 0.4;
117  else if (k < 18)
118  beta = 0.3;
119  else if (k < 20)
120  beta = 0.2;
121  else
122  beta = 0.1;
123  bvec.record(beta);
124 }
double beta
Probability of each broadcast attempt.
Definition: ProbabilisticBroadcast.h:168
NeighborMap neighMap
Definition: AdaptiveProbabilisticBroadcast.h:55
const double k
Definition: QAM16Modulation.cc:24
cOutVector bvec
Definition: AdaptiveProbabilisticBroadcast.h:54
void inet::AdaptiveProbabilisticBroadcast::updateNeighMap ( ProbabilisticBroadcastDatagram m)
protected

Referenced by handleLowerPacket().

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  scheduleAt(simTime() + 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  cancelEvent(it->second);
72  // Define a new event in order to remove the entry after initT seconds
73  // Set the context pointer to point to the integer that resembles to the address of
74  // the node to be removed when the corresponding event occurs
75  it->second->setContextPointer((void *)(&it->first));
76 
77  scheduleAt(simTime() + timeInNeighboursTable, it->second);
78  }
79  updateBeta();
80 }
simtime_t timeInNeighboursTable
Default ttl for NeighborTable entries in seconds.
Definition: AdaptiveProbabilisticBroadcast.h:53
Definition: ProbabilisticBroadcast.h:72
NeighborMap neighMap
Definition: AdaptiveProbabilisticBroadcast.h:55
void updateBeta()
Definition: AdaptiveProbabilisticBroadcast.cc:97
value< double, units::m > m
Definition: Units.h:1047

Member Data Documentation

cOutVector inet::AdaptiveProbabilisticBroadcast::bvec
protected

Referenced by initialize(), and updateBeta().

NeighborMap inet::AdaptiveProbabilisticBroadcast::neighMap
protected
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: