A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
dsr-rcache.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 Yufei Cheng
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Yufei Cheng <yfcheng@ittc.ku.edu>
7 * Song Luan <lsuper@mail.ustc.edu.cn> (Implemented Link Cache using dijsktra algorithm
8 * to get the best route)
9 *
10 * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
11 * ResiliNets Research Group https://resilinets.org/
12 * Information and Telecommunication Technology Center (ITTC)
13 * and Department of Electrical Engineering and Computer Science
14 * The University of Kansas Lawrence, KS USA.
15 *
16 * Work supported in part by NSF FIND (Future Internet Design) Program
17 * under grant CNS-0626918 (Postmodern Internet Architecture),
18 * NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI),
19 * US Department of Defense (DoD), and ITTC at The University of Kansas.
20 */
21
22#ifndef DSR_RCACHE_H
23#define DSR_RCACHE_H
24
25#include "dsr-option-header.h"
26
27#include "ns3/arp-cache.h"
28#include "ns3/callback.h"
29#include "ns3/enum.h"
30#include "ns3/header.h"
31#include "ns3/ipv4-address.h"
32#include "ns3/ipv4-l3-protocol.h"
33#include "ns3/ipv4-route.h"
34#include "ns3/ipv4.h"
35#include "ns3/net-device.h"
36#include "ns3/nstime.h"
37#include "ns3/simple-ref-count.h"
38#include "ns3/simulator.h"
39#include "ns3/timer.h"
40
41#include <cassert>
42#include <iostream>
43#include <map>
44#include <stdint.h>
45#include <sys/types.h>
46#include <vector>
47
48namespace ns3
49{
50
51class Time;
52class WifiMacHeader;
53
54namespace dsr
55{
56
57/**
58 * The route cache structure
59 \verbatim
60 +-+-+-+-+-+-+-+-+-+-+-+- +-+-+-+-+-+-+-+-+-+-+- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
61 | Destination Address |---------| Route Cache Entry | ---------- | IP_VECTOR | dst | exp time |
62 +-+-+-+-+-+-+-+-+-+-+-+- Map +-+-+-+-+-+-+-+-+-+-+- Contains +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
63 +-+-+-+-+-+-+-+-+-+-+- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
64 | Route Cache Entry | ---------- | IP_VECTOR | dst | exp time |
65 +-+-+-+-+-+-+-+-+-+-+- Contains +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
66 . .
67 . .
68 . .
69 . .
70 +-+-+-+-+-+-+-+-+-+-+- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
71 | Route Cache Entry | ---------- | IP_VECTOR | dst | exp time |
72 +-+-+-+-+-+-+-+-+-+-+- Contains +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
73
74 \endverbatim
75 */
76/**
77 * \ingroup dsr
78 * \brief DSR Route Cache Entry
79 */
80struct Link
81{
82 Ipv4Address m_low; ///< low IP address
83 Ipv4Address m_high; ///< high IP address
84
85 /**
86 * Constructor
87 *
88 * \param ip1 first IP address
89 * \param ip2 second IP address
90 */
92 {
93 if (ip1 < ip2)
94 {
95 m_low = ip1;
96 m_high = ip2;
97 }
98 else
99 {
100 m_low = ip2;
101 m_high = ip1;
102 }
103 }
104
105 /**
106 * \brief less than comparison operator
107 * \param L link to compare
108 * \return true if less than
109 */
110 bool operator<(const Link& L) const
111 {
112 if (m_low < L.m_low)
113 {
114 return true;
115 }
116 else if (m_low == L.m_low)
117 {
118 return (m_high < L.m_high);
119 }
120 else
121 {
122 return false;
123 }
124 }
125
126 /// Print function
127 void Print() const;
128};
129
130/**
131 * \class DsrLinkStab
132 * \brief DsrLinkStab class (DSR link stability)
133 */
135{
136 public:
137 /**
138 * \brief Constructor
139 * \param linkStab duration of the link stability
140 */
141 DsrLinkStab(Time linkStab = Simulator::Now());
142 /**
143 * \brief Destructor
144 */
145 virtual ~DsrLinkStab();
146
147 /**
148 * \brief set the link stability
149 * \param linkStab duration of the link stability
150 */
151 void SetLinkStability(Time linkStab)
152 {
153 m_linkStability = linkStab + Simulator::Now();
154 }
155
156 /**
157 * \brief get the link stability
158 * \returns remaining duration of the link stability
159 */
161 {
163 }
164
165 /// Print function
166 void Print() const;
167
168 private:
169 /**
170 * The link stability lifetime expected, when the time is due, the link expires the expiration
171 * happens when purge the node and link cache before update them when receiving new information
172 */
174};
175
176/**
177 * \class DsrNodeStab
178 * \brief DsrNodeStab class (DSR node stability)
179 */
181{
182 public:
183 /**
184 * Constructor
185 *
186 * \param nodeStab duration of stable node time
187 */
188 DsrNodeStab(Time nodeStab = Simulator::Now());
189 virtual ~DsrNodeStab();
190
191 /**
192 * Set node stability
193 * \param nodeStab duration of the node stability
194 */
195 void SetNodeStability(Time nodeStab)
196 {
197 m_nodeStability = nodeStab + Simulator::Now();
198 }
199
200 /**
201 * Get node stability
202 * \returns the remaining time for node stability
203 */
205 {
207 }
208
209 private:
210 Time m_nodeStability; ///< the node stability
211};
212
213/**
214 * \class DsrRouteCacheEntry
215 * \brief DsrRouteCacheEntry class for entries in the route cache
216 */
218{
219 public:
220 typedef std::vector<Ipv4Address> IP_VECTOR; ///< Define the vector to hold Ip address
221 typedef std::vector<Ipv4Address>::iterator Iterator; ///< Define the iterator
222
223 /**
224 * Constructor
225 *
226 * \param ip IP_VECTOR
227 * \param dst destination IPv4 address
228 * \param exp expiration time
229 */
231 Ipv4Address dst = Ipv4Address(),
232 Time exp = Simulator::Now());
233 virtual ~DsrRouteCacheEntry();
234
235 /// Mark entry as "down" (i.e. disable it)
236 /// \param badLinkLifetime Time before purging the link for real.
237 void Invalidate(Time badLinkLifetime);
238
239 // Fields
240 /**
241 * Set unidirectional flag
242 * \param u the unidirectional flag
243 */
244 void SetUnidirectional(bool u)
245 {
247 }
248
249 /**
250 * Get unidirectional flag
251 * \returns the unidirectional flag
252 */
253 bool IsUnidirectional() const
254 {
255 return m_blackListState;
256 }
257
258 /**
259 * Set blacklist timeout
260 * \param t the blacklist timeout
261 */
263 {
265 }
266
267 /**
268 * Get blacklist timeout
269 * \returns the blacklist timeout
270 */
272 {
273 return m_blackListTimeout;
274 }
275
276 /**
277 * Get destination address
278 * \returns the destination IP address
279 */
281 {
282 return m_dst;
283 }
284
285 /**
286 * Set destination address
287 * \param d the destination IP address
288 */
290 {
291 m_dst = d;
292 }
293
294 /**
295 * Get the IP vector
296 * \returns the IP vector
297 */
299 {
300 return m_path;
301 }
302
303 /**
304 * Sets the IP vector
305 * \param v the IP vector
306 */
308 {
309 m_path = v;
310 }
311
312 /**
313 * Set expire time
314 * \param exp the expire time
315 */
317 {
318 m_expire = exp + Simulator::Now();
319 }
320
321 /**
322 * Get expire time
323 * \returns the expire time
324 */
326 {
327 return m_expire - Simulator::Now();
328 }
329
330 /**
331 * \brief Print necessary fields
332 * \param os the output stream
333 */
334 void Print(std::ostream& os) const;
335
336 /**
337 * \brief Compare the route cache entry. Only the paths are compared.
338 * \param o entry to compare
339 * \return true if both route cache entries are equal
340 */
341 bool operator==(const DsrRouteCacheEntry& o) const
342 {
343 return m_path == o.m_path;
344 }
345
346 private:
347 Timer m_ackTimer; ///< RREP_ACK timer
348 Ipv4Address m_dst; ///< The destination Ip address
349 IP_VECTOR m_path; ///< brief The IP address constructed route
350 Time m_expire; ///< Expire time for queue entry
351 Ipv4InterfaceAddress m_iface; ///< Output interface address
352 uint8_t m_reqCount; ///< Number of route requests
353 bool m_blackListState; ///< Indicate if this entry is in "blacklist"
354 Time m_blackListTimeout; ///< Time for which the node is put into the blacklist
355 Ptr<Ipv4Route> m_ipv4Route; ///< The Ipv4 route
356 Ptr<Ipv4> m_ipv4; ///< The Ipv4 layer 3
357};
358
359/**
360 * \ingroup dsr
361 * \brief DSR route request queue
362 * Since DSR is an on demand routing we queue requests while looking for route.
363 */
364class DsrRouteCache : public Object
365{
366 public:
367 /**
368 * \brief Get the type ID.
369 * \return the object TypeId
370 */
371 static TypeId GetTypeId();
372
374 ~DsrRouteCache() override;
375
376 // Delete assignment operator to avoid misuse
378
379 /**
380 * \brief Remove the aged route cache entries when the route cache is full
381 * \param rtVector the route cache to scan.
382 */
383 void RemoveLastEntry(std::list<DsrRouteCacheEntry>& rtVector);
384 /**
385 * \brief Define the vector of route entries.
386 */
387 typedef std::list<DsrRouteCacheEntry::IP_VECTOR> routeVector;
388
389 // Fields
390 /**
391 * Get subroute indicator
392 * \returns true if a subroute exists
393 */
394 bool GetSubRoute() const
395 {
396 return m_subRoute;
397 }
398
399 /**
400 * Set subroute indicator
401 * \param subRoute the subroute indicator
402 */
403 void SetSubRoute(bool subRoute)
404 {
405 m_subRoute = subRoute;
406 }
407
408 /**
409 * Get the max queue length
410 * \returns the maximum queue length
411 */
413 {
414 return m_maxCacheLen;
415 }
416
417 /**
418 * Set the max queue length
419 * \param len the maximum queue length
420 */
422 {
423 m_maxCacheLen = len;
424 }
425
426 /**
427 * Get cache timeout value
428 * \returns the cache timeout time
429 */
431 {
432 return RouteCacheTimeout;
433 }
434
435 /**
436 * Set cache timeout value
437 * \param t the cache timeout time
438 */
440 {
442 }
443
444 /**
445 * Get max entries for each destination
446 * \returns the maximum entries for each destination
447 */
449 {
450 return m_maxEntriesEachDst;
451 }
452
453 /**
454 * Set max entries for each destination
455 * \param entries the maximum entries for each destination
456 */
458 {
459 m_maxEntriesEachDst = entries;
460 }
461
462 /**
463 * Get bad link lifetime function
464 * \returns the bad link lifetime
465 */
467 {
468 return m_badLinkLifetime;
469 }
470
471 /**
472 * Set bad link lifetime function
473 * \param t the bad link lifetime
474 */
476 {
478 }
479
480 /**
481 * Get stability decrease factor
482 * \returns the stability decrease factor
483 */
484 uint64_t GetStabilityDecrFactor() const
485 {
487 }
488
489 /**
490 * Set stability decrease factor
491 * \param decrFactor the stability decrease factor
492 */
493 void SetStabilityDecrFactor(uint64_t decrFactor)
494 {
495 m_stabilityDecrFactor = decrFactor;
496 }
497
498 /**
499 * Get stability increase factor
500 * \returns the stability increase factor
501 */
502 uint64_t GetStabilityIncrFactor() const
503 {
505 }
506
507 /**
508 * Set stability increase factor
509 * \param incrFactor the stability increase factor
510 */
511 void SetStabilityIncrFactor(uint64_t incrFactor)
512 {
513 m_stabilityIncrFactor = incrFactor;
514 }
515
516 /**
517 * Get initial stability
518 * \returns the initial stability
519 */
521 {
522 return m_initStability;
523 }
524
525 /**
526 * Set initial stability
527 * \param initStability the initial stability
528 */
529 void SetInitStability(Time initStability)
530 {
531 m_initStability = initStability;
532 }
533
534 /**
535 * Get minimum lifetime
536 * \returns the minimum lifetime
537 */
539 {
540 return m_minLifeTime;
541 }
542
543 /**
544 * Set minimum lifetime
545 * \param minLifeTime the minimum lifetime
546 */
547 void SetMinLifeTime(Time minLifeTime)
548 {
549 m_minLifeTime = minLifeTime;
550 }
551
552 /**
553 * Get use extends
554 * \returns the use extends time
555 */
557 {
558 return m_useExtends;
559 }
560
561 /**
562 * Set use extends
563 * \param useExtends the use extends time
564 */
565 void SetUseExtends(Time useExtends)
566 {
567 m_useExtends = useExtends;
568 }
569
570 /**
571 * \brief Update route cache entry if it has been recently used and successfully delivered the
572 * data packet
573 * \param dst destination address of the route
574 * \return true in success
575 */
577 /**
578 * \brief Add route cache entry if it doesn't yet exist in route cache
579 * \param rt route cache entry
580 * \return true on success
581 */
583 /**
584 * \brief Lookup route cache entry with destination address dst
585 * \param id destination address
586 * \param rt entry with destination address id, if exists
587 * \return true on success
588 */
590 /**
591 * \brief Print the route vector elements
592 * \param vec the route vector
593 */
594 void PrintVector(std::vector<Ipv4Address>& vec);
595 /**
596 * \brief Print all the route vector elements from the route list
597 * \param route the route list
598 */
599 void PrintRouteVector(std::list<DsrRouteCacheEntry> route);
600 /**
601 * \brief Find the same route in the route cache
602 * \param rt entry with destination address dst, if exists
603 * \param rtVector the route vector
604 * \return true if same
605 */
606 bool FindSameRoute(DsrRouteCacheEntry& rt, std::list<DsrRouteCacheEntry>& rtVector);
607 /**
608 * \brief Delete the route with certain destination address
609 * \param dst the destination address of the routes that should be deleted
610 * \return true if the route was deleted
611 */
612 bool DeleteRoute(Ipv4Address dst);
613 /**
614 * \brief Delete all the routes which includes the link from next hop address that has just been
615 * notified as unreachable
616 *
617 * \param errorSrc The error source address
618 * \param unreachNode The unreachable node
619 * \param node This node's ip address
620 */
622 Ipv4Address unreachNode,
623 Ipv4Address node);
624
625 /// Delete all entries from routing table
626 void Clear()
627 {
629 }
630
631 /// Delete all outdated entries and invalidate valid entry if Lifetime is expired
632 void Purge();
633 /// Print route cache
634 /// \param os the output stream
635 void Print(std::ostream& os);
636
637 //------------------------------------------------------------------------------------------
638 /**
639 * \brief Check for duplicate ids and save new entries if the id is not present in the table
640 * \param nextHop to check for in cache
641 * \return ack ID
642 */
643 uint16_t CheckUniqueAckId(Ipv4Address nextHop);
644 /**
645 * \brief Get the ack table size
646 * \return ack size
647 */
648 uint16_t GetAckSize();
649
650 // --------------------------------------------------------------------------------------------
651 /// Structure to manage neighbor state
652 struct Neighbor
653 {
654 Ipv4Address m_neighborAddress; ///< neighbor address
655 Mac48Address m_hardwareAddress; ///< neighbor MAC address
656 Time m_expireTime; ///< route expire time
657 bool close; ///< is route active
658
659 /**
660 * Constructor
661 *
662 * \param ip IP address of neighbor
663 * \param mac MAC address of neighbor
664 * \param t expiration time
665 */
667 : m_neighborAddress(ip),
669 m_expireTime(t),
670 close(false)
671 {
672 }
673
675 {
676 } // For Python bindings
677 };
678
679 /**
680 * \brief Return expire time for neighbor node with address addr, if exists, else return 0.
681 * \param addr IP address
682 * \return expire time
683 */
685 /**
686 * \brief Check that node with address addr is neighbor
687 * \param addr IP address
688 * \return true if neighbor
689 */
690 bool IsNeighbor(Ipv4Address addr);
691 /**
692 * \brief Update expire time for entry with address addr, if it exists, else add new entry
693 * \param nodeList list of addresses
694 * \param expire expiration time
695 */
696 void UpdateNeighbor(std::vector<Ipv4Address> nodeList, Time expire);
697 /**
698 * \brief Add to the neighbor list
699 * \param nodeList neighbor list
700 * \param ownAddress local address
701 * \param expire expiration time
702 */
703 void AddNeighbor(std::vector<Ipv4Address> nodeList, Ipv4Address ownAddress, Time expire);
704 /**
705 * \brief Remove all expired mac entries
706 */
707 void PurgeMac();
708 /**
709 * \brief Schedule m_ntimer.
710 */
711 void ScheduleTimer();
712
713 /**
714 * \brief Remove all entries
715 */
716 void ClearMac()
717 {
718 m_nb.clear();
719 }
720
721 /**
722 * \brief Add ARP cache to be used to allow layer 2 notifications processing
723 * \param a ARP cache
724 */
726 /**
727 * \brief Don't use the provided ARP cache any more (interface is down)
728 * \param a ARP cache
729 */
731
732 /**
733 * Handle link failure callback
734 * \param cb the callback to be set
735 */
740
741 /**
742 * Handle link failure callback
743 * \return The callback to LinkFailure
744 */
749
750 private:
752 m_vector; ///< The route vector to save the ip addresses for intermediate nodes.
753 uint32_t m_maxCacheLen; ///< The maximum number of packets that we allow a routing protocol to
754 ///< buffer.
755 Time RouteCacheTimeout; ///< The maximum period of time that dsr is allowed to for an unused
756 ///< route.
757 Time m_badLinkLifetime; ///< The time for which the neighboring node is put into the blacklist.
758 /*
759 * Define the parameters for link cache type
760 */
761 uint32_t m_stabilityDecrFactor; ///< stability decrease factor
762 uint32_t m_stabilityIncrFactor; ///< stability increase factor
763 Time m_initStability; ///< initial stability
764 Time m_minLifeTime; ///< minimum lifetime
765 Time m_useExtends; ///< use extend
766 /**
767 * Define the route cache data structure
768 */
769 typedef std::list<DsrRouteCacheEntry> routeEntryVector;
770
771 std::map<Ipv4Address, routeEntryVector>
772 m_sortedRoutes; ///< Map the ipv4Address to route entry vector
773
774 routeEntryVector m_routeEntryVector; ///< Define the route vector
775
776 uint32_t m_maxEntriesEachDst; ///< number of entries for each destination
777
778 std::map<Ipv4Address, uint16_t> m_ackIdCache; ///< The id cache to ensure all the ids are unique
779
780 bool m_isLinkCache; ///< Check if the route is using path cache or link cache
781
782 bool m_subRoute; ///< Check if save the sub route entries or not
783/**
784 * The link cache to update all the link status, bi-link is two link for link is a struct
785 * when the weight is calculated we normalized them: 100*weight/max of Weight
786 */
787#define MAXWEIGHT 0xFFFF;
788 /**
789 * Current network graph state for this node, double is weight, which is calculated by the node
790 * information and link information, any time some changes of link cache and node cache change
791 * the weight and then recompute the best choice for each node
792 */
793 std::map<Ipv4Address, std::map<Ipv4Address, uint32_t>> m_netGraph;
794
795 std::map<Ipv4Address, DsrRouteCacheEntry::IP_VECTOR>
796 m_bestRoutesTable_link; ///< for link route cache
797 std::map<Link, DsrLinkStab> m_linkCache; ///< The data structure to store link info
798 std::map<Ipv4Address, DsrNodeStab> m_nodeCache; ///< The data structure to store node info
799 /**
800 * \brief used by LookupRoute when LinkCache
801 * \param id the ip address we are looking for
802 * \param rt the route cache entry to store the found one
803 * \return true if route route found
804 */
806 /**
807 * \brief increase the stability of the node
808 * \param node the ip address of the node we want to increase stability
809 * \return true if success
810 */
811 bool IncStability(Ipv4Address node);
812 /**
813 * \brief decrease the stability of the node
814 * \param node the ip address of the node we want to decrease stability
815 * \return true if success
816 */
817 bool DecStability(Ipv4Address node);
818
819 public:
820 /**
821 * \brief Dijsktra algorithm to get the best route from m_netGraph and update the
822 * m_bestRoutesTable_link when current graph information has changed
823 * \param type The type of the cache
824 */
825 void SetCacheType(std::string type);
826 /**
827 * \brief is link cached
828 * \return true if the link is cached
829 */
830 bool IsLinkCache();
831 /**
832 * \brief dd route link to cache
833 * \param nodelist vector of nodes
834 * \param node ip address of node to add
835 * \return true if the link is cached
836 */
838 /**
839 * \brief Rebuild the best route table
840 * \note Use MAXWEIGHT to represent maximum weight, use the IPv4 broadcast
841 * address of 255.255.255.255 to represent a null preceding address
842 * \param source The source address used for computing the routes
843 */
845 /**
846 * \brief Purge from the cache if the stability time expired
847 */
848 void PurgeLinkNode();
849 /**
850 * When a link from the Route Cache is used in routing a packet originated or salvaged
851 * by that node, the stability metric for each of the two endpoint nodes of that link is
852 * incremented by the amount of time since that link was last used. When a link is used in a
853 * route chosen for a packet originated or salvaged by this node, the link's lifetime is set to
854 * be at least UseExtends into the future
855 * \param rt cache entry
856 */
858 /**
859 * \brief Update the Net Graph for the link and node cache has changed
860 */
861 void UpdateNetGraph();
862 //---------------------------------------------------------------------------------------
863 /**
864 * The following code handles link-layer acks
865 */
867
868 Timer m_ntimer; ///< Timer for neighbor's list. Schedule Purge().
869
870 std::vector<Neighbor> m_nb; ///< vector of entries
871
872 std::vector<Ptr<ArpCache>>
873 m_arp; ///< list of ARP cached to be used for layer 2 notifications processing
874
875 Time m_delay; ///< This timeout deals with the passive ack
876
877 /// Find MAC address by IP using list of ARP caches
878 /// \param addr the IPv4 address to look for
879 /// \return The MAC address
881
882 /// Process layer 2 TX error notification
883 /// \param hdr Wi-Fi Mac Header
884 void ProcessTxError(const WifiMacHeader& hdr);
885};
886} // namespace dsr
887} // namespace ns3
888#endif /* DSR_RCACHE_H */
Callback template class.
Definition callback.h:422
Ipv4 addresses are stored in host order in this class.
a class to store IPv4 address information on an interface
an EUI-48 address
A base class which provides memory management and object aggregation.
Definition object.h:78
Smart pointer class similar to boost::intrusive_ptr.
static Time Now()
Return the current simulation virtual time.
Definition simulator.cc:197
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
A simple virtual Timer class.
Definition timer.h:67
a unique identifier for an interface.
Definition type-id.h:48
Implements the IEEE 802.11 MAC header.
DsrNodeStab class (DSR node stability)
Definition dsr-rcache.h:181
Time GetNodeStability() const
Get node stability.
Definition dsr-rcache.h:204
Time m_nodeStability
the node stability
Definition dsr-rcache.h:210
void SetNodeStability(Time nodeStab)
Set node stability.
Definition dsr-rcache.h:195
DsrNodeStab(Time nodeStab=Simulator::Now())
Constructor.
Definition dsr-rcache.cc:78
DsrRouteCacheEntry class for entries in the route cache.
Definition dsr-rcache.h:218
IP_VECTOR GetVector() const
Get the IP vector.
Definition dsr-rcache.h:298
void SetDestination(Ipv4Address d)
Set destination address.
Definition dsr-rcache.h:289
Time m_expire
Expire time for queue entry.
Definition dsr-rcache.h:350
DsrRouteCacheEntry(IP_VECTOR const &ip=IP_VECTOR(), Ipv4Address dst=Ipv4Address(), Time exp=Simulator::Now())
Constructor.
IP_VECTOR m_path
brief The IP address constructed route
Definition dsr-rcache.h:349
Ipv4Address m_dst
The destination Ip address.
Definition dsr-rcache.h:348
Ptr< Ipv4Route > m_ipv4Route
The Ipv4 route.
Definition dsr-rcache.h:355
Time GetBlacklistTimeout() const
Get blacklist timeout.
Definition dsr-rcache.h:271
std::vector< Ipv4Address >::iterator Iterator
Define the iterator.
Definition dsr-rcache.h:221
uint8_t m_reqCount
Number of route requests.
Definition dsr-rcache.h:352
Timer m_ackTimer
RREP_ACK timer.
Definition dsr-rcache.h:347
Ptr< Ipv4 > m_ipv4
The Ipv4 layer 3.
Definition dsr-rcache.h:356
Ipv4Address GetDestination() const
Get destination address.
Definition dsr-rcache.h:280
void SetBlacklistTimeout(Time t)
Set blacklist timeout.
Definition dsr-rcache.h:262
Ipv4InterfaceAddress m_iface
Output interface address.
Definition dsr-rcache.h:351
virtual ~DsrRouteCacheEntry()
Time m_blackListTimeout
Time for which the node is put into the blacklist.
Definition dsr-rcache.h:354
bool IsUnidirectional() const
Get unidirectional flag.
Definition dsr-rcache.h:253
void Invalidate(Time badLinkLifetime)
Mark entry as "down" (i.e.
void Print(std::ostream &os) const
Print necessary fields.
void SetUnidirectional(bool u)
Set unidirectional flag.
Definition dsr-rcache.h:244
std::vector< Ipv4Address > IP_VECTOR
Define the vector to hold Ip address.
Definition dsr-rcache.h:220
bool m_blackListState
Indicate if this entry is in "blacklist".
Definition dsr-rcache.h:353
Time GetExpireTime() const
Get expire time.
Definition dsr-rcache.h:325
void SetExpireTime(Time exp)
Set expire time.
Definition dsr-rcache.h:316
void SetVector(IP_VECTOR v)
Sets the IP vector.
Definition dsr-rcache.h:307
bool operator==(const DsrRouteCacheEntry &o) const
Compare the route cache entry.
Definition dsr-rcache.h:341
DSR route request queue Since DSR is an on demand routing we queue requests while looking for route.
Definition dsr-rcache.h:365
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:793
uint32_t m_stabilityDecrFactor
stability decrease factor
Definition dsr-rcache.h:761
std::list< DsrRouteCacheEntry::IP_VECTOR > routeVector
Define the vector of route entries.
Definition dsr-rcache.h:387
static TypeId GetTypeId()
Get the type ID.
void SetBadLinkLifetime(Time t)
Set bad link lifetime function.
Definition dsr-rcache.h:475
void PurgeLinkNode()
Purge from the cache if the stability time expired.
Callback< void, Ipv4Address, uint8_t > m_handleLinkFailure
The following code handles link-layer acks.
Definition dsr-rcache.h:866
std::map< Link, DsrLinkStab > m_linkCache
The data structure to store link info.
Definition dsr-rcache.h:797
void ScheduleTimer()
Schedule m_ntimer.
void SetInitStability(Time initStability)
Set initial stability.
Definition dsr-rcache.h:529
void RebuildBestRouteTable(Ipv4Address source)
Rebuild the best route table.
void SetCacheType(std::string type)
Dijsktra algorithm to get the best route from m_netGraph and update the m_bestRoutesTable_link when c...
std::list< DsrRouteCacheEntry > routeEntryVector
Define the route cache data structure.
Definition dsr-rcache.h:769
void SetStabilityDecrFactor(uint64_t decrFactor)
Set stability decrease factor.
Definition dsr-rcache.h:493
uint64_t GetStabilityDecrFactor() const
Get stability decrease factor.
Definition dsr-rcache.h:484
routeEntryVector m_routeEntryVector
Define the route vector.
Definition dsr-rcache.h:774
void AddArpCache(Ptr< ArpCache > a)
Add ARP cache to be used to allow layer 2 notifications processing.
std::map< Ipv4Address, DsrNodeStab > m_nodeCache
The data structure to store node info.
Definition dsr-rcache.h:798
void Purge()
Delete all outdated entries and invalidate valid entry if Lifetime is expired.
Time m_initStability
initial stability
Definition dsr-rcache.h:763
uint16_t CheckUniqueAckId(Ipv4Address nextHop)
Check for duplicate ids and save new entries if the id is not present in the table.
bool IsLinkCache()
is link cached
Time GetBadLinkLifetime() const
Get bad link lifetime function.
Definition dsr-rcache.h:466
void SetMinLifeTime(Time minLifeTime)
Set minimum lifetime.
Definition dsr-rcache.h:547
uint32_t GetMaxEntriesEachDst() const
Get max entries for each destination.
Definition dsr-rcache.h:448
uint32_t m_stabilityIncrFactor
stability increase factor
Definition dsr-rcache.h:762
Time GetInitStability() const
Get initial stability.
Definition dsr-rcache.h:520
Time GetCacheTimeout() const
Get cache timeout value.
Definition dsr-rcache.h:430
uint64_t GetStabilityIncrFactor() const
Get stability increase factor.
Definition dsr-rcache.h:502
void SetMaxCacheLen(uint32_t len)
Set the max queue length.
Definition dsr-rcache.h:421
bool LookupRoute(Ipv4Address id, DsrRouteCacheEntry &rt)
Lookup route cache entry with destination address dst.
bool GetSubRoute() const
Get subroute indicator.
Definition dsr-rcache.h:394
uint16_t GetAckSize()
Get the ack table size.
std::map< Ipv4Address, uint16_t > m_ackIdCache
The id cache to ensure all the ids are unique.
Definition dsr-rcache.h:778
void ProcessTxError(const WifiMacHeader &hdr)
Process layer 2 TX error notification.
Time RouteCacheTimeout
The maximum period of time that dsr is allowed to for an unused route.
Definition dsr-rcache.h:755
void SetMaxEntriesEachDst(uint32_t entries)
Set max entries for each destination.
Definition dsr-rcache.h:457
bool AddRoute_Link(DsrRouteCacheEntry::IP_VECTOR nodelist, Ipv4Address node)
dd route link to cache
Time m_badLinkLifetime
The time for which the neighboring node is put into the blacklist.
Definition dsr-rcache.h:757
uint32_t m_maxCacheLen
The maximum number of packets that we allow a routing protocol to buffer.
Definition dsr-rcache.h:753
std::vector< Ptr< ArpCache > > m_arp
list of ARP cached to be used for layer 2 notifications processing
Definition dsr-rcache.h:873
Mac48Address LookupMacAddress(Ipv4Address addr)
Find MAC address by IP using list of ARP caches.
Callback< void, Ipv4Address, uint8_t > GetCallback() const
Handle link failure callback.
Definition dsr-rcache.h:745
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,...
void PurgeMac()
Remove all expired mac entries.
bool FindSameRoute(DsrRouteCacheEntry &rt, std::list< DsrRouteCacheEntry > &rtVector)
Find the same route in the route cache.
void Clear()
Delete all entries from routing table.
Definition dsr-rcache.h:626
std::map< Ipv4Address, routeEntryVector > m_sortedRoutes
Map the ipv4Address to route entry vector.
Definition dsr-rcache.h:772
Time GetMinLifeTime() const
Get minimum lifetime.
Definition dsr-rcache.h:538
DsrRouteCacheEntry::IP_VECTOR m_vector
The route vector to save the ip addresses for intermediate nodes.
Definition dsr-rcache.h:752
void ClearMac()
Remove all entries.
Definition dsr-rcache.h:716
void SetUseExtends(Time useExtends)
Set use extends.
Definition dsr-rcache.h:565
Time GetUseExtends() const
Get use extends.
Definition dsr-rcache.h:556
void PrintVector(std::vector< Ipv4Address > &vec)
Print the route vector elements.
bool m_isLinkCache
Check if the route is using path cache or link cache.
Definition dsr-rcache.h:780
Time m_delay
This timeout deals with the passive ack.
Definition dsr-rcache.h:875
bool DeleteRoute(Ipv4Address dst)
Delete the route with certain destination address.
bool IncStability(Ipv4Address node)
increase the stability of the node
void PrintRouteVector(std::list< DsrRouteCacheEntry > route)
Print all the route vector elements from the route list.
uint32_t m_maxEntriesEachDst
number of entries for each destination
Definition dsr-rcache.h:776
Time GetExpireTime(Ipv4Address addr)
Return expire time for neighbor node with address addr, if exists, else return 0.
Time m_useExtends
use extend
Definition dsr-rcache.h:765
std::vector< Neighbor > m_nb
vector of entries
Definition dsr-rcache.h:870
uint32_t GetMaxCacheLen() const
Get the max queue length.
Definition dsr-rcache.h:412
Time m_minLifeTime
minimum lifetime
Definition dsr-rcache.h:764
void DelArpCache(Ptr< ArpCache >)
Don't use the provided ARP cache any more (interface is down)
void SetSubRoute(bool subRoute)
Set subroute indicator.
Definition dsr-rcache.h:403
void Print(std::ostream &os)
Print route cache.
void SetCacheTimeout(Time t)
Set cache timeout value.
Definition dsr-rcache.h:439
bool LookupRoute_Link(Ipv4Address id, DsrRouteCacheEntry &rt)
used by LookupRoute when LinkCache
void SetStabilityIncrFactor(uint64_t incrFactor)
Set stability increase factor.
Definition dsr-rcache.h:511
bool UpdateRouteEntry(Ipv4Address dst)
Update route cache entry if it has been recently used and successfully delivered the data packet.
void UpdateNeighbor(std::vector< Ipv4Address > nodeList, Time expire)
Update expire time for entry with address addr, if it exists, else add new entry.
void RemoveLastEntry(std::list< DsrRouteCacheEntry > &rtVector)
Remove the aged route cache entries when the route cache is full.
void SetCallback(Callback< void, Ipv4Address, uint8_t > cb)
Handle link failure callback.
Definition dsr-rcache.h:736
Timer m_ntimer
Timer for neighbor's list. Schedule Purge().
Definition dsr-rcache.h:868
DsrRouteCache & operator=(const DsrRouteCache &)=delete
bool m_subRoute
Check if save the sub route entries or not.
Definition dsr-rcache.h:782
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...
bool IsNeighbor(Ipv4Address addr)
Check that node with address addr is neighbor.
std::map< Ipv4Address, DsrRouteCacheEntry::IP_VECTOR > m_bestRoutesTable_link
for link route cache
Definition dsr-rcache.h:796
bool DecStability(Ipv4Address node)
decrease the stability of the node
void UpdateNetGraph()
Update the Net Graph for the link and node cache has changed.
bool AddRoute(DsrRouteCacheEntry &rt)
Add route cache entry if it doesn't yet exist in route cache.
void AddNeighbor(std::vector< Ipv4Address > nodeList, Ipv4Address ownAddress, Time expire)
Add to the neighbor list.
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Definition nstime.h:828
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Structure to manage neighbor state.
Definition dsr-rcache.h:653
Mac48Address m_hardwareAddress
neighbor MAC address
Definition dsr-rcache.h:655
Neighbor(Ipv4Address ip, Mac48Address mac, Time t)
Constructor.
Definition dsr-rcache.h:666
Ipv4Address m_neighborAddress
neighbor address
Definition dsr-rcache.h:654
Time m_expireTime
route expire time
Definition dsr-rcache.h:656