Mesh: fixed updating routing information in HWMP, fixed precursor list in
routing table
This commit is contained in:
@@ -174,9 +174,9 @@ HwmpRtableTest::TestPrecursorAdd ()
|
||||
{
|
||||
for (std::vector<Mac48Address>::const_iterator i = precursors.begin (); i != precursors.end (); i++)
|
||||
{
|
||||
table->AddPrecursor (dst, iface, *i);
|
||||
table->AddPrecursor (dst, iface, *i, Seconds (100));
|
||||
// Check that duplicates are filtered
|
||||
table->AddPrecursor (dst, iface, *i);
|
||||
table->AddPrecursor (dst, iface, *i, Seconds (100));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -415,15 +415,18 @@ HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, M
|
||||
}
|
||||
}
|
||||
}
|
||||
m_hwmpSeqnoMetricDatabase[preq.GetOriginatorAddress ()] = std::make_pair (preq.GetOriginatorSeqNumber (), preq.GetMetric ());
|
||||
|
||||
m_hwmpSeqnoMetricDatabase[preq.GetOriginatorAddress ()] =
|
||||
std::make_pair (preq.GetOriginatorSeqNumber (), preq.GetMetric ());
|
||||
NS_LOG_DEBUG("I am " << GetAddress () << "Accepted preq from address" << from << ", preq:" << preq);
|
||||
std::vector<Ptr<DestinationAddressUnit> > destinations = preq.GetDestinationList ();
|
||||
//Add reactive path to originator:
|
||||
if (
|
||||
((m_rtable->LookupReactive (preq.GetOriginatorAddress ())).retransmitter == Mac48Address::GetBroadcast ()) ||
|
||||
((m_rtable->LookupReactive (preq.GetOriginatorAddress ())).metric > preq.GetMetric ())
|
||||
((int32_t)(i->second.first - preq.GetOriginatorSeqNumber ()) < 0) ||
|
||||
(
|
||||
(m_rtable->LookupReactive (preq.GetOriginatorAddress ()).retransmitter == Mac48Address::GetBroadcast ()) ||
|
||||
(m_rtable->LookupReactive (preq.GetOriginatorAddress ()).metric > preq.GetMetric ())
|
||||
)
|
||||
)
|
||||
{
|
||||
m_rtable->AddReactivePath (
|
||||
preq.GetOriginatorAddress (),
|
||||
@@ -432,13 +435,12 @@ HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, M
|
||||
preq.GetMetric (),
|
||||
MicroSeconds (preq.GetLifetime () * 1024),
|
||||
preq.GetOriginatorSeqNumber ()
|
||||
);
|
||||
);
|
||||
ReactivePathResolved (preq.GetOriginatorAddress ());
|
||||
}
|
||||
//Add reactive path for precursor:
|
||||
if (
|
||||
((m_rtable->LookupReactive (fromMp)).retransmitter == Mac48Address::GetBroadcast ()) ||
|
||||
((m_rtable->LookupReactive (fromMp)).metric > preq.GetMetric ())
|
||||
(m_rtable->LookupReactive (fromMp).retransmitter == Mac48Address::GetBroadcast ()) ||
|
||||
(m_rtable->LookupReactive (fromMp).metric > metric)
|
||||
)
|
||||
{
|
||||
m_rtable->AddReactivePath (
|
||||
@@ -477,15 +479,6 @@ HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, M
|
||||
preq.GetOriginatorSeqNumber ()
|
||||
);
|
||||
ProactivePathResolved ();
|
||||
m_rtable->AddReactivePath (
|
||||
preq.GetOriginatorAddress (),
|
||||
from,
|
||||
interface,
|
||||
preq.GetMetric (),
|
||||
MicroSeconds (preq.GetLifetime () * 1024),
|
||||
preq.GetOriginatorSeqNumber ()
|
||||
);
|
||||
ReactivePathResolved (preq.GetOriginatorAddress ());
|
||||
}
|
||||
if (!preq.IsNeedNotPrep ())
|
||||
{
|
||||
@@ -493,7 +486,7 @@ HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, M
|
||||
GetAddress (),
|
||||
preq.GetOriginatorAddress (),
|
||||
from,
|
||||
preq.GetMetric (),
|
||||
(uint32_t)0,
|
||||
preq.GetOriginatorSeqNumber (),
|
||||
GetNextHwmpSeqno (),
|
||||
preq.GetLifetime (),
|
||||
@@ -523,9 +516,6 @@ HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, M
|
||||
if ((! ((*i)->IsDo ())) && (result.retransmitter != Mac48Address::GetBroadcast ()))
|
||||
{
|
||||
//have a valid information and can answer
|
||||
//!NB: If there is information from peer - set lifetime as
|
||||
//we have got from PREQ, and set the rest lifetime of the
|
||||
//route if the information is correct
|
||||
uint32_t lifetime = result.lifetime.GetMicroSeconds () / 1024;
|
||||
if ((lifetime > 0) && ((int32_t)(result.seqnum - (*i)->GetDestSeqNumber ()) >= 0))
|
||||
{
|
||||
@@ -539,6 +529,8 @@ HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, M
|
||||
lifetime,
|
||||
interface
|
||||
);
|
||||
m_rtable->AddPrecursor ((*i)->GetDestinationAddress (), interface, from,
|
||||
MicroSeconds (preq.GetLifetime () * 1024));
|
||||
if ((*i)->IsRf ())
|
||||
{
|
||||
(*i)->SetFlags (true, false, (*i)->IsUsn ()); //DO = 1, RF = 0
|
||||
@@ -579,29 +571,35 @@ HwmpProtocol::ReceivePrep (IePrep prep, Mac48Address from, uint32_t interface, M
|
||||
//Now add a path to destination and add precursor to source
|
||||
NS_LOG_DEBUG ("I am " << GetAddress () << ", received prep from " << prep.GetOriginatorAddress () << ", receiver was:" << from);
|
||||
HwmpRtable::LookupResult result = m_rtable->LookupReactive (prep.GetDestinationAddress ());
|
||||
//Add a reactive path only if it is better than existing:
|
||||
//Add a reactive path only if seqno is fresher or it improves the
|
||||
//metric
|
||||
if (
|
||||
((m_rtable->LookupReactive (prep.GetOriginatorAddress ())).retransmitter == Mac48Address::GetBroadcast ()) ||
|
||||
((m_rtable->LookupReactive (prep.GetOriginatorAddress ())).metric > prep.GetMetric ())
|
||||
(((int32_t)(i->second.first - prep.GetOriginatorSeqNumber ()) < 0)) ||
|
||||
(
|
||||
((m_rtable->LookupReactive (prep.GetOriginatorAddress ())).retransmitter == Mac48Address::GetBroadcast ()) ||
|
||||
((m_rtable->LookupReactive (prep.GetOriginatorAddress ())).metric > prep.GetMetric ())
|
||||
)
|
||||
)
|
||||
{
|
||||
m_rtable->AddReactivePath (
|
||||
prep.GetOriginatorAddress (),
|
||||
from,
|
||||
interface,
|
||||
prep.GetMetric (),
|
||||
MicroSeconds(prep.GetLifetime () * 1024),
|
||||
MicroSeconds (prep.GetLifetime () * 1024),
|
||||
prep.GetOriginatorSeqNumber ());
|
||||
m_rtable->AddPrecursor (prep.GetDestinationAddress (), interface, from);
|
||||
m_rtable->AddPrecursor (prep.GetDestinationAddress (), interface, from,
|
||||
MicroSeconds (prep.GetLifetime () * 1024));
|
||||
if (result.retransmitter != Mac48Address::GetBroadcast ())
|
||||
{
|
||||
m_rtable->AddPrecursor (prep.GetOriginatorAddress (), interface, result.retransmitter);
|
||||
m_rtable->AddPrecursor (prep.GetOriginatorAddress (), interface, result.retransmitter,
|
||||
result.lifetime);
|
||||
}
|
||||
ReactivePathResolved (prep.GetOriginatorAddress ());
|
||||
}
|
||||
if (
|
||||
((m_rtable->LookupReactive (fromMp)).retransmitter == Mac48Address::GetBroadcast ()) ||
|
||||
((m_rtable->LookupReactive (fromMp)).metric > prep.GetMetric ())
|
||||
((m_rtable->LookupReactive (fromMp)).metric > metric)
|
||||
)
|
||||
{
|
||||
m_rtable->AddReactivePath (
|
||||
@@ -669,7 +667,7 @@ HwmpProtocol::SendPrep (
|
||||
prep.SetDestinationAddress (dst);
|
||||
prep.SetDestinationSeqNumber (destinationSN);
|
||||
prep.SetLifetime (lifetime);
|
||||
prep.SetMetric (0);
|
||||
prep.SetMetric (initMetric);
|
||||
prep.SetOriginatorAddress (src);
|
||||
prep.SetOriginatorSeqNumber (originatorDsn);
|
||||
HwmpProtocolMacMap::const_iterator prep_sender = m_interfaces.find (interface);
|
||||
|
||||
@@ -84,11 +84,12 @@ HwmpRtable::AddProactivePath (uint32_t metric, Mac48Address root, Mac48Address r
|
||||
}
|
||||
void
|
||||
HwmpRtable::AddPrecursor (Mac48Address destination, uint32_t precursorInterface,
|
||||
Mac48Address precursorAddress)
|
||||
Mac48Address precursorAddress, Time lifetime)
|
||||
{
|
||||
std::pair<uint32_t, Mac48Address> precursor;
|
||||
precursor.first = precursorInterface;
|
||||
precursor.second = precursorAddress;
|
||||
Precursor precursor;
|
||||
precursor.interface = precursorInterface;
|
||||
precursor.address = precursorAddress;
|
||||
precursor.whenExpire = Simulator::Now () + lifetime;
|
||||
std::map<Mac48Address, ReactiveRoute>::iterator i = m_routes.find (destination);
|
||||
if (i != m_routes.end ())
|
||||
{
|
||||
@@ -97,9 +98,10 @@ HwmpRtable::AddPrecursor (Mac48Address destination, uint32_t precursorInterface,
|
||||
{
|
||||
//NB: Only one active route may exist, so do not check
|
||||
//interface ID, just address
|
||||
if (i->second.precursors[j].second == precursorAddress)
|
||||
if (i->second.precursors[j].address == precursorAddress)
|
||||
{
|
||||
should_add = false;
|
||||
i->second.precursors[j].whenExpire = precursor.whenExpire;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -108,17 +110,6 @@ HwmpRtable::AddPrecursor (Mac48Address destination, uint32_t precursorInterface,
|
||||
i->second.precursors.push_back (precursor);
|
||||
}
|
||||
}
|
||||
if (m_root.root == destination)
|
||||
{
|
||||
for (unsigned int j = 0; j < m_root.precursors.size (); j++)
|
||||
{
|
||||
if (m_root.precursors[j].second == precursorAddress)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
m_root.precursors.push_back (precursor);
|
||||
}
|
||||
void
|
||||
HwmpRtable::DeleteProactivePath ()
|
||||
@@ -221,27 +212,12 @@ HwmpRtable::GetPrecursors (Mac48Address destination)
|
||||
std::map<Mac48Address, ReactiveRoute>::iterator route = m_routes.find (destination);
|
||||
if (route != m_routes.end ())
|
||||
{
|
||||
for (unsigned int i = 0; i < route->second.precursors.size (); i++)
|
||||
for (std::vector<Precursor>::const_iterator i = route->second.precursors.begin ();
|
||||
i != route->second.precursors.end (); i++)
|
||||
{
|
||||
retval.push_back (route->second.precursors[i]);
|
||||
}
|
||||
}
|
||||
if (m_root.root == destination)
|
||||
{
|
||||
for (unsigned int i = 0; i < m_root.precursors.size (); i++)
|
||||
{
|
||||
bool should_add = true;
|
||||
for (unsigned int j = 0; j < retval.size (); j++)
|
||||
if (i->whenExpire > Simulator::Now ())
|
||||
{
|
||||
if (retval[j].second == m_root.precursors[i].second)
|
||||
{
|
||||
should_add = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (should_add)
|
||||
{
|
||||
retval.push_back (m_root.precursors[i]);
|
||||
retval.push_back (std::make_pair(i->interface, i->address));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public:
|
||||
Time lifetime,
|
||||
uint32_t seqnum
|
||||
);
|
||||
void AddPrecursor (Mac48Address destination, uint32_t precursorInterface, Mac48Address precursorAddress);
|
||||
void AddPrecursor (Mac48Address destination, uint32_t precursorInterface, Mac48Address precursorAddress, Time lifetime);
|
||||
PrecursorList GetPrecursors (Mac48Address destination);
|
||||
void DeleteProactivePath ();
|
||||
void DeleteProactivePath (Mac48Address root);
|
||||
@@ -109,6 +109,12 @@ public:
|
||||
|
||||
private:
|
||||
/// Route found in reactive mode
|
||||
struct Precursor
|
||||
{
|
||||
Mac48Address address;
|
||||
uint32_t interface;
|
||||
Time whenExpire;
|
||||
};
|
||||
struct ReactiveRoute
|
||||
{
|
||||
Mac48Address retransmitter;
|
||||
@@ -116,7 +122,7 @@ private:
|
||||
uint32_t metric;
|
||||
Time whenExpire;
|
||||
uint32_t seqnum;
|
||||
std::vector<std::pair<uint32_t, Mac48Address> > precursors;
|
||||
std::vector<Precursor> precursors;
|
||||
};
|
||||
/// Route fond in proactive mode
|
||||
struct ProactiveRoute
|
||||
@@ -127,7 +133,7 @@ private:
|
||||
uint32_t metric;
|
||||
Time whenExpire;
|
||||
uint32_t seqnum;
|
||||
std::vector<std::pair<uint32_t, Mac48Address> > precursors;
|
||||
std::vector<Precursor> precursors;
|
||||
};
|
||||
|
||||
/// List of routes
|
||||
|
||||
@@ -135,6 +135,7 @@ void
|
||||
IePrep::DecrementTtl ()
|
||||
{
|
||||
m_ttl--;
|
||||
m_hopcount ++;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -317,17 +317,17 @@ void
|
||||
IePreq::Print (std::ostream &os) const
|
||||
{
|
||||
os << std::endl << "<information_element id=" << ElementId () << ">" << std::endl;
|
||||
os << " originator address = " << m_originatorAddress << "std::endl";
|
||||
os << " TTL = " << (uint16_t) m_ttl << "std::endl";
|
||||
os << " hop count = " << (uint16_t) m_hopCount << "std::endl";
|
||||
os << " metric = " << m_metric << "std::endl";
|
||||
os << " seqno = " << m_originatorSeqNumber << "std::endl";
|
||||
os << " lifetime = " << m_lifetime << "std::endl";
|
||||
os << " preq ID = " << m_preqId << "std::endl";
|
||||
os << " Destinations are:std::endl";
|
||||
os << " originator address = " << m_originatorAddress << std::endl;
|
||||
os << " TTL = " << (uint16_t) m_ttl << std::endl;
|
||||
os << " hop count = " << (uint16_t) m_hopCount << std::endl;
|
||||
os << " metric = " << m_metric << std::endl;
|
||||
os << " seqno = " << m_originatorSeqNumber << std::endl;
|
||||
os << " lifetime = " << m_lifetime << std::endl;
|
||||
os << " preq ID = " << m_preqId << std::endl;
|
||||
os << " Destinations are:" << std::endl;
|
||||
for (int j = 0; j < m_destCount; j++)
|
||||
{
|
||||
os << " " << m_destinations[j]->GetDestinationAddress () << "std::endl";
|
||||
os << " " << m_destinations[j]->GetDestinationAddress () << std::endl;
|
||||
}
|
||||
os << "</information_element>" << std::endl;
|
||||
}
|
||||
|
||||
@@ -152,12 +152,12 @@ void
|
||||
IeRann::Print (std::ostream &os) const
|
||||
{
|
||||
os << std::endl << "<information_element id=" << ElementId () << ">" << std::endl;
|
||||
os << " flags = " << (int) m_flags << "std::endl";
|
||||
os << " hop count = " << (int) m_hopcount << "std::endl";
|
||||
os << " TTL = " << (int) m_ttl << "std::endl";
|
||||
os << " originator address = " << m_originatorAddress << "std::endl";
|
||||
os << " dst seq. number = " << m_destSeqNumber << "std::endl";
|
||||
os << " metric = " << m_metric << "std::endl";
|
||||
os << " flags = " << (int) m_flags << std::endl;
|
||||
os << " hop count = " << (int) m_hopcount << std::endl;
|
||||
os << " TTL = " << (int) m_ttl << std::endl;
|
||||
os << " originator address = " << m_originatorAddress << std::endl;
|
||||
os << " dst seq. number = " << m_destSeqNumber << std::endl;
|
||||
os << " metric = " << m_metric << std::endl;
|
||||
os << "</information_element>" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user