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