Removed commented code, removed unneded debg messages
authorKirill Andreev <andreev@iitp.ru>
Wed, 01 Apr 2009 16:53:20 +0400
changeset 4925 765deb024525
parent 4924 aa4bd88fadb9
child 4926 a9382a693fa1
Removed commented code, removed unneded debg messages
src/devices/mesh/dot11s/hwmp-mac-plugin.cc
src/devices/mesh/dot11s/hwmp-mac-plugin.h
src/devices/mesh/dot11s/hwmp-protocol.cc
--- a/src/devices/mesh/dot11s/hwmp-mac-plugin.cc	Wed Apr 01 16:21:42 2009 +0400
+++ b/src/devices/mesh/dot11s/hwmp-mac-plugin.cc	Wed Apr 01 16:53:20 2009 +0400
@@ -142,17 +142,6 @@
   header.SetAddr1(tag.GetAddress());
   return true;
 }
-#if 0
-HwmpMacPlugin::HwmpMacPlugin ():
-{
-}
-
-HwmpMacPlugin::~HwmpMacPlugin ()
-{
-  m_preqQueue.clear ();
-}
-//Interaction with HWMP:
-#endif
 void
 HwmpMacPlugin::SendPreq(IePreq preq)
 {
@@ -205,73 +194,14 @@
     m_preqQueue.push_back (preq);
     //set iterator position to my preq:
     m_myPreq = m_preqQueue.end () -1;
-    NS_LOG_UNCOND("no preq");
     SendOnePreq ();
   }
   else
   {
     NS_ASSERT (m_myPreq->GetOriginatorAddress() == m_parent->GetAddress());
-    NS_LOG_UNCOND ("add a destination "<<dst);
     m_myPreq->AddDestinationAddressElement (false, false, dst, 0); //DO = 0, RF = 0
   }
 }
-#if 0
-void
-HwmpMacPlugin::SendPathError (std::vector<HwmpRtable::FailedDestination> destinations)
-{
-  std::vector<Mac48Address> receivers =  m_retransmittersOfPerrCallback (destinations, m_ifIndex);
-  NS_LOG_DEBUG ("SendPathError started");
-  if (receivers.size () == 0)
-    return;
-  NS_LOG_DEBUG (m_address<<" Should Send PERR to");
-  for (unsigned int i = 0; i < receivers.size (); i ++)
-    {
-      AddPerrReceiver (receivers[i]);
-      NS_LOG_DEBUG (receivers[i]);
-    }
-  NS_LOG_DEBUG ("To tel about failure with");
-  for (unsigned int i = 0; i < destinations.size (); i ++)
-    {
-      m_myPerr.AddAddressUnit (destinations[i]);
-      NS_LOG_DEBUG (destinations[i].destination);
-    }
-  if (!m_perrTimer.IsRunning ())
-    {
-      m_perrCallback (m_myPerr,m_myPerrReceivers);
-      m_myPerr.ResetPerr ();
-      m_perrTimer = Simulator::Schedule (dot11sParameters::dot11MeshHWMPperrMinInterval,&HwmpMacPlugin::SendOnePerr,this);
-    }
-}
-void
-HwmpMacPlugin::ReceivePerr (IeDot11sPerr& perr, const Mac48Address& from)
-{
-  if (m_disabled)
-    return;
-  NS_LOG_DEBUG (m_address<<" RECEIVED PERR from "<<from);
-  /**
-   * Check forwarding conditions:
-   */
-  std::vector<HwmpRtable::FailedDestination> destinations = perr.GetAddressUnitVector ();
-  for (unsigned int i = 0; i < destinations.size (); i ++)
-    {
-      /**
-       * Lookup for a valid routing information
-       */
-      HwmpRtable::LookupResult result = m_requestRouteCallback (destinations[i].destination);
-      if (
-        (result.retransmitter != from)
-        || (result.seqnum >= destinations[i].seqnum)
-      )
-
-        perr.DeleteAddressUnit (destinations[i].destination);
-    }
-  NS_LOG_DEBUG ("Retransmit "<<(int)perr.GetNumOfDest());
-  if (perr.GetNumOfDest () == 0)
-    return;
-  destinations = perr.GetAddressUnitVector ();
-  SendPathError (destinations);
-}
-#endif
 void
 HwmpMacPlugin::SendOnePreq ()
 {
@@ -281,7 +211,6 @@
     return;
   if (m_myPreq == m_preqQueue.begin ())
     m_myPreq == m_preqQueue.end ();
-  NS_LOG_UNCOND ("I am "<<m_parent->GetAddress ()<<"sending PREQ:"<<m_preqQueue[0]);
   SendPreq(m_preqQueue[0]);
   //erase first!
   m_preqQueue.erase (m_preqQueue.begin());
@@ -362,7 +291,6 @@
   hdr.SetAddr2 (m_parent->GetAddress ());
   hdr.SetAddr3 (prep.GetDestinationAddress ());
   //Send Management frame
-  NS_LOG_UNCOND("Sending PREP");
   m_parent->SendManagementFrame(packet, hdr);
 }
 void
--- a/src/devices/mesh/dot11s/hwmp-mac-plugin.h	Wed Apr 01 16:21:42 2009 +0400
+++ b/src/devices/mesh/dot11s/hwmp-mac-plugin.h	Wed Apr 01 16:53:20 2009 +0400
@@ -89,48 +89,6 @@
   };
   MyPerr m_myPerr;
 };
-
-#if 0
-class HwmpMacPlugin : public MeshWifiInterfaceMacPlugin {
-public:
-  private:
-  //true means that we can add a destination to
-  //existing PREQ element
-  //False means that we must send
-  void  SendPrep (
-    Mac48Address dst, //dst is PREQ's originator address
-    Mac48Address src, //src is PREQ's destination address
-    Mac48Address retransmitter,
-    uint32_t initMetric,
-    uint32_t dsn,/* taken form PREQ*/
-    uint32_t originatorDsn, //taken from rtable or as m_myDsn ++;
-    uint32_t lifetime //taken from PREQ
-  );
-  //HWMP interaction callbacks:
-  Callback<void, INFO>  m_routingInfoCallback;
-  Callback<std::vector<Mac48Address>, std::vector<HwmpRtable::FailedDestination>, uint32_t>  m_retransmittersOfPerrCallback;
-  Callback<HwmpRtable::LookupResult, const Mac48Address&>          m_requestRouteCallback;
-  Callback<HwmpRtable::LookupResult, uint32_t>                     m_requestRootPathCallback;
-  //Mac interaction callbacks:
-  Callback<void, const IeDot11sPreq&>                              m_preqCallback;
-  Callback<void, const IeDot11sPrep&, const Mac48Address&>         m_prepCallback;
-  Callback<void, const IeDot11sPerr&, std::vector<Mac48Address> >  m_perrCallback;
-  //HwmpCounters:
-  uint32_t m_preqId;
-  uint32_t m_myDsn;
-  //Seqno and metric database
-  std::map<Mac48Address, uint32_t>  m_dsnDatabase;
-  std::map<Mac48Address, uint32_t>  m_preqMetricDatabase;
-  //Disable/enable functionality
-  bool  m_disabled;
-  //Proactive PREQ mechanism:
-  EventId  m_proactivePreqTimer;
-  void  SendProactivePreq ();
-   IeDot11sPerr  m_myPerr;
-  EventId  m_perrTimer;
-  void  SendOnePerr ();
-};
-#endif
 } //namespace dot11s
 } //namespace ns3
 #endif
--- a/src/devices/mesh/dot11s/hwmp-protocol.cc	Wed Apr 01 16:21:42 2009 +0400
+++ b/src/devices/mesh/dot11s/hwmp-protocol.cc	Wed Apr 01 16:53:20 2009 +0400
@@ -172,7 +172,6 @@
       tag.SetTtl (m_maxTtl+1);
       if (m_dataSeqno == 0xffffffff)
         m_dataSeqno = 0;
-      NS_LOG_UNCOND("add a tag"<<packet->GetUid());
       packet->AddPacketTag(tag);
     }
   }
@@ -320,7 +319,6 @@
         }
       if ((*i)->GetDestinationAddress () == m_address)
         {
-          NS_LOG_UNCOND("PREQ has reached destination:"<<m_address);
           preq.DelDestinationAddressElement ((*i)->GetDestinationAddress());
           SendPrep (
               m_address,
@@ -373,7 +371,7 @@
   if (preq.GetDestCount () == 0)
     return;
   //Forward PREQ to all interfaces:
-  NS_LOG_UNCOND("I am "<<m_address<<"retransmitting PREQ:"<<preq);
+  NS_LOG_DEBUG("I am "<<m_address<<"retransmitting PREQ:"<<preq);
   for(HwmpPluginMap::iterator i = m_interfaces.begin (); i != m_interfaces.end (); i ++)
     i->second->SendPreq (preq);
 }
@@ -382,7 +380,7 @@
 {
   prep.IncrementMetric (1);
   //acceptance cretirea:
-  NS_LOG_UNCOND("I am "<<m_address<<", received prep");
+  NS_LOG_DEBUG("I am "<<m_address<<", received prep");
   std::map<Mac48Address, uint32_t>::iterator i = m_lastHwmpSeqno.find (prep.GetOriginatorAddress());
   if (i == m_lastHwmpSeqno.end ())
     {
@@ -408,10 +406,7 @@
     //try to look for default route
     result = m_rtable->LookupProactive ();
   if (result.retransmitter == Mac48Address::GetBroadcast ())
-  {
-    NS_LOG_UNCOND("I am "<<m_address<<", can not forward prep");
     return;
-  }
   m_rtable->AddPrecursor (prep.GetOriginatorAddress (), interface, result.retransmitter);
   //Forward PREP
   HwmpPluginMap::iterator prep_sender = m_interfaces.find (result.ifIndex);
@@ -423,13 +418,13 @@
 HwmpProtocol::ReceivePerr (IePerr perr, Mac48Address from, uint32_t interface)
 {
   //Acceptance cretirea:
-  NS_LOG_UNCOND("I am "<<m_address<<", received PERR from "<<from);
+  NS_LOG_DEBUG("I am "<<m_address<<", received PERR from "<<from);
   std::vector<IePerr::FailedDestination> destinations = perr.GetAddressUnitVector ();
   HwmpRtable::LookupResult result;
   for(unsigned int i = 0; i < destinations.size (); i ++)
   {
     result = m_rtable->LookupReactive (destinations[i].destination);
-    NS_LOG_UNCOND("Destination = "<<destinations[i].destination<<", RA = "<<result.retransmitter);
+    NS_LOG_DEBUG("Destination = "<<destinations[i].destination<<", RA = "<<result.retransmitter);
     if (
         (result.retransmitter != from) ||
         (result.ifIndex != interface) ||
@@ -443,6 +438,7 @@
   }
   if(perr.GetNumOfDest () == 0)
     return;
+  NS_LOG_UNCOND("Forward PERR");
   MakePathError (destinations);
 }
 void
@@ -456,7 +452,6 @@
     uint32_t lifetime,
     uint32_t interface)
 {
-  NS_LOG_UNCOND("sending prep to "<<dst<<" through "<<retransmitter);
   IePrep prep;
   prep.SetHopcount (0);
   prep.SetTtl (m_maxTtl);
@@ -494,10 +489,6 @@
   mp->SetRoutingProtocol (this);
   // Mesh point aggregates all installed protocols
   mp->AggregateObject (this);
-  //Address tmp_addr = mp->GetAddress ();
-  //Mac48Address * address = dynamic_cast<Mac48Address *> (&tmp_addr);
-  //if (address == NULL)
-  //  return false;
   m_address = Mac48Address::ConvertFrom (mp->GetAddress ());//* address;
   return true;
 }
@@ -505,9 +496,7 @@
 HwmpProtocol::PeerLinkStatus(Mac48Address peerAddress, uint32_t interface, bool status)
 {
   if(status)
-  {
-   // m_rtable->AddReactivePath(peerAddress, peerAddress, interface, 1, Seconds (0), 0);
-  }
+    m_rtable->AddReactivePath(peerAddress, peerAddress, interface, 1, Seconds (0), 0);
   else
   {
     std::vector<IePerr::FailedDestination> destinations = m_rtable->GetUnreachableDestinations (peerAddress);
@@ -533,101 +522,13 @@
   }
   return false;
 }
-
-#if 0
-void
-HwmpProtocol::ObtainRoutingInformation (
-  HwmpProtocolState::INFO info
-)
-{
-  switch (info.type)
-    {
-    case HwmpProtocolState::INFO_PREP:
-      if (info.me != info.source)
-        {
-          m_rtable->AddPrecursor (info.source, info.outPort, info.nextHop);
-          m_rtable->AddPrecursor (info.destination, info.outPort, info.prevHop);
-          NS_LOG_DEBUG ("path to "<<info.source<<" precursor is "<<info.nextHop);
-          NS_LOG_DEBUG ("path to "<<info.destination<<" precursor is "<<info.prevHop);
-        }
-    case HwmpProtocolState::INFO_PREQ:
-      m_rtable->AddReactivePath (
-        info.destination,
-        info.nextHop,
-        info.outPort,
-        info.metric,
-        info.lifetime,
-        info.dsn);
-      SendAllPossiblePackets (info.destination);
-      break;
-    case HwmpProtocolState::INFO_PERR:
-      //delete first subentry
-    case HwmpProtocolState::INFO_PROACTIVE:
-      //add information to the root MP.
-      m_rtable->AddProactivePath (
-        info.metric,
-        info.destination,
-        info.nextHop,
-        info.outPort,
-        info.lifetime,
-        info.dsn);
-      //Set mode as PROACTIVE:
-      SetProactive (info.outPort);
-      break;
-    case HwmpProtocolState::INFO_NEW_PEER:
-#if 0
-      m_rtable->AddReactivePath (
-        info.destination,
-        info.nextHop,
-        info.outPort,
-        info.metric,
-        Seconds (0),
-        0);
-#endif
-      break;
-    case HwmpProtocolState::INFO_FAILED_PEER:
-      /**
-       * Conditions for generating PERR
-       */
-    {
-      NS_LOG_DEBUG ("Failed peer"<<info.destination);
-      std::vector<HwmpRtable::FailedDestination> failedDestinations =
-        m_rtable->GetUnreachableDestinations (info.destination, info.outPort);
-      /**
-       * Entry about peer does not contain seqnum
-       */
-      HwmpRtable::FailedDestination peer;
-      peer.destination = info.destination;
-      peer.seqnum = 0;
-      failedDestinations.push_back (peer);
-      MakePathError (failedDestinations, info.outPort);
-    }
-    break;
-    default:
-      return;
-    }
-}
-#endif
 void
 HwmpProtocol::MakePathError (std::vector<IePerr::FailedDestination> destinations)
 {
-  NS_LOG_UNCOND ("START PERR, I am "<<m_address);
-  //TODO:
-  //make a perr IE and send
   //HwmpRtable increments a sequence number as written in 11B.9.7.2
-  NS_LOG_UNCOND("Number of unreachable destinations:"<<destinations.size ());
-  for(std::vector<IePerr::FailedDestination>::iterator i =  destinations.begin (); i != destinations.end (); i ++)
-  {
-    HwmpRtable::LookupResult result = m_rtable->LookupReactiveExpired (i->destination);
-    NS_LOG_UNCOND("Address::"<<i->destination<<", next hop is "<<result.retransmitter);
-  }
   std::vector<std::pair<uint32_t, Mac48Address> > receivers = GetPerrReceivers (destinations);
-  NS_LOG_UNCOND("Number of perr receivers:"<<receivers.size ());
   if(receivers.size () == 0)
     return;
-  for(std::vector<std::pair<uint32_t, Mac48Address> >::iterator i = receivers.begin (); i != receivers.end (); i ++)
-    NS_LOG_UNCOND("Address:"<<i->second<<", interface:"<<i->first);
-  //form a path error and send it to proper ports
   IePerr perr;
   for(unsigned int i = 0; i < destinations.size (); i ++)
   {
@@ -642,7 +543,6 @@
         receivers_for_interface.push_back(receivers[j].second);
     i->second->SendOnePerr (perr, receivers_for_interface);
   }
-
 }
 std::vector<std::pair<uint32_t, Mac48Address> >
 HwmpProtocol::GetPerrReceivers (std::vector<IePerr::FailedDestination> failedDest)
@@ -657,16 +557,10 @@
       retval.push_back(precursors[j]);
   }
   //Check if we have dublicates in retval and precursors:
-  unsigned int size = retval.size();
-  for (unsigned int i = 0; i < size; i ++)
-    for (unsigned int j = i; j < size; j ++)
+  for (unsigned int i = 0; i < retval.size(); i ++)
+    for (unsigned int j = i; j < retval.size(); j ++)
       if(retval[i].second == retval[j].second)
-      {
-        //erase and check size
-        NS_LOG_UNCOND("deleting dublicate");
         retval.erase(retval.begin() + j);
-        size --;
-      }
   return retval;
 }
 std::vector<Mac48Address>
@@ -762,7 +656,6 @@
   std::map<Mac48Address, EventId>::iterator i = m_preqTimeouts.find (dst);
   if (i == m_preqTimeouts.end ())
     {
-      NS_LOG_UNCOND("Timeout is:" <<2*(m_dot11MeshHWMPnetDiameterTraversalTime.GetMilliSeconds()));
       m_preqTimeouts[dst] = Simulator::Schedule (
           MilliSeconds (2*(m_dot11MeshHWMPnetDiameterTraversalTime.GetMilliSeconds())),
           &HwmpProtocol::RetryPathDiscovery, this, dst, 0);
@@ -801,11 +694,7 @@
       return;
     }
   for(HwmpPluginMap::iterator i = m_interfaces.begin (); i != m_interfaces.end (); i ++)
-  {
     i->second->RequestDestination(dst);
-    i->second->RequestDestination(Mac48Address("00:00:00:00:00:10"));
-    i->second->RequestDestination(Mac48Address("00:00:00:00:00:24"));
-  }
   m_preqTimeouts[dst] = Simulator::Schedule (
       MilliSeconds (2*(m_dot11MeshHWMPnetDiameterTraversalTime.GetMilliSeconds())),
       &HwmpProtocol::RetryPathDiscovery, this, dst, numOfRetry);