A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
dsr-rcache.cc
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 Yufei Cheng
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Yufei Cheng <yfcheng@ittc.ku.edu>
19  * Song Luan <lsuper@mail.ustc.edu.cn> (Implemented Link Cache using Dijsktra algorithm)
20  *
21  * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
22  * ResiliNets Research Group http://wiki.ittc.ku.edu/resilinets
23  * Information and Telecommunication Technology Center (ITTC)
24  * and Department of Electrical Engineering and Computer Science
25  * The University of Kansas Lawrence, KS USA.
26  *
27  * Work supported in part by NSF FIND (Future Internet Design) Program
28  * under grant CNS-0626918 (Postmodern Internet Architecture),
29  * NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI),
30  * US Department of Defense (DoD), and ITTC at The University of Kansas.
31  */
32 
33 #include "dsr-rcache.h"
34 #include <map>
35 #include <cmath>
36 #include <algorithm>
37 #include <iostream>
38 #include <list>
39 #include <vector>
40 #include <functional>
41 #include <iomanip>
42 
43 #include "ns3/simulator.h"
44 #include "ns3/ipv4-route.h"
45 #include "ns3/socket.h"
46 #include "ns3/log.h"
47 #include "ns3/address-utils.h"
48 #include "ns3/packet.h"
49 
50 NS_LOG_COMPONENT_DEFINE ("RouteCache");
51 
52 namespace ns3 {
53 namespace dsr {
54 
55 bool CompareRoutesBoth (const RouteCacheEntry &a, const RouteCacheEntry &b)
56 {
57  // compare based on both with hop count considered priority
58  return (a.GetVector ().size () < b.GetVector ().size ())
59  || ((a.GetVector ().size () == b.GetVector ().size ()) && (a.GetExpireTime () > b.GetExpireTime ()))
60  ;
61 }
62 
63 bool CompareRoutesHops (const RouteCacheEntry &a, const RouteCacheEntry &b)
64 {
65  // compare based on hops
66  return a.GetVector ().size () < b.GetVector ().size ();
67 }
68 
69 bool CompareRoutesExpire (const RouteCacheEntry &a, const RouteCacheEntry &b)
70 {
71  // compare based on expire time
72  return a.GetExpireTime () > b.GetExpireTime ();
73 }
74 
75 void Link::Print () const
76 {
77  NS_LOG_DEBUG (m_low << "----" << m_high);
78 }
79 
81  : m_nodeStability (nodeStab + Simulator::Now ())
82 {
83 }
84 
86 {
87 }
88 
90  : m_linkStability (linkStab + Simulator::Now ())
91 {
92 }
93 
95 {
96 }
97 
98 void LinkStab::Print ( ) const
99 {
100  NS_LOG_LOGIC ("LifeTime: " << GetLinkStability ().GetSeconds ());
101 }
102 
103 typedef std::list<RouteCacheEntry>::value_type route_pair;
104 
106  : m_ackTimer (Timer::CANCEL_ON_DESTROY),
107  m_dst (dst),
108  m_path (ip),
109  m_expire (exp + Simulator::Now ()),
110  m_reqCount (0),
111  m_blackListState (false),
112  m_blackListTimeout (Simulator::Now ())
113 {
114 }
115 
117 {
118 }
119 
120 void
121 RouteCacheEntry::Invalidate (Time badLinkLifetime)
122 {
123  m_reqCount = 0;
124  m_expire = badLinkLifetime + Simulator::Now ();
125 }
126 
127 void
128 RouteCacheEntry::Print (std::ostream & os) const
129 {
130  os << m_dst << "\t" << (m_expire - Simulator::Now ()).GetSeconds ()
131  << "\t";
132 }
133 
134 NS_OBJECT_ENSURE_REGISTERED (RouteCache);
135 
137 {
138  static TypeId tid = TypeId ("ns3::dsr::RouteCache")
139  .SetParent<Object> ()
140  .AddConstructor<RouteCache> ()
141  ;
142  return tid;
143 }
144 
146  : m_vector (0),
147  m_maxEntriesEachDst (3),
148  m_isLinkCache (false),
149  m_ntimer (Timer::CANCEL_ON_DESTROY),
150  m_delay (MilliSeconds (100))
151 {
152  /*
153  * The timer to set layer 2 notification, not fully supported by ns3 yet
154  */
158 }
159 
161 {
163  // clear the route cache when done
164  m_sortedRoutes.clear ();
165 }
166 
167 void
168 RouteCache::RemoveLastEntry (std::list<RouteCacheEntry> & rtVector)
169 {
170  NS_LOG_FUNCTION (this);
171  // Release the last entry of route list
172  rtVector.pop_back ();
173 }
174 
175 bool
177 {
178  NS_LOG_FUNCTION (this << dst);
179  std::map<Ipv4Address, std::list<RouteCacheEntry> >::const_iterator i =
180  m_sortedRoutes.find (dst);
181  if (i == m_sortedRoutes.end ())
182  {
183  NS_LOG_LOGIC ("Failed to find the route entry for the destination " << dst);
184  return false;
185  }
186  else
187  {
188  std::list<RouteCacheEntry> rtVector = i->second;
189  RouteCacheEntry successEntry = rtVector.front ();
190  successEntry.SetExpireTime (RouteCacheTimeout);
191  rtVector.pop_front ();
192  rtVector.push_back (successEntry);
193  rtVector.sort (CompareRoutesExpire); // sort the route vector first
194  m_sortedRoutes.erase (dst); // erase the entry first
195  /*
196  * Save the new route cache along with the destination address in map
197  */
198  std::pair<std::map<Ipv4Address, std::list<RouteCacheEntry> >::iterator, bool> result =
199  m_sortedRoutes.insert (std::make_pair (dst, rtVector));
200  return result.second;
201  }
202  return false;
203 }
204 
205 bool
207 {
208  NS_LOG_FUNCTION (this << id);
209  if (IsLinkCache ())
210  {
211  return LookupRoute_Link (id, rt);
212  }
213  else
214  {
215  Purge (); // Purge first to remove expired entries
216  if (m_sortedRoutes.empty ())
217  {
218  NS_LOG_LOGIC ("Route to " << id << " not found; m_sortedRoutes is empty");
219  return false;
220  }
221  std::map<Ipv4Address, std::list<RouteCacheEntry> >::const_iterator i = m_sortedRoutes.find (id);
222  if (i == m_sortedRoutes.end ())
223  {
224  NS_LOG_LOGIC ("No Direct Route to " << id << " found");
225  for (std::map<Ipv4Address, std::list<RouteCacheEntry> >::const_iterator j =
226  m_sortedRoutes.begin (); j != m_sortedRoutes.end (); ++j)
227  {
228  std::list<RouteCacheEntry> rtVector = j->second; // The route cache vector linked with destination address
229  /*
230  * Loop through the possibly multiple routes within the route vector
231  */
232  for (std::list<RouteCacheEntry>::const_iterator k = rtVector.begin (); k != rtVector.end (); ++k)
233  {
234  // return the first route in the route vector
235  RouteCacheEntry::IP_VECTOR routeVector = k->GetVector ();
236  RouteCacheEntry::IP_VECTOR changeVector;
237 
238  for (RouteCacheEntry::IP_VECTOR::iterator l = routeVector.begin (); l != routeVector.end (); ++l)
239  {
240  if (*l != id)
241  {
242  changeVector.push_back (*l);
243  }
244  else
245  {
246  changeVector.push_back (*l);
247  break;
248  }
249  }
250  /*
251  * When the changed vector is smaller in size and larger than 1, which means we have found a route with the destination
252  * address we are looking for
253  */
254  if ((changeVector.size () < routeVector.size ()) && (changeVector.size () > 1))
255  {
256  RouteCacheEntry changeEntry; // Create the route entry
257  changeEntry.SetVector (changeVector);
258  changeEntry.SetDestination (id);
259  // Use the expire time from original route entry
260  changeEntry.SetExpireTime (k->GetExpireTime ());
261  // We need to add new route entry here
262  std::list<RouteCacheEntry> newVector;
263  newVector.push_back (changeEntry);
264  newVector.sort (CompareRoutesExpire); // sort the route vector first
265  m_sortedRoutes[id] = newVector; // Only get the first sub route and add it in route cache
266  NS_LOG_INFO ("We have a sub-route to " << id << " add it in route cache");
267  }
268  }
269  }
270  }
271  NS_LOG_INFO ("Here we check the route cache again after updated the sub routes");
272  std::map<Ipv4Address, std::list<RouteCacheEntry> >::const_iterator m = m_sortedRoutes.find (id);
273  if (m == m_sortedRoutes.end ())
274  {
275  NS_LOG_LOGIC ("No updated route till last time");
276  return false;
277  }
278  /*
279  * We have a direct route to the destination address
280  */
281  std::list<RouteCacheEntry> rtVector = m->second;
282  rt = rtVector.front (); // use the first entry in the route vector
283  NS_LOG_LOGIC ("Route to " << id << " with route size " << rtVector.size ());
284  return true;
285  }
286 }
287 
288 void
289 RouteCache::SetCacheType (std::string type)
290 {
291  NS_LOG_FUNCTION (this << type);
292  if (type == std::string ("LinkCache"))
293  {
294  m_isLinkCache = true;
295  }
296  else if (type == std::string ("PathCache"))
297  {
298  m_isLinkCache = false;
299  }
300  else
301  {
302  m_isLinkCache = true; // use link cache as default
303  NS_LOG_INFO ("Error Cache Type");
304  }
305 }
306 
307 bool
308 RouteCache::IsLinkCache ()
309 {
310  NS_LOG_FUNCTION (this);
311  return m_isLinkCache;
312 }
313 
314 void
316 {
317  NS_LOG_FUNCTION (this << source);
321  // @d shortest-path estimate
322  std::map<Ipv4Address, uint32_t> d;
323  // @pre preceeding node
324  std::map<Ipv4Address, Ipv4Address> pre;
325  for (std::map<Ipv4Address, std::map<Ipv4Address, uint32_t> >::iterator i = m_netGraph.begin (); i != m_netGraph.end (); ++i)
326  {
327  if (i->second.find (source) != i->second.end ())
328  {
329  d[i->first] = i->second[source];
330  pre[i->first] = source;
331  }
332  else
333  {
334  d[i->first] = MAXWEIGHT;
335  pre[i->first] = Ipv4Address ("255.255.255.255");
336  }
337  }
338  d[source] = 0;
342  // the node set which shortest distance has been calculated, if true calculated
343  std::map<Ipv4Address, bool> s;
344  double temp = MAXWEIGHT;
345  Ipv4Address tempip = Ipv4Address ("255.255.255.255");
346  for (uint32_t i = 0; i < m_netGraph.size (); i++)
347  {
348  temp = MAXWEIGHT;
349  for (std::map<Ipv4Address,uint32_t>::const_iterator j = d.begin (); j != d.end (); ++j)
350  {
351  Ipv4Address ip = j->first;
352  if (s.find (ip) == s.end ())
353  {
354  /*
355  * \brief The followings are for comparison
356  */
357  if (j->second <= temp)
358  {
359  temp = j->second;
360  tempip = ip;
361  }
362  }
363  }
364  if (!tempip.IsBroadcast ())
365  {
366  s[tempip] = true;
367  for (std::map<Ipv4Address, uint32_t>::const_iterator k = m_netGraph[tempip].begin (); k != m_netGraph[tempip].end (); ++k)
368  {
369  if (s.find (k->first) == s.end () && d[k->first] > d[tempip] + k->second)
370  {
371  d[k->first] = d[tempip] + k->second;
372  pre[k->first] = tempip;
373  }
374  /*
375  * Selects the shortest-length route that has the longest expected lifetime
376  * (highest minimum timeout of any link in the route)
377  * For the computation overhead and complexity
378  * Here I just implement kind of greedy strategy to select link with the longest expected lifetime when there is two options
379  */
380  else if (d[k->first] == d[tempip] + k->second)
381  {
382  std::map<Link, LinkStab>::iterator oldlink = m_linkCache.find (Link (k->first, pre[k->first]));
383  std::map<Link, LinkStab>::iterator newlink = m_linkCache.find (Link (k->first, tempip));
384  if (oldlink != m_linkCache.end () && newlink != m_linkCache.end ())
385  {
386  if (oldlink->second.GetLinkStability () < newlink->second.GetLinkStability ())
387  {
388  NS_LOG_INFO ("Select the link with longest expected lifetime");
389  d[k->first] = d[tempip] + k->second;
390  pre[k->first] = tempip;
391  }
392  }
393  else
394  {
395  NS_LOG_INFO ("Link Stability Info Corrupt");
396  }
397  }
398  }
399  }
400  }
401  // clean the best route table
402  m_bestRoutesTable_link.clear ();
403  for (std::map<Ipv4Address, Ipv4Address>::iterator i = pre.begin (); i != pre.end (); ++i)
404  {
405  // loop for all vertexes
407  Ipv4Address iptemp = i->first;
408 
409  if (!i->second.IsBroadcast () && iptemp != source)
410  {
411  while (iptemp != source)
412  {
413  route.push_back (iptemp);
414  iptemp = pre[iptemp];
415  }
416  route.push_back (source);
417  // Reverse the route
418  RouteCacheEntry::IP_VECTOR reverseroute;
419  for (RouteCacheEntry::IP_VECTOR::reverse_iterator j = route.rbegin (); j != route.rend (); ++j)
420  {
421  reverseroute.push_back (*j);
422  }
423  NS_LOG_LOGIC ("Add newly calculated best routes");
424  PrintVector (reverseroute);
425  m_bestRoutesTable_link[i->first] = reverseroute;
426  }
427  }
428 }
429 
430 bool
432 {
433  NS_LOG_FUNCTION (this << id);
435  PurgeLinkNode ();
436  std::map<Ipv4Address, RouteCacheEntry::IP_VECTOR>::const_iterator i = m_bestRoutesTable_link.find (id);
437  if (i == m_bestRoutesTable_link.end ())
438  {
439  NS_LOG_INFO ("No route find to " << id);
440  return false;
441  }
442  else
443  {
444  if (i->second.size () < 2)
445  {
446  NS_LOG_LOGIC ("Route to " << id << " error");
447  return false;
448  }
449 
450  RouteCacheEntry newEntry; // Create the route entry
451  newEntry.SetVector (i->second);
452  newEntry.SetDestination (id);
453  newEntry.SetExpireTime (RouteCacheTimeout);
454  NS_LOG_INFO ("Route to " << id << " found with the length " << i->second.size ());
455  rt = newEntry;
456  std::vector<Ipv4Address> path = rt.GetVector ();
457  PrintVector (path);
458  return true;
459  }
460 }
461 
462 void
464 {
465  NS_LOG_FUNCTION (this);
466  for (std::map<Link, LinkStab>::iterator i = m_linkCache.begin (); i != m_linkCache.end (); )
467  {
468  NS_LOG_DEBUG ("The link stability " << i->second.GetLinkStability ().GetSeconds ());
469  std::map<Link, LinkStab>::iterator itmp = i;
470  if (i->second.GetLinkStability () <= Seconds (0))
471  {
472  ++i;
473  m_linkCache.erase (itmp);
474  }
475  else
476  {
477  ++i;
478  }
479  }
481  for (std::map<Ipv4Address, NodeStab>::iterator i = m_nodeCache.begin (); i != m_nodeCache.end (); )
482  {
483  NS_LOG_DEBUG ("The node stability " << i->second.GetNodeStability ().GetSeconds ());
484  std::map<Ipv4Address, NodeStab>::iterator itmp = i;
485  if (i->second.GetNodeStability () <= Seconds (0))
486  {
487  ++i;
488  m_nodeCache.erase (itmp);
489  }
490  else
491  {
492  ++i;
493  }
494  }
495 }
496 
497 void
499 {
500  NS_LOG_FUNCTION (this);
501  m_netGraph.clear ();
502  for (std::map<Link, LinkStab>::iterator i = m_linkCache.begin (); i != m_linkCache.end (); ++i)
503  {
504  // Here the weight is set as 1
505  // May need to set different weight for different link here later TODO
506  uint32_t weight = 1;
507  m_netGraph[i->first.m_low][i->first.m_high] = weight;
508  m_netGraph[i->first.m_high][i->first.m_low] = weight;
509  }
510 }
511 
512 bool
514 {
515  NS_LOG_FUNCTION (this << node);
516  std::map<Ipv4Address, NodeStab>::const_iterator i = m_nodeCache.find (node);
517  if (i == m_nodeCache.end ())
518  {
519  NS_LOG_INFO ("The initial stability " << m_initStability.GetSeconds ());
520  NodeStab ns (m_initStability);
521  m_nodeCache[node] = ns;
522  return false;
523  }
524  else
525  {
527  NS_LOG_INFO ("The node stability " << i->second.GetNodeStability ().GetSeconds ());
528  NS_LOG_INFO ("The stability here " << Time (i->second.GetNodeStability () * m_stabilityIncrFactor).GetSeconds ());
529  NodeStab ns (Time (i->second.GetNodeStability () * m_stabilityIncrFactor));
530  m_nodeCache[node] = ns;
531  return true;
532  }
533  return false;
534 }
535 
536 bool
538 {
539  NS_LOG_FUNCTION (this << node);
540  std::map<Ipv4Address, NodeStab>::const_iterator i = m_nodeCache.find (node);
541  if (i == m_nodeCache.end ())
542  {
543  NodeStab ns (m_initStability);
544  m_nodeCache[node] = ns;
545  return false;
546  }
547  else
548  {
549  // TODO remove it here
550  NS_LOG_INFO ("The stability here " << i->second.GetNodeStability ().GetSeconds ());
551  NS_LOG_INFO ("The stability here " << Time (i->second.GetNodeStability () / m_stabilityDecrFactor).GetSeconds ());
552  NodeStab ns (Time (i->second.GetNodeStability () / m_stabilityDecrFactor));
553  m_nodeCache[node] = ns;
554  return true;
555  }
556  return false;
557 }
558 
559 bool
561 {
562  NS_LOG_FUNCTION (this << source);
563  NS_LOG_LOGIC ("Use Link Cache");
565  PurgeLinkNode ();
566  for (uint32_t i = 0; i < nodelist.size () - 1; i++)
567  {
568  NodeStab ns;
569  ns.SetNodeStability (m_initStability);
570 
571  if (m_nodeCache.find (nodelist[i]) == m_nodeCache.end ())
572  {
573  m_nodeCache[nodelist[i]] = ns;
574  }
575  if (m_nodeCache.find (nodelist[i + 1]) == m_nodeCache.end ())
576  {
577  m_nodeCache[nodelist[i + 1]] = ns;
578  }
579  Link link (nodelist[i], nodelist[i + 1]);
580  LinkStab stab;
581  stab.SetLinkStability (m_initStability);
583  if (m_nodeCache[nodelist[i]].GetNodeStability () < m_nodeCache[nodelist[i + 1]].GetNodeStability ())
584  {
585  stab.SetLinkStability (m_nodeCache[nodelist[i]].GetNodeStability ());
586  }
587  else
588  {
589  stab.SetLinkStability (m_nodeCache[nodelist[i + 1]].GetNodeStability ());
590  }
591  if (stab.GetLinkStability () < m_minLifeTime)
592  {
593  NS_LOG_LOGIC ("Stability: " << stab.GetLinkStability ().GetSeconds ());
595  stab.SetLinkStability (m_minLifeTime);
596  }
597  m_linkCache[link] = stab;
598  NS_LOG_DEBUG ("Add a new link");
599  link.Print ();
600  NS_LOG_DEBUG ("Link Info");
601  stab.Print ();
602  }
603  UpdateNetGraph ();
604  RebuildBestRouteTable (source);
605  return true;
606 }
607 
608 void
610 {
611  NS_LOG_FUNCTION (this);
613  PurgeLinkNode ();
614  if (rt.size () < 2)
615  {
616  NS_LOG_INFO ("The route is too short");
617  return;
618  }
619  for (RouteCacheEntry::IP_VECTOR::iterator i = rt.begin (); i != rt.end () - 1; ++i)
620  {
621  Link link (*i, *(i + 1));
622  if (m_linkCache.find (link) != m_linkCache.end ())
623  {
624  if (m_linkCache[link].GetLinkStability () < m_useExtends)
625  {
626  m_linkCache[link].SetLinkStability (m_useExtends);
628  NS_LOG_INFO ("The time of the link " << m_linkCache[link].GetLinkStability ().GetSeconds ());
629  }
630  }
631  else
632  {
633  NS_LOG_INFO ("We cannot find a link in cache");
634  }
635  }
637  for (RouteCacheEntry::IP_VECTOR::iterator i = rt.begin (); i != rt.end (); ++i)
638  {
639  if (m_nodeCache.find (*i) != m_nodeCache.end ())
640  {
641  NS_LOG_LOGIC ("Increase the stability");
642  if (m_nodeCache[*i].GetNodeStability () <= m_initStability)
643  {
644  IncStability (*i);
645  }
646  else
647  {
648  NS_LOG_INFO ("The node stability has already been increased");
649  }
650  }
651  }
652 }
653 
654 bool
656 {
657  NS_LOG_FUNCTION (this);
658  Purge ();
659  std::list<RouteCacheEntry> rtVector; // Declare the route cache entry vector
660  Ipv4Address dst = rt.GetDestination ();
661  std::vector<Ipv4Address> route = rt.GetVector ();
662 
663  NS_LOG_DEBUG ("The route destination we have " << dst);
664  std::map<Ipv4Address, std::list<RouteCacheEntry> >::const_iterator i =
665  m_sortedRoutes.find (dst);
666 
667  if (i == m_sortedRoutes.end ())
668  {
669  rtVector.push_back (rt);
670  m_sortedRoutes.erase (dst); // Erase the route entries for dst first
674  std::pair<std::map<Ipv4Address, std::list<RouteCacheEntry> >::iterator, bool> result =
675  m_sortedRoutes.insert (std::make_pair (dst, rtVector));
676  return result.second;
677  }
678  else
679  {
680  rtVector = i->second;
681  NS_LOG_DEBUG ("The existing route size " << rtVector.size () << " for destination address " << dst);
685  if (rtVector.size () >= m_maxEntriesEachDst)
686  {
687  RemoveLastEntry (rtVector); // Drop the last entry for the sorted route cache, the route has already been sorted
688  }
689 
690  if (FindSameRoute (rt, rtVector))
691  {
692  NS_LOG_DEBUG ("Find same vector, the FindSameRoute function will update the route expire time");
693  return true;
694  }
695  else
696  {
697  // Check if the expire time for the new route has expired or not
698  if (rt.GetExpireTime () > 0)
699  {
700  rtVector.push_back (rt);
701  // This sort function will sort the route cache entries based on the size of route in each of the
702  // route entries
703  rtVector.sort (CompareRoutesExpire);
704  NS_LOG_DEBUG ("The first time" << rtVector.front ().GetExpireTime ().GetSeconds () << " The second time "
705  << rtVector.back ().GetExpireTime ().GetSeconds ());
706  NS_LOG_DEBUG ("The first hop" << rtVector.front ().GetVector ().size () << " The second hop "
707  << rtVector.back ().GetVector ().size ());
708  m_sortedRoutes.erase (dst); // erase the route entries for dst first
712  std::pair<std::map<Ipv4Address, std::list<RouteCacheEntry> >::iterator, bool> result =
713  m_sortedRoutes.insert (std::make_pair (dst, rtVector));
714  return result.second;
715  }
716  else
717  {
718  NS_LOG_INFO ("The newly found route is already expired");
719  }
720  }
721  }
722  return false;
723 }
724 
725 bool RouteCache::FindSameRoute (RouteCacheEntry & rt, std::list<RouteCacheEntry> & rtVector)
726 {
727  NS_LOG_FUNCTION (this);
728  for (std::list<RouteCacheEntry>::iterator i = rtVector.begin (); i != rtVector.end (); ++i)
729  {
730  // return the first route in the route vector
731  RouteCacheEntry::IP_VECTOR routeVector = i->GetVector ();
732  RouteCacheEntry::IP_VECTOR newVector = rt.GetVector ();
733 
734  if (routeVector == newVector)
735  {
736  NS_LOG_DEBUG ("Found same routes in the route cache with the vector size "
737  << rt.GetDestination () << " " << rtVector.size ());
738  NS_LOG_DEBUG ("The new route expire time " << rt.GetExpireTime ().GetSeconds ()
739  << " the original expire time " << i->GetExpireTime ().GetSeconds ());
740  if (rt.GetExpireTime () > i->GetExpireTime ())
741  {
742  i->SetExpireTime (rt.GetExpireTime ());
743  }
744  m_sortedRoutes.erase (rt.GetDestination ()); // erase the entry first
745  rtVector.sort (CompareRoutesExpire); // sort the route vector first
746  /*
747  * Save the new route cache along with the destination address in map
748  */
749  std::pair<std::map<Ipv4Address, std::list<RouteCacheEntry> >::iterator, bool> result =
750  m_sortedRoutes.insert (std::make_pair (rt.GetDestination (), rtVector));
751  return result.second;
752  }
753  }
754  return false;
755 }
756 
757 bool
759 {
760  NS_LOG_FUNCTION (this << dst);
761  Purge (); // purge the route cache first to remove timeout entries
762  if (m_sortedRoutes.erase (dst) != 0)
763  {
764  NS_LOG_LOGIC ("Route deletion to " << dst << " successful");
765  return true;
766  }
767  NS_LOG_LOGIC ("Route deletion to " << dst << " not successful");
768  return false;
769 }
770 
771 void
773 {
774  NS_LOG_FUNCTION (this << errorSrc << unreachNode << node);
775  if (IsLinkCache ())
776  {
777  // Purge the link node cache first
778  PurgeLinkNode ();
779  /*
780  * The followings are for cleaning the broken link in link cache
781  * We basically remove the link between errorSrc and unreachNode
782  */
783  Link link1 (errorSrc, unreachNode);
784  Link link2 (unreachNode, errorSrc);
785  // erase the two kind of links to make sure the link is removed from the link cache
786  NS_LOG_DEBUG ("Erase the route");
787  m_linkCache.erase (link1);
789  NS_LOG_DEBUG ("The link cache size " << m_linkCache.size());
790  m_linkCache.erase (link2);
791  NS_LOG_DEBUG ("The link cache size " << m_linkCache.size());
792 
793  std::map<Ipv4Address, NodeStab>::iterator i = m_nodeCache.find (errorSrc);
794  if (i == m_nodeCache.end ())
795  {
796  NS_LOG_LOGIC ("Update the node stability unsuccessfully");
797  }
798  else
799  {
800  DecStability (i->first);
801  }
802  i = m_nodeCache.find (unreachNode);
803  if (i == m_nodeCache.end ())
804  {
805  NS_LOG_LOGIC ("Update the node stability unsuccessfully");
806  }
807  else
808  {
809  DecStability (i->first);
810  }
811  UpdateNetGraph ();
812  RebuildBestRouteTable (node);
813  }
814  else
815  {
816  /*
817  * the followings are for cleaning the broken link in pathcache
818  *
819  */
820  Purge ();
821  if (m_sortedRoutes.empty ())
822  {
823  return;
824  }
825  /*
826  * Loop all the routes saved in the route cache
827  */
828  for (std::map<Ipv4Address, std::list<RouteCacheEntry> >::iterator j =
829  m_sortedRoutes.begin (); j != m_sortedRoutes.end (); )
830  {
831  std::map<Ipv4Address, std::list<RouteCacheEntry> >::iterator jtmp = j;
832  Ipv4Address address = j->first;
833  std::list<RouteCacheEntry> rtVector = j->second;
834  /*
835  * Loop all the routes for a single destination
836  */
837  for (std::list<RouteCacheEntry>::iterator k = rtVector.begin (); k != rtVector.end (); )
838  {
839  // return the first route in the route vector
840  RouteCacheEntry::IP_VECTOR routeVector = k->GetVector ();
841  RouteCacheEntry::IP_VECTOR changeVector;
842  /*
843  * Loop the ip addresses within a single route entry
844  */
845  for (RouteCacheEntry::IP_VECTOR::iterator i = routeVector.begin (); i != routeVector.end (); ++i)
846  {
847  if (*i != errorSrc)
848  {
849  changeVector.push_back (*i);
850  }
851  else
852  {
853  if (*(i + 1) == unreachNode)
854  {
855  changeVector.push_back (*i);
856  break;
857  }
858  else
859  {
860  changeVector.push_back (*i);
861  }
862  }
863  }
864  /*
865  * Verify if need to remove some affected links
866  */
867  if (changeVector.size () == routeVector.size ())
868  {
869  NS_LOG_DEBUG ("The route does not contain the broken link");
870  ++k;
871  }
872  else if ((changeVector.size () < routeVector.size ()) && (changeVector.size () > 1))
873  {
874  NS_LOG_DEBUG ("sub route " << m_subRoute);
875  if (m_subRoute)
876  {
877  Time expire = k->GetExpireTime ();
878  /*
879  * Remove the route first
880  */
881  k = rtVector.erase (k);
882  RouteCacheEntry changeEntry;
883  changeEntry.SetVector (changeVector);
884  Ipv4Address destination = changeVector.back ();
885  NS_LOG_DEBUG ("The destination of the newly formed route " << destination << " and the size of the route " << changeVector.size ());
886  changeEntry.SetDestination (destination);
887  changeEntry.SetExpireTime (expire); // Initialize the timeout value to the one it has
888  rtVector.push_back (changeEntry); // Add the route entry to the route list
889  NS_LOG_DEBUG ("We have a sub-route to " << destination);
890  }
891  else
892  {
893  /*
894  * Remove the route
895  */
896  k = rtVector.erase (k);
897  }
898  }
899  else
900  {
901  NS_LOG_LOGIC ("Cut route unsuccessful and erase the route");
902  /*
903  * Remove the route
904  */
905  k = rtVector.erase (k);
906  }
907  }
908  ++j;
909  if (!IsLinkCache ())
910  {
911  m_sortedRoutes.erase (jtmp);
912  }
913  if (rtVector.size ())
914  {
915  /*
916  * Save the new route cache along with the destination address in map
917  */
918  rtVector.sort (CompareRoutesExpire);
919  m_sortedRoutes[address] = rtVector;
920  }
921  else
922  {
923  NS_LOG_DEBUG ("There is no route left for that destination " << address);
924  }
925  }
926  }
927 }
928 
929 void
930 RouteCache::PrintVector (std::vector<Ipv4Address>& vec)
931 {
932  NS_LOG_FUNCTION (this);
933  /*
934  * Check elements in a route vector, used when one wants to check the IP addresses saved in
935  */
936  if (!vec.size ())
937  {
938  NS_LOG_DEBUG ("The vector is empty");
939  }
940  else
941  {
942  NS_LOG_DEBUG ("Print all the elements in a vector");
943  for (std::vector<Ipv4Address>::const_iterator i = vec.begin (); i != vec.end (); ++i)
944  {
945  NS_LOG_DEBUG ("The ip address " << *i);
946  }
947  }
948 }
949 
950 void
951 RouteCache::PrintRouteVector (std::list<RouteCacheEntry> route)
952 {
953  NS_LOG_FUNCTION (this);
954  for (std::list<RouteCacheEntry>::iterator i = route.begin (); i != route.end (); i++)
955  {
956  std::vector<Ipv4Address> path = i->GetVector ();
957  NS_LOG_INFO ("Route NO. ");
958  PrintVector (path);
959  }
960 }
961 
962 void
963 RouteCache::Purge ()
964 {
965  NS_LOG_FUNCTION (this);
966  //Trying to purge the route cache
967  if (m_sortedRoutes.empty ())
968  {
969  NS_LOG_DEBUG ("The route cache is empty");
970  return;
971  }
972  for (std::map<Ipv4Address, std::list<RouteCacheEntry> >::iterator i =
973  m_sortedRoutes.begin (); i != m_sortedRoutes.end (); )
974  {
975  // Loop of route cache entry with the route size
976  std::map<Ipv4Address, std::list<RouteCacheEntry> >::iterator itmp = i;
977  /*
978  * The route cache entry vector
979  */
980  Ipv4Address dst = i->first;
981  std::list<RouteCacheEntry> rtVector = i->second;
982  NS_LOG_DEBUG ("The route vector size of 1 " << dst << " " << rtVector.size ());
983  if (rtVector.size ())
984  {
985  for (std::list<RouteCacheEntry>::iterator j = rtVector.begin (); j != rtVector.end (); )
986  {
987  NS_LOG_DEBUG ("The expire time of every entry with expire time " << j->GetExpireTime ());
988  /*
989  * First verify if the route has expired or not
990  */
991  if (j->GetExpireTime () <= Seconds (0))
992  {
993  /*
994  * When the expire time has passed, erase the certain route
995  */
996  NS_LOG_DEBUG ("Erase the expired route for " << dst << " with expire time " << j->GetExpireTime ());
997  j = rtVector.erase (j);
998  }
999  else
1000  {
1001  ++j;
1002  }
1003  }
1004  NS_LOG_DEBUG ("The route vector size of 2 " << dst << " " << rtVector.size ());
1005  if (rtVector.size ())
1006  {
1007  ++i;
1008  m_sortedRoutes.erase (itmp); // erase the entry first
1009  /*
1010  * Save the new route cache along with the destination address in map
1011  */
1012  m_sortedRoutes.insert (std::make_pair (dst, rtVector));
1013  }
1014  else
1015  {
1016  ++i;
1017  m_sortedRoutes.erase (itmp);
1018  }
1019  }
1020  else
1021  {
1022  ++i;
1023  m_sortedRoutes.erase (itmp);
1024  }
1025  }
1026  return;
1027 }
1028 
1029 void
1030 RouteCache::Print (std::ostream &os)
1031 {
1032  NS_LOG_FUNCTION (this);
1033  Purge ();
1034  os << "\nDSR Route Cache\n"
1035  << "Destination\tGateway\t\tInterface\tFlag\tExpire\tHops\n";
1036  for (std::list<RouteCacheEntry>::const_iterator i =
1037  m_routeEntryVector.begin (); i != m_routeEntryVector.end (); ++i)
1038  {
1039  i->Print (os);
1040  }
1041  os << "\n";
1042 }
1043 
1044 // ----------------------------------------------------------------------------------------------------------
1048 uint16_t
1050 {
1051  NS_LOG_FUNCTION (this);
1052  std::map<Ipv4Address, uint16_t>::const_iterator i =
1053  m_ackIdCache.find (nextHop);
1054  if (i == m_ackIdCache.end ())
1055  {
1056  NS_LOG_LOGIC ("No Ack id for " << nextHop << " found and use id 1 for the first network ack id");
1057  m_ackIdCache[nextHop] = 1;
1058  return 1;
1059  }
1060  else
1061  {
1062  uint16_t ackId = m_ackIdCache[nextHop];
1063  NS_LOG_LOGIC ("Ack id for " << nextHop << " found in the cache has value " << ackId);
1064  ackId++;
1065  m_ackIdCache[nextHop] = ackId;
1066  return ackId;
1067  }
1068 }
1069 
1070 uint16_t
1072 {
1073  return m_ackIdCache.size ();
1074 }
1075 
1076 // ----------------------------------------------------------------------------------------------------------
1080 bool
1082 {
1083  NS_LOG_FUNCTION (this);
1084  PurgeMac (); // purge the mac cache
1085  for (std::vector<Neighbor>::const_iterator i = m_nb.begin ();
1086  i != m_nb.end (); ++i)
1087  {
1088  if (i->m_neighborAddress == addr)
1089  {
1090  return true;
1091  }
1092  }
1093  return false;
1094 }
1095 
1096 Time
1098 {
1099  NS_LOG_FUNCTION (this);
1100  PurgeMac ();
1101  for (std::vector<Neighbor>::const_iterator i = m_nb.begin (); i
1102  != m_nb.end (); ++i)
1103  {
1104  if (i->m_neighborAddress == addr)
1105  {
1106  return (i->m_expireTime - Simulator::Now ());
1107  }
1108  }
1109  return Seconds (0);
1110 }
1111 
1112 void
1113 RouteCache::UpdateNeighbor (std::vector<Ipv4Address> nodeList, Time expire)
1114 {
1115  NS_LOG_FUNCTION (this);
1116  for (std::vector<Neighbor>::iterator i = m_nb.begin (); i != m_nb.end (); ++i)
1117  {
1118  for (std::vector<Ipv4Address>::iterator j = nodeList.begin (); j != nodeList.end (); ++j)
1119  {
1120  if (i->m_neighborAddress == (*j))
1121  {
1122  i->m_expireTime
1123  = std::max (expire + Simulator::Now (), i->m_expireTime);
1124  if (i->m_hardwareAddress == Mac48Address ())
1125  {
1126  i->m_hardwareAddress = LookupMacAddress (i->m_neighborAddress);
1127  }
1128  return;
1129  }
1130  }
1131  }
1132 
1133  Ipv4Address addr;
1134  NS_LOG_LOGIC ("Open link to " << addr);
1135  Neighbor neighbor (addr, LookupMacAddress (addr), expire + Simulator::Now ());
1136  m_nb.push_back (neighbor);
1137  PurgeMac ();
1138 }
1139 
1140 void
1141 RouteCache::AddNeighbor (std::vector<Ipv4Address> nodeList, Ipv4Address ownAddress, Time expire)
1142 {
1143  NS_LOG_LOGIC ("Add neighbor number " << nodeList.size ());
1144  for (std::vector<Ipv4Address>::iterator j = nodeList.begin (); j != nodeList.end (); ++j)
1145  {
1146  Ipv4Address addr = *j;
1147  if (addr == ownAddress)
1148  {
1149  nodeList.erase (j);
1150  NS_LOG_DEBUG ("The node list size " << nodeList.size ());
1151  }
1152  Neighbor neighbor (addr, LookupMacAddress (addr), expire + Simulator::Now ());
1153  m_nb.push_back (neighbor);
1154  PurgeMac ();
1155  }
1156 }
1157 
1159 {
1160  bool operator() (const RouteCache::Neighbor & nb) const
1161  {
1162  return ((nb.m_expireTime < Simulator::Now ()) || nb.close);
1163  }
1164 };
1165 
1166 void
1168 {
1169  if (m_nb.empty ())
1170  {
1171  return;
1172  }
1173 
1174  CloseNeighbor pred;
1175  if (!m_handleLinkFailure.IsNull ())
1176  {
1177  for (std::vector<Neighbor>::iterator j = m_nb.begin (); j != m_nb.end (); ++j)
1178  {
1179  if (pred (*j))
1180  {
1181  NS_LOG_LOGIC ("Close link to " << j->m_neighborAddress);
1182  // disable temporarily TODO
1183 // m_handleLinkFailure (j->m_neighborAddress);
1184  }
1185  }
1186  }
1187  m_nb.erase (std::remove_if (m_nb.begin (), m_nb.end (), pred), m_nb.end ());
1188  m_ntimer.Cancel ();
1189  m_ntimer.Schedule ();
1190 }
1191 
1192 void
1194 {
1195  m_ntimer.Cancel ();
1196  m_ntimer.Schedule ();
1197 }
1198 
1199 void
1201 {
1202  m_arp.push_back (a);
1203 }
1204 
1205 void
1207 {
1208  m_arp.erase (std::remove (m_arp.begin (), m_arp.end (), a), m_arp.end ());
1209 }
1210 
1213 {
1214  Mac48Address hwaddr;
1215  for (std::vector<Ptr<ArpCache> >::const_iterator i = m_arp.begin ();
1216  i != m_arp.end (); ++i)
1217  {
1218  ArpCache::Entry * entry = (*i)->Lookup (addr);
1219  if (entry != 0 && entry->IsAlive () && !entry->IsExpired ())
1220  {
1221  hwaddr = Mac48Address::ConvertFrom (entry->GetMacAddress ());
1222  break;
1223  }
1224  }
1225  return hwaddr;
1226 }
1227 
1228 void
1230 {
1231  Mac48Address addr = hdr.GetAddr1 ();
1232 
1233  for (std::vector<Neighbor>::iterator i = m_nb.begin (); i != m_nb.end (); ++i)
1234  {
1235  if (i->m_hardwareAddress == addr)
1236  {
1237  i->close = true;
1238  }
1239  }
1240  PurgeMac ();
1241 }
1242 } // namespace dsr
1243 } // namespace ns3
bool DeleteRoute(Ipv4Address dst)
Delete the route with certain destination address.
Definition: dsr-rcache.cc:758
static TypeId GetTypeId()
The Route Cache used by DSR.
Definition: dsr-rcache.cc:136
keep track of time unit.
Definition: nstime.h:149
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:311
void PurgeMac()
Remove all expired mac entries.
Definition: dsr-rcache.cc:1167
Control the scheduling of simulation events.
Definition: simulator.h:58
a simple Timer class
Definition: timer.h:45
bool IncStability(Ipv4Address node)
increase the stability of the node
Definition: dsr-rcache.cc:513
Ipv4Address m_dst
The destination Ip address.
Definition: dsr-rcache.h:282
#define NS_LOG_COMPONENT_DEFINE(name)
Definition: log.h:122
Time RouteCacheTimeout
The maximum period of time that dsr is allowed to for an unused route.
Definition: dsr-rcache.h:580
bool AddRoute(RouteCacheEntry &rt)
Add route cache entry if it doesn't yet exist in route cache.
Definition: dsr-rcache.cc:655
#define NS_LOG_INFO(msg)
Definition: log.h:264
void RebuildBestRouteTable(Ipv4Address source)
USE MAXWEIGHT TO REPRESENT MAX; USE BROADCAST ADDRESS TO REPRESENT NULL PRECEEDING ADDRESS...
Definition: dsr-rcache.cc:315
NodeStab(Time nodeStab=Simulator::Now())
Constructor.
Definition: dsr-rcache.cc:80
#define NS_LOG_FUNCTION_NOARGS()
Definition: log.h:275
bool LookupRoute_Link(Ipv4Address id, RouteCacheEntry &rt)
used by LookupRoute when LinkCache
Definition: dsr-rcache.cc:431
std::map< Ipv4Address, std::map< Ipv4Address, uint32_t > > m_netGraph
Definition: dsr-rcache.h:616
bool IsAlive(void)
Definition: arp-cache.cc:285
uint32_t m_stabilityDecrFactor
Definition: dsr-rcache.h:585
std::map< Ipv4Address, uint16_t > m_ackIdCache
The id cache to ensure all the ids are unique.
Definition: dsr-rcache.h:601
void SetCacheType(std::string type)
dijsktra algorithm to get the best route from m_netGraph and update the m_bestRoutesTable_link curre...
Definition: dsr-rcache.cc:289
double GetSeconds(void) const
Definition: nstime.h:262
void UseExtends(RouteCacheEntry::IP_VECTOR rt)
Definition: dsr-rcache.cc:609
uint16_t CheckUniqueAckId(Ipv4Address nextHop)
Check for duplicate ids and save new entries if the id is not present in the table.
Definition: dsr-rcache.cc:1049
std::list< RouteCacheEntry::IP_VECTOR > routeVector
Define the vector of route entries.
Definition: dsr-rcache.h:329
void Schedule(void)
Definition: timer.cc:152
void AddNeighbor(std::vector< Ipv4Address > nodeList, Ipv4Address ownAddress, Time expire)
Add to the neighbor list.
Definition: dsr-rcache.cc:1141
void UpdateNeighbor(std::vector< Ipv4Address > nodeList, Time expire)
Update expire time for entry with address addr, if it exists, else add new entry. ...
Definition: dsr-rcache.cc:1113
void SetFunction(FN fn)
Definition: timer.h:254
void ScheduleTimer()
Schedule m_ntimer.
Definition: dsr-rcache.cc:1193
std::vector< Ipv4Address > IP_VECTOR
Define the vector to hold Ip address.
Definition: dsr-rcache.h:183
bool m_subRoute
Check if save the sub route entries or not.
Definition: dsr-rcache.h:605
bool IsBroadcast(void) const
bool UpdateRouteEntry(Ipv4Address dst)
Update route cache entry if it has been recently used and successfully delivered the data packet...
Definition: dsr-rcache.cc:176
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:502
void DelArpCache(Ptr< ArpCache >)
Don't use given ARP cache any more (interface is down)
Definition: dsr-rcache.cc:1206
bool IsExpired(void) const
Definition: arp-cache.cc:382
RouteCacheEntry(IP_VECTOR const &ip=IP_VECTOR(), Ipv4Address dst=Ipv4Address(), Time exp=Simulator::Now())
Constructor.
Definition: dsr-rcache.cc:105
Definition: dsr-rcache.h:180
void PrintRouteVector(std::list< RouteCacheEntry > route)
Print all the route vector elements from the route list.
Definition: dsr-rcache.cc:951
std::map< Link, LinkStab > m_linkCache
The data structure to store link info.
Definition: dsr-rcache.h:619
void SetDelay(const Time &delay)
Definition: timer.cc:69
#define NS_LOG_LOGIC(msg)
Definition: log.h:334
Address GetMacAddress(void) const
Definition: arp-cache.cc:346
virtual ~RouteCacheEntry()
Destructor.
Definition: dsr-rcache.cc:116
Callback< void, WifiMacHeader const & > m_txErrorCallback
TX error callback.
Definition: dsr-rcache.h:670
void ProcessTxError(WifiMacHeader const &)
Process layer 2 TX error notification.
Definition: dsr-rcache.cc:1229
Mac48Address LookupMacAddress(Ipv4Address)
Find MAC address by IP using list of ARP caches.
Definition: dsr-rcache.cc:1212
uint8_t m_reqCount
Number of route requests.
Definition: dsr-rcache.h:290
bool AddRoute_Link(RouteCacheEntry::IP_VECTOR nodelist, Ipv4Address node)
Definition: dsr-rcache.cc:560
static Mac48Address ConvertFrom(const Address &address)
void RemoveLastEntry(std::list< RouteCacheEntry > &rtVector)
Remove the aged route cache entries when the route cache is full.
Definition: dsr-rcache.cc:168
void PrintVector(std::vector< Ipv4Address > &vec)
Print the route vector elements.
Definition: dsr-rcache.cc:930
void Print(std::ostream &os) const
Print necessary fields.
Definition: dsr-rcache.cc:128
an EUI-48 address
Definition: mac48-address.h:41
DSR route request queue Since DSR is an on demand routing we queue requests while looking for route...
Definition: dsr-rcache.h:305
A record that that holds information about an ArpCache entry.
Definition: arp-cache.h:116
uint16_t GetAckSize()
Get the ack table size.
Definition: dsr-rcache.cc:1071
static Time Now(void)
Definition: simulator.cc:179
RouteCache()
Constructor.
Definition: dsr-rcache.cc:145
std::vector< Ptr< ArpCache > > m_arp
list of ARP cached to be used for layer 2 notifications processing
Definition: dsr-rcache.h:676
bool LookupRoute(Ipv4Address id, RouteCacheEntry &rt)
Lookup route cache entry with destination address dst.
Definition: dsr-rcache.cc:206
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
uint32_t m_maxEntriesEachDst
number of entries for each destination
Definition: dsr-rcache.h:599
Timer m_ntimer
Timer for neighbor's list. Schedule Purge().
Definition: dsr-rcache.h:672
virtual ~NodeStab()
Destructor.
Definition: dsr-rcache.cc:85
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
Definition: nstime.h:586
std::map< Ipv4Address, RouteCacheEntry::IP_VECTOR > m_bestRoutesTable_link
for link route cache
Definition: dsr-rcache.h:618
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:286
#define NS_LOG_DEBUG(msg)
Definition: log.h:255
void Cancel(void)
Definition: timer.cc:103
std::map< Ipv4Address, routeEntryVector > m_sortedRoutes
Map the ipv4Address to route entry vector.
Definition: dsr-rcache.h:595
Time m_expire
Expire time for queue entry.
Definition: dsr-rcache.h:286
Time MilliSeconds(uint64_t ms)
create ns3::Time instances in units of milliseconds.
Definition: nstime.h:601
void UpdateNetGraph()
Update the Net Graph for the link and node cache has changed.
Definition: dsr-rcache.cc:498
Callback< void, Ipv4Address, uint8_t > m_handleLinkFailure
link failure callback
Definition: dsr-rcache.h:668
bool FindSameRoute(RouteCacheEntry &rt, std::list< RouteCacheEntry > &rtVector)
Find the same route in the route cache.
Definition: dsr-rcache.cc:725
a base class which provides memory management and object aggregation
Definition: object.h:63
void DeleteAllRoutesIncludeLink(Ipv4Address errorSrc, Ipv4Address unreachNode, Ipv4Address node)
Delete all the routes which includes the link from next hop address that has just been notified as un...
Definition: dsr-rcache.cc:772
bool DecStability(Ipv4Address node)
decrease the stability of the node
Definition: dsr-rcache.cc:537
std::vector< Neighbor > m_nb
vector of entries
Definition: dsr-rcache.h:674
routeEntryVector m_routeEntryVector
Define the route vector.
Definition: dsr-rcache.h:597
bool m_isLinkCache
Check if the route is using path cache or link cache.
Definition: dsr-rcache.h:603
a unique identifier for an interface.
Definition: type-id.h:44
bool IsNeighbor(Ipv4Address addr)
Check that node with address addr is neighbor.
Definition: dsr-rcache.cc:1081
Time GetExpireTime(Ipv4Address addr)
Return expire time for neighbor node with address addr, if exists, else return 0. ...
Definition: dsr-rcache.cc:1097
TypeId SetParent(TypeId tid)
Definition: type-id.cc:471
Time m_delay
This timeout deals with the passive ack.
Definition: dsr-rcache.h:678
void AddArpCache(Ptr< ArpCache >)
Add ARP cache to be used to allow layer 2 notifications processing.
Definition: dsr-rcache.cc:1200
std::map< Ipv4Address, NodeStab > m_nodeCache
The data structure to store node info.
Definition: dsr-rcache.h:620
virtual ~RouteCache()
Destructor.
Definition: dsr-rcache.cc:160