32 #include "ns3/simulator.h" 47 : m_ackTimer (
Timer::CANCEL_ON_DESTROY),
48 m_validSeqNo (vSeqNo),
55 m_blackListState (false),
88 for (std::vector<Ipv4Address>::const_iterator i =
m_precursorList.begin (); i
105 std::vector<Ipv4Address>::iterator i = std::remove (
m_precursorList.begin (),
141 for (std::vector<Ipv4Address>::const_iterator i =
m_precursorList.begin (); i
145 for (std::vector<Ipv4Address>::const_iterator j = prec.begin (); j
198 *os << std::setiosflags (std::ios::fixed) <<
199 std::setiosflags (std::ios::left) << std::setprecision (2) <<
201 *os <<
"\t" <<
m_hops <<
"\n";
209 : m_badLinkLifetime (t)
220 NS_LOG_LOGIC (
"Route to " <<
id <<
" not found; m_ipv4AddressEntry is empty");
223 std::map<Ipv4Address, RoutingTableEntry>::const_iterator i =
255 NS_LOG_LOGIC (
"Route deletion to " << dst <<
" successful");
258 NS_LOG_LOGIC (
"Route deletion to " << dst <<
" not successful");
271 std::pair<std::map<Ipv4Address, RoutingTableEntry>::iterator,
bool> result =
273 return result.second;
280 std::map<Ipv4Address, RoutingTableEntry>::iterator i =
291 i->second.SetRreqCnt (0);
300 std::map<Ipv4Address, RoutingTableEntry>::iterator i =
304 NS_LOG_LOGIC (
"Route set entry state to " <<
id <<
" fails; not found");
307 i->second.SetFlag (state);
308 i->second.SetRreqCnt (0);
309 NS_LOG_LOGIC (
"Route set entry state to " <<
id <<
": new state is " << state);
318 unreachable.clear ();
319 for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator i =
322 if (i->second.GetNextHop () == nextHop)
324 NS_LOG_LOGIC (
"Unreachable insert " << i->first <<
" " << i->second.GetSeqNo ());
325 unreachable.insert (std::make_pair (i->first, i->second.GetSeqNo ()));
335 for (std::map<Ipv4Address, RoutingTableEntry>::iterator i =
338 for (std::map<Ipv4Address, uint32_t>::const_iterator j =
339 unreachable.begin (); j != unreachable.end (); ++j)
341 if ((i->first == j->first) && (i->second.GetFlag () ==
VALID))
343 NS_LOG_LOGIC (
"Invalidate route with destination address " << i->first);
358 for (std::map<Ipv4Address, RoutingTableEntry>::iterator i =
361 if (i->second.GetInterface () == iface)
363 std::map<Ipv4Address, RoutingTableEntry>::iterator tmp = i;
382 for (std::map<Ipv4Address, RoutingTableEntry>::iterator i =
385 if (i->second.GetLifeTime () <
Seconds (0))
387 if (i->second.GetFlag () ==
INVALID)
389 std::map<Ipv4Address, RoutingTableEntry>::iterator tmp = i;
393 else if (i->second.GetFlag () ==
VALID)
395 NS_LOG_LOGIC (
"Invalidate route with destination address " << i->first);
419 for (std::map<Ipv4Address, RoutingTableEntry>::iterator i =
420 table.begin (); i != table.end (); )
422 if (i->second.GetLifeTime () <
Seconds (0))
424 if (i->second.GetFlag () ==
INVALID)
426 std::map<Ipv4Address, RoutingTableEntry>::iterator tmp = i;
430 else if (i->second.GetFlag () ==
VALID)
432 NS_LOG_LOGIC (
"Invalidate route with destination address " << i->first);
452 std::map<Ipv4Address, RoutingTableEntry>::iterator i =
456 NS_LOG_LOGIC (
"Mark link unidirectional to " << neighbor <<
" fails; not found");
459 i->second.SetUnidirectional (
true);
460 i->second.SetBlacklistTimeout (blacklistTimeout);
461 i->second.SetRreqCnt (0);
462 NS_LOG_LOGIC (
"Set link to " << neighbor <<
" to unidirectional");
471 *stream->
GetStream () <<
"\nAODV Routing table\n" 472 <<
"Destination\tGateway\t\tInterface\tFlag\tExpire\t\tHops\n";
473 for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator i =
474 table.begin (); i != table.end (); ++i)
476 i->second.Print (stream);
void InvalidateRoutesWithDst(std::map< Ipv4Address, uint32_t > const &unreachable)
Update routing entries with this destination as follows:
Simulation virtual time values and global simulation resolution.
bool MarkLinkAsUnidirectional(Ipv4Address neighbor, Time blacklistTimeout)
Mark entry as unidirectional (e.g.
Smart pointer class similar to boost::intrusive_ptr.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
Control the scheduling of simulation events.
bool LookupRoute(Ipv4Address dst, RoutingTableEntry &rt)
Lookup routing table entry with destination address dst.
void Print(Ptr< OutputStreamWrapper > stream) const
Print routing table.
bool Update(RoutingTableEntry &rt)
Update routing table.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Ipv4Address GetDestination() const
Get destination address function.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
RoutingTableEntry(Ptr< NetDevice > dev=0, Ipv4Address dst=Ipv4Address(), bool vSeqNo=false, uint32_t seqNo=0, Ipv4InterfaceAddress iface=Ipv4InterfaceAddress(), uint16_t hops=0, Ipv4Address nextHop=Ipv4Address(), Time lifetime=Simulator::Now())
constructor
bool IsPrecursorListEmpty() const
Check that precursor list is empty.
void GetPrecursors(std::vector< Ipv4Address > &prec) const
Inserts precursors in output parameter prec if they do not yet exist in vector.
void SetSource(Ipv4Address src)
bool InsertPrecursor(Ipv4Address id)
Insert precursor in precursor list if it doesn't yet exist in the list.
void SetRreqCnt(uint8_t n)
Set the RREQ count.
RouteFlags m_flag
Routing flags: valid, invalid or in search.
void DeleteAllRoutesFromInterface(Ipv4InterfaceAddress iface)
Delete all route from interface with address iface.
void Print(Ptr< OutputStreamWrapper > stream) const
Print packet to trace file.
bool SetEntryState(Ipv4Address dst, RouteFlags state)
Set routing table entry flags.
bool LookupPrecursor(Ipv4Address id)
Lookup precursor by address.
void SetGateway(Ipv4Address gw)
uint8_t m_reqCount
Number of route requests.
Time m_badLinkLifetime
Deletion time for invalid routes.
bool DeletePrecursor(Ipv4Address id)
Delete precursor.
Ptr< Ipv4Route > m_ipv4Route
Ip route, include.
Ipv4Address GetDestination(void) const
std::vector< Ipv4Address > m_precursorList
List of precursors.
void DeleteAllPrecursors()
Delete all precursors.
void GetListOfDestinationWithNextHop(Ipv4Address nextHop, std::map< Ipv4Address, uint32_t > &unreachable)
Lookup routing entries with next hop Address dst and not empty list of precursors.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void Invalidate(Time badLinkLifetime)
Mark entry as "down" (i.e.
static Time Now(void)
Return the current simulation virtual time.
void SetOutputDevice(Ptr< NetDevice > outputDevice)
Equivalent in Linux to dst_entry.dev.
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
Ipv4InterfaceAddress m_iface
Output interface address.
Ipv4Address GetGateway(void) const
RoutingTable(Time t)
constructor
Time m_lifeTime
Expiration or deletion time of the route Lifetime field in the routing table plays dual role: for an ...
Ipv4 addresses are stored in host order in this class.
a class to store IPv4 address information on an interface
bool AddRoute(RoutingTableEntry &r)
Add routing table entry if it doesn't yet exist in routing table.
Time Seconds(double value)
Construct a Time in the indicated unit.
Ipv4Address GetLocal(void) const
Get the local address.
uint16_t m_hops
Hop Count (number of hops needed to reach destination)
RouteFlags GetFlag() const
Get the route flags.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
bool LookupValidRoute(Ipv4Address dst, RoutingTableEntry &rt)
Lookup route in VALID state.
bool DeleteRoute(Ipv4Address dst)
Delete routing table entry with destination address dst, if it exists.
void Purge()
Delete all outdated entries and invalidate valid entry if Lifetime is expired.
std::map< Ipv4Address, RoutingTableEntry > m_ipv4AddressEntry
The routing table.
std::ostream * GetStream(void)
Return a pointer to an ostream previously set in the wrapper.
void SetDestination(Ipv4Address dest)
RouteFlags
Route record states.