Fixed PREQ propagation, added comments to PREQ information element
authorKirill Andreev <andreev@iitp.ru>
Wed, 08 Jul 2009 13:42:46 +0400
changeset 5107 ec4196c70800
parent 5106 de6fe90556c8
child 5108 c7e52ca238d3
Fixed PREQ propagation, added comments to PREQ information element
src/devices/mesh/dot11s/hwmp-protocol-mac.cc
src/devices/mesh/dot11s/hwmp-protocol-mac.h
src/devices/mesh/dot11s/ie-dot11s-preq.cc
src/devices/mesh/dot11s/ie-dot11s-preq.h
--- a/src/devices/mesh/dot11s/hwmp-protocol-mac.cc	Mon Jul 06 14:31:55 2009 +0400
+++ b/src/devices/mesh/dot11s/hwmp-protocol-mac.cc	Wed Jul 08 13:42:46 2009 +0400
@@ -170,43 +170,9 @@
 void
 HwmpProtocolMac::SendPreq(IePreq preq)
 {
-  m_preqQueue.push_back (preq);
-  SendOnePreq ();
-}
-void
-HwmpProtocolMac::RequestDestination (Mac48Address dst, uint32_t originator_seqno, uint32_t dst_seqno)
-{
-  for(std::vector<IePreq>::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 (m_protocol->GetDoFlag (), m_protocol->GetRfFlag (), dst, dst_seqno);
-  m_preqQueue.push_back (preq);
-  //set iterator position to my preq:
-  SendOnePreq ();
-}
-void
-HwmpProtocolMac::SendOnePreq ()
-{
-  if(m_preqTimer.IsRunning ())
-    return;
-  if (m_preqQueue.size () == 0)
-    return;
-  //reschedule sending PREQ
-  NS_ASSERT (!m_preqTimer.IsRunning());
-  m_preqTimer = Simulator::Schedule (m_protocol->GetPreqMinInterval (), &HwmpProtocolMac::SendOnePreq, this);
-  Ptr<Packet> packet  = Create<Packet> ();
-  packet->AddHeader(m_preqQueue[0]);
+  NS_LOG_FUNCTION_NOARGS ();
+  Ptr<Packet> packet = Create<Packet> ();
+  packet->AddHeader(preq);
   //Action header:
   WifiMeshActionHeader actionHdr;
   WifiMeshActionHeader::ActionValue action;
@@ -230,12 +196,41 @@
     m_stats.txMgtBytes += packet->GetSize ();
     m_parent->SendManagementFrame(packet, hdr);
   }
-  //erase queue
-  m_preqQueue.erase (m_preqQueue.begin());
+}
+void
+HwmpProtocolMac::RequestDestination (Mac48Address dst, uint32_t originator_seqno, uint32_t dst_seqno)
+{
+  NS_LOG_FUNCTION_NOARGS ();
+  if(m_myPreq.GetDestCount () == 0)
+  {
+    m_myPreq.SetHopcount (0);
+    m_myPreq.SetTTL (m_protocol->GetMaxTtl ());
+    m_myPreq.SetPreqID (m_protocol->GetNextPreqId ());
+    m_myPreq.SetOriginatorAddress (m_protocol->GetAddress ());
+    m_myPreq.SetOriginatorSeqNumber (originator_seqno);
+    m_myPreq.SetLifetime (m_protocol->GetActivePathLifetime ());
+  }
+  m_myPreq.AddDestinationAddressElement (m_protocol->GetDoFlag(), m_protocol->GetRfFlag(), dst, dst_seqno);
+  SendMyPreq ();
+}
+void
+HwmpProtocolMac::SendMyPreq ()
+{
+  NS_LOG_FUNCTION_NOARGS ();
+  if(m_preqTimer.IsRunning ())
+    return;
+  if(m_myPreq.GetDestCount () == 0)
+    return;
+  //reschedule sending PREQ
+  NS_ASSERT (!m_preqTimer.IsRunning());
+  m_preqTimer = Simulator::Schedule (m_protocol->GetPreqMinInterval (), &HwmpProtocolMac::SendMyPreq, this);
+  SendPreq (m_myPreq);
+  m_myPreq.ClearDestinationAddressElements ();
 }
 void
 HwmpProtocolMac::SendOnePerr()
 {
+  NS_LOG_FUNCTION_NOARGS ();
   if(m_perrTimer.IsRunning ())
     return;
   if(m_myPerr.receivers.size () >= m_protocol->GetUnicastPerrThreshold ())
@@ -275,6 +270,7 @@
 void
 HwmpProtocolMac::SendPrep (IePrep prep, Mac48Address receiver)
 {
+  NS_LOG_FUNCTION_NOARGS ();
   //Create packet
   Ptr<Packet> packet  = Create<Packet> ();
   packet->AddHeader(prep);
@@ -301,6 +297,7 @@
 void
 HwmpProtocolMac::SendPerr(IePerr perr, std::vector<Mac48Address> receivers)
 {
+  NS_LOG_FUNCTION_NOARGS ();
   m_myPerr.perr.Merge(perr);
   for(unsigned int i = 0; i < receivers.size (); i ++)
   {
--- a/src/devices/mesh/dot11s/hwmp-protocol-mac.h	Mon Jul 06 14:31:55 2009 +0400
+++ b/src/devices/mesh/dot11s/hwmp-protocol-mac.h	Wed Jul 08 13:42:46 2009 +0400
@@ -23,6 +23,7 @@
 #define HWMP_STATE_H
 
 #include "ns3/mesh-wifi-interface-mac-plugin.h"
+#include "ie-dot11s-preq.h"
 #include "ie-dot11s-perr.h"
 
 namespace ns3 {
@@ -73,7 +74,7 @@
   //\}
   
   /// Sends one PREQ when PreqMinInterval after last PREQ expires (if any PREQ exists in rhe queue)
-  void SendOnePreq ();
+  void SendMyPreq ();
   void SendOnePerr ();
   /// \return metric to HWMP protocol, needed only by metrics to add
   //peer as routing entry
@@ -87,10 +88,10 @@
   uint32_t m_ifIndex;
   Ptr<HwmpProtocol> m_protocol;
   
-  ///\name PREQ queue and PREQ timer:
+  ///\name my PREQ and PREQ timer:
   //\{
-  EventId  m_preqTimer;
-  std::vector<IePreq>  m_preqQueue;
+  EventId m_preqTimer;
+  IePreq  m_myPreq;
   //\}
   ///\name PERR timer and stored path error
   //\{
--- a/src/devices/mesh/dot11s/ie-dot11s-preq.cc	Mon Jul 06 14:31:55 2009 +0400
+++ b/src/devices/mesh/dot11s/ie-dot11s-preq.cc	Wed Jul 08 13:42:46 2009 +0400
@@ -355,7 +355,7 @@
       }
 }
 void
-IePreq::ClearDestinationAddressElement ()
+IePreq::ClearDestinationAddressElements ()
 {
   int i;
   for (std::vector<Ptr<DestinationAddressUnit> >::iterator j = m_destinations.begin (); j != m_destinations.end(); j++)
@@ -363,6 +363,7 @@
   for (i = 0; i < m_destCount; i ++)
     m_destinations.pop_back ();
   m_destinations.clear ();
+  m_destCount = 0;
 }
 bool operator== (const DestinationAddressUnit & a, const DestinationAddressUnit & b)
 {
--- a/src/devices/mesh/dot11s/ie-dot11s-preq.h	Mon Jul 06 14:31:55 2009 +0400
+++ b/src/devices/mesh/dot11s/ie-dot11s-preq.h	Wed Jul 08 13:42:46 2009 +0400
@@ -64,20 +64,30 @@
 public:
   IePreq ();
   ~IePreq ();
+  /**
+   * Add a destination address unit: flags, destination and sequence
+   * number
+   */
   void AddDestinationAddressElement (
     bool doFlag,
     bool rfFlag,
     Mac48Address dest_address,
     uint32_t dest_seq_number
   );
+  /// Delete a destination address unit by destination
   void DelDestinationAddressElement (Mac48Address dest_address);
-  void ClearDestinationAddressElement ();
+  /// Clear PREQ: remove all destinations
+  void ClearDestinationAddressElements ();
+  /// Get all destinations, which are stored in PREQ:
   std::vector<Ptr<DestinationAddressUnit> > GetDestinationList ();
+  /// SetProper flags which indicate that PREQ is unicast
   void SetUnicastPreq ();
   /*
    * \brief In proactive case: need we send PREP
    */
   void SetNeedNotPrep ();
+  ///\name Setters for fields:
+  ///\{
   void SetHopcount (uint8_t hopcount);
   void SetTTL (uint8_t ttl);
   void SetPreqID (uint32_t id);
@@ -86,7 +96,9 @@
   void SetLifetime (uint32_t lifetime);
   void SetMetric (uint32_t metric);
   void SetDestCount (uint8_t dest_count);
-
+  ///\}
+  ///\name Getters for fields:
+  ///\{
   bool  IsUnicastPreq () const;
   bool  IsNeedNotPrep () const;
   uint8_t  GetHopCount () const;
@@ -97,6 +109,8 @@
   uint32_t GetLifetime () const;
   uint32_t GetMetric () const;
   uint8_t  GetDestCount () const;
+  ///\}
+  /// Handle TTL and Metric:
   void  DecrementTtl ();
   void  IncrementMetric (uint32_t metric);
   /*