|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
32 #include "ns3/simulator.h"
52 m_lifeTime (lifetime),
55 m_settlingTime (SettlingTime),
56 m_entriesChanged (areChanged)
79 std::map<Ipv4Address, RoutingTableEntry>::const_iterator i =
m_ipv4AddressEntry.find (
id);
97 std::map<Ipv4Address, RoutingTableEntry>::const_iterator i =
m_ipv4AddressEntry.find (
id);
102 if (forRouteInput ==
true &&
id == i->second.GetInterface ().GetBroadcast ())
130 std::pair<std::map<Ipv4Address, RoutingTableEntry>::iterator,
bool> result =
m_ipv4AddressEntry.insert (std::make_pair (
132 return result.second;
156 if (i->second.GetInterface () == iface)
158 std::map<Ipv4Address, RoutingTableEntry>::iterator tmp = i;
174 if (i->second.GetDestination () !=
Ipv4Address (
"127.0.0.1") && i->second.GetFlag () ==
VALID)
177 std::make_pair (i->first,i->second));
184 std::map<Ipv4Address, RoutingTableEntry> & unreachable)
186 unreachable.clear ();
187 for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator i =
m_ipv4AddressEntry.begin (); i
190 if (i->second.GetNextHop () == nextHop)
192 unreachable.insert (std::make_pair (i->first,i->second));
202 std::ios oldState (
nullptr);
203 oldState.copyfmt (*os);
205 *os << std::resetiosflags (std::ios::adjustfield) << std::setiosflags (std::ios::left);
207 std::ostringstream dest, gw, iface, ltime, stime;
214 *os << std::setw (16) << dest.str ();
215 *os << std::setw (16) << gw.str ();
216 *os << std::setw (16) << iface.str ();
217 *os << std::setw (16) <<
m_hops;
218 *os << std::setw (16) <<
m_seqNo;
219 *os << std::setw(16) << ltime.str ();
220 *os << stime.str () << std::endl;
222 (*os).copyfmt (oldState);
234 std::map<Ipv4Address, RoutingTableEntry>::iterator itmp = i;
235 if (i->second.GetLifeTime () >
m_holddownTime && (i->second.GetHop () > 0))
239 if ((j->second.GetNextHop () == i->second.GetDestination ()) && (i->second.GetHop () != j->second.GetHop ()))
241 std::map<Ipv4Address, RoutingTableEntry>::iterator jtmp = j;
242 removedAddresses.insert (std::make_pair (j->first,j->second));
251 removedAddresses.insert (std::make_pair (i->first,i->second));
274 std::ios oldState (
nullptr);
275 oldState.copyfmt (*os);
277 *os << std::resetiosflags (std::ios::adjustfield) << std::setiosflags (std::ios::left);
279 *os <<
"\nDSDV Routing table\n";
280 *os << std::setw (16) <<
"Destination";
281 *os << std::setw (16) <<
"Gateway";
282 *os << std::setw (16) <<
"Interface";
283 *os << std::setw (16) <<
"HopCount";
284 *os << std::setw (16) <<
"SeqNum";
285 *os << std::setw (16) <<
"LifeTime";
286 *os <<
"SettlingTime" << std::endl;
287 for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator i =
m_ipv4AddressEntry.begin (); i
290 i->second.Print (stream, unit);
294 (*os).copyfmt (oldState);
301 std::pair<std::map<Ipv4Address, EventId>::iterator,
bool> result =
m_ipv4Events.insert (std::make_pair (
address,
id));
302 return result.second;
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
bool DeleteRoute(Ipv4Address dst)
Delete routing table entry with destination address dst, if it exists.
An identifier for simulation events.
EventId GetEventId(Ipv4Address address)
Get the EcentId associated with that address.
static Time Now(void)
Return the current simulation virtual time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool AnyRunningEvent(Ipv4Address address)
Force delete an update waiting for settling time to complete as a better update to same destination w...
std::map< Ipv4Address, EventId > m_ipv4Events
an entry in the event table.
Time m_lifeTime
Expiration or deletion time of the route Lifetime field in the routing table plays dual role – for an...
bool AddIpv4Event(Ipv4Address address, EventId id)
Add an event for a destination address so that the update to for that destination is sent after the e...
Ipv4 addresses are stored in host order in this class.
bool DeleteIpv4Event(Ipv4Address address)
Clear up the entry from the map after the event is completed.
std::ostream * GetStream(void)
Return a pointer to an ostream previously set in the wrapper.
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Ipv4InterfaceAddress m_iface
Output interface address.
Time m_holddownTime
hold down time of an expired route
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
a class to store IPv4 address information on an interface
static void Cancel(const EventId &id)
Set the cancel bit on this event: the event's associated function will not be invoked when it expires...
void DeleteAllRoutesFromInterface(Ipv4InterfaceAddress iface)
Delete all route from interface with address iface.
bool AddRoute(RoutingTableEntry &r)
Add routing table entry if it doesn't yet exist in routing table.
void GetListOfAllRoutes(std::map< Ipv4Address, RoutingTableEntry > &allRoutes)
Lookup list of all addresses in the routing table.
bool Update(RoutingTableEntry &rt)
Updating the routing Table with routing table entry rt.
Simulation virtual time values and global simulation resolution.
void Print(Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S) const
Print routing table.
Time m_settlingTime
Time for which the node retains an update with changed metric before broadcasting it.
std::map< Ipv4Address, RoutingTableEntry > m_ipv4AddressEntry
an entry in the routing table.
Ptr< Ipv4Route > m_ipv4Route
Ip route, include.
uint32_t RoutingTableSize()
Provides the number of routes present in that nodes routing table.
RoutingTableEntry(Ptr< NetDevice > dev=0, Ipv4Address dst=Ipv4Address(), uint32_t seqNo=0, Ipv4InterfaceAddress iface=Ipv4InterfaceAddress(), uint32_t hops=0, Ipv4Address nextHop=Ipv4Address(), Time lifetime=Simulator::Now(), Time SettlingTime=Simulator::Now(), bool changedEntries=false)
c-tor
void GetListOfDestinationWithNextHop(Ipv4Address nxtHp, std::map< Ipv4Address, RoutingTableEntry > &dstList)
Lookup list of addresses for which nxtHp is the next Hop address.
Ipv4Address GetDestination() const
Get destination IP address.
bool ForceDeleteIpv4Event(Ipv4Address address)
Force delete an update waiting for settling time to complete as a better update to same destination w...
Ipv4Address GetLocal(void) const
Get the local address.
uint32_t m_seqNo
Destination Sequence Number.
void Purge(std::map< Ipv4Address, RoutingTableEntry > &removedAddresses)
Delete all outdated entries if Lifetime is expired.
bool LookupRoute(Ipv4Address dst, RoutingTableEntry &rt)
Lookup routing table entry with destination address dst.
uint32_t m_hops
Hop Count (number of hops needed to reach destination)
Unit
The unit to use to interpret a number representing time.
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
void Print(Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S) const
Print routing table entry.