mesh: Add trace source to trace HWMP routing table changes

Also add GetRoutingTable method returning pointer to routing table
This commit is contained in:
Tom Henderson
2017-04-08 23:38:24 -07:00
parent 34ff7bbc63
commit 19c38690cd
2 changed files with 103 additions and 0 deletions

View File

@@ -168,6 +168,11 @@ HwmpProtocol::GetTypeId ()
&HwmpProtocol::m_routeDiscoveryTimeCallback),
"ns3::Time::TracedCallback"
)
.AddTraceSource ("RouteChange",
"Routing table changed",
MakeTraceSourceAccessor (&HwmpProtocol::m_routeChangeTraceSource),
"ns3::HwmpProtocol::RouteChangeTracedCallback"
)
;
return tid;
}
@@ -457,6 +462,16 @@ HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, M
MicroSeconds (preq.GetLifetime () * 1024),
preq.GetOriginatorSeqNumber ()
);
// Notify trace source of routing change
struct RouteChange rChange;
rChange.type = "Add Reactive";
rChange.destination = preq.GetOriginatorAddress ();
rChange.retransmitter = from;
rChange.interface = interface;
rChange.metric = preq.GetMetric ();
rChange.lifetime = MicroSeconds (preq.GetLifetime () * 1024);
rChange.seqnum = preq.GetOriginatorSeqNumber ();
m_routeChangeTraceSource (rChange);
ReactivePathResolved (preq.GetOriginatorAddress ());
}
if (
@@ -472,6 +487,16 @@ HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, M
MicroSeconds (preq.GetLifetime () * 1024),
preq.GetOriginatorSeqNumber ()
);
// Notify trace source of routing change
struct RouteChange rChange;
rChange.type = "Add Reactive";
rChange.destination = fromMp;
rChange.retransmitter = from;
rChange.interface = interface;
rChange.metric = metric;
rChange.lifetime = MicroSeconds (preq.GetLifetime () * 1024);
rChange.seqnum = preq.GetOriginatorSeqNumber ();
m_routeChangeTraceSource (rChange);
ReactivePathResolved (fromMp);
}
for (std::vector<Ptr<DestinationAddressUnit> >::const_iterator i = destinations.begin (); i != destinations.end (); i++)
@@ -499,6 +524,16 @@ HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, M
MicroSeconds (preq.GetLifetime () * 1024),
preq.GetOriginatorSeqNumber ()
);
// Notify trace source of routing change
struct RouteChange rChange;
rChange.type = "Add Proactive";
rChange.destination = preq.GetOriginatorAddress ();
rChange.retransmitter = from;
rChange.interface = interface;
rChange.metric = preq.GetMetric ();
rChange.lifetime = MicroSeconds (preq.GetLifetime () * 1024);
rChange.seqnum = preq.GetOriginatorSeqNumber ();
m_routeChangeTraceSource (rChange);
ProactivePathResolved ();
}
if (!preq.IsNeedNotPrep ())
@@ -619,6 +654,16 @@ HwmpProtocol::ReceivePrep (IePrep prep, Mac48Address from, uint32_t interface, M
prep.GetMetric (),
MicroSeconds (prep.GetLifetime () * 1024),
sequence);
// Notify trace source of routing change
struct RouteChange rChange;
rChange.type = "Add Reactive";
rChange.destination = prep.GetOriginatorAddress ();
rChange.retransmitter = from;
rChange.interface = interface;
rChange.metric = prep.GetMetric ();
rChange.lifetime = MicroSeconds (prep.GetLifetime () * 1024);
rChange.seqnum = sequence;
m_routeChangeTraceSource (rChange);
m_rtable->AddPrecursor (prep.GetDestinationAddress (), interface, from,
MicroSeconds (prep.GetLifetime () * 1024));
if (result.retransmitter != Mac48Address::GetBroadcast ())
@@ -640,6 +685,16 @@ HwmpProtocol::ReceivePrep (IePrep prep, Mac48Address from, uint32_t interface, M
metric,
MicroSeconds (prep.GetLifetime () * 1024),
sequence);
// Notify trace source of routing change
struct RouteChange rChange;
rChange.type = "Add Reactive";
rChange.destination = fromMp;
rChange.retransmitter = from;
rChange.interface = interface;
rChange.metric = metric;
rChange.lifetime = MicroSeconds (prep.GetLifetime () * 1024);
rChange.seqnum = sequence;
m_routeChangeTraceSource (rChange);
ReactivePathResolved (fromMp);
}
if (prep.GetDestinationAddress () == GetAddress ())
@@ -796,6 +851,12 @@ HwmpProtocol::MakePathError (std::vector<FailedDestination> destinations)
{
retval.destinations.push_back (destinations[i]);
m_rtable->DeleteReactivePath (destinations[i].destination);
// Notify trace source of routing change
struct RouteChange rChange;
rChange.type = "Delete Reactive";
rChange.destination = destinations[i].destination;
rChange.seqnum = destinations[i].seqnum;
m_routeChangeTraceSource (rChange);
}
return retval;
}
@@ -843,7 +904,19 @@ HwmpProtocol::GetPerrReceivers (std::vector<FailedDestination> failedDest)
{
HwmpRtable::PrecursorList precursors = m_rtable->GetPrecursors (failedDest[i].destination);
m_rtable->DeleteReactivePath (failedDest[i].destination);
// Notify trace source of routing change
struct RouteChange rChange;
rChange.type = "Delete Reactive";
rChange.destination = failedDest[i].destination;
rChange.seqnum = failedDest[i].seqnum;
m_routeChangeTraceSource (rChange);
m_rtable->DeleteProactivePath (failedDest[i].destination);
// Notify trace source of routing change
struct RouteChange rChangePro;
rChangePro.type = "Delete Proactive";
rChangePro.destination = failedDest[i].destination;
rChangePro.seqnum = failedDest[i].seqnum;
m_routeChangeTraceSource (rChangePro);
for (unsigned int j = 0; j < precursors.size (); j++)
{
retval.push_back (precursors[j]);
@@ -1211,6 +1284,12 @@ HwmpProtocol::AssignStreams (int64_t stream)
return 1;
}
Ptr<HwmpRtable>
HwmpProtocol::GetRoutingTable (void) const
{
return m_rtable;
}
HwmpProtocol::QueuedPacket::QueuedPacket () :
pkt (0),
protocol (0),

View File

@@ -39,6 +39,20 @@ class HwmpRtable;
class IePerr;
class IePreq;
class IePrep;
/**
* Structure to encapsulate route change information
*/
struct RouteChange
{
std::string type; ///< type of change
Mac48Address destination; ///< route destination
Mac48Address retransmitter; ///< route source
uint32_t interface; ///< interface index
uint32_t metric; ///< metric of route
Time lifetime; ///< lifetime of route
uint32_t seqnum; ///< sequence number of route
};
/**
* \ingroup dot11s
*
@@ -112,6 +126,12 @@ public:
*/
int64_t AssignStreams (int64_t stream);
/**
* \brief Get pointer to HWMP routing table
* \return pointer to routing table
*/
Ptr<HwmpRtable> GetRoutingTable (void) const;
private:
friend class HwmpProtocolMac;
@@ -211,6 +231,10 @@ private:
//\}
/// Route discovery time:
TracedCallback<Time> m_routeDiscoveryTimeCallback;
/// RouteChangeTracedCallback typedef
typedef TracedCallback <struct RouteChange> RouteChangeTracedCallback;
/// Route change trace source
TracedCallback<struct RouteChange> m_routeChangeTraceSource;
///\name Methods related to Queue/Dequeue procedures
///\{
bool QueuePacket (QueuedPacket packet);