A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::dsr::DsrRouteCache Class Reference

DSR route request queue Since DSR is an on demand routing we queue requests while looking for route. More...

#include "dsr-rcache.h"

+ Inheritance diagram for ns3::dsr::DsrRouteCache:
+ Collaboration diagram for ns3::dsr::DsrRouteCache:

Classes

struct  Neighbor
 Structure to manage neighbor state. More...
 

Public Types

typedef std::list< DsrRouteCacheEntry::IP_VECTORrouteVector
 Define the vector of route entries.
 

Public Member Functions

 DsrRouteCache ()
 
 ~DsrRouteCache () override
 
void AddArpCache (Ptr< ArpCache > a)
 Add ARP cache to be used to allow layer 2 notifications processing.
 
void AddNeighbor (std::vector< Ipv4Address > nodeList, Ipv4Address ownAddress, Time expire)
 Add to the neighbor list.
 
bool AddRoute (DsrRouteCacheEntry &rt)
 Add route cache entry if it doesn't yet exist in route cache.
 
bool AddRoute_Link (DsrRouteCacheEntry::IP_VECTOR nodelist, Ipv4Address node)
 dd route link to cache
 
uint16_t CheckUniqueAckId (Ipv4Address nextHop)
 Check for duplicate ids and save new entries if the id is not present in the table.
 
void Clear ()
 Delete all entries from routing table.
 
void ClearMac ()
 Remove all entries.
 
void DelArpCache (Ptr< ArpCache >)
 Don't use the provided ARP cache any more (interface is down)
 
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 unreachable.
 
bool DeleteRoute (Ipv4Address dst)
 Delete the route with certain destination address.
 
bool FindSameRoute (DsrRouteCacheEntry &rt, std::list< DsrRouteCacheEntry > &rtVector)
 Find the same route in the route cache.
 
uint16_t GetAckSize ()
 Get the ack table size.
 
Time GetBadLinkLifetime () const
 Get bad link lifetime function.
 
Time GetCacheTimeout () const
 Get cache timeout value.
 
Callback< void, Ipv4Address, uint8_t > GetCallback () const
 Handle link failure callback.
 
Time GetExpireTime (Ipv4Address addr)
 Return expire time for neighbor node with address addr, if exists, else return 0.
 
Time GetInitStability () const
 Get initial stability.
 
uint32_t GetMaxCacheLen () const
 Get the max queue length.
 
uint32_t GetMaxEntriesEachDst () const
 Get max entries for each destination.
 
Time GetMinLifeTime () const
 Get minimum lifetime.
 
uint64_t GetStabilityDecrFactor () const
 Get stability decrease factor.
 
uint64_t GetStabilityIncrFactor () const
 Get stability increase factor.
 
bool GetSubRoute () const
 Get subroute indicator.
 
Time GetUseExtends () const
 Get use extends.
 
bool IsLinkCache ()
 is link cached
 
bool IsNeighbor (Ipv4Address addr)
 Check that node with address addr is neighbor.
 
Mac48Address LookupMacAddress (Ipv4Address addr)
 Find MAC address by IP using list of ARP caches.
 
bool LookupRoute (Ipv4Address id, DsrRouteCacheEntry &rt)
 Lookup route cache entry with destination address dst.
 
DsrRouteCacheoperator= (const DsrRouteCache &)=delete
 
void Print (std::ostream &os)
 Print route cache.
 
void PrintRouteVector (std::list< DsrRouteCacheEntry > route)
 Print all the route vector elements from the route list.
 
void PrintVector (std::vector< Ipv4Address > &vec)
 Print the route vector elements.
 
void ProcessTxError (const WifiMacHeader &hdr)
 Process layer 2 TX error notification.
 
void Purge ()
 Delete all outdated entries and invalidate valid entry if Lifetime is expired.
 
void PurgeLinkNode ()
 Purge from the cache if the stability time expired.
 
void PurgeMac ()
 Remove all expired mac entries.
 
void RebuildBestRouteTable (Ipv4Address source)
 Rebuild the best route table.
 
void RemoveLastEntry (std::list< DsrRouteCacheEntry > &rtVector)
 Remove the aged route cache entries when the route cache is full.
 
void ScheduleTimer ()
 Schedule m_ntimer.
 
void SetBadLinkLifetime (Time t)
 Set bad link lifetime function.
 
void SetCacheTimeout (Time t)
 Set cache timeout value.
 
void SetCacheType (std::string type)
 Dijsktra algorithm to get the best route from m_netGraph and update the m_bestRoutesTable_link when current graph information has changed.
 
void SetCallback (Callback< void, Ipv4Address, uint8_t > cb)
 Handle link failure callback.
 
void SetInitStability (Time initStability)
 Set initial stability.
 
void SetMaxCacheLen (uint32_t len)
 Set the max queue length.
 
void SetMaxEntriesEachDst (uint32_t entries)
 Set max entries for each destination.
 
void SetMinLifeTime (Time minLifeTime)
 Set minimum lifetime.
 
void SetStabilityDecrFactor (uint64_t decrFactor)
 Set stability decrease factor.
 
void SetStabilityIncrFactor (uint64_t incrFactor)
 Set stability increase factor.
 
void SetSubRoute (bool subRoute)
 Set subroute indicator.
 
void SetUseExtends (Time useExtends)
 Set use extends.
 
void UpdateNeighbor (std::vector< Ipv4Address > nodeList, Time expire)
 Update expire time for entry with address addr, if it exists, else add new entry.
 
void UpdateNetGraph ()
 Update the Net Graph for the link and node cache has changed.
 
bool UpdateRouteEntry (Ipv4Address dst)
 Update route cache entry if it has been recently used and successfully delivered the data packet.
 
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, the stability metric for each of the two endpoint nodes of that link is incremented by the amount of time since that link was last used.
 
- Public Member Functions inherited from ns3::Object
 Object ()
 Constructor.
 
 ~Object () override
 Destructor.
 
void AggregateObject (Ptr< Object > other)
 Aggregate two Objects together.
 
void Dispose ()
 Dispose of this Object.
 
AggregateIterator GetAggregateIterator () const
 Get an iterator to the Objects aggregated to this one.
 
TypeId GetInstanceTypeId () const override
 Get the most derived TypeId for this Object.
 
template<typename T >
Ptr< T > GetObject () const
 Get a pointer to the requested aggregated Object.
 
template<>
Ptr< ObjectGetObject () const
 Specialization of () for objects of type ns3::Object.
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 Get a pointer to the requested aggregated Object by TypeId.
 
template<>
Ptr< ObjectGetObject (TypeId tid) const
 Specialization of (TypeId tid) for objects of type ns3::Object.
 
void Initialize ()
 Invoke DoInitialize on all Objects aggregated to this one.
 
bool IsInitialized () const
 Check if the object has been initialized.
 
void UnidirectionalAggregateObject (Ptr< Object > other)
 Aggregate an Object to another Object.
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 Default constructor.
 
 SimpleRefCount (const SimpleRefCount &o)
 Copy constructor.
 
uint32_t GetReferenceCount () const
 Get the reference count of the object.
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 Assignment operator.
 
void Ref () const
 Increment the reference count.
 
void Unref () const
 Decrement the reference count.
 
- Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
 Virtual destructor.
 
void GetAttribute (std::string name, AttributeValue &value, bool permissive=false) const
 Get the value of an attribute, raising fatal errors if unsuccessful.
 
bool GetAttributeFailSafe (std::string name, AttributeValue &value) const
 Get the value of an attribute without raising errors.
 
void SetAttribute (std::string name, const AttributeValue &value)
 Set a single attribute, raising fatal errors if unsuccessful.
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 Set a single attribute without raising errors.
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 Connect a TraceSource to a Callback with a context.
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 Connect a TraceSource to a Callback without a context.
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected with a context.
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected without a context.
 

Static Public Member Functions

static TypeId GetTypeId ()
 Get the type ID.
 
- Static Public Member Functions inherited from ns3::Object
static TypeId GetTypeId ()
 Register this type.
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId ()
 Get the type ID.
 

Public Attributes

std::vector< Ptr< ArpCache > > m_arp
 list of ARP cached to be used for layer 2 notifications processing
 
Time m_delay
 This timeout deals with the passive ack.
 
Callback< void, Ipv4Address, uint8_t > m_handleLinkFailure
 The following code handles link-layer acks.
 
std::vector< Neighborm_nb
 vector of entries
 
Timer m_ntimer
 Timer for neighbor's list. Schedule Purge().
 

Private Types

typedef std::list< DsrRouteCacheEntryrouteEntryVector
 Define the route cache data structure.
 

Private Member Functions

bool DecStability (Ipv4Address node)
 decrease the stability of the node
 
bool IncStability (Ipv4Address node)
 increase the stability of the node
 
bool LookupRoute_Link (Ipv4Address id, DsrRouteCacheEntry &rt)
 used by LookupRoute when LinkCache
 

Private Attributes

std::map< Ipv4Address, uint16_t > m_ackIdCache
 The id cache to ensure all the ids are unique.
 
Time m_badLinkLifetime
 The time for which the neighboring node is put into the blacklist.
 
std::map< Ipv4Address, DsrRouteCacheEntry::IP_VECTORm_bestRoutesTable_link
 for link route cache
 
Time m_initStability
 initial stability
 
bool m_isLinkCache
 Check if the route is using path cache or link cache.
 
std::map< Link, DsrLinkStabm_linkCache
 The data structure to store link info.
 
uint32_t m_maxCacheLen
 The maximum number of packets that we allow a routing protocol to buffer.
 
uint32_t m_maxEntriesEachDst
 number of entries for each destination
 
Time m_minLifeTime
 minimum lifetime
 
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 information and link information, any time some changes of link cache and node cache change the weight and then recompute the best choice for each node.
 
std::map< Ipv4Address, DsrNodeStabm_nodeCache
 The data structure to store node info.
 
routeEntryVector m_routeEntryVector
 Define the route vector.
 
std::map< Ipv4Address, routeEntryVectorm_sortedRoutes
 Map the ipv4Address to route entry vector.
 
uint32_t m_stabilityDecrFactor
 stability decrease factor
 
uint32_t m_stabilityIncrFactor
 stability increase factor
 
bool m_subRoute
 Check if save the sub route entries or not.
 
Time m_useExtends
 use extend
 
DsrRouteCacheEntry::IP_VECTOR m_vector
 The route vector to save the ip addresses for intermediate nodes.
 
Time RouteCacheTimeout
 The maximum period of time that dsr is allowed to for an unused route.
 

Additional Inherited Members

- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 Copy an Object.
 
virtual void DoDispose ()
 Destructor implementation.
 
virtual void DoInitialize ()
 Initialize() implementation.
 
virtual void NotifyNewAggregate ()
 Notify all Objects aggregated to this one of a new Object being aggregated.
 
- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 Complete construction of ObjectBase; invoked by derived classes.
 
virtual void NotifyConstructionCompleted ()
 Notifier called once the ObjectBase is fully constructed.
 

Detailed Description

DSR route request queue Since DSR is an on demand routing we queue requests while looking for route.

Config Paths

ns3::dsr::DsrRouteCache is accessible through the following paths with Config::Set and Config::Connect:

  • "/NodeList/[i]/$ns3::dsr::DsrRouting/RouteCache"

No Attributes are defined for this type.
No TraceSources are defined for this type.
Group: Dsr

Size of this type is 584 bytes (on a 64-bit architecture).

Definition at line 364 of file dsr-rcache.h.

Member Typedef Documentation

◆ routeEntryVector

Define the route cache data structure.

Definition at line 769 of file dsr-rcache.h.

◆ routeVector

Define the vector of route entries.

Definition at line 387 of file dsr-rcache.h.

Constructor & Destructor Documentation

◆ DsrRouteCache()

ns3::dsr::DsrRouteCache::DsrRouteCache ( )

Definition at line 144 of file dsr-rcache.cc.

References m_delay, m_ntimer, PurgeMac(), ns3::Timer::SetDelay(), and ns3::Timer::SetFunction().

+ Here is the call graph for this function:

◆ ~DsrRouteCache()

ns3::dsr::DsrRouteCache::~DsrRouteCache ( )
override

Definition at line 158 of file dsr-rcache.cc.

References m_sortedRoutes, and NS_LOG_FUNCTION_NOARGS.

Member Function Documentation

◆ AddArpCache()

void ns3::dsr::DsrRouteCache::AddArpCache ( Ptr< ArpCache > a)

Add ARP cache to be used to allow layer 2 notifications processing.

Parameters
aARP cache

Definition at line 1199 of file dsr-rcache.cc.

References m_arp.

◆ AddNeighbor()

void ns3::dsr::DsrRouteCache::AddNeighbor ( std::vector< Ipv4Address > nodeList,
Ipv4Address ownAddress,
Time expire )

Add to the neighbor list.

Parameters
nodeListneighbor list
ownAddresslocal address
expireexpiration time

Definition at line 1129 of file dsr-rcache.cc.

References LookupMacAddress(), m_nb, ns3::Simulator::Now(), NS_LOG_DEBUG, NS_LOG_LOGIC, and PurgeMac().

+ Here is the call graph for this function:

◆ AddRoute()

bool ns3::dsr::DsrRouteCache::AddRoute ( DsrRouteCacheEntry & rt)

Add route cache entry if it doesn't yet exist in route cache.

Parameters
rtroute cache entry
Returns
true on success

Save the new route cache along with the destination address in map

Drop the most aged packet when buffer reaches to max

Save the new route cache along with the destination address in map

Definition at line 646 of file dsr-rcache.cc.

References ns3::dsr::CompareRoutesExpire(), FindSameRoute(), ns3::dsr::DsrRouteCacheEntry::GetDestination(), ns3::dsr::DsrRouteCacheEntry::GetExpireTime(), ns3::dsr::DsrRouteCacheEntry::GetVector(), ns3::Time::IsStrictlyPositive(), m_maxEntriesEachDst, m_sortedRoutes, NS_LOG_DEBUG, NS_LOG_FUNCTION, NS_LOG_INFO, Purge(), RemoveLastEntry(), and ns3::Time::S.

+ Here is the call graph for this function:

◆ AddRoute_Link()

bool ns3::dsr::DsrRouteCache::AddRoute_Link ( DsrRouteCacheEntry::IP_VECTOR nodelist,
Ipv4Address node )

dd route link to cache

Parameters
nodelistvector of nodes
nodeip address of node to add
Returns
true if the link is cached

Purge the link node cache first

This is the node stability

Link represent the one link for the route

Link stability

Set the link stability as the smallest node stability

Set the link stability as the m)minLifeTime, default is 1 second

Definition at line 549 of file dsr-rcache.cc.

References ns3::Time::As(), ns3::dsr::DsrLinkStab::GetLinkStability(), m_initStability, m_linkCache, m_minLifeTime, m_nodeCache, NS_LOG_DEBUG, NS_LOG_FUNCTION, NS_LOG_LOGIC, ns3::dsr::DsrLinkStab::Print(), PurgeLinkNode(), RebuildBestRouteTable(), ns3::Time::S, ns3::dsr::DsrLinkStab::SetLinkStability(), ns3::dsr::DsrNodeStab::SetNodeStability(), and UpdateNetGraph().

+ Here is the call graph for this function:

◆ CheckUniqueAckId()

uint16_t ns3::dsr::DsrRouteCache::CheckUniqueAckId ( Ipv4Address nextHop)

Check for duplicate ids and save new entries if the id is not present in the table.

This part of code maintains an Acknowledgment id cache for next hop and remove duplicate ids.

Parameters
nextHopto check for in cache
Returns
ack ID

Definition at line 1042 of file dsr-rcache.cc.

References m_ackIdCache, NS_LOG_FUNCTION, and NS_LOG_LOGIC.

◆ Clear()

void ns3::dsr::DsrRouteCache::Clear ( )
inline

Delete all entries from routing table.

Definition at line 626 of file dsr-rcache.h.

References m_routeEntryVector.

◆ ClearMac()

void ns3::dsr::DsrRouteCache::ClearMac ( )
inline

Remove all entries.

Definition at line 716 of file dsr-rcache.h.

References m_nb.

◆ DecStability()

bool ns3::dsr::DsrRouteCache::DecStability ( Ipv4Address node)
private

decrease the stability of the node

Parameters
nodethe ip address of the node we want to decrease stability
Returns
true if success
Todo
remove it here

Definition at line 525 of file dsr-rcache.cc.

References ns3::Time::As(), m_initStability, m_nodeCache, m_stabilityDecrFactor, NS_LOG_FUNCTION, NS_LOG_INFO, and ns3::Time::S.

Referenced by DeleteAllRoutesIncludeLink().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DelArpCache()

void ns3::dsr::DsrRouteCache::DelArpCache ( Ptr< ArpCache > a)

Don't use the provided ARP cache any more (interface is down)

Parameters
aARP cache

Definition at line 1205 of file dsr-rcache.cc.

References m_arp.

◆ DeleteAllRoutesIncludeLink()

void ns3::dsr::DsrRouteCache::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 unreachable.

Parameters
errorSrcThe error source address
unreachNodeThe unreachable node
nodeThis node's ip address
Todo
get rid of this one

Definition at line 765 of file dsr-rcache.cc.

References ns3::dsr::CompareRoutesExpire(), DecStability(), IsLinkCache(), m_linkCache, m_nodeCache, m_sortedRoutes, m_subRoute, NS_LOG_DEBUG, NS_LOG_FUNCTION, NS_LOG_LOGIC, Purge(), PurgeLinkNode(), RebuildBestRouteTable(), ns3::dsr::DsrRouteCacheEntry::SetDestination(), ns3::dsr::DsrRouteCacheEntry::SetExpireTime(), ns3::dsr::DsrRouteCacheEntry::SetVector(), and UpdateNetGraph().

+ Here is the call graph for this function:

◆ DeleteRoute()

bool ns3::dsr::DsrRouteCache::DeleteRoute ( Ipv4Address dst)

Delete the route with certain destination address.

Parameters
dstthe destination address of the routes that should be deleted
Returns
true if the route was deleted

Definition at line 751 of file dsr-rcache.cc.

References m_sortedRoutes, NS_LOG_FUNCTION, NS_LOG_LOGIC, and Purge().

+ Here is the call graph for this function:

◆ FindSameRoute()

bool ns3::dsr::DsrRouteCache::FindSameRoute ( DsrRouteCacheEntry & rt,
std::list< DsrRouteCacheEntry > & rtVector )

Find the same route in the route cache.

Parameters
rtentry with destination address dst, if exists
rtVectorthe route vector
Returns
true if same

Definition at line 718 of file dsr-rcache.cc.

References ns3::Time::As(), ns3::dsr::CompareRoutesExpire(), ns3::dsr::DsrRouteCacheEntry::GetDestination(), ns3::dsr::DsrRouteCacheEntry::GetExpireTime(), ns3::dsr::DsrRouteCacheEntry::GetVector(), m_sortedRoutes, NS_LOG_DEBUG, NS_LOG_FUNCTION, and ns3::Time::S.

Referenced by AddRoute().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetAckSize()

uint16_t ns3::dsr::DsrRouteCache::GetAckSize ( )

Get the ack table size.

Returns
ack size

Definition at line 1062 of file dsr-rcache.cc.

References m_ackIdCache.

◆ GetBadLinkLifetime()

Time ns3::dsr::DsrRouteCache::GetBadLinkLifetime ( ) const
inline

Get bad link lifetime function.

Returns
the bad link lifetime

Definition at line 466 of file dsr-rcache.h.

References m_badLinkLifetime.

◆ GetCacheTimeout()

Time ns3::dsr::DsrRouteCache::GetCacheTimeout ( ) const
inline

Get cache timeout value.

Returns
the cache timeout time

Definition at line 430 of file dsr-rcache.h.

References RouteCacheTimeout.

◆ GetCallback()

Callback< void, Ipv4Address, uint8_t > ns3::dsr::DsrRouteCache::GetCallback ( ) const
inline

Handle link failure callback.

Returns
The callback to LinkFailure

Definition at line 745 of file dsr-rcache.h.

References m_handleLinkFailure.

◆ GetExpireTime()

Time ns3::dsr::DsrRouteCache::GetExpireTime ( Ipv4Address addr)

Return expire time for neighbor node with address addr, if exists, else return 0.

Parameters
addrIP address
Returns
expire time

Definition at line 1087 of file dsr-rcache.cc.

References m_nb, ns3::Simulator::Now(), NS_LOG_FUNCTION, PurgeMac(), and ns3::Seconds().

+ Here is the call graph for this function:

◆ GetInitStability()

Time ns3::dsr::DsrRouteCache::GetInitStability ( ) const
inline

Get initial stability.

Returns
the initial stability

Definition at line 520 of file dsr-rcache.h.

References m_initStability.

◆ GetMaxCacheLen()

uint32_t ns3::dsr::DsrRouteCache::GetMaxCacheLen ( ) const
inline

Get the max queue length.

Returns
the maximum queue length

Definition at line 412 of file dsr-rcache.h.

References m_maxCacheLen.

◆ GetMaxEntriesEachDst()

uint32_t ns3::dsr::DsrRouteCache::GetMaxEntriesEachDst ( ) const
inline

Get max entries for each destination.

Returns
the maximum entries for each destination

Definition at line 448 of file dsr-rcache.h.

References m_maxEntriesEachDst.

◆ GetMinLifeTime()

Time ns3::dsr::DsrRouteCache::GetMinLifeTime ( ) const
inline

Get minimum lifetime.

Returns
the minimum lifetime

Definition at line 538 of file dsr-rcache.h.

References m_minLifeTime.

◆ GetStabilityDecrFactor()

uint64_t ns3::dsr::DsrRouteCache::GetStabilityDecrFactor ( ) const
inline

Get stability decrease factor.

Returns
the stability decrease factor

Definition at line 484 of file dsr-rcache.h.

References m_stabilityDecrFactor.

◆ GetStabilityIncrFactor()

uint64_t ns3::dsr::DsrRouteCache::GetStabilityIncrFactor ( ) const
inline

Get stability increase factor.

Returns
the stability increase factor

Definition at line 502 of file dsr-rcache.h.

References m_stabilityIncrFactor.

◆ GetSubRoute()

bool ns3::dsr::DsrRouteCache::GetSubRoute ( ) const
inline

Get subroute indicator.

Returns
true if a subroute exists

Definition at line 394 of file dsr-rcache.h.

References m_subRoute.

◆ GetTypeId()

TypeId ns3::dsr::DsrRouteCache::GetTypeId ( )
static

Get the type ID.

Returns
the object TypeId

Definition at line 135 of file dsr-rcache.cc.

References ns3::TypeId::SetParent().

+ Here is the call graph for this function:

◆ GetUseExtends()

Time ns3::dsr::DsrRouteCache::GetUseExtends ( ) const
inline

Get use extends.

Returns
the use extends time

Definition at line 556 of file dsr-rcache.h.

References m_useExtends.

◆ IncStability()

bool ns3::dsr::DsrRouteCache::IncStability ( Ipv4Address node)
private

increase the stability of the node

Parameters
nodethe ip address of the node we want to increase stability
Returns
true if success
Todo
get rid of the debug here

Definition at line 500 of file dsr-rcache.cc.

References ns3::Time::As(), m_initStability, m_nodeCache, m_stabilityIncrFactor, NS_LOG_FUNCTION, NS_LOG_INFO, and ns3::Time::S.

Referenced by UseExtends().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsLinkCache()

bool ns3::dsr::DsrRouteCache::IsLinkCache ( )

is link cached

Returns
true if the link is cached

Definition at line 300 of file dsr-rcache.cc.

References m_isLinkCache, and NS_LOG_FUNCTION.

Referenced by DeleteAllRoutesIncludeLink(), and LookupRoute().

+ Here is the caller graph for this function:

◆ IsNeighbor()

bool ns3::dsr::DsrRouteCache::IsNeighbor ( Ipv4Address addr)

Check that node with address addr is neighbor.

This part maintains a neighbor list to handle unidirectional links and link-layer acks.

Parameters
addrIP address
Returns
true if neighbor

Definition at line 1072 of file dsr-rcache.cc.

References m_nb, NS_LOG_FUNCTION, and PurgeMac().

+ Here is the call graph for this function:

◆ LookupMacAddress()

Mac48Address ns3::dsr::DsrRouteCache::LookupMacAddress ( Ipv4Address addr)

Find MAC address by IP using list of ARP caches.

Parameters
addrthe IPv4 address to look for
Returns
The MAC address

Definition at line 1211 of file dsr-rcache.cc.

References ns3::Mac48Address::ConvertFrom(), ns3::ArpCache::Entry::GetMacAddress(), ns3::ArpCache::Entry::IsAlive(), ns3::ArpCache::Entry::IsExpired(), ns3::ArpCache::Entry::IsPermanent(), and m_arp.

Referenced by AddNeighbor(), and UpdateNeighbor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LookupRoute()

bool ns3::dsr::DsrRouteCache::LookupRoute ( Ipv4Address id,
DsrRouteCacheEntry & rt )

Lookup route cache entry with destination address dst.

Parameters
iddestination address
rtentry with destination address id, if exists
Returns
true on success

Definition at line 202 of file dsr-rcache.cc.

References ns3::dsr::CompareRoutesExpire(), IsLinkCache(), LookupRoute_Link(), m_sortedRoutes, NS_LOG_FUNCTION, NS_LOG_INFO, NS_LOG_LOGIC, Purge(), ns3::dsr::DsrRouteCacheEntry::SetDestination(), ns3::dsr::DsrRouteCacheEntry::SetExpireTime(), and ns3::dsr::DsrRouteCacheEntry::SetVector().

+ Here is the call graph for this function:

◆ LookupRoute_Link()

bool ns3::dsr::DsrRouteCache::LookupRoute_Link ( Ipv4Address id,
DsrRouteCacheEntry & rt )
private

used by LookupRoute when LinkCache

Parameters
idthe ip address we are looking for
rtthe route cache entry to store the found one
Returns
true if route route found

We need to purge the link node cache

Definition at line 420 of file dsr-rcache.cc.

References ns3::dsr::DsrRouteCacheEntry::GetVector(), m_bestRoutesTable_link, NS_LOG_FUNCTION, NS_LOG_INFO, NS_LOG_LOGIC, PrintVector(), PurgeLinkNode(), RouteCacheTimeout, ns3::dsr::DsrRouteCacheEntry::SetDestination(), ns3::dsr::DsrRouteCacheEntry::SetExpireTime(), and ns3::dsr::DsrRouteCacheEntry::SetVector().

Referenced by LookupRoute().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator=()

DsrRouteCache & ns3::dsr::DsrRouteCache::operator= ( const DsrRouteCache & )
delete

◆ Print()

void ns3::dsr::DsrRouteCache::Print ( std::ostream & os)

Print route cache.

Parameters
osthe output stream

Definition at line 1024 of file dsr-rcache.cc.

References m_routeEntryVector, NS_LOG_FUNCTION, and Purge().

+ Here is the call graph for this function:

◆ PrintRouteVector()

void ns3::dsr::DsrRouteCache::PrintRouteVector ( std::list< DsrRouteCacheEntry > route)

Print all the route vector elements from the route list.

Parameters
routethe route list

Definition at line 945 of file dsr-rcache.cc.

References NS_LOG_FUNCTION, NS_LOG_INFO, and PrintVector().

+ Here is the call graph for this function:

◆ PrintVector()

void ns3::dsr::DsrRouteCache::PrintVector ( std::vector< Ipv4Address > & vec)

Print the route vector elements.

Parameters
vecthe route vector

Definition at line 924 of file dsr-rcache.cc.

References NS_LOG_DEBUG, and NS_LOG_FUNCTION.

Referenced by LookupRoute_Link(), PrintRouteVector(), and RebuildBestRouteTable().

+ Here is the caller graph for this function:

◆ ProcessTxError()

void ns3::dsr::DsrRouteCache::ProcessTxError ( const WifiMacHeader & hdr)

Process layer 2 TX error notification.

Parameters
hdrWi-Fi Mac Header

Definition at line 1227 of file dsr-rcache.cc.

References ns3::WifiMacHeader::GetAddr1(), m_nb, and PurgeMac().

+ Here is the call graph for this function:

◆ Purge()

void ns3::dsr::DsrRouteCache::Purge ( )

Delete all outdated entries and invalidate valid entry if Lifetime is expired.

Definition at line 957 of file dsr-rcache.cc.

References m_sortedRoutes, NS_LOG_DEBUG, and NS_LOG_FUNCTION.

Referenced by AddRoute(), DeleteAllRoutesIncludeLink(), DeleteRoute(), LookupRoute(), and Print().

+ Here is the caller graph for this function:

◆ PurgeLinkNode()

void ns3::dsr::DsrRouteCache::PurgeLinkNode ( )

Purge from the cache if the stability time expired.

may need to remove them after verify

Definition at line 450 of file dsr-rcache.cc.

References m_linkCache, m_nodeCache, NS_LOG_DEBUG, NS_LOG_FUNCTION, and ns3::Time::S.

Referenced by AddRoute_Link(), DeleteAllRoutesIncludeLink(), LookupRoute_Link(), and UseExtends().

+ Here is the caller graph for this function:

◆ PurgeMac()

void ns3::dsr::DsrRouteCache::PurgeMac ( )

Remove all expired mac entries.

Todo
disable temporarily

Definition at line 1166 of file dsr-rcache.cc.

References ns3::Timer::Cancel(), m_handleLinkFailure, m_nb, m_ntimer, NS_LOG_LOGIC, and ns3::Timer::Schedule().

Referenced by DsrRouteCache(), AddNeighbor(), GetExpireTime(), IsNeighbor(), ProcessTxError(), and UpdateNeighbor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RebuildBestRouteTable()

void ns3::dsr::DsrRouteCache::RebuildBestRouteTable ( Ipv4Address source)

Rebuild the best route table.

Note
Use MAXWEIGHT to represent maximum weight, use the IPv4 broadcast address of 255.255.255.255 to represent a null preceding address
Parameters
sourceThe source address used for computing the routes

The following are initialize-single-source

The following is the core of Dijkstra algorithm

Definition at line 307 of file dsr-rcache.cc.

References ns3::Ipv4Address::IsBroadcast(), m_bestRoutesTable_link, m_linkCache, m_netGraph, MAXWEIGHT, NS_LOG_FUNCTION, NS_LOG_INFO, NS_LOG_LOGIC, and PrintVector().

Referenced by AddRoute_Link(), and DeleteAllRoutesIncludeLink().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RemoveLastEntry()

void ns3::dsr::DsrRouteCache::RemoveLastEntry ( std::list< DsrRouteCacheEntry > & rtVector)

Remove the aged route cache entries when the route cache is full.

Parameters
rtVectorthe route cache to scan.

Definition at line 166 of file dsr-rcache.cc.

References NS_LOG_FUNCTION.

Referenced by AddRoute().

+ Here is the caller graph for this function:

◆ ScheduleTimer()

void ns3::dsr::DsrRouteCache::ScheduleTimer ( )

Schedule m_ntimer.

Definition at line 1192 of file dsr-rcache.cc.

References ns3::Timer::Cancel(), m_ntimer, and ns3::Timer::Schedule().

+ Here is the call graph for this function:

◆ SetBadLinkLifetime()

void ns3::dsr::DsrRouteCache::SetBadLinkLifetime ( Time t)
inline

Set bad link lifetime function.

Parameters
tthe bad link lifetime

Definition at line 475 of file dsr-rcache.h.

References m_badLinkLifetime.

◆ SetCacheTimeout()

void ns3::dsr::DsrRouteCache::SetCacheTimeout ( Time t)
inline

Set cache timeout value.

Parameters
tthe cache timeout time

Definition at line 439 of file dsr-rcache.h.

References RouteCacheTimeout.

◆ SetCacheType()

void ns3::dsr::DsrRouteCache::SetCacheType ( std::string type)

Dijsktra algorithm to get the best route from m_netGraph and update the m_bestRoutesTable_link when current graph information has changed.

Parameters
typeThe type of the cache

Definition at line 281 of file dsr-rcache.cc.

References m_isLinkCache, NS_LOG_FUNCTION, and NS_LOG_INFO.

◆ SetCallback()

void ns3::dsr::DsrRouteCache::SetCallback ( Callback< void, Ipv4Address, uint8_t > cb)
inline

Handle link failure callback.

Parameters
cbthe callback to be set

Definition at line 736 of file dsr-rcache.h.

References m_handleLinkFailure.

◆ SetInitStability()

void ns3::dsr::DsrRouteCache::SetInitStability ( Time initStability)
inline

Set initial stability.

Parameters
initStabilitythe initial stability

Definition at line 529 of file dsr-rcache.h.

References m_initStability.

◆ SetMaxCacheLen()

void ns3::dsr::DsrRouteCache::SetMaxCacheLen ( uint32_t len)
inline

Set the max queue length.

Parameters
lenthe maximum queue length

Definition at line 421 of file dsr-rcache.h.

References m_maxCacheLen.

◆ SetMaxEntriesEachDst()

void ns3::dsr::DsrRouteCache::SetMaxEntriesEachDst ( uint32_t entries)
inline

Set max entries for each destination.

Parameters
entriesthe maximum entries for each destination

Definition at line 457 of file dsr-rcache.h.

References m_maxEntriesEachDst.

◆ SetMinLifeTime()

void ns3::dsr::DsrRouteCache::SetMinLifeTime ( Time minLifeTime)
inline

Set minimum lifetime.

Parameters
minLifeTimethe minimum lifetime

Definition at line 547 of file dsr-rcache.h.

References m_minLifeTime.

◆ SetStabilityDecrFactor()

void ns3::dsr::DsrRouteCache::SetStabilityDecrFactor ( uint64_t decrFactor)
inline

Set stability decrease factor.

Parameters
decrFactorthe stability decrease factor

Definition at line 493 of file dsr-rcache.h.

References m_stabilityDecrFactor.

◆ SetStabilityIncrFactor()

void ns3::dsr::DsrRouteCache::SetStabilityIncrFactor ( uint64_t incrFactor)
inline

Set stability increase factor.

Parameters
incrFactorthe stability increase factor

Definition at line 511 of file dsr-rcache.h.

References m_stabilityIncrFactor.

◆ SetSubRoute()

void ns3::dsr::DsrRouteCache::SetSubRoute ( bool subRoute)
inline

Set subroute indicator.

Parameters
subRoutethe subroute indicator

Definition at line 403 of file dsr-rcache.h.

References m_subRoute.

◆ SetUseExtends()

void ns3::dsr::DsrRouteCache::SetUseExtends ( Time useExtends)
inline

Set use extends.

Parameters
useExtendsthe use extends time

Definition at line 565 of file dsr-rcache.h.

References m_useExtends.

◆ UpdateNeighbor()

void ns3::dsr::DsrRouteCache::UpdateNeighbor ( std::vector< Ipv4Address > nodeList,
Time expire )

Update expire time for entry with address addr, if it exists, else add new entry.

Parameters
nodeListlist of addresses
expireexpiration time

Definition at line 1102 of file dsr-rcache.cc.

References LookupMacAddress(), m_nb, ns3::Simulator::Now(), NS_LOG_FUNCTION, NS_LOG_LOGIC, and PurgeMac().

+ Here is the call graph for this function:

◆ UpdateNetGraph()

void ns3::dsr::DsrRouteCache::UpdateNetGraph ( )

Update the Net Graph for the link and node cache has changed.

Todo
May need to set different weight for different link here later

Definition at line 485 of file dsr-rcache.cc.

References m_linkCache, m_netGraph, and NS_LOG_FUNCTION.

Referenced by AddRoute_Link(), and DeleteAllRoutesIncludeLink().

+ Here is the caller graph for this function:

◆ UpdateRouteEntry()

bool ns3::dsr::DsrRouteCache::UpdateRouteEntry ( Ipv4Address dst)

Update route cache entry if it has been recently used and successfully delivered the data packet.

Parameters
dstdestination address of the route
Returns
true in success

Definition at line 174 of file dsr-rcache.cc.

References ns3::dsr::CompareRoutesExpire(), m_sortedRoutes, NS_LOG_FUNCTION, NS_LOG_LOGIC, RouteCacheTimeout, and ns3::dsr::DsrRouteCacheEntry::SetExpireTime().

+ Here is the call graph for this function:

◆ UseExtends()

void ns3::dsr::DsrRouteCache::UseExtends ( DsrRouteCacheEntry::IP_VECTOR rt)

When a link from the Route Cache is used in routing a packet originated or salvaged by that node, the stability metric for each of the two endpoint nodes of that link is incremented by the amount of time since that link was last used.

When a link is used in a route chosen for a packet originated or salvaged by this node, the link's lifetime is set to be at least UseExtends into the future

Parameters
rtcache entry

Purge the link node cache first

Todo
remove after debug

Increase the stability of the node cache

Definition at line 599 of file dsr-rcache.cc.

References IncStability(), m_initStability, m_linkCache, m_nodeCache, m_useExtends, NS_LOG_FUNCTION, NS_LOG_INFO, NS_LOG_LOGIC, PurgeLinkNode(), and ns3::Time::S.

+ Here is the call graph for this function:

Member Data Documentation

◆ m_ackIdCache

std::map<Ipv4Address, uint16_t> ns3::dsr::DsrRouteCache::m_ackIdCache
private

The id cache to ensure all the ids are unique.

Definition at line 778 of file dsr-rcache.h.

Referenced by CheckUniqueAckId(), and GetAckSize().

◆ m_arp

std::vector<Ptr<ArpCache> > ns3::dsr::DsrRouteCache::m_arp

list of ARP cached to be used for layer 2 notifications processing

Definition at line 873 of file dsr-rcache.h.

Referenced by AddArpCache(), DelArpCache(), and LookupMacAddress().

◆ m_badLinkLifetime

Time ns3::dsr::DsrRouteCache::m_badLinkLifetime
private

The time for which the neighboring node is put into the blacklist.

Definition at line 757 of file dsr-rcache.h.

Referenced by GetBadLinkLifetime(), and SetBadLinkLifetime().

◆ m_bestRoutesTable_link

std::map<Ipv4Address, DsrRouteCacheEntry::IP_VECTOR> ns3::dsr::DsrRouteCache::m_bestRoutesTable_link
private

for link route cache

Definition at line 796 of file dsr-rcache.h.

Referenced by LookupRoute_Link(), and RebuildBestRouteTable().

◆ m_delay

Time ns3::dsr::DsrRouteCache::m_delay

This timeout deals with the passive ack.

Definition at line 875 of file dsr-rcache.h.

Referenced by DsrRouteCache().

◆ m_handleLinkFailure

Callback<void, Ipv4Address, uint8_t> ns3::dsr::DsrRouteCache::m_handleLinkFailure

The following code handles link-layer acks.

link failure callback

Definition at line 866 of file dsr-rcache.h.

Referenced by GetCallback(), PurgeMac(), and SetCallback().

◆ m_initStability

Time ns3::dsr::DsrRouteCache::m_initStability
private

initial stability

Definition at line 763 of file dsr-rcache.h.

Referenced by AddRoute_Link(), DecStability(), GetInitStability(), IncStability(), SetInitStability(), and UseExtends().

◆ m_isLinkCache

bool ns3::dsr::DsrRouteCache::m_isLinkCache
private

Check if the route is using path cache or link cache.

Definition at line 780 of file dsr-rcache.h.

Referenced by IsLinkCache(), and SetCacheType().

◆ m_linkCache

std::map<Link, DsrLinkStab> ns3::dsr::DsrRouteCache::m_linkCache
private

The data structure to store link info.

Definition at line 797 of file dsr-rcache.h.

Referenced by AddRoute_Link(), DeleteAllRoutesIncludeLink(), PurgeLinkNode(), RebuildBestRouteTable(), UpdateNetGraph(), and UseExtends().

◆ m_maxCacheLen

uint32_t ns3::dsr::DsrRouteCache::m_maxCacheLen
private

The maximum number of packets that we allow a routing protocol to buffer.

Definition at line 753 of file dsr-rcache.h.

Referenced by GetMaxCacheLen(), and SetMaxCacheLen().

◆ m_maxEntriesEachDst

uint32_t ns3::dsr::DsrRouteCache::m_maxEntriesEachDst
private

number of entries for each destination

Definition at line 776 of file dsr-rcache.h.

Referenced by AddRoute(), GetMaxEntriesEachDst(), and SetMaxEntriesEachDst().

◆ m_minLifeTime

Time ns3::dsr::DsrRouteCache::m_minLifeTime
private

minimum lifetime

Definition at line 764 of file dsr-rcache.h.

Referenced by AddRoute_Link(), GetMinLifeTime(), and SetMinLifeTime().

◆ m_nb

std::vector<Neighbor> ns3::dsr::DsrRouteCache::m_nb

vector of entries

Definition at line 870 of file dsr-rcache.h.

Referenced by AddNeighbor(), ClearMac(), GetExpireTime(), IsNeighbor(), ProcessTxError(), PurgeMac(), and UpdateNeighbor().

◆ m_netGraph

std::map<Ipv4Address, std::map<Ipv4Address, uint32_t> > ns3::dsr::DsrRouteCache::m_netGraph
private

Current network graph state for this node, double is weight, which is calculated by the node information and link information, any time some changes of link cache and node cache change the weight and then recompute the best choice for each node.

Definition at line 793 of file dsr-rcache.h.

Referenced by RebuildBestRouteTable(), and UpdateNetGraph().

◆ m_nodeCache

std::map<Ipv4Address, DsrNodeStab> ns3::dsr::DsrRouteCache::m_nodeCache
private

The data structure to store node info.

Definition at line 798 of file dsr-rcache.h.

Referenced by AddRoute_Link(), DecStability(), DeleteAllRoutesIncludeLink(), IncStability(), PurgeLinkNode(), and UseExtends().

◆ m_ntimer

Timer ns3::dsr::DsrRouteCache::m_ntimer

Timer for neighbor's list. Schedule Purge().

Definition at line 868 of file dsr-rcache.h.

Referenced by DsrRouteCache(), PurgeMac(), and ScheduleTimer().

◆ m_routeEntryVector

routeEntryVector ns3::dsr::DsrRouteCache::m_routeEntryVector
private

Define the route vector.

Definition at line 774 of file dsr-rcache.h.

Referenced by Clear(), and Print().

◆ m_sortedRoutes

std::map<Ipv4Address, routeEntryVector> ns3::dsr::DsrRouteCache::m_sortedRoutes
private

Map the ipv4Address to route entry vector.

Definition at line 772 of file dsr-rcache.h.

Referenced by ~DsrRouteCache(), AddRoute(), DeleteAllRoutesIncludeLink(), DeleteRoute(), FindSameRoute(), LookupRoute(), Purge(), and UpdateRouteEntry().

◆ m_stabilityDecrFactor

uint32_t ns3::dsr::DsrRouteCache::m_stabilityDecrFactor
private

stability decrease factor

Definition at line 761 of file dsr-rcache.h.

Referenced by DecStability(), GetStabilityDecrFactor(), and SetStabilityDecrFactor().

◆ m_stabilityIncrFactor

uint32_t ns3::dsr::DsrRouteCache::m_stabilityIncrFactor
private

stability increase factor

Definition at line 762 of file dsr-rcache.h.

Referenced by GetStabilityIncrFactor(), IncStability(), and SetStabilityIncrFactor().

◆ m_subRoute

bool ns3::dsr::DsrRouteCache::m_subRoute
private

Check if save the sub route entries or not.

Definition at line 782 of file dsr-rcache.h.

Referenced by DeleteAllRoutesIncludeLink(), GetSubRoute(), and SetSubRoute().

◆ m_useExtends

Time ns3::dsr::DsrRouteCache::m_useExtends
private

use extend

Definition at line 765 of file dsr-rcache.h.

Referenced by GetUseExtends(), SetUseExtends(), and UseExtends().

◆ m_vector

DsrRouteCacheEntry::IP_VECTOR ns3::dsr::DsrRouteCache::m_vector
private

The route vector to save the ip addresses for intermediate nodes.

Definition at line 752 of file dsr-rcache.h.

◆ RouteCacheTimeout

Time ns3::dsr::DsrRouteCache::RouteCacheTimeout
private

The maximum period of time that dsr is allowed to for an unused route.

Definition at line 755 of file dsr-rcache.h.

Referenced by GetCacheTimeout(), LookupRoute_Link(), SetCacheTimeout(), and UpdateRouteEntry().


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