39 #include <sys/types.h>
43 #include "ns3/simulator.h"
44 #include "ns3/timer.h"
45 #include "ns3/simple-ref-count.h"
46 #include "ns3/header.h"
48 #include "ns3/ipv4-address.h"
49 #include "ns3/nstime.h"
51 #include "ns3/ipv4-route.h"
52 #include "ns3/net-device.h"
53 #include "ns3/ipv4-l3-protocol.h"
54 #include "ns3/callback.h"
55 #include "ns3/wifi-mac-header.h"
56 #include "ns3/arp-cache.h"
57 #include "dsr-option-header.h"
103 bool operator < (
Link const& L)
const
109 else if (m_low == L.m_low)
111 return (m_high < L.m_high);
140 Time GetLinkStability ()
const
168 void SetNodeStability (
Time nodeStab)
172 Time GetNodeStability ()
const
177 Time m_nodeStability;
184 typedef std::vector<Ipv4Address>::iterator
Iterator;
195 void Invalidate (
Time badLinkLifetime);
198 void SetUnidirectional (
bool u)
202 bool IsUnidirectional ()
const
206 void SetBlacklistTimeout (
Time t)
210 Time GetBlacklistTimeout ()
const
214 Ipv4Address GetDestination ()
const
218 void SetDestination (Ipv4Address d)
230 void SetExpireTime (Time exp)
234 Time GetExpireTime ()
const
242 void Print (std::ostream & os)
const;
254 IP_VECTOR::const_iterator j = o.
m_path.begin ();
255 for (IP_VECTOR::const_iterator i =
m_path.begin (); i
256 !=
m_path.end (); i++, j++)
261 if (((*i) == 0) || ((*j) == 0))
265 else if (!((*i) == (*j)) )
344 bool GetSubRoute ()
const
348 void SetSubRoute (
bool subRoute)
352 uint32_t GetMaxCacheLen ()
const
356 void SetMaxCacheLen (uint32_t len)
360 Time GetCacheTimeout ()
const
364 void SetCacheTimeout (Time t)
368 uint32_t GetMaxEntriesEachDst ()
const
372 void SetMaxEntriesEachDst (uint32_t entries)
376 Time GetBadLinkLifetime ()
const
380 void SetBadLinkLifetime (Time t)
384 uint64_t GetStabilityDecrFactor ()
const
388 void SetStabilityDecrFactor (uint64_t decrFactor)
392 uint64_t GetStabilityIncrFactor ()
const
394 return m_stabilityIncrFactor;
396 void SetStabilityIncrFactor (uint64_t incrFactor)
398 m_stabilityIncrFactor = incrFactor;
400 Time GetInitStability ()
const
402 return m_initStability;
404 void SetInitStability (Time initStability)
406 m_initStability = initStability;
408 Time GetMinLifeTime ()
const
410 return m_minLifeTime;
412 void SetMinLifeTime (Time minLifeTime)
414 m_minLifeTime = minLifeTime;
416 Time GetUseExtends ()
const
420 void SetUseExtends (Time useExtends)
422 m_useExtends = useExtends;
437 bool AddRoute (RouteCacheEntry & rt);
444 bool LookupRoute (Ipv4Address
id, RouteCacheEntry & rt);
460 bool FindSameRoute (RouteCacheEntry & rt, std::list<RouteCacheEntry> & rtVector);
483 void Print (std::ostream &os);
508 : m_neighborAddress (ip),
509 m_hardwareAddress (mac),
586 uint32_t m_stabilityIncrFactor;
587 Time m_initStability;
610 #define MAXWEIGHT 0xFFFF;
616 std::map<Ipv4Address, std::map<Ipv4Address, uint32_t> >
m_netGraph;
bool DeleteRoute(Ipv4Address dst)
Delete the route with certain destination address.
static TypeId GetTypeId()
The Route Cache used by DSR.
LinkStab(Time linkStab=Simulator::Now())
Constructor.
void PurgeMac()
Remove all expired mac entries.
IP_VECTOR m_path
brief The IP address constructed route
bool IncStability(Ipv4Address node)
increase the stability of the node
Ipv4Address m_dst
The destination Ip address.
Ipv4InterfaceAddress m_iface
Output interface address.
void SetLinkStability(Time linkStab)
set/get the link stability
virtual ~LinkStab()
Destructor.
#define NS_ASSERT(condition)
Time RouteCacheTimeout
The maximum period of time that dsr is allowed to for an unused route.
bool AddRoute(RouteCacheEntry &rt)
Add route cache entry if it doesn't yet exist in route cache.
void RebuildBestRouteTable(Ipv4Address source)
USE MAXWEIGHT TO REPRESENT MAX; USE BROADCAST ADDRESS TO REPRESENT NULL PRECEEDING ADDRESS...
NodeStab(Time nodeStab=Simulator::Now())
Constructor.
Ipv4Address GetDestination(void) const
Get the destination address of the route.
void DropPathWithDst(Ipv4Address dst)
Remove all packets with destination IP address dst.
bool LookupRoute_Link(Ipv4Address id, RouteCacheEntry &rt)
used by LookupRoute when LinkCache
std::map< Ipv4Address, std::map< Ipv4Address, uint32_t > > m_netGraph
uint32_t m_stabilityDecrFactor
std::map< Ipv4Address, uint16_t > m_ackIdCache
The id cache to ensure all the ids are unique.
Ptr< Ipv4 > m_ipv4
The Ipv4 layer 3.
bool operator==(RouteCacheEntry const &o) const
Compare the route cache entry.
void SetCacheType(std::string type)
dijsktra algorithm to get the best route from m_netGraph and update the m_bestRoutesTable_link curre...
void UseExtends(RouteCacheEntry::IP_VECTOR rt)
RouteCacheEntry::IP_VECTOR m_vector
The route vector to save the ip addresses for intermediate nodes.
uint16_t CheckUniqueAckId(Ipv4Address nextHop)
Check for duplicate ids and save new entries if the id is not present in the table.
std::list< RouteCacheEntry::IP_VECTOR > routeVector
Define the vector of route entries.
void AddNeighbor(std::vector< Ipv4Address > nodeList, Ipv4Address ownAddress, Time expire)
Add to the neighbor list.
void ClearMac()
Remove all entries.
void UpdateNeighbor(std::vector< Ipv4Address > nodeList, Time expire)
Update expire time for entry with address addr, if it exists, else add new entry. ...
void ScheduleTimer()
Schedule m_ntimer.
std::vector< Ipv4Address > IP_VECTOR
Define the vector to hold Ip address.
bool m_subRoute
Check if save the sub route entries or not.
bool UpdateRouteEntry(Ipv4Address dst)
Update route cache entry if it has been recently used and successfully delivered the data packet...
void DelArpCache(Ptr< ArpCache >)
Don't use given ARP cache any more (interface is down)
RouteCacheEntry(IP_VECTOR const &ip=IP_VECTOR(), Ipv4Address dst=Ipv4Address(), Time exp=Simulator::Now())
Constructor.
uint32_t m_maxCacheLen
The maximum number of packets that we allow a routing protocol to buffer.
void PrintRouteVector(std::list< RouteCacheEntry > route)
Print all the route vector elements from the route list.
std::map< Link, LinkStab > m_linkCache
The data structure to store link info.
virtual ~RouteCacheEntry()
Destructor.
Callback< void, WifiMacHeader const & > m_txErrorCallback
TX error callback.
void ProcessTxError(WifiMacHeader const &)
Process layer 2 TX error notification.
Mac48Address LookupMacAddress(Ipv4Address)
Find MAC address by IP using list of ARP caches.
uint8_t m_reqCount
Number of route requests.
bool AddRoute_Link(RouteCacheEntry::IP_VECTOR nodelist, Ipv4Address node)
bool IsEqual(RouteCacheEntry ca)
To know if the two entries are the same.
std::list< RouteCacheEntry > routeEntryVector
void RemoveLastEntry(std::list< RouteCacheEntry > &rtVector)
Remove the aged route cache entries when the route cache is full.
Ptr< Ipv4Route > m_ipv4Route
The Ipv4 route.
void PrintVector(std::vector< Ipv4Address > &vec)
Print the route vector elements.
void Print(std::ostream &os) const
Print necessary fields.
DSR route request queue Since DSR is an on demand routing we queue requests while looking for route...
uint16_t GetAckSize()
Get the ack table size.
std::vector< Ptr< ArpCache > > m_arp
list of ARP cached to be used for layer 2 notifications processing
bool LookupRoute(Ipv4Address id, RouteCacheEntry &rt)
Lookup route cache entry with destination address dst.
bool m_blackListState
Indicate if this entry is in "blacklist".
Ipv4 addresses are stored in host order in this class.
uint32_t m_maxEntriesEachDst
number of entries for each destination
Timer m_ntimer
Timer for neighbor's list. Schedule Purge().
virtual ~NodeStab()
Destructor.
Callback< void, WifiMacHeader const & > GetTxErrorCallback() const
Get callback to ProcessTxError, this callback is trying to use the wifi mac tx error header to notify...
std::map< Ipv4Address, RouteCacheEntry::IP_VECTOR > m_bestRoutesTable_link
for link route cache
a class to store IPv4 address information on an interface
std::map< Ipv4Address, routeEntryVector > m_sortedRoutes
Map the ipv4Address to route entry vector.
Time m_expire
Expire time for queue entry.
Time m_badLinkLifetime
The time for which the neighboring node is put into the blacklist.
Timer m_ackTimer
RREP_ACK timer.
void UpdateNetGraph()
Update the Net Graph for the link and node cache has changed.
Callback< void, Ipv4Address, uint8_t > m_handleLinkFailure
link failure callback
Time m_blackListTimeout
Time for which the node is put into the blacklist.
bool FindSameRoute(RouteCacheEntry &rt, std::list< RouteCacheEntry > &rtVector)
Find the same route in the route cache.
a base class which provides memory management and object aggregation
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 DecStability(Ipv4Address node)
decrease the stability of the node
std::vector< Neighbor > m_nb
vector of entries
routeEntryVector m_routeEntryVector
Define the route vector.
bool m_isLinkCache
Check if the route is using path cache or link cache.
a unique identifier for an interface.
bool IsNeighbor(Ipv4Address addr)
Check that node with address addr is neighbor.
Time GetExpireTime(Ipv4Address addr)
Return expire time for neighbor node with address addr, if exists, else return 0. ...
Time m_delay
This timeout deals with the passive ack.
void AddArpCache(Ptr< ArpCache >)
Add ARP cache to be used to allow layer 2 notifications processing.
std::vector< Ipv4Address >::iterator Iterator
Define the iterator.
std::map< Ipv4Address, NodeStab > m_nodeCache
The data structure to store node info.
virtual ~RouteCache()
Destructor.