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"
109 else if (m_low == L.
m_low)
111 return (m_high < L.
m_high);
178 typedef std::vector<Ipv4Address>::iterator
Iterator;
231 void Print (std::ostream & os)
const;
243 IP_VECTOR::const_iterator j = o.
m_path.begin ();
244 for (IP_VECTOR::const_iterator i =
m_path.begin (); i
245 !=
m_path.end (); i++, j++)
250 if (((*i) == 0) || ((*j) == 0))
254 else if (!((*i) == (*j)) )
442 void Print (std::ostream &os);
467 : m_neighborAddress (ip),
468 m_hardwareAddress (mac),
569 #define MAXWEIGHT 0xFFFF;
575 std::map<Ipv4Address, std::map<Ipv4Address, uint32_t> >
m_netGraph;
Ipv4Address m_neighborAddress
Simulation virtual time values and global simulation resolution.
Ipv4Address GetDestination() const
DSR route request queue Since DSR is an on demand routing we queue requests while looking for route...
void SetDestination(Ipv4Address d)
uint16_t CheckUniqueAckId(Ipv4Address nextHop)
Check for duplicate ids and save new entries if the id is not present in the table.
void AddNeighbor(std::vector< Ipv4Address > nodeList, Ipv4Address ownAddress, Time expire)
Add to the neighbor list.
Time GetLinkStability() const
void SetBlacklistTimeout(Time t)
Time m_badLinkLifetime
The time for which the neighboring node is put into the blacklist.
Mac48Address m_hardwareAddress
void SetNodeStability(Time nodeStab)
std::vector< Ptr< ArpCache > > m_arp
list of ARP cached to be used for layer 2 notifications processing
void SetMinLifeTime(Time minLifeTime)
void UpdateNetGraph()
Update the Net Graph for the link and node cache has changed.
std::list< DsrRouteCacheEntry > routeEntryVector
Define the route cache data structure.
uint32_t m_maxEntriesEachDst
number of entries for each destination
bool m_blackListState
Indicate if this entry is in "blacklist".
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...
void Invalidate(Time badLinkLifetime)
Mark entry as "down" (i.e. disable it)
uint64_t GetStabilityDecrFactor() const
Timer m_ackTimer
RREP_ACK timer.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
DsrNodeStab(Time nodeStab=Simulator::Now())
IP_VECTOR GetVector() const
IP_VECTOR m_path
brief The IP address constructed route
Callback< void, WifiMacHeader const & > GetTxErrorCallback() const
Get callback to ProcessTxError, this callback is trying to use the wifi mac tx error header to notify...
void SetCallback(Callback< void, Ipv4Address, uint8_t > cb)
Handle link failure callback.
std::vector< Neighbor > m_nb
vector of entries
void PrintRouteVector(std::list< DsrRouteCacheEntry > route)
Print all the route vector elements from the route list.
Time GetCacheTimeout() const
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Timer m_ntimer
Timer for neighbor's list. Schedule Purge().
Ptr< Ipv4 > m_ipv4
The Ipv4 layer 3.
void RebuildBestRouteTable(Ipv4Address source)
USE MAXWEIGHT TO REPRESENT MAX; USE BROADCAST ADDRESS TO REPRESENT NULL PRECEEDING ADDRESS...
routeEntryVector m_routeEntryVector
Define the route vector.
uint16_t GetAckSize()
Get the ack table size.
void AddArpCache(Ptr< ArpCache >)
Add ARP cache to be used to allow layer 2 notifications processing.
Time RouteCacheTimeout
The maximum period of time that dsr is allowed to for an unused route.
bool IsUnidirectional() const
bool UpdateRouteEntry(Ipv4Address dst)
Update route cache entry if it has been recently used and successfully delivered the data packet...
Time m_expire
Expire time for queue entry.
Time m_delay
This timeout deals with the passive ack.
bool m_isLinkCache
Check if the route is using path cache or link cache.
std::map< Ipv4Address, DsrNodeStab > m_nodeCache
The data structure to store node info.
void Print(std::ostream &os) const
Print necessary fields.
std::list< DsrRouteCacheEntry::IP_VECTOR > routeVector
Define the vector of route entries.
void Clear()
Delete all entries from routing table.
static TypeId GetTypeId()
Time m_linkStability
The link stability lifetime expected, when the time is due, the link expires the expiration happens w...
Time GetUseExtends() const
void ClearMac()
Remove all entries.
Time GetNodeStability() const
std::map< Link, DsrLinkStab > m_linkCache
The data structure to store link info.
bool IncStability(Ipv4Address node)
increase the stability of the node
void ScheduleTimer()
Schedule m_ntimer.
Time GetExpireTime(Ipv4Address addr)
Return expire time for neighbor node with address addr, if exists, else return 0. ...
void SetStabilityIncrFactor(uint64_t incrFactor)
The route cache structure.
DsrLinkStab(Time linkStab=Simulator::Now())
Constructor.
uint32_t m_stabilityDecrFactor
Define the parameters for link cache type.
bool IsNeighbor(Ipv4Address addr)
Check that node with address addr is neighbor.
bool LookupRoute_Link(Ipv4Address id, DsrRouteCacheEntry &rt)
used by LookupRoute when LinkCache
Time GetBlacklistTimeout() const
std::vector< Ipv4Address > IP_VECTOR
Define the vector to hold Ip address.
uint32_t m_maxCacheLen
The maximum number of packets that we allow a routing protocol to buffer.
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...
void SetBadLinkLifetime(Time t)
bool LookupRoute(Ipv4Address id, DsrRouteCacheEntry &rt)
Lookup route cache entry with destination address dst.
std::map< Ipv4Address, uint16_t > m_ackIdCache
The id cache to ensure all the ids are unique.
Time GetExpireTime() const
void SetUnidirectional(bool u)
DsrRouteCacheEntry::IP_VECTOR m_vector
The route vector to save the ip addresses for intermediate nodes.
bool AddRoute_Link(DsrRouteCacheEntry::IP_VECTOR nodelist, Ipv4Address node)
Time GetMinLifeTime() const
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Mac48Address LookupMacAddress(Ipv4Address)
Find MAC address by IP using list of ARP caches.
Ipv4InterfaceAddress m_iface
Output interface address.
Neighbor(Ipv4Address ip, Mac48Address mac, Time t)
void SetLinkStability(Time linkStab)
set/get the link stability
bool FindSameRoute(DsrRouteCacheEntry &rt, std::list< DsrRouteCacheEntry > &rtVector)
Find the same route in the route cache.
void SetSubRoute(bool subRoute)
void Purge()
Delete all outdated entries and invalidate valid entry if Lifetime is expired.
Ipv4Address m_dst
The destination Ip address.
bool DeleteRoute(Ipv4Address dst)
Delete the route with certain destination address.
std::vector< Ipv4Address >::iterator Iterator
Define the iterator.
Time m_blackListTimeout
Time for which the node is put into the blacklist.
DsrRouteCache & operator=(DsrRouteCache const &)
void UpdateNeighbor(std::vector< Ipv4Address > nodeList, Time expire)
Update expire time for entry with address addr, if it exists, else add new entry. ...
void SetInitStability(Time initStability)
virtual ~DsrLinkStab()
Destructor.
static Time Now(void)
Return the current simulation virtual time.
Ptr< Ipv4Route > m_ipv4Route
The Ipv4 route.
Link(Ipv4Address ip1, Ipv4Address ip2)
std::map< Ipv4Address, DsrRouteCacheEntry::IP_VECTOR > m_bestRoutesTable_link
for link route cache
bool operator<(Link const &L) const
void ProcessTxError(WifiMacHeader const &)
Process layer 2 TX error notification.
void RemoveLastEntry(std::list< DsrRouteCacheEntry > &rtVector)
Remove the aged route cache entries when the route cache is full.
std::map< Ipv4Address, routeEntryVector > m_sortedRoutes
Map the ipv4Address to route entry vector.
uint64_t GetStabilityIncrFactor() const
Ipv4 addresses are stored in host order in this class.
virtual ~DsrRouteCacheEntry()
Callback< void, WifiMacHeader const & > m_txErrorCallback
TX error callback.
uint32_t GetMaxCacheLen() const
void DelArpCache(Ptr< ArpCache >)
Don't use given ARP cache any more (interface is down)
a class to store IPv4 address information on an interface
void SetVector(IP_VECTOR v)
bool DecStability(Ipv4Address node)
decrease the stability of the node
void PurgeMac()
Remove all expired mac entries.
void Print(std::ostream &os)
Print route cache.
void SetExpireTime(Time exp)
Time GetBadLinkLifetime() const
uint32_t m_stabilityIncrFactor
void SetCacheType(std::string type)
Dijsktra algorithm to get the best route from m_netGraph and update the m_bestRoutesTable_link when c...
bool AddRoute(DsrRouteCacheEntry &rt)
Add route cache entry if it doesn't yet exist in route cache.
DsrRouteCacheEntry(IP_VECTOR const &ip=IP_VECTOR(), Ipv4Address dst=Ipv4Address(), Time exp=Simulator::Now())
uint32_t GetMaxEntriesEachDst() const
A base class which provides memory management and object aggregation.
void SetUseExtends(Time useExtends)
Callback< void, Ipv4Address, uint8_t > m_handleLinkFailure
The following code handles link-layer acks.
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 SetMaxCacheLen(uint32_t len)
Callback< void, Ipv4Address, uint8_t > GetCallback() const
Handle link failure callback.
Time GetInitStability() const
a unique identifier for an interface.
void PrintVector(std::vector< Ipv4Address > &vec)
Print the route vector elements.
void SetMaxEntriesEachDst(uint32_t entries)
void SetStabilityDecrFactor(uint64_t decrFactor)
uint8_t m_reqCount
Number of route requests.
void SetCacheTimeout(Time t)
bool m_subRoute
Check if save the sub route entries or not.
bool operator==(DsrRouteCacheEntry const &o) const
Compare the route cache entry.