From ad35fe761a66f2df7d5e940fee5398c38ed0ae94 Mon Sep 17 00:00:00 2001 From: Kirill Andreev Date: Thu, 16 Apr 2009 16:36:19 +0400 Subject: [PATCH] Preq queue bugfix. deleted m_myPreq --- src/devices/mesh/dot11s/hwmp-mac-plugin.cc | 54 ++++++++-------------- src/devices/mesh/dot11s/hwmp-mac-plugin.h | 1 - src/devices/mesh/dot11s/ie-dot11s-preq.cc | 28 ++++------- src/devices/mesh/dot11s/ie-dot11s-preq.h | 7 ++- 4 files changed, 36 insertions(+), 54 deletions(-) diff --git a/src/devices/mesh/dot11s/hwmp-mac-plugin.cc b/src/devices/mesh/dot11s/hwmp-mac-plugin.cc index d7b56f438..29863de51 100644 --- a/src/devices/mesh/dot11s/hwmp-mac-plugin.cc +++ b/src/devices/mesh/dot11s/hwmp-mac-plugin.cc @@ -35,10 +35,9 @@ namespace dot11s { NS_LOG_COMPONENT_DEFINE ("HwmpMacPlugin"); HwmpMacPlugin::HwmpMacPlugin (uint32_t ifIndex, Ptr protocol): - m_myPreq (m_preqQueue.end()) + m_ifIndex (ifIndex), + m_protocol (protocol) { - m_ifIndex = ifIndex; - m_protocol = protocol; } HwmpMacPlugin::~HwmpMacPlugin () { @@ -154,39 +153,30 @@ HwmpMacPlugin::UpdateOutcomingFrame (Ptr packet, WifiMacHeader & header, void HwmpMacPlugin::SendPreq(IePreq preq) { - if(m_myPreq == m_preqQueue.end ()) - { - m_preqQueue.push_back (preq); - m_myPreq = m_preqQueue.end (); - } - else m_preqQueue.push_back (preq); SendOnePreq (); } void HwmpMacPlugin::RequestDestination (Mac48Address dst, uint32_t originator_seqno, uint32_t dst_seqno) { - if (m_preqQueue.end () == m_myPreq) - { - IePreq preq; - //fill PREQ: - preq.SetHopcount (0); - preq.SetTTL (m_protocol->GetMaxTtl ()); - preq.SetPreqID (m_protocol->GetNextPreqId ()); - preq.SetOriginatorAddress (m_protocol->GetAddress ()); - preq.SetOriginatorSeqNumber (originator_seqno); - preq.SetLifetime (m_protocol->GetActivePathLifetime ()); - preq.AddDestinationAddressElement (false, false, dst, dst_seqno); - m_preqQueue.push_back (preq); - //set iterator position to my preq: - m_myPreq = m_preqQueue.end () - 1; - SendOnePreq (); - } - else - { - NS_ASSERT (m_myPreq->GetOriginatorAddress() == m_protocol->GetAddress()); - m_myPreq->AddDestinationAddressElement (m_protocol->GetDoFlag(), m_protocol->GetRfFlag(), dst, dst_seqno); - } + for(std::vector::iterator i = m_preqQueue.begin (); i != m_preqQueue.end (); i ++) + if(i->MayAddAddress(m_protocol->GetAddress ())) + { + i->AddDestinationAddressElement (m_protocol->GetDoFlag(), m_protocol->GetRfFlag(), dst, dst_seqno); + return; + } + IePreq preq; + //fill PREQ: + preq.SetHopcount (0); + preq.SetTTL (m_protocol->GetMaxTtl ()); + preq.SetPreqID (m_protocol->GetNextPreqId ()); + preq.SetOriginatorAddress (m_protocol->GetAddress ()); + preq.SetOriginatorSeqNumber (originator_seqno); + preq.SetLifetime (m_protocol->GetActivePathLifetime ()); + preq.AddDestinationAddressElement (false, false, dst, dst_seqno); + m_preqQueue.push_back (preq); + //set iterator position to my preq: + SendOnePreq (); } void HwmpMacPlugin::SendOnePreq () @@ -195,8 +185,6 @@ HwmpMacPlugin::SendOnePreq () return; if (m_preqQueue.size () == 0) return; - if (m_myPreq == m_preqQueue.begin ()) - m_myPreq == m_preqQueue.end (); //reschedule sending PREQ NS_ASSERT (!m_preqTimer.IsRunning()); m_preqTimer = Simulator::Schedule (m_protocol->GetPreqMinInterval (), &HwmpMacPlugin::SendOnePreq, this); @@ -232,8 +220,6 @@ HwmpMacPlugin::SendOnePreq () } //erase queue m_preqQueue.erase (m_preqQueue.begin()); - if(m_preqQueue.size () == 0) - m_myPreq = m_preqQueue.end (); } void HwmpMacPlugin::SendOnePerr() diff --git a/src/devices/mesh/dot11s/hwmp-mac-plugin.h b/src/devices/mesh/dot11s/hwmp-mac-plugin.h index c13bd4faa..beb6f438b 100644 --- a/src/devices/mesh/dot11s/hwmp-mac-plugin.h +++ b/src/devices/mesh/dot11s/hwmp-mac-plugin.h @@ -88,7 +88,6 @@ private: //\{ EventId m_preqTimer; std::vector m_preqQueue; - std::vector::iterator m_myPreq; //\} ///\name PERR timer and stored path error //{ diff --git a/src/devices/mesh/dot11s/ie-dot11s-preq.cc b/src/devices/mesh/dot11s/ie-dot11s-preq.cc index c45bcf465..aa55538bf 100644 --- a/src/devices/mesh/dot11s/ie-dot11s-preq.cc +++ b/src/devices/mesh/dot11s/ie-dot11s-preq.cc @@ -174,24 +174,16 @@ IePreq::SetDestCount (uint8_t dest_count) { m_destCount = dest_count; } - -//uint8_t -//IePreq::GetFlags () const -//{ -// return m_flags; -//} bool IePreq::IsUnicastPreq () const { return (m_flags & (1<<1)); } - bool IePreq::IsNeedNotPrep () const { return (m_flags & (1<<2)); } - uint8_t IePreq::GetHopCount () const { @@ -233,20 +225,17 @@ IePreq::GetDestCount () const { return m_destCount; } - void IePreq::DecrementTtl () { m_ttl --; m_hopCount ++; } - void IePreq::IncrementMetric (uint32_t metric) { m_metric +=metric; } - void IePreq::SerializeInformation (Buffer::Iterator i) const { @@ -277,7 +266,6 @@ IePreq::SerializeInformation (Buffer::Iterator i) const break; } } - uint8_t IePreq::DeserializeInformation (Buffer::Iterator start, uint8_t length) { @@ -375,7 +363,6 @@ IePreq::AddDestinationAddressElement ( m_destinations.push_back (new_element); m_destCount++; } - void IePreq::DelDestinationAddressElement (Mac48Address dest_address) { @@ -387,7 +374,6 @@ IePreq::DelDestinationAddressElement (Mac48Address dest_address) break; } } - void IePreq::ClearDestinationAddressElement () { @@ -397,8 +383,7 @@ IePreq::ClearDestinationAddressElement () for (i = 0; i < m_destCount; i ++) m_destinations.pop_back (); m_destinations.clear (); -}; - +} bool operator== (const DestinationAddressUnit & a, const DestinationAddressUnit & b) { return (a.m_do == b.m_do @@ -408,7 +393,6 @@ bool operator== (const DestinationAddressUnit & a, const DestinationAddressUnit && a.m_destSeqNumber == b.m_destSeqNumber ); } - bool operator== (const IePreq & a, const IePreq & b) { bool ok = ( a.m_flags == b.m_flags @@ -437,7 +421,15 @@ bool operator== (const IePreq & a, const IePreq & b) return true; } - +bool +IePreq::MayAddAddress (Mac48Address originator) +{ + if (m_originatorAddress != originator) + return false; + if(m_destinations[0]->GetDestinationAddress () == Mac48Address::GetBroadcast ()) + return false; + return true; +} #ifdef RUN_SELF_TESTS /// Built-in self test for IePreq diff --git a/src/devices/mesh/dot11s/ie-dot11s-preq.h b/src/devices/mesh/dot11s/ie-dot11s-preq.h index e6baf9914..ea39d1fc3 100644 --- a/src/devices/mesh/dot11s/ie-dot11s-preq.h +++ b/src/devices/mesh/dot11s/ie-dot11s-preq.h @@ -46,7 +46,6 @@ public: bool IsUsn (); Mac48Address GetDestinationAddress () const; uint32_t GetDestSeqNumber () const; - private: bool m_do; bool m_rf; @@ -102,6 +101,12 @@ public: uint8_t GetDestCount () const; void DecrementTtl (); void IncrementMetric (uint32_t metric); + /* + * \brief Checks that preq's originator address equals to originator, and + * this preq is not proactive + */ + bool MayAddAddress(Mac48Address originator); + private: WifiElementId ElementId () const{ return IE11S_PREQ;