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

Wiseroute is a simple loop-free routing algorithm that builds a routing tree from a central network point. More...

#include <WiseRoute.h>

Inheritance diagram for inet::WiseRoute:
inet::NetworkProtocolBase inet::INetworkProtocol inet::LayeredProtocolBase inet::OperationalBase inet::ILifecycle

Classes

struct  tRouteTableEntry
 

Public Member Functions

 WiseRoute ()
 
virtual int numInitStages () const override
 Initialization of the module and some variables. More...
 
virtual void initialize (int) override
 
virtual void finish () override
 
virtual ~WiseRoute ()
 
- 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

enum  messagesTypes { DATA, ROUTE_FLOOD, SEND_ROUTE_FLOOD_TIMER }
 
enum  floodTypes { NOTAFLOOD, FORWARD, FORME, DUPLICATE }
 
typedef enum inet::WiseRoute::floodTypes floodTypes
 
typedef struct inet::WiseRoute::tRouteTableEntry tRouteTableEntry
 
typedef std::map< L3Address, tRouteTableEntrytRouteTable
 
typedef std::multimap< tRouteTable::key_type, unsigned long > tFloodTable
 

Protected Member Functions

Handle Messages

Functions to redefine by the programmer

These are the functions provided to add own functionality to your modules. These functions are called whenever a self message or a data message from the upper or lower layer arrives respectively.

virtual void handleUpperPacket (cPacket *msg) override
 Handle messages from upper layer. More...
 
virtual void handleLowerPacket (cPacket *msg) override
 Handle messages from lower layer. More...
 
virtual void handleSelfMessage (cMessage *msg) override
 Handle self messages. More...
 
virtual void updateRouteTable (const tRouteTable::key_type &origin, const L3Address &lastHop, double rssi, double ber)
 Update routing table. More...
 
cMessage * decapsMsg (WiseRouteDatagram *msg)
 Decapsulate a message. More...
 
floodTypes updateFloodTable (bool isFlood, const tFloodTable::key_type &srcAddr, const tFloodTable::key_type &destAddr, unsigned long seqNum)
 update flood table. More...
 
tFloodTable::key_type getRoute (const tFloodTable::key_type &destAddr, bool iAmOrigin=false) const
 find a route to destination address. 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

tRouteTable routeTable
 
tFloodTable floodTable
 
IARParp = nullptr
 
int headerLength = 0
 Length of the NetwPkt header Read from omnetpp.ini. More...
 
L3Address myNetwAddr
 
L3Address sinkAddress
 
double rssiThreshold = 0.0
 Minimal received RSSI necessary for adding source to routing table. More...
 
double routeFloodsInterval = 0.0
 Interval [seconds] between two route floods. More...
 
unsigned long floodSeqNumber = 0
 Flood sequence number. More...
 
cMessage * routeFloodTimer = nullptr
 
long nbDataPacketsForwarded = 0
 
long nbDataPacketsReceived = 0
 
long nbDataPacketsSent = 0
 
long nbDuplicatedFloodsReceived = 0
 
long nbFloodsSent = 0
 
long nbPureUnicastSent = 0
 
long nbRouteFloodsSent = 0
 
long nbRouteFloodsReceived = 0
 
long nbUnicastFloodForwarded = 0
 
long nbPureUnicastForwarded = 0
 
long nbGetRouteFailures = 0
 
long nbRoutesRecorded = 0
 
long nbHops = 0
 
cOutVector receivedRSSI
 
cOutVector routeRSSI
 
cOutVector allReceivedRSSI
 
cOutVector allReceivedBER
 
cOutVector routeBER
 
cOutVector receivedBER
 
cOutVector nextHopSelectionForSink
 
bool trace = false
 
- Protected Attributes inherited from inet::NetworkProtocolBase
ProtocolMapping protocolMapping
 
IInterfaceTableinterfaceTable
 
- Protected Attributes inherited from inet::OperationalBase
bool isOperational
 
simtime_t lastChange
 

Private Member Functions

 WiseRoute (const WiseRoute &)
 Copy constructor is not allowed. More...
 
WiseRouteoperator= (const WiseRoute &)
 Assignment operator is not allowed. More...
 

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

Detailed Description

Wiseroute is a simple loop-free routing algorithm that builds a routing tree from a central network point.

It is especially useful for wireless sensor networks and convergecast traffic, hence its name (Wireless Sensors Routing). The sink (the device at the center of the network) broadcasts a route building message. Each network node that receives it selects the sink as parent in the routing tree, and rebroadcasts the route building message. This procedure maximizes the probability that all network nodes can join the network, and avoids loops.

Author
Jerome Rousselot

Member Typedef Documentation

typedef std::multimap<tRouteTable::key_type, unsigned long> inet::WiseRoute::tFloodTable
protected

Member Enumeration Documentation

Enumerator
NOTAFLOOD 
FORWARD 
FORME 
DUPLICATE 
79  {
80  NOTAFLOOD,
81  FORWARD,
82  FORME,
83  DUPLICATE
84  } floodTypes;
floodTypes
Definition: WiseRoute.h:79
Definition: WiseRoute.h:82
Definition: WiseRoute.h:83
Definition: WiseRoute.h:81
Definition: WiseRoute.h:80
Enumerator
DATA 
ROUTE_FLOOD 
SEND_ROUTE_FLOOD_TIMER 
73  {
74  DATA,
77  };
Definition: WiseRoute.h:74
Definition: WiseRoute.h:75
Definition: WiseRoute.h:76

Constructor & Destructor Documentation

inet::WiseRoute::WiseRoute ( const WiseRoute )
private

Copy constructor is not allowed.

inet::WiseRoute::WiseRoute ( )
inline
62 {}
inet::WiseRoute::~WiseRoute ( )
virtual
95 {
96  cancelAndDelete(routeFloodTimer);
97 }
cMessage * routeFloodTimer
Definition: WiseRoute.h:120

Member Function Documentation

cMessage * inet::WiseRoute::decapsMsg ( WiseRouteDatagram msg)
protected

Decapsulate a message.

Referenced by handleLowerPacket().

328 {
329  cMessage *m = msg->decapsulate();
330  SimpleNetworkProtocolControlInfo *const controlInfo = new SimpleNetworkProtocolControlInfo();
331  controlInfo->setSourceAddress(msg->getInitialSrcAddr());
332  controlInfo->setTransportProtocol(msg->getTransportProtocol());
333  m->setControlInfo(controlInfo);
334  nbHops = nbHops + msg->getNbHops();
335  // delete the netw packet
336  delete msg;
337  return m;
338 }
long nbHops
Definition: WiseRoute.h:134
value< double, units::m > m
Definition: Units.h:1047
void inet::WiseRoute::finish ( )
overridevirtual
274 {
275  recordScalar("nbDataPacketsForwarded", nbDataPacketsForwarded);
276  recordScalar("nbDataPacketsReceived", nbDataPacketsReceived);
277  recordScalar("nbDataPacketsSent", nbDataPacketsSent);
278  recordScalar("nbDuplicatedFloodsReceived", nbDuplicatedFloodsReceived);
279  recordScalar("nbFloodsSent", nbFloodsSent);
280  recordScalar("nbPureUnicastSent", nbPureUnicastSent);
281  recordScalar("nbRouteFloodsSent", nbRouteFloodsSent);
282  recordScalar("nbRouteFloodsReceived", nbRouteFloodsReceived);
283  recordScalar("nbUnicastFloodForwarded", nbUnicastFloodForwarded);
284  recordScalar("nbPureUnicastForwarded", nbPureUnicastForwarded);
285  recordScalar("nbGetRouteFailures", nbGetRouteFailures);
286  recordScalar("nbRoutesRecorded", nbRoutesRecorded);
287  recordScalar("meanNbHops", (double)nbHops / (double)nbDataPacketsReceived);
288 }
long nbUnicastFloodForwarded
Definition: WiseRoute.h:130
long nbRouteFloodsSent
Definition: WiseRoute.h:128
long nbDataPacketsReceived
Definition: WiseRoute.h:123
long nbDataPacketsSent
Definition: WiseRoute.h:124
long nbFloodsSent
Definition: WiseRoute.h:126
long nbPureUnicastSent
Definition: WiseRoute.h:127
long nbHops
Definition: WiseRoute.h:134
long nbGetRouteFailures
Definition: WiseRoute.h:132
long nbPureUnicastForwarded
Definition: WiseRoute.h:131
long nbDataPacketsForwarded
Definition: WiseRoute.h:122
long nbRoutesRecorded
Definition: WiseRoute.h:133
long nbRouteFloodsReceived
Definition: WiseRoute.h:129
long nbDuplicatedFloodsReceived
Definition: WiseRoute.h:125
WiseRoute::tFloodTable::key_type inet::WiseRoute::getRoute ( const tFloodTable::key_type &  destAddr,
bool  iAmOrigin = false 
) const
protected

find a route to destination address.

Referenced by handleLowerPacket(), and handleUpperPacket().

362 {
363  // Find a route to dest address. As in the embedded code, if no route exists, indicate
364  // final destination as next hop. If we'are lucky, final destination is one hop away...
365  // If I am the origin of the packet and no route exists, use flood, hence return broadcast
366  // address for next hop.
367  tRouteTable::const_iterator pos = routeTable.find(destAddr);
368  if (pos != routeTable.end())
369  return pos->second.nextHop;
370  else
372 }
IL3AddressType * getAddressType() const
Definition: L3Address.cc:60
L3Address myNetwAddr
Definition: WiseRoute.h:106
virtual L3Address getBroadcastAddress() const =0
tRouteTable routeTable
Definition: WiseRoute.h:95
void inet::WiseRoute::handleLowerPacket ( cPacket *  msg)
overrideprotectedvirtual

Handle messages from lower layer.

Implements inet::LayeredProtocolBase.

128 {
129  WiseRouteDatagram *netwMsg = check_and_cast<WiseRouteDatagram *>(msg);
130  const L3Address& finalDestAddr = netwMsg->getFinalDestAddr();
131  const L3Address& initialSrcAddr = netwMsg->getInitialSrcAddr();
132  const L3Address& srcAddr = netwMsg->getSrcAddr();
133  check_and_cast<IMACProtocolControlInfo *>(netwMsg->getControlInfo());
134  // KLUDGE: TODO: get rssi and ber
135  EV_ERROR << "Getting RSSI and BER from the received frame is not yet implemented. Using default values.\n";
136  double rssi = 1; // TODO: ctrlInfo->getRSSI();
137  double ber = 0; // TODO: ctrlInfo->getBitErrorRate();
138  // Check whether the message is a flood and if it has to be forwarded.
139  floodTypes floodType = updateFloodTable(netwMsg->getIsFlood(), initialSrcAddr, finalDestAddr,
140  netwMsg->getSeqNum());
141  allReceivedRSSI.record(rssi);
142  allReceivedBER.record(ber);
143  if (floodType == DUPLICATE) {
145  delete netwMsg;
146  }
147  else {
148  const cObject *pCtrlInfo = nullptr;
149  // If the message is a route flood, update the routing table.
150  if (netwMsg->getKind() == ROUTE_FLOOD)
151  updateRouteTable(initialSrcAddr, srcAddr, rssi, ber);
152 
153  if (finalDestAddr == myNetwAddr || finalDestAddr.isBroadcast()) {
154  WiseRouteDatagram *msgCopy;
155  if (floodType == FORWARD) {
156  // it's a flood. copy for delivery, forward original.
157  // if we are here (see updateFloodTable()), finalDestAddr == IP Broadcast. Hence finalDestAddr,
158  // initialSrcAddr, and destAddr have already been correctly set
159  // at origin, as well as the MAC control info. Hence only update
160  // local hop source address.
161  msgCopy = check_and_cast<WiseRouteDatagram *>(netwMsg->dup());
162  netwMsg->setSrcAddr(myNetwAddr);
163  pCtrlInfo = netwMsg->removeControlInfo();
165  netwMsg->setNbHops(netwMsg->getNbHops() + 1);
166  sendDown(netwMsg);
168  }
169  else
170  msgCopy = netwMsg;
171  if (msgCopy->getKind() == DATA) {
172  int protocol = msgCopy->getTransportProtocol();
173  sendUp(decapsMsg(msgCopy), protocol);
175  }
176  else {
178  delete msgCopy;
179  }
180  }
181  else {
182  // not for me. if flood, forward as flood. else select a route
183  if (floodType == FORWARD) {
184  netwMsg->setSrcAddr(myNetwAddr);
185  pCtrlInfo = netwMsg->removeControlInfo();
187  netwMsg->setNbHops(netwMsg->getNbHops() + 1);
188  sendDown(netwMsg);
191  }
192  else {
193  L3Address nextHop = getRoute(finalDestAddr);
194  if (nextHop.isBroadcast()) {
195  // no route exist to destination, attempt to send to final destination
196  nextHop = finalDestAddr;
198  }
199  netwMsg->setSrcAddr(myNetwAddr);
200  netwMsg->setDestAddr(nextHop);
201  pCtrlInfo = netwMsg->removeControlInfo();
202  MACAddress nextHopMacAddr = arp->resolveL3Address(nextHop, nullptr); //FIXME interface entry pointer needed
203  if (nextHopMacAddr.isUnspecified())
204  throw cRuntimeError("Cannot immediately resolve MAC address. Please configure a GenericARP module.");
205  setDownControlInfo(netwMsg, nextHopMacAddr);
206  netwMsg->setNbHops(netwMsg->getNbHops() + 1);
207  sendDown(netwMsg);
210  }
211  }
212  if (pCtrlInfo != nullptr)
213  delete pCtrlInfo;
214  }
215 }
IARP * arp
Definition: WiseRoute.h:98
long nbUnicastFloodForwarded
Definition: WiseRoute.h:130
uint8_t protocol
Definition: TCP_NSC.cc:88
floodTypes
Definition: WiseRoute.h:79
virtual void updateRouteTable(const tRouteTable::key_type &origin, const L3Address &lastHop, double rssi, double ber)
Update routing table.
Definition: WiseRoute.cc:290
long nbDataPacketsReceived
Definition: WiseRoute.h:123
tFloodTable::key_type getRoute(const tFloodTable::key_type &destAddr, bool iAmOrigin=false) const
find a route to destination address.
Definition: WiseRoute.cc:361
cOutVector allReceivedRSSI
Definition: WiseRoute.h:138
virtual void sendUp(cMessage *message, int transportProtocol)
Definition: NetworkProtocolBase.cc:46
floodTypes updateFloodTable(bool isFlood, const tFloodTable::key_type &srcAddr, const tFloodTable::key_type &destAddr, unsigned long seqNum)
update flood table.
Definition: WiseRoute.cc:340
Definition: WiseRoute.h:83
Definition: WiseRoute.h:74
cMessage * decapsMsg(WiseRouteDatagram *msg)
Decapsulate a message.
Definition: WiseRoute.cc:327
virtual MACAddress resolveL3Address(const L3Address &address, const InterfaceEntry *ie)=0
Tries to resolve the given network address to a MAC address.
bool isBroadcast() const
Definition: L3Address.cc:211
cOutVector allReceivedBER
Definition: WiseRoute.h:139
long nbGetRouteFailures
Definition: WiseRoute.h:132
Definition: WiseRoute.h:75
L3Address myNetwAddr
Definition: WiseRoute.h:106
Definition: WiseRoute.h:81
long nbPureUnicastForwarded
Definition: WiseRoute.h:131
long nbDataPacketsForwarded
Definition: WiseRoute.h:122
long nbRouteFloodsReceived
Definition: WiseRoute.h:129
virtual cObject * setDownControlInfo(cMessage *const pMsg, const MACAddress &pDestAddr)
Attaches a "control info" (NetwToMac) structure (object) to the message pMsg.
Definition: WiseRoute.cc:377
long nbDuplicatedFloodsReceived
Definition: WiseRoute.h:125
virtual void sendDown(cMessage *message, int interfaceId=-1)
Definition: NetworkProtocolBase.cc:53
static const MACAddress BROADCAST_ADDRESS
The broadcast MAC address, ff:ff:ff:ff:ff:ff.
Definition: MACAddress.h:60
void inet::WiseRoute::handleSelfMessage ( cMessage *  msg)
overrideprotectedvirtual

Handle self messages.

Reimplemented from inet::LayeredProtocolBase.

100 {
101  if (msg->getKind() == SEND_ROUTE_FLOOD_TIMER) {
102  // Send route flood packet and restart the timer
103  WiseRouteDatagram *pkt = new WiseRouteDatagram("route-flood", ROUTE_FLOOD);
104  L3Address broadcastAddress = myNetwAddr.getAddressType()->getBroadcastAddress();
105  pkt->setByteLength(headerLength);
106  pkt->setInitialSrcAddr(myNetwAddr);
107  pkt->setFinalDestAddr(broadcastAddress);
108  pkt->setSrcAddr(myNetwAddr);
109  pkt->setDestAddr(broadcastAddress);
110  pkt->setNbHops(0);
111  floodTable.insert(make_pair(myNetwAddr, floodSeqNumber));
112  pkt->setSeqNum(floodSeqNumber);
113  floodSeqNumber++;
114  pkt->setIsFlood(1);
116  sendDown(pkt);
117  nbFloodsSent++;
119  scheduleAt(simTime() + routeFloodsInterval + uniform(0, 1), routeFloodTimer);
120  }
121  else {
122  EV << "WiseRoute - handleSelfMessage: got unexpected message of kind " << msg->getKind() << endl;
123  delete msg;
124  }
125 }
unsigned long floodSeqNumber
Flood sequence number.
Definition: WiseRoute.h:118
double routeFloodsInterval
Interval [seconds] between two route floods.
Definition: WiseRoute.h:115
long nbRouteFloodsSent
Definition: WiseRoute.h:128
cMessage * routeFloodTimer
Definition: WiseRoute.h:120
long nbFloodsSent
Definition: WiseRoute.h:126
IL3AddressType * getAddressType() const
Definition: L3Address.cc:60
tFloodTable floodTable
Definition: WiseRoute.h:96
int headerLength
Length of the NetwPkt header Read from omnetpp.ini.
Definition: WiseRoute.h:104
Definition: WiseRoute.h:75
L3Address myNetwAddr
Definition: WiseRoute.h:106
virtual L3Address getBroadcastAddress() const =0
virtual cObject * setDownControlInfo(cMessage *const pMsg, const MACAddress &pDestAddr)
Attaches a "control info" (NetwToMac) structure (object) to the message pMsg.
Definition: WiseRoute.cc:377
virtual void sendDown(cMessage *message, int interfaceId=-1)
Definition: NetworkProtocolBase.cc:53
Definition: WiseRoute.h:76
static const MACAddress BROADCAST_ADDRESS
The broadcast MAC address, ff:ff:ff:ff:ff:ff.
Definition: MACAddress.h:60
void inet::WiseRoute::handleUpperPacket ( cPacket *  msg)
overrideprotectedvirtual

Handle messages from upper layer.

Implements inet::LayeredProtocolBase.

218 {
219  L3Address finalDestAddr;
220  L3Address nextHopAddr;
221  MACAddress nextHopMacAddr;
222  WiseRouteDatagram *pkt = new WiseRouteDatagram(msg->getName(), DATA);
223  INetworkProtocolControlInfo *cInfo = check_and_cast<INetworkProtocolControlInfo *>(msg->removeControlInfo());
224 
225  pkt->setByteLength(headerLength);
226 
227  if (cInfo == nullptr) {
228  EV << "WiseRoute warning: Application layer did not specifiy a destination L3 address\n"
229  << "\tusing broadcast address instead\n";
230  finalDestAddr = myNetwAddr.getAddressType()->getBroadcastAddress();
231  }
232  else {
233  EV << "WiseRoute: CInfo removed, netw addr=" << cInfo->getDestinationAddress() << endl;
234  finalDestAddr = cInfo->getDestinationAddress();
235  }
236 
237  pkt->setFinalDestAddr(finalDestAddr);
238  pkt->setInitialSrcAddr(myNetwAddr);
239  pkt->setSrcAddr(myNetwAddr);
240  pkt->setNbHops(0);
241  pkt->setTransportProtocol(cInfo->getTransportProtocol());
242  delete cInfo;
243 
244  if (finalDestAddr.isBroadcast())
245  nextHopAddr = myNetwAddr.getAddressType()->getBroadcastAddress();
246  else
247  nextHopAddr = getRoute(finalDestAddr, true);
248  pkt->setDestAddr(nextHopAddr);
249  if (nextHopAddr.isBroadcast()) {
250  // it's a flood.
251  nextHopMacAddr = MACAddress::BROADCAST_ADDRESS;
252  pkt->setIsFlood(1);
253  nbFloodsSent++;
254  // record flood in flood table
255  floodTable.insert(make_pair(myNetwAddr, floodSeqNumber));
256  pkt->setSeqNum(floodSeqNumber);
257  floodSeqNumber++;
259  }
260  else {
261  pkt->setIsFlood(0);
263  nextHopMacAddr = arp->resolveL3Address(nextHopAddr, nullptr); //FIXME interface entry pointer needed
264  if (nextHopMacAddr.isUnspecified())
265  throw cRuntimeError("Cannot immediately resolve MAC address. Please configure a GenericARP module.");
266  }
267  setDownControlInfo(pkt, nextHopMacAddr);
268  pkt->encapsulate(static_cast<cPacket *>(msg));
269  sendDown(pkt);
271 }
IARP * arp
Definition: WiseRoute.h:98
unsigned long floodSeqNumber
Flood sequence number.
Definition: WiseRoute.h:118
tFloodTable::key_type getRoute(const tFloodTable::key_type &destAddr, bool iAmOrigin=false) const
find a route to destination address.
Definition: WiseRoute.cc:361
long nbDataPacketsSent
Definition: WiseRoute.h:124
long nbFloodsSent
Definition: WiseRoute.h:126
long nbPureUnicastSent
Definition: WiseRoute.h:127
Definition: WiseRoute.h:74
IL3AddressType * getAddressType() const
Definition: L3Address.cc:60
virtual MACAddress resolveL3Address(const L3Address &address, const InterfaceEntry *ie)=0
Tries to resolve the given network address to a MAC address.
tFloodTable floodTable
Definition: WiseRoute.h:96
int headerLength
Length of the NetwPkt header Read from omnetpp.ini.
Definition: WiseRoute.h:104
long nbGetRouteFailures
Definition: WiseRoute.h:132
L3Address myNetwAddr
Definition: WiseRoute.h:106
virtual L3Address getBroadcastAddress() const =0
virtual cObject * setDownControlInfo(cMessage *const pMsg, const MACAddress &pDestAddr)
Attaches a "control info" (NetwToMac) structure (object) to the message pMsg.
Definition: WiseRoute.cc:377
virtual void sendDown(cMessage *message, int interfaceId=-1)
Definition: NetworkProtocolBase.cc:53
static const MACAddress BROADCAST_ADDRESS
The broadcast MAC address, ff:ff:ff:ff:ff:ff.
Definition: MACAddress.h:60
void inet::WiseRoute::initialize ( int  stage)
overridevirtual

Reimplemented from inet::NetworkProtocolBase.

47 {
49  if (stage == INITSTAGE_LOCAL) {
50  arp = getModuleFromPar<IARP>(par("arpModule"), this);
51  headerLength = par("headerLength");
52  rssiThreshold = par("rssiThreshold").doubleValue();
54  routeFloodsInterval = par("routeFloodsInterval");
55 
56  floodSeqNumber = 0;
57 
62  nbFloodsSent = 0;
69  nbRoutesRecorded = 0;
70  nbHops = 0;
71  receivedRSSI.setName("receivedRSSI");
72  routeRSSI.setName("routeRSSI");
73  allReceivedRSSI.setName("allReceivedRSSI");
74  receivedBER.setName("receivedBER");
75  routeBER.setName("routeBER");
76  allReceivedBER.setName("allReceivedBER");
77  nextHopSelectionForSink.setName("nextHopSelectionForSink");
78 
79  routeFloodTimer = new cMessage("route-flood-timer", SEND_ROUTE_FLOOD_TIMER);
80  }
81  else if (stage == INITSTAGE_NETWORK_LAYER_3) {
82  L3AddressResolver addressResolver;
83  sinkAddress = addressResolver.resolve(par("sinkAddress"));
84 
85  IInterfaceTable *interfaceTable = getModuleFromPar<IInterfaceTable>(par("interfaceTableModule"), this);
86  myNetwAddr = interfaceTable->getInterface(1)->getNetworkAddress();
87 
88  // only schedule a flood of the node is a sink!!
89  if (routeFloodsInterval > 0 && myNetwAddr == sinkAddress)
90  scheduleAt(simTime() + uniform(0.5, 1.5), routeFloodTimer);
91  }
92 }
virtual void initialize(int stage) override
Definition: NetworkProtocolBase.cc:28
IARP * arp
Definition: WiseRoute.h:98
unsigned long floodSeqNumber
Flood sequence number.
Definition: WiseRoute.h:118
cOutVector receivedRSSI
Definition: WiseRoute.h:136
double dBm2mW(double dBm)
Converts a dBm value into milliwatts.
Definition: INETMath.h:176
long nbUnicastFloodForwarded
Definition: WiseRoute.h:130
cOutVector routeRSSI
Definition: WiseRoute.h:137
double routeFloodsInterval
Interval [seconds] between two route floods.
Definition: WiseRoute.h:115
cOutVector receivedBER
Definition: WiseRoute.h:141
long nbRouteFloodsSent
Definition: WiseRoute.h:128
cOutVector routeBER
Definition: WiseRoute.h:140
long nbDataPacketsReceived
Definition: WiseRoute.h:123
Initialization of network-layer protocols, stage 3.
Definition: InitStages.h:84
cOutVector nextHopSelectionForSink
Definition: WiseRoute.h:142
cOutVector allReceivedRSSI
Definition: WiseRoute.h:138
cMessage * routeFloodTimer
Definition: WiseRoute.h:120
long nbDataPacketsSent
Definition: WiseRoute.h:124
long nbFloodsSent
Definition: WiseRoute.h:126
long nbPureUnicastSent
Definition: WiseRoute.h:127
Local initializations.
Definition: InitStages.h:35
IInterfaceTable * interfaceTable
Definition: NetworkProtocolBase.h:32
int headerLength
Length of the NetwPkt header Read from omnetpp.ini.
Definition: WiseRoute.h:104
cOutVector allReceivedBER
Definition: WiseRoute.h:139
long nbHops
Definition: WiseRoute.h:134
long nbGetRouteFailures
Definition: WiseRoute.h:132
L3Address myNetwAddr
Definition: WiseRoute.h:106
L3Address sinkAddress
Definition: WiseRoute.h:107
long nbPureUnicastForwarded
Definition: WiseRoute.h:131
long nbDataPacketsForwarded
Definition: WiseRoute.h:122
long nbRoutesRecorded
Definition: WiseRoute.h:133
double rssiThreshold
Minimal received RSSI necessary for adding source to routing table.
Definition: WiseRoute.h:110
long nbRouteFloodsReceived
Definition: WiseRoute.h:129
long nbDuplicatedFloodsReceived
Definition: WiseRoute.h:125
Definition: WiseRoute.h:76
virtual int inet::WiseRoute::numInitStages ( ) const
inlineoverridevirtual

Initialization of the module and some variables.

Reimplemented from inet::OperationalBase.

64 { return NUM_INIT_STAGES; }
The number of initialization stages.
Definition: InitStages.h:116
WiseRoute& inet::WiseRoute::operator= ( const WiseRoute )
private

Assignment operator is not allowed.

cObject * inet::WiseRoute::setDownControlInfo ( cMessage *const  pMsg,
const MACAddress pDestAddr 
)
protectedvirtual

Attaches a "control info" (NetwToMac) structure (object) to the message pMsg.

Attaches a "control info" structure (object) to the down message pMsg.

This is most useful when passing packets between protocol layers of a protocol stack, the control info will contain the destination MAC address.

The "control info" object will be deleted when the message is deleted. Only one "control info" structure can be attached (the second setL3ToL2ControlInfo() call throws an error).

Parameters
pMsgThe message where the "control info" shall be attached.
pDestAddrThe MAC address of the message receiver.

Referenced by handleLowerPacket(), handleSelfMessage(), and handleUpperPacket().

378 {
379  SimpleLinkLayerControlInfo *const cCtrlInfo = new SimpleLinkLayerControlInfo();
380  cCtrlInfo->setDest(pDestAddr);
381  pMsg->setControlInfo(cCtrlInfo);
382  return cCtrlInfo;
383 }
WiseRoute::floodTypes inet::WiseRoute::updateFloodTable ( bool  isFlood,
const tFloodTable::key_type &  srcAddr,
const tFloodTable::key_type &  destAddr,
unsigned long  seqNum 
)
protected

update flood table.

returns detected flood type (general or unicast flood to forward, duplicate flood to delete, unicast flood to me

Referenced by handleLowerPacket().

341 {
342  if (isFlood) {
343  auto pos = floodTable.lower_bound(srcAddr);
344  auto posEnd = floodTable.upper_bound(srcAddr);
345 
346  while (pos != posEnd) {
347  if (seqNum == pos->second)
348  return DUPLICATE; // this flood is known, don't forward it.
349  ++pos;
350  }
351  floodTable.insert(make_pair(srcAddr, seqNum));
352  if (destAddr == myNetwAddr)
353  return FORME;
354  else
355  return FORWARD;
356  }
357  else
358  return NOTAFLOOD;
359 }
Definition: WiseRoute.h:82
Definition: WiseRoute.h:83
tFloodTable floodTable
Definition: WiseRoute.h:96
L3Address myNetwAddr
Definition: WiseRoute.h:106
Definition: WiseRoute.h:81
Definition: WiseRoute.h:80
void inet::WiseRoute::updateRouteTable ( const tRouteTable::key_type &  origin,
const L3Address lastHop,
double  rssi,
double  ber 
)
protectedvirtual

Update routing table.

The tuple provided in argument gives the next hop address to the origin. The table is updated only if the RSSI value is above the threshold.

Referenced by handleLowerPacket().

291 {
292  auto pos = routeTable.find(origin);
293  receivedRSSI.record(rssi);
294  receivedBER.record(ber);
295  if (pos == routeTable.end()) {
296  // A route towards origin does not exist yet. Insert the currently discovered one
297  // only if the received RSSI is above the threshold.
298  if (rssi > rssiThreshold) {
299  tRouteTableEntry newEntry;
300 
301  // last hop from origin means next hop towards origin.
302  newEntry.nextHop = lastHop;
303  newEntry.rssi = rssi;
304  routeRSSI.record(rssi);
305  routeBER.record(ber);
306  routeTable.insert(make_pair(origin, newEntry));
308  if (origin.isUnspecified()) {
309  // TODO: nextHopSelectionForSink.record(static_cast<double>(lastHop));
310  }
311  }
312  }
313  else {
314  // A route towards the node which originated the received packet already exists.
315  // Replace its entry only if the route proposal that we just received has a stronger
316  // RSSI.
317 // tRouteTableEntry entry = pos->second;
318 // if (entry.rssi > rssiThreshold) {
319 // entry.nextHop = lastHop;
320 // entry.rssi = rssi;
321 // if (origin == 0)
322 // nextHopSelectionForSink.record(lastHop);
323 // }
324  }
325 }
cOutVector receivedRSSI
Definition: WiseRoute.h:136
cOutVector routeRSSI
Definition: WiseRoute.h:137
cOutVector receivedBER
Definition: WiseRoute.h:141
cOutVector routeBER
Definition: WiseRoute.h:140
struct inet::WiseRoute::tRouteTableEntry tRouteTableEntry
long nbRoutesRecorded
Definition: WiseRoute.h:133
double rssiThreshold
Minimal received RSSI necessary for adding source to routing table.
Definition: WiseRoute.h:110
L3Address nextHop
Definition: WiseRoute.h:88
tRouteTable routeTable
Definition: WiseRoute.h:95

Member Data Documentation

cOutVector inet::WiseRoute::allReceivedBER
protected

Referenced by handleLowerPacket(), and initialize().

cOutVector inet::WiseRoute::allReceivedRSSI
protected

Referenced by handleLowerPacket(), and initialize().

IARP* inet::WiseRoute::arp = nullptr
protected
unsigned long inet::WiseRoute::floodSeqNumber = 0
protected

Flood sequence number.

Referenced by handleSelfMessage(), handleUpperPacket(), and initialize().

tFloodTable inet::WiseRoute::floodTable
protected
int inet::WiseRoute::headerLength = 0
protected

Length of the NetwPkt header Read from omnetpp.ini.

Referenced by handleSelfMessage(), handleUpperPacket(), and initialize().

long inet::WiseRoute::nbDataPacketsForwarded = 0
protected
long inet::WiseRoute::nbDataPacketsReceived = 0
protected
long inet::WiseRoute::nbDataPacketsSent = 0
protected
long inet::WiseRoute::nbDuplicatedFloodsReceived = 0
protected
long inet::WiseRoute::nbFloodsSent = 0
protected
long inet::WiseRoute::nbGetRouteFailures = 0
protected
long inet::WiseRoute::nbHops = 0
protected

Referenced by decapsMsg(), finish(), and initialize().

long inet::WiseRoute::nbPureUnicastForwarded = 0
protected
long inet::WiseRoute::nbPureUnicastSent = 0
protected
long inet::WiseRoute::nbRouteFloodsReceived = 0
protected
long inet::WiseRoute::nbRouteFloodsSent = 0
protected
long inet::WiseRoute::nbRoutesRecorded = 0
protected
long inet::WiseRoute::nbUnicastFloodForwarded = 0
protected
cOutVector inet::WiseRoute::nextHopSelectionForSink
protected

Referenced by initialize().

cOutVector inet::WiseRoute::receivedBER
protected

Referenced by initialize(), and updateRouteTable().

cOutVector inet::WiseRoute::receivedRSSI
protected

Referenced by initialize(), and updateRouteTable().

cOutVector inet::WiseRoute::routeBER
protected

Referenced by initialize(), and updateRouteTable().

double inet::WiseRoute::routeFloodsInterval = 0.0
protected

Interval [seconds] between two route floods.

A route flood is a simple flood from which other nodes can extract routing (next hop) information.

Referenced by handleSelfMessage(), and initialize().

cMessage* inet::WiseRoute::routeFloodTimer = nullptr
protected
cOutVector inet::WiseRoute::routeRSSI
protected

Referenced by initialize(), and updateRouteTable().

tRouteTable inet::WiseRoute::routeTable
protected

Referenced by getRoute(), and updateRouteTable().

double inet::WiseRoute::rssiThreshold = 0.0
protected

Minimal received RSSI necessary for adding source to routing table.

Referenced by initialize(), and updateRouteTable().

L3Address inet::WiseRoute::sinkAddress
protected

Referenced by initialize().

bool inet::WiseRoute::trace = false
protected

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