21 #include "ns3/object.h"
22 #include "ns3/assert.h"
23 #include "ns3/simulator.h"
27 #include "hwmp-rtable.h"
34 NS_OBJECT_ENSURE_REGISTERED (HwmpRtable);
37 HwmpRtable::GetTypeId ()
39 static TypeId tid = TypeId (
"ns3::dot11s::HwmpRtable")
41 .AddConstructor<HwmpRtable> ();
44 HwmpRtable::HwmpRtable ()
46 DeleteProactivePath ();
48 HwmpRtable::~HwmpRtable ()
58 uint32_t metric,
Time lifetime, uint32_t seqnum)
60 std::map<Mac48Address, ReactiveRoute>::iterator i =
m_routes.find (destination);
63 ReactiveRoute newroute;
68 i->second.retransmitter = retransmitter;
69 i->second.interface = interface;
70 i->second.metric = metric;
72 i->second.seqnum = seqnum;
75 HwmpRtable::AddProactivePath (uint32_t metric, Mac48Address root, Mac48Address retransmitter,
76 uint32_t interface, Time lifetime, uint32_t seqnum)
79 m_root.retransmitter = retransmitter;
83 m_root.interface = interface;
86 HwmpRtable::AddPrecursor (Mac48Address destination, uint32_t precursorInterface,
87 Mac48Address precursorAddress, Time lifetime)
90 precursor.interface = precursorInterface;
91 precursor.address = precursorAddress;
93 std::map<Mac48Address, ReactiveRoute>::iterator i =
m_routes.find (destination);
96 bool should_add =
true;
97 for (
unsigned int j = 0; j < i->second.precursors.size (); j++)
101 if (i->second.precursors[j].address == precursorAddress)
104 i->second.precursors[j].whenExpire = precursor.whenExpire;
110 i->second.precursors.push_back (precursor);
115 HwmpRtable::DeleteProactivePath ()
117 m_root.precursors.clear ();
125 HwmpRtable::DeleteProactivePath (Mac48Address root)
129 DeleteProactivePath ();
133 HwmpRtable::DeleteReactivePath (Mac48Address destination)
135 std::map<Mac48Address, ReactiveRoute>::iterator i =
m_routes.find (destination);
141 HwmpRtable::LookupResult
144 std::map<Mac48Address, ReactiveRoute>::iterator i =
m_routes.find (destination);
159 std::map<Mac48Address, ReactiveRoute>::iterator i =
m_routes.find (destination);
164 return LookupResult (i->second.retransmitter, i->second.interface, i->second.metric, i->second.seqnum,
172 NS_LOG_DEBUG (
"Proactive route has expired and will be deleted, sorry.");
173 DeleteProactivePath ();
183 std::vector<HwmpProtocol::FailedDestination>
187 std::vector<HwmpProtocol::FailedDestination> retval;
188 for (std::map<Mac48Address, ReactiveRoute>::iterator i =
m_routes.begin (); i !=
m_routes.end (); i++)
190 if (i->second.retransmitter == peerAddress)
192 dst.destination = i->first;
194 dst.seqnum = i->second.seqnum;
195 retval.push_back (dst);
199 if (
m_root.retransmitter == peerAddress)
201 dst.destination =
m_root.root;
202 dst.seqnum =
m_root.seqnum;
203 retval.push_back (dst);
212 std::map<Mac48Address, ReactiveRoute>::iterator route =
m_routes.find (destination);
215 for (std::vector<Precursor>::const_iterator i = route->second.precursors.begin ();
216 i != route->second.precursors.end (); i++)
220 retval.push_back (std::make_pair (i->interface, i->address));
229 return (retransmitter == o.retransmitter && ifIndex == o.ifIndex && metric == o.metric && seqnum
232 HwmpRtable::LookupResult::LookupResult (
Mac48Address r, uint32_t i, uint32_t m, uint32_t s,
Time l) :
233 retransmitter (r), ifIndex (i), metric (m), seqnum (s), lifetime (l)
ProactiveRoute m_root
Path to proactive tree root MP.
static const uint32_t MAX_METRIC
Maximum (the best?) path metric.
Route lookup result, return type of LookupXXX methods.
structure of unreachable destination - address and sequence number
#define NS_ASSERT(condition)
#define NS_LOG_COMPONENT_DEFINE(name)
LookupResult LookupReactiveExpired(Mac48Address destination)
Return all reactive paths, including expired.
bool IsValid() const
True for valid route.
LookupResult LookupReactive(Mac48Address destination)
Lookup path to destination.
std::vector< std::pair< uint32_t, Mac48Address > > PrecursorList
Path precursor = {MAC, interface ID}.
std::vector< HwmpProtocol::FailedDestination > GetUnreachableDestinations(Mac48Address peerAddress)
When peer link with a given MAC-address fails - it returns list of unreachable destination addresses...
static Mac48Address GetBroadcast(void)
LookupResult LookupProactiveExpired()
Return all proactive paths, including expired.
static const uint32_t INTERFACE_ANY
Means all interfaces.
bool operator==(const LookupResult &o) const
Compare route lookup results, used by tests.
std::map< Mac48Address, ReactiveRoute > m_routes
List of routes.
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
#define NS_LOG_DEBUG(msg)
LookupResult LookupProactive()
Find proactive path to tree root. Note that calling this method has side effect of deleting expired p...