Added proper flags to HWMP PREQ, routing information is updated in accordance
with D3.0
--- a/src/devices/mesh/dot11s/hwmp-mac-plugin.cc Thu Apr 09 14:57:44 2009 +0400
+++ b/src/devices/mesh/dot11s/hwmp-mac-plugin.cc Thu Apr 09 17:47:14 2009 +0400
@@ -155,7 +155,7 @@
SendOnePreq ();
}
void
-HwmpMacPlugin::RequestDestination (Mac48Address dst, uint32_t seqno)
+HwmpMacPlugin::RequestDestination (Mac48Address dst, uint32_t originator_seqno, uint32_t dst_seqno)
{
if (m_preqQueue.end () == m_myPreq)
{
@@ -165,9 +165,9 @@
preq.SetTTL (m_protocol->GetMaxTtl ());
preq.SetPreqID (m_protocol->GetNextPreqId ());
preq.SetOriginatorAddress (m_protocol->GetAddress ());
- preq.SetOriginatorSeqNumber (seqno);
+ preq.SetOriginatorSeqNumber (originator_seqno);
preq.SetLifetime (m_protocol->GetActivePathLifetime ());
- preq.AddDestinationAddressElement (false, false, dst, 0); //DO = 0, RF = 0
+ preq.AddDestinationAddressElement (false, false, dst, dst_seqno);
m_preqQueue.push_back (preq);
//set iterator position to my preq:
m_myPreq = m_preqQueue.end () - 1;
@@ -176,7 +176,7 @@
else
{
NS_ASSERT (m_myPreq->GetOriginatorAddress() == m_protocol->GetAddress());
- m_myPreq->AddDestinationAddressElement (m_protocol->GetDoFlag(), m_protocol->GetRfFlag(), dst, 0); //DO = 0, RF = 0
+ m_myPreq->AddDestinationAddressElement (m_protocol->GetDoFlag(), m_protocol->GetRfFlag(), dst, dst_seqno);
}
}
void
--- a/src/devices/mesh/dot11s/hwmp-mac-plugin.h Thu Apr 09 14:57:44 2009 +0400
+++ b/src/devices/mesh/dot11s/hwmp-mac-plugin.h Thu Apr 09 17:47:14 2009 +0400
@@ -63,7 +63,13 @@
void SendPreq(IePreq preq);
void SendPrep(IePrep prep, Mac48Address receiver);
void SendPerr(IePerr perr, std::vector<Mac48Address> receivers);
- void RequestDestination (Mac48Address dest, uint32_t seqno);
+ ///\brief Request a destination. If can not send preq immediately -
+ //add a destination to exisying PREQ generated by me and stored in
+ //PREQ queue
+ ///\param originator_seqno is a sequence number that shall be preq
+ //originator sequenece number
+ ///\param dst_seqno is a sequence number taken from routing table
+ void RequestDestination (Mac48Address dest, uint32_t originator_seqno, uint32_t dst_seqno);
//\}
/// Sends one PREQ when PreqMinInterval after last PREQ expires (if any PREQ exists in rhe queue)
--- a/src/devices/mesh/dot11s/hwmp-protocol.cc Thu Apr 09 14:57:44 2009 +0400
+++ b/src/devices/mesh/dot11s/hwmp-protocol.cc Thu Apr 09 17:47:14 2009 +0400
@@ -276,11 +276,15 @@
return false;
}
//Request a destination:
+ result = m_rtable->LookupReactiveExpired (destination);
if(ShouldSendPreq(destination))
{
- uint32_t seqno = GetNextHwmpSeqno ();
+ uint32_t originator_seqno = GetNextHwmpSeqno ();
+ uint32_t dst_seqno = 0;
+ if(result.retransmitter != Mac48Address::GetBroadcast ())
+ dst_seqno = result.seqnum;
for(HwmpPluginMap::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i ++)
- i->second->RequestDestination(destination, seqno);
+ i->second->RequestDestination(destination, originator_seqno, dst_seqno);
}
QueuedPacket pkt;
HwmpTag tag;
@@ -376,7 +380,7 @@
{
//have a valid information and acn answer
if ((*i)->IsRf ())
- (*i)->SetFlags (true, false); //DO = 1, RF = 0 (as it was)
+ (*i)->SetFlags (true, false, (*i)->IsUsn ()); //DO = 1, RF = 0 (as it was)
else
{
//send a PREP and delete destination
@@ -432,21 +436,28 @@
NS_LOG_DEBUG("I am "<<m_address<<", received prep from "<<prep.GetOriginatorAddress ()<<", receiver was:"<<from);
//update routing info
//Now add a path to destination and add precursor to source
- m_rtable->AddPrecursor (prep.GetDestinationAddress (), interface, from);
- m_rtable->AddReactivePath (
- prep.GetOriginatorAddress (),
- from,
- interface,
- prep.GetMetric (),
- MicroSeconds(prep.GetLifetime () * 1024),
- prep.GetOriginatorSeqNumber ());
HwmpRtable::LookupResult result = m_rtable->LookupReactive(prep.GetDestinationAddress());
+ //Add a reactive path only if it is better than existing:
+ if (
+ (result.retransmitter == Mac48Address::GetBroadcast ()) ||
+ (result.retransmitter != Mac48Address::GetBroadcast ()) && (result.metric > prep.GetMetric ())
+ )
+ {
+ m_rtable->AddPrecursor (prep.GetDestinationAddress (), interface, from);
+ m_rtable->AddReactivePath (
+ prep.GetOriginatorAddress (),
+ from,
+ interface,
+ prep.GetMetric (),
+ MicroSeconds(prep.GetLifetime () * 1024),
+ prep.GetOriginatorSeqNumber ());
+ m_rtable->AddPrecursor (prep.GetOriginatorAddress (), interface, result.retransmitter);
+ }
if (result.retransmitter == Mac48Address::GetBroadcast ())
//try to look for default route
result = m_rtable->LookupProactive ();
if (result.retransmitter == Mac48Address::GetBroadcast ())
return;
- m_rtable->AddPrecursor (prep.GetOriginatorAddress (), interface, result.retransmitter);
//Forward PREP
HwmpPluginMap::const_iterator prep_sender = m_interfaces.find (result.ifIndex);
NS_ASSERT(prep_sender != m_interfaces.end ());
@@ -539,8 +550,8 @@
NS_ASSERT(i != m_interfaces.end ());
if(result.metric < i->second->GetLinkMetric(peerAddress))
{
- m_rtable->AddReactivePath(meshPointAddress, peerAddress, interface, 1, Seconds (0), i->second->GetLinkMetric(peerAddress));
- ReactivePathResolved (meshPointAddress);
+ m_rtable->AddReactivePath(meshPointAddress, peerAddress, interface, 1, Seconds (0), i->second->GetLinkMetric(peerAddress));
+ ReactivePathResolved (meshPointAddress);
}
}
else
@@ -756,9 +767,12 @@
m_preqTimeouts.erase (i);
return;
}
- uint32_t seqno = GetNextHwmpSeqno ();
+ uint32_t originator_seqno = GetNextHwmpSeqno ();
+ uint32_t dst_seqno = 0;
+ if(result.retransmitter != Mac48Address::GetBroadcast ())
+ dst_seqno = result.seqnum;
for(HwmpPluginMap::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i ++)
- i->second->RequestDestination(dst, seqno);
+ i->second->RequestDestination(dst, originator_seqno, dst_seqno);
m_preqTimeouts[dst] = Simulator::Schedule (
MilliSeconds (2*(m_dot11MeshHWMPnetDiameterTraversalTime.GetMilliSeconds())),
&HwmpProtocol::RetryPathDiscovery, this, dst, numOfRetry);
@@ -831,7 +845,7 @@
{
m_hwmpSeqno ++;
if(m_hwmpSeqno == 0xffffffff)
- m_hwmpSeqno = 0;
+ m_hwmpSeqno = 1;
return m_hwmpSeqno;
}
uint32_t
--- a/src/devices/mesh/dot11s/ie-dot11s-preq.cc Thu Apr 09 14:57:44 2009 +0400
+++ b/src/devices/mesh/dot11s/ie-dot11s-preq.cc Thu Apr 09 17:47:14 2009 +0400
@@ -31,29 +31,28 @@
/*************************
* DestinationAddressUnit
************************/
-DestinationAddressUnit::DestinationAddressUnit ()
+DestinationAddressUnit::DestinationAddressUnit ():
+ m_do (false),
+ m_rf (false),
+ m_usn (false),
+ m_destinationAddress (Mac48Address ()),
+ m_destSeqNumber (0)
{
- m_do = false;
- m_rf = false;
- m_destSeqNumber = 0;
- uint8_t mac_buffer[6];
- for (int j = 0; j < 6; j++)
- {
- mac_buffer[j] = 0;
- }
- m_destinationAddress.CopyFrom (mac_buffer);
}
void
-DestinationAddressUnit::SetFlags (bool doFlag, bool rfFlag)
+DestinationAddressUnit::SetFlags (bool doFlag, bool rfFlag, bool usnFlag)
{
m_do = doFlag;
m_rf = rfFlag;
+ m_usn = usnFlag;
}
void
DestinationAddressUnit::SetDestSeqNumber (uint32_t dest_seq_number)
{
m_destSeqNumber = dest_seq_number;
+ if(m_destSeqNumber != 0)
+ m_usn = true;
}
void
DestinationAddressUnit::SetDestinationAddress (Mac48Address dest_address)
@@ -71,7 +70,11 @@
{
return m_rf;
}
-
+bool
+DestinationAddressUnit::IsUsn ()
+{
+ return m_usn;
+}
uint32_t
DestinationAddressUnit::GetDestSeqNumber () const
{
@@ -261,9 +264,11 @@
{
uint8_t flags = 0;
if ((*j)->IsDo ())
- flags +=128;
+ flags += 128;
if ((*j)->IsRf ())
- flags +=64;
+ flags += 64;
+ if((*j)->IsUsn ())
+ flags += 32;
i.WriteU8 (flags);
WriteTo (i, (*j)->GetDestinationAddress());
i.WriteHtonU32 ((*j)->GetDestSeqNumber ());
@@ -291,6 +296,7 @@
Ptr<DestinationAddressUnit> new_element = Create<DestinationAddressUnit> ();
bool doFlag = false;
bool rfFlag = false;
+ bool usnFlag = false;
uint8_t flags = i.ReadU8 ();
if (flags >= 128)
{
@@ -298,8 +304,13 @@
flags -=128;
}
if (flags >=64)
+ {
rfFlag = true;
- new_element->SetFlags (doFlag, rfFlag);
+ flags -= 64;
+ }
+ if (flags >= 32)
+ usnFlag = true;
+ new_element->SetFlags (doFlag, rfFlag, usnFlag);
Mac48Address addr;
ReadFrom (i,addr);
new_element->SetDestinationAddress (addr);
@@ -358,7 +369,7 @@
if ((*i)->GetDestinationAddress () == dest_address)
return;
Ptr<DestinationAddressUnit>new_element = Create<DestinationAddressUnit> ();
- new_element->SetFlags (doFlag, rfFlag);
+ new_element->SetFlags (doFlag, rfFlag, false);
new_element->SetDestinationAddress (dest_address);
new_element->SetDestSeqNumber (dest_seq_number);
m_destinations.push_back (new_element);
@@ -392,6 +403,7 @@
{
return (a.m_do == b.m_do
&& a.m_rf == b.m_rf
+ && a.m_usn == b.m_usn
&& a.m_destinationAddress == b.m_destinationAddress
&& a.m_destSeqNumber == b.m_destSeqNumber
);
--- a/src/devices/mesh/dot11s/ie-dot11s-preq.h Thu Apr 09 14:57:44 2009 +0400
+++ b/src/devices/mesh/dot11s/ie-dot11s-preq.h Thu Apr 09 17:47:14 2009 +0400
@@ -38,17 +38,19 @@
{
public:
DestinationAddressUnit ();
- void SetFlags (bool doFlag, bool rfflag);
+ void SetFlags (bool doFlag, bool rfFlag, bool usnFlag);
void SetDestinationAddress (Mac48Address dest_address);
void SetDestSeqNumber (uint32_t dest_seq_number);
bool IsDo ();
bool IsRf ();
+ bool IsUsn ();
Mac48Address GetDestinationAddress () const;
uint32_t GetDestSeqNumber () const;
private:
bool m_do;
bool m_rf;
+ bool m_usn;
Mac48Address m_destinationAddress;
uint32_t m_destSeqNumber;