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