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