Faker's code review response
authorPavel Boyko <boyko@iitp.ru>
Mon, 15 Jun 2009 13:10:56 +0400
changeset 5063 97b947e83640
parent 5062 cfc9bba09692
child 5064 1529a2729c60
Faker's code review response
examples/mesh.cc
src/devices/mesh/dot11s/airtime-metric.cc
src/devices/mesh/dot11s/airtime-metric.h
src/devices/mesh/dot11s/dot11s-mac-header.cc
src/devices/mesh/dot11s/hwmp-mac-plugin.cc
src/devices/mesh/dot11s/hwmp-mac-plugin.h
src/devices/mesh/dot11s/hwmp-protocol.cc
src/devices/mesh/dot11s/hwmp-rtable.cc
src/devices/mesh/dot11s/ie-dot11s-beacon-timing.cc
src/devices/mesh/dot11s/ie-dot11s-beacon-timing.h
src/devices/mesh/dot11s/ie-dot11s-configuration.cc
src/devices/mesh/dot11s/ie-dot11s-id.cc
src/devices/mesh/dot11s/ie-dot11s-peering-protocol.cc
src/devices/mesh/dot11s/ie-dot11s-perr.cc
src/devices/mesh/dot11s/peer-link-frame.cc
src/devices/mesh/dot11s/peer-link.cc
src/devices/mesh/dot11s/peer-link.h
src/devices/mesh/dot11s/peer-management-protocol.cc
src/devices/mesh/mesh-l2-routing-protocol.h
src/devices/mesh/mesh-point-device.cc
src/devices/mesh/mesh-wifi-beacon.h
src/devices/mesh/mesh-wifi-interface-mac.cc
src/helper/dot11s-helper.h
--- a/examples/mesh.cc	Wed Jun 10 20:26:44 2009 +0400
+++ b/examples/mesh.cc	Mon Jun 15 13:10:56 2009 +0400
@@ -67,7 +67,7 @@
     //InternetStackHelper stack;
     //Ipv4AddressHelper address;
   private:
-    /// Create nodes and setup theis mobility
+    /// Create nodes and setup their mobility
     void CreateNodes ();
     /// Install internet stack on nodes
     void InstallInternetStack ();
--- a/src/devices/mesh/dot11s/airtime-metric.cc	Wed Jun 10 20:26:44 2009 +0400
+++ b/src/devices/mesh/dot11s/airtime-metric.cc	Mon Jun 15 13:10:56 2009 +0400
@@ -56,19 +56,34 @@
         );
   return tid;
 } 
+
 uint32_t
 AirtimeLinkMetricCalculator::CalculateMetric(Mac48Address peerAddress, Ptr<MeshWifiInterfaceMac> mac)
 {
+  /* Airtime link metric is defined in 11B.10 of 802.11s Draft D3.0 as:
+   * 
+   * airtime = (O + Bt/r)* (1 + average retry counter), where 
+   * o  -- the PHY dependent channel access which includes frame headers, training sequences, 
+   *       access protocol frames, etc. 
+   * bt -- the test packet length in bits (8192 by default), 
+   * r  -- the current bitrate of the packet,
+   *  
+   * Final result is expressed in units of 0.01 Time Unit = 10.24 us (as required by 802.11s draft)
+   */
+  
+  const double sec2ns = 1e9;   // seconds -> nanoseconds conversion factor
+  const double ns2tu  = 10240; // nanoseconds -> 0.01 TU conversion factor
+  
   WifiRemoteStation * station = mac->GetStationManager ()->Lookup(peerAddress);
   NS_ASSERT(station != 0);
   Ptr<Packet> test_frame = Create<Packet> (m_testLength+ m_headerLength+ m_meshHeaderLength);
   uint32_t rate = station->GetDataMode(test_frame, m_testLength + m_headerLength + m_meshHeaderLength).GetDataRate ();
-  uint32_t payload_nanosec = (uint32_t) ((double) ((m_testLength + m_meshHeaderLength) * 8) * 1e9 / ((double)rate));
+  uint32_t payload_nanosec = (uint32_t) ((double) ((m_testLength + m_meshHeaderLength) * 8 /*octets -> bits*/) * sec2ns / ((double)rate));
   uint32_t header_nanosec = (uint32_t)(
-      (double) (m_headerLength * 8 * 1e9) / ((double) mac->GetStationManager () -> GetBasicMode (0).GetDataRate ())
+      (double) (m_headerLength * 8 /*octets -> bits*/ * sec2ns) / ((double) mac->GetStationManager () -> GetBasicMode (0).GetDataRate ())
       );
   uint32_t metric = (uint32_t) (
-      ((double) (payload_nanosec + header_nanosec + m_overheadNanosec)) / 10240 * (station->GetAvgSlrc () + 1)
+      ((double) (payload_nanosec + header_nanosec + m_overheadNanosec)) / ns2tu * (station->GetAvgSlrc () + 1)
       );
   return metric;
 }
--- a/src/devices/mesh/dot11s/airtime-metric.h	Wed Jun 10 20:26:44 2009 +0400
+++ b/src/devices/mesh/dot11s/airtime-metric.h	Mon Jun 15 13:10:56 2009 +0400
@@ -27,9 +27,17 @@
  * \ingroup dot11s
  * 
  * \brief airtime link metric calculator
- * \details airtime = (o + bt/r)* (1+avgrerycounter), where o is
- * overhead, bt - is the tess length, r - the current rate of the
- * packet, expressed in units of 10.24 us
+ * 
+ * \details Airtime link metric is defined in 11B.10 of 802.11s Draft D3.0 as:
+ * 
+ * airtime = (O + Bt/r)* (1 + average retry counter), where 
+ * 
+ * o  -- the PHY dependent channel access which includes frame headers, training sequences, 
+ *       access protocol frames, etc. 
+ * bt -- the test packet length in bits (8192 by default), 
+ * r  -- the current bitrate of the packet,
+ *  
+ * Final result is expressed in units of 0.01 Time Unit = 10.24 us (as required by 802.11s draft)
  */
 class AirtimeLinkMetricCalculator : public Object
 {
@@ -43,7 +51,7 @@
     uint32_t m_testLength;
     ///\brief header length (used in overhead)
     uint16_t m_headerLength;
-    ///\brief meshHeader length (6 octets ussialy)
+    ///\brief meshHeader length (6 octets usually)
     uint16_t m_meshHeaderLength;
 };
 } //namespace dot11s
--- a/src/devices/mesh/dot11s/dot11s-mac-header.cc	Wed Jun 10 20:26:44 2009 +0400
+++ b/src/devices/mesh/dot11s/dot11s-mac-header.cc	Mon Jun 15 13:10:56 2009 +0400
@@ -109,8 +109,7 @@
 void
 MeshHeader::SetAddressExt (uint8_t num_of_addresses)
 {
-  if (num_of_addresses > 3)
-    return;
+  NS_ASSERT (num_of_addresses <= 3);
   m_meshFlags |= 0x03 & num_of_addresses;
 }
 uint8_t
@@ -253,7 +252,7 @@
           retval.peerLink = PEER_LINK_CLOSE;
           return retval;
         default:
-          NS_ASSERT (false);
+          NS_FATAL_ERROR ("Unknown mesh peering management action code");
           return retval;
         }
     case MESH_PATH_SELECTION:
@@ -272,17 +271,17 @@
           retval.pathSelection = ROOT_ANNOUNCEMENT;
           return retval;
         default:
-          NS_ASSERT (false);
+          NS_FATAL_ERROR ("Unknown mesh path selection action code");
           return retval;
         }
     case MESH_LINK_METRIC:
-      // ???
+      // not yet supported 
     case MESH_INTERWORKING:
-      // ???
+      // not yet supported
     case MESH_RESOURCE_COORDINATION:
-      // ???
+      // not yet supported
     default:
-      NS_ASSERT (false);
+      NS_FATAL_ERROR ("Unsupported mesh action");
       return retval;
     }
 }
--- a/src/devices/mesh/dot11s/hwmp-mac-plugin.cc	Wed Jun 10 20:26:44 2009 +0400
+++ b/src/devices/mesh/dot11s/hwmp-mac-plugin.cc	Mon Jun 15 13:10:56 2009 +0400
@@ -47,89 +47,106 @@
 {
   m_parent = parent;
 }
+
+bool
+HwmpMacPlugin::ReceiveData (Ptr<Packet> packet, const WifiMacHeader & header)
+{
+  NS_ASSERT (header.IsData());
+
+  MeshHeader meshHdr;
+  HwmpTag tag;
+  if(packet->PeekPacketTag (tag))
+  {
+    NS_FATAL_ERROR ("HWMP tag is not supposed to be received by network");
+  }
+  
+  packet->RemoveHeader(meshHdr);
+  m_stats.rxData ++;
+  m_stats.rxDataBytes += packet->GetSize ();
+  
+  //TODO: address extension
+  Mac48Address destination;
+  Mac48Address source;
+  switch (meshHdr.GetAddressExt ())
+  {
+    case 0:
+      source = header.GetAddr4 ();
+      destination = header.GetAddr3 ();
+      break;
+    default:
+      NS_FATAL_ERROR ("6-address scheme is not yet supported and 4-address extension is not supposed to be used for data frames.");
+  };
+  tag.SetSeqno (meshHdr.GetMeshSeqno ());
+  tag.SetTtl (meshHdr.GetMeshTtl ());
+  if(m_protocol->GetAddress() != destination)
+    packet->AddPacketTag(tag);
+  
+  if (destination == Mac48Address::GetBroadcast ())
+    if(m_protocol->DropDataFrame (meshHdr.GetMeshSeqno (), source))
+      return false;
+  
+  return true;
+}
+
+bool
+HwmpMacPlugin::ReceiveAction (Ptr<Packet> packet, const WifiMacHeader & header)
+{
+  m_stats.rxMgt ++;
+  m_stats.rxMgtBytes += packet->GetSize ();
+  WifiMeshActionHeader actionHdr;
+  packet->RemoveHeader (actionHdr);
+  WifiMeshActionHeader::ActionValue actionValue = actionHdr.GetAction ();
+  if(actionHdr.GetCategory () != WifiMeshActionHeader::MESH_PATH_SELECTION)
+    return true;
+  switch (actionValue.pathSelection)
+  {
+    case WifiMeshActionHeader::PATH_REQUEST:
+      {
+        IePreq preq;
+        m_stats.rxPreq ++;
+        packet->RemoveHeader (preq);
+        if(preq.GetOriginatorAddress () == m_protocol->GetAddress ())
+          return false;
+        if (preq.GetTtl () == 0)
+          return false;
+        preq.DecrementTtl ();
+        m_protocol->ReceivePreq (preq, header.GetAddr2 (), m_ifIndex, header.GetAddr3 (), m_parent->GetLinkMetric(header.GetAddr2 ()));
+        return false;
+      }
+    case WifiMeshActionHeader::PATH_REPLY:
+      {
+        IePrep prep;
+        m_stats.rxPrep ++;
+        packet->RemoveHeader (prep);
+        if(prep.GetTtl () == 0)
+          return false;
+        prep.DecrementTtl ();
+        m_protocol->ReceivePrep (prep, header.GetAddr2 (), m_ifIndex, header.GetAddr3 (), m_parent->GetLinkMetric(header.GetAddr2 ()));
+        return false;
+      }
+    case WifiMeshActionHeader::PATH_ERROR:
+      {
+        IePerr perr;
+        m_stats.rxPerr ++;
+        packet->RemoveHeader (perr);
+        m_protocol->ReceivePerr (perr, header.GetAddr2 (), m_ifIndex, header.GetAddr3 ());
+        return false;
+      }
+    case WifiMeshActionHeader::ROOT_ANNOUNCEMENT:
+      return false;
+  }
+  return true;
+}
+
 bool
 HwmpMacPlugin::Receive (Ptr<Packet> packet, const WifiMacHeader & header)
 {
-  //TODO: here we fix only mesh header
-  if(header.IsData())
-  {
-    MeshHeader meshHdr;
-    HwmpTag tag;
-    if(packet->PeekPacketTag (tag))
-    {
-      NS_ASSERT (false);
-    }
-    packet->RemoveHeader(meshHdr);
-    m_stats.rxData ++;
-    m_stats.rxDataBytes += packet->GetSize ();
-    //TODO: address extension
-    Mac48Address destination;
-    Mac48Address source;
-    switch (meshHdr.GetAddressExt ())
-    {
-      case 0:
-        source = header.GetAddr4 ();
-        destination = header.GetAddr3 ();
-        break;
-      default:
-        NS_ASSERT(false);
-    };
-    tag.SetSeqno (meshHdr.GetMeshSeqno ());
-    tag.SetTtl (meshHdr.GetMeshTtl ());
-    if(m_protocol->GetAddress() != destination)
-      packet->AddPacketTag(tag);
-    if (destination == Mac48Address::GetBroadcast ())
-      if(m_protocol->DropDataFrame (meshHdr.GetMeshSeqno (), source))
-        return false;
-  }
-  if(header.IsAction())
-  {
-    m_stats.rxMgt ++;
-    m_stats.rxMgtBytes += packet->GetSize ();
-    WifiMeshActionHeader actionHdr;
-    packet->RemoveHeader (actionHdr);
-    WifiMeshActionHeader::ActionValue actionValue = actionHdr.GetAction ();
-    if(actionHdr.GetCategory () != WifiMeshActionHeader::MESH_PATH_SELECTION)
-      return true;
-    switch (actionValue.pathSelection)
-    {
-      case WifiMeshActionHeader::PATH_REQUEST:
-        {
-          IePreq preq;
-          m_stats.rxPreq ++;
-          packet->RemoveHeader (preq);
-          if(preq.GetOriginatorAddress () == m_protocol->GetAddress ())
-            return false;
-          if (preq.GetTtl () == 0)
-            return false;
-          preq.DecrementTtl ();
-          m_protocol->ReceivePreq (preq, header.GetAddr2 (), m_ifIndex, header.GetAddr3 (), m_parent->GetLinkMetric(header.GetAddr2 ()));
-          return false;
-        }
-      case WifiMeshActionHeader::PATH_REPLY:
-        {
-          IePrep prep;
-          m_stats.rxPrep ++;
-          packet->RemoveHeader (prep);
-          if(prep.GetTtl () == 0)
-            return false;
-          prep.DecrementTtl ();
-          m_protocol->ReceivePrep (prep, header.GetAddr2 (), m_ifIndex, header.GetAddr3 (), m_parent->GetLinkMetric(header.GetAddr2 ()));
-          return false;
-        }
-      case WifiMeshActionHeader::PATH_ERROR:
-        {
-          IePerr perr;
-          m_stats.rxPerr ++;
-          packet->RemoveHeader (perr);
-          m_protocol->ReceivePerr (perr, header.GetAddr2 (), m_ifIndex, header.GetAddr3 ());
-          return false;
-        }
-      case WifiMeshActionHeader::ROOT_ANNOUNCEMENT:
-        return false;
-    }
-  }
-  return true;
+  if (header.IsData ())
+    return ReceiveData (packet, header);
+  else if (header.IsAction ())
+    return ReceiveAction (packet, header);
+  else
+    return true; // don't care
 }
 bool
 HwmpMacPlugin::UpdateOutcomingFrame (Ptr<Packet> packet, WifiMacHeader & header, Mac48Address from, Mac48Address to)
@@ -140,8 +157,7 @@
   bool tagExists = packet->RemovePacketTag(tag);
   if (!tagExists)
   {
-     //do it this way to silence compiler
-     NS_ASSERT (false);
+    NS_FATAL_ERROR ("HWMP tag must exist at this point");
   }
   m_stats.txData ++;
   m_stats.txDataBytes += packet->GetSize ();
--- a/src/devices/mesh/dot11s/hwmp-mac-plugin.h	Wed Jun 10 20:26:44 2009 +0400
+++ b/src/devices/mesh/dot11s/hwmp-mac-plugin.h	Mon Jun 15 13:10:56 2009 +0400
@@ -63,12 +63,12 @@
   void SendPreq(IePreq preq);
   void SendPrep(IePrep prep, Mac48Address receiver);
   void SendPerr(IePerr perr, std::vector<Mac48Address> receivers);
-  ///\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
+  /** \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);
   //\}
   
@@ -79,7 +79,7 @@
   //peer as routing entry
   uint32_t GetLinkMetric (Mac48Address peerAddress) const;
   uint16_t GetChannelId () const;
-  ///\brief Statistics:
+  /// Report statistics
   void Report (std::ostream &) const;
   void ResetStats ();
 private:
@@ -93,7 +93,7 @@
   std::vector<IePreq>  m_preqQueue;
   //\}
   ///\name PERR timer and stored path error
-  //{
+  //\{
   EventId m_perrTimer;
   struct MyPerr {
     IePerr perr;
@@ -101,7 +101,7 @@
   };
   MyPerr m_myPerr;
   ///\name Statistics:
-  ///\{
+  //\{
   struct Statistics
   {
     uint16_t txPreq;
@@ -137,7 +137,12 @@
       {}
   };
   Statistics m_stats;
-  ///\}
+  //\}
+private:
+  /// Receive data frame
+  bool ReceiveData (Ptr<Packet> packet, const WifiMacHeader & header);
+  /// Receive action management frame
+  bool ReceiveAction (Ptr<Packet> packet, const WifiMacHeader & header);
 };
 } //namespace dot11s
 } //namespace ns3
--- a/src/devices/mesh/dot11s/hwmp-protocol.cc	Wed Jun 10 20:26:44 2009 +0400
+++ b/src/devices/mesh/dot11s/hwmp-protocol.cc	Mon Jun 15 13:10:56 2009 +0400
@@ -206,7 +206,7 @@
   {
     if(packet->PeekPacketTag(tag))
     {
-      NS_ASSERT (false);
+      NS_FATAL_ERROR ("HWMP tag is not supposed to be here at this point.");
     }
     //Filling TAG:
     if(destination == Mac48Address::GetBroadcast ())
@@ -217,8 +217,7 @@
   {
     if(!packet->RemovePacketTag(tag))
     {
-      NS_ASSERT(false);
-      return false;
+      NS_FATAL_ERROR ("HWMP tag is supposed to be here at this point.");
     }
     tag.DecrementTtl ();
     if (tag.GetTtl () == 0)
@@ -237,7 +236,7 @@
     {
       bool should_send = true;
       for(std::vector<uint16_t>::const_iterator chan = channels.begin(); chan != channels.end(); chan ++)
-        if(*chan == plugin->second->GetChannelId ())
+        if( (*chan) == plugin->second->GetChannelId ())
           should_send = false;
       if(!should_send)
         continue;
@@ -470,7 +469,7 @@
             }
         }
     }
-  //chack if must retransmit:
+  //check if must retransmit:
   if (preq.GetDestCount () == 0)
     return;
   //Forward PREQ to all interfaces:
@@ -734,7 +733,7 @@
 HwmpProtocol::DequeueFirstPacketByDst (Mac48Address dst)
 {
   QueuedPacket retval;
-  retval.pkt = NULL;
+  retval.pkt = 0;
   for(std::vector<QueuedPacket>::iterator i = m_rqueue.begin (); i != m_rqueue.end (); i++)
     if((*i).dst == dst)
     {
@@ -764,12 +763,9 @@
   HwmpRtable::LookupResult result = m_rtable->LookupReactive (dst);
   NS_ASSERT(result.retransmitter != Mac48Address::GetBroadcast ());
   //Send all packets stored for this destination    
-  QueuedPacket packet;
-  while (1)
+  QueuedPacket packet = DequeueFirstPacketByDst (dst);
+  while (packet.pkt != 0)
   {
-    packet = DequeueFirstPacketByDst (dst);
-    if (packet.pkt == NULL)
-      return;
     //set RA tag for retransmitter:
     HwmpTag tag;
     packet.pkt->RemovePacketTag(tag);
@@ -778,6 +774,8 @@
     m_stats.txUnicast ++;
     m_stats.txBytes += packet.pkt->GetSize ();
     packet.reply (true, packet.pkt, packet.src, packet.dst, packet.protocol, result.ifIndex);
+    
+    packet = DequeueFirstPacketByDst (dst);
   }
 }
 void
@@ -786,23 +784,22 @@
   //send all packets to root
   HwmpRtable::LookupResult result = m_rtable->LookupProactive ();
   NS_ASSERT(result.retransmitter != Mac48Address::GetBroadcast ());
-  QueuedPacket packet;
-  while (1)
+  QueuedPacket packet = DequeueFirstPacket ();
+  while (packet.pkt != 0)
   {
-    packet = DequeueFirstPacket ();
-    if (packet.pkt == NULL)
-      return;
     //set RA tag for retransmitter:
     HwmpTag tag;
     if(!packet.pkt->RemovePacketTag (tag))
     {
-      NS_ASSERT (false);
+      NS_FATAL_ERROR ("HWMP tag must be present at this point");
     }
     tag.SetAddress (result.retransmitter);
     packet.pkt->AddPacketTag (tag);
     m_stats.txUnicast ++;
     m_stats.txBytes += packet.pkt->GetSize ();
     packet.reply (true, packet.pkt, packet.src, packet.dst, packet.protocol, result.ifIndex);
+    
+    packet = DequeueFirstPacket ();
   }
 }
 
@@ -835,15 +832,13 @@
   numOfRetry++;
   if (numOfRetry > m_dot11MeshHWMPmaxPREQretries)
     {
-      QueuedPacket packet;
+      QueuedPacket packet = DequeueFirstPacketByDst (dst);
       //purge queue and delete entry from retryDatabase
-      while (1)
+      while (packet.pkt != 0)
         {
-          packet = DequeueFirstPacketByDst (dst);
-          if (packet.pkt == NULL)
-            break;
           m_stats.totalDropped ++;
           packet.reply (false, packet.pkt, packet.src, packet.dst, packet.protocol, HwmpRtable::MAX_METRIC);
+          packet = DequeueFirstPacketByDst (dst);
         }
       std::map<Mac48Address, EventId>::iterator i = m_preqTimeouts.find (dst);
       NS_ASSERT (i !=  m_preqTimeouts.end());
--- a/src/devices/mesh/dot11s/hwmp-rtable.cc	Wed Jun 10 20:26:44 2009 +0400
+++ b/src/devices/mesh/dot11s/hwmp-rtable.cc	Mon Jun 15 13:10:56 2009 +0400
@@ -227,7 +227,7 @@
 HwmpRtable::PrecursorList
 HwmpRtable::GetPrecursors (Mac48Address destination)
 {
-  //We suppose that no dublicates here can be
+  //We suppose that no duplicates here can be
   PrecursorList retval;
   std::map<Mac48Address, ReactiveRoute>::iterator route = m_routes.find (destination);
   if (route != m_routes.end ())
--- a/src/devices/mesh/dot11s/ie-dot11s-beacon-timing.cc	Wed Jun 10 20:26:44 2009 +0400
+++ b/src/devices/mesh/dot11s/ie-dot11s-beacon-timing.cc	Mon Jun 15 13:10:56 2009 +0400
@@ -23,6 +23,9 @@
 #include "ns3/log.h"
 #include "ns3/test.h"
 #include "ns3/packet.h"
+
+NS_LOG_COMPONENT_DEFINE ("IeBeaconTiming");
+
 namespace ns3 {
 namespace dot11s {
 /*******************************************
@@ -92,15 +95,21 @@
 )
 {
   if (m_numOfUnits == 50)
-    return;
-  //First we lookup if this element already exists
+    {
+      NS_LOG_WARN ("Neighbor timing element is ignored, since more than 50 neighbors can not be supported in single information element.");
+      return;
+    }
+  //First we lookup if this element already exists 
   for (NeighboursTimingUnitsList::const_iterator i = m_neighbours.begin (); i != m_neighbours.end(); i++)
     if (
       ((*i)->GetAid () == AidToU8(aid))
       && ((*i)->GetLastBeacon () == TimestampToU16(last_beacon))
       && ((*i)->GetBeaconInterval () == BeaconIntervalToU16(beacon_interval))
     )
-      return;
+      {
+        NS_LOG_WARN ("Duplicated neighbor timing element is ignored.");
+        return;
+      }
   Ptr<IeBeaconTimingUnit>new_element = Create<IeBeaconTimingUnit> ();
   new_element->SetAid (AidToU8(aid));
   new_element->SetLastBeacon (TimestampToU16(last_beacon));
@@ -187,15 +196,15 @@
 };
 
 uint16_t
-IeBeaconTiming::TimestampToU16 (Time x)
+IeBeaconTiming::TimestampToU16 (Time t)
 {
-  return ((uint16_t) ((x.GetMicroSeconds() >> 8)&0xffff));
+  return ((uint16_t) ((t.GetMicroSeconds() >> 8)&0xffff));
 };
 
 uint16_t 
-IeBeaconTiming::BeaconIntervalToU16 (Time x)
+IeBeaconTiming::BeaconIntervalToU16 (Time t)
 {
-  return ((uint16_t) (x.GetMicroSeconds() >>10)&0xffff);
+  return ((uint16_t) (t.GetMicroSeconds() >>10)&0xffff);
 };
 
 uint8_t
--- a/src/devices/mesh/dot11s/ie-dot11s-beacon-timing.h	Wed Jun 10 20:26:44 2009 +0400
+++ b/src/devices/mesh/dot11s/ie-dot11s-beacon-timing.h	Mon Jun 15 13:10:56 2009 +0400
@@ -43,18 +43,13 @@
   uint8_t GetAid () const;
   uint16_t GetLastBeacon () const;
   uint16_t GetBeaconInterval () const;
-  /**
-   * \brief Least significant octet of AID:
-   */
+  
+private:
+  /// Least significant octet of AID:
   uint8_t m_aid;
-  /**
-   * \brief Last time we received a beacon in accordance with a
-   * local TSF measured in 256 microseconds unit:
-   */
+  /// Last time we received a beacon in accordance with a local TSF measured in 256 microseconds unit
   uint16_t m_lastBeacon;
-  /**
-   * \brief Beacon interval of remote mesh point:
-   */
+  /// Beacon interval of remote mesh point
   uint16_t m_beaconInterval;
   friend bool operator== (const IeBeaconTimingUnit & a, const IeBeaconTimingUnit & b);
 };
--- a/src/devices/mesh/dot11s/ie-dot11s-configuration.cc	Wed Jun 10 20:26:44 2009 +0400
+++ b/src/devices/mesh/dot11s/ie-dot11s-configuration.cc	Mon Jun 15 13:10:56 2009 +0400
@@ -134,7 +134,6 @@
 void
 IeConfiguration::PrintInformation (std::ostream& os) const
 {
-  //TODO: print
 }
 void
 IeConfiguration::SetRouting (dot11sPathSelectionProtocol routingId)
--- a/src/devices/mesh/dot11s/ie-dot11s-id.cc	Wed Jun 10 20:26:44 2009 +0400
+++ b/src/devices/mesh/dot11s/ie-dot11s-id.cc	Mon Jun 15 13:10:56 2009 +0400
@@ -111,7 +111,7 @@
 void 
 IeMeshId::PrintInformation (std::ostream& os) const
 {
-  //TODO
+  os << "meshId =  " << PeekString (); 
 }
 bool operator== (const IeMeshId & a, const IeMeshId & b)
 {
--- a/src/devices/mesh/dot11s/ie-dot11s-peering-protocol.cc	Wed Jun 10 20:26:44 2009 +0400
+++ b/src/devices/mesh/dot11s/ie-dot11s-peering-protocol.cc	Mon Jun 15 13:10:56 2009 +0400
@@ -47,7 +47,7 @@
 void
 IePeeringProtocol::PrintInformation (std::ostream& os) const
 {
-  //TODO: print
+  os << "peering protocol = " << m_protocol;
 }
 } // namespace dot11s
 } //namespace ns3
--- a/src/devices/mesh/dot11s/ie-dot11s-perr.cc	Wed Jun 10 20:26:44 2009 +0400
+++ b/src/devices/mesh/dot11s/ie-dot11s-perr.cc	Mon Jun 15 13:10:56 2009 +0400
@@ -32,7 +32,7 @@
 void
 IePerr::PrintInformation (std::ostream &os) const
 {
-    // TODO:FILL
+  // TODO
 }
 IePerr::IePerr ():
     m_numOfDest (0)
--- a/src/devices/mesh/dot11s/peer-link-frame.cc	Wed Jun 10 20:26:44 2009 +0400
+++ b/src/devices/mesh/dot11s/peer-link-frame.cc	Mon Jun 15 13:10:56 2009 +0400
@@ -128,7 +128,7 @@
   m_protocol.Serialize (i);
   i.Next (m_protocol.GetSerializedSize ());
   if ((uint8_t)(WifiMeshActionHeader::PEER_LINK_CLOSE) != m_subtype)
-    i.WriteHtolsbU16(m_capability);
+    i.WriteHtolsbU16 (m_capability);
   if ((uint8_t)(WifiMeshActionHeader::PEER_LINK_CONFIRM) == m_subtype)
     i.WriteHtolsbU16 (m_aid);
   if ((uint8_t)(WifiMeshActionHeader::PEER_LINK_CLOSE) != m_subtype)
--- a/src/devices/mesh/dot11s/peer-link.cc	Wed Jun 10 20:26:44 2009 +0400
+++ b/src/devices/mesh/dot11s/peer-link.cc	Mon Jun 15 13:10:56 2009 +0400
@@ -307,7 +307,7 @@
           SetRetryTimer ();
           break;
         default:
-        {}
+          NS_FATAL_ERROR ("Invalid action in IDLE state");
         }
       break;
     case OPN_SNT:
@@ -353,7 +353,7 @@
           SetHoldingTimer ();
           break;
         default:
-        {}
+          NS_FATAL_ERROR ("Invalid action in OPN_SNT state");
         }
       break;
     case CNF_RCVD:
@@ -394,7 +394,7 @@
           SetHoldingTimer ();
           break;
         default:
-        {}
+          NS_FATAL_ERROR ("Invalid action in CNF_RCVD state");
         }
       break;
     case OPN_RCVD:
@@ -438,7 +438,7 @@
           SetHoldingTimer ();
           break;
         default:
-        {}
+          NS_FATAL_ERROR ("Invalid action in OPN_RCVD state");
         }
       break;
     case ESTAB:
@@ -468,7 +468,7 @@
           m_linkStatusCallback (m_interface, m_peerAddress, m_peerMeshPointAddress, false);
           break;
         default:
-        {}
+          NS_FATAL_ERROR ("Invalid action in ESTAB state");
         }
       break;
     case HOLDING:
@@ -492,7 +492,7 @@
           SendPeerLinkClose (reasoncode);
           break;
         default:
-        {}
+          NS_FATAL_ERROR ("Invalid action in HOLDING state");
         }
       break;
     }
--- a/src/devices/mesh/dot11s/peer-link.h	Wed Jun 10 20:26:44 2009 +0400
+++ b/src/devices/mesh/dot11s/peer-link.h	Mon Jun 15 13:10:56 2009 +0400
@@ -103,8 +103,6 @@
    * \attention In all this methods {local/peer}LinkID correspond to _peer_ station, as written in
    * received frame, e.g. I am peerLinkID and peer link is localLinkID .
    * 
-   * TODO is that clear?
-   * 
    * \{
    */
   /// Close link
@@ -221,7 +219,7 @@
   /// Assoc Id assigned to me by peer
   uint16_t m_peerAssocId;
     
-  /// When last beacon was sent (TODO or received?)
+  /// When last beacon was received
   Time  m_lastBeacon;
   /// Current beacon interval on corresponding interface
   Time  m_beaconInterval;
@@ -252,7 +250,7 @@
   uint16_t  m_maxBeaconLoss;
   //\}
   
-  /// ?
+  /// Several successive beacons were lost, close link
   void BeaconLoss ();
    
   /// How to report my status change
--- a/src/devices/mesh/dot11s/peer-management-protocol.cc	Wed Jun 10 20:26:44 2009 +0400
+++ b/src/devices/mesh/dot11s/peer-management-protocol.cc	Mon Jun 15 13:10:56 2009 +0400
@@ -41,32 +41,32 @@
 namespace ns3 {
 namespace dot11s {
 /***************************************************
- * PeerManager
- ***************************************************/
+* PeerManager
+***************************************************/
 NS_OBJECT_ENSURE_REGISTERED (PeerManagementProtocol);
 
 TypeId
 PeerManagementProtocol::GetTypeId (void)
 {
   static TypeId tid = TypeId ("ns3::dot11s::PeerManagementProtocol")
-    .SetParent<Object> ()
-    .AddConstructor<PeerManagementProtocol> ()
-    // maximum number of peer links. Now we calculate the total
-    // number of peer links on all interfaces
-    .AddAttribute ("MaxNumberOfPeerLinks",
-        "Maximum number of peer links",
-        UintegerValue (32),
-        MakeUintegerAccessor (&PeerManagementProtocol::m_maxNumberOfPeerLinks),
-        MakeUintegerChecker<uint8_t> ()
-        );
+  .SetParent<Object> ()
+  .AddConstructor<PeerManagementProtocol> ()
+  // maximum number of peer links. Now we calculate the total
+  // number of peer links on all interfaces
+  .AddAttribute ("MaxNumberOfPeerLinks",
+      "Maximum number of peer links",
+      UintegerValue (32),
+      MakeUintegerAccessor (&PeerManagementProtocol::m_maxNumberOfPeerLinks),
+      MakeUintegerChecker<uint8_t> ()
+  );
   return tid;
 }
 PeerManagementProtocol::PeerManagementProtocol ():
   m_lastAssocId (0),
   m_lastLocalLinkId (1),
   m_numberOfActivePeers (0)
-{
-}
+  {
+  }
 PeerManagementProtocol::~PeerManagementProtocol ()
 {
 }
@@ -78,15 +78,15 @@
   for (PeerLinksMap::iterator j = m_peerLinks.begin (); j != m_peerLinks.end (); j++)
     {
       for (PeerLinksOnInterface::iterator i = j->second.begin (); i != j->second.end(); i++)
-          (*i) = 0;
+        (*i) = 0;
       j->second.clear ();
     }
   m_peerLinks.clear ();
   //cleaning beacon structures:
   for(BeaconInfoMap::iterator i =  m_neighbourBeacons.begin(); i != m_neighbourBeacons.end(); i ++)
-  {
-    i->second.clear();
-  }
+    {
+      i->second.clear();
+    }
   m_neighbourBeacons.clear();
 }
 
@@ -95,19 +95,19 @@
 {
   std::vector<Ptr<NetDevice> > interfaces = mp->GetInterfaces ();
   for(std::vector<Ptr<NetDevice> >::iterator i = interfaces.begin(); i != interfaces.end(); i ++)
-  {
-    Ptr<WifiNetDevice> wifiNetDev = (*i)->GetObject<WifiNetDevice> ();
-    if (wifiNetDev == 0)
-      return false;
-    Ptr<MeshWifiInterfaceMac>  mac = wifiNetDev->GetMac ()->GetObject<MeshWifiInterfaceMac> ();
-    if (mac == 0)
-      return false;
-    Ptr<PeerManagerMacPlugin> peerPlugin = Create<PeerManagerMacPlugin> ((*i)->GetIfIndex(), this);
-    mac->InstallPlugin(peerPlugin);
-    m_plugins[(*i)->GetIfIndex()] = peerPlugin;
-    PeerLinksOnInterface newmap;
-    m_peerLinks[(*i)->GetIfIndex()] = newmap;
-  }
+    {
+      Ptr<WifiNetDevice> wifiNetDev = (*i)->GetObject<WifiNetDevice> ();
+      if (wifiNetDev == 0)
+        return false;
+      Ptr<MeshWifiInterfaceMac>  mac = wifiNetDev->GetMac ()->GetObject<MeshWifiInterfaceMac> ();
+      if (mac == 0)
+        return false;
+      Ptr<PeerManagerMacPlugin> peerPlugin = Create<PeerManagerMacPlugin> ((*i)->GetIfIndex(), this);
+      mac->InstallPlugin(peerPlugin);
+      m_plugins[(*i)->GetIfIndex()] = peerPlugin;
+      PeerLinksOnInterface newmap;
+      m_peerLinks[(*i)->GetIfIndex()] = newmap;
+    }
   // Mesh point aggregates all installed protocols
   m_address = Mac48Address::ConvertFrom(mp->GetAddress ());
   NS_LOG_UNCOND("MP address:"<<m_address);
@@ -124,25 +124,25 @@
     return retval;
   bool cleaned = false;
   while(!cleaned)
-  {
-    for(BeaconsOnInterface::iterator j = i->second.begin(); j != i->second.end(); j++)
     {
-      //check beacon loss and make a timing element
-      //if last beacon was 3 beacons ago - we do not put it to the
-      //timing element
-      if(
-          (j->second.referenceTbtt.GetMicroSeconds() +
-           (j->second.beaconInterval.GetMicroSeconds()* 3))
-          <
-          Simulator::Now().GetMicroSeconds()
+      for(BeaconsOnInterface::iterator j = i->second.begin(); j != i->second.end(); j++)
+        {
+          //check beacon loss and make a timing element
+          //if last beacon was 3 beacons ago - we do not put it to the
+          //timing element
+          if(
+              (j->second.referenceTbtt.GetMicroSeconds() +
+                  (j->second.beaconInterval.GetMicroSeconds()* 3))
+                  <
+                  Simulator::Now().GetMicroSeconds()
           )
-      {
-        i->second.erase(j);
-        break;
-      }
+            {
+              i->second.erase(j);
+              break;
+            }
+        }
+      cleaned = true;
     }
-    cleaned = true;
-  }
   for(BeaconsOnInterface::const_iterator j = i->second.begin(); j != i->second.end(); j++)
     retval->AddNeighboursTimingElementUnit(j->second.aid, j->second.referenceTbtt, j->second.beaconInterval);
   return retval;
@@ -153,27 +153,27 @@
 {
   BeaconInfoMap::iterator i = m_neighbourBeacons.find(interface);
   if(i == m_neighbourBeacons.end())
-  {
-     BeaconsOnInterface newMap;
-     m_neighbourBeacons[interface] = newMap;
-  }
+    {
+      BeaconsOnInterface newMap;
+      m_neighbourBeacons[interface] = newMap;
+    }
   i = m_neighbourBeacons.find(interface);
   BeaconsOnInterface::iterator j = i->second.find(peerAddress);
   if(j == i->second.end())
-  {
-    BeaconInfo newInfo;
-    newInfo.referenceTbtt = receivingTime;
-    newInfo.beaconInterval = beaconInterval;
-    newInfo.aid = m_lastAssocId++;
-    if(m_lastAssocId == 0xff)
-      m_lastAssocId = 0;
-    i->second[peerAddress] = newInfo;
-  }
+    {
+      BeaconInfo newInfo;
+      newInfo.referenceTbtt = receivingTime;
+      newInfo.beaconInterval = beaconInterval;
+      newInfo.aid = m_lastAssocId++;
+      if(m_lastAssocId == 0xff)
+        m_lastAssocId = 0;
+      i->second[peerAddress] = newInfo;
+    }
   else
-  {
-    j->second.referenceTbtt = receivingTime;
-    j->second.beaconInterval = beaconInterval;
-  }
+    {
+      j->second.referenceTbtt = receivingTime;
+      j->second.beaconInterval = beaconInterval;
+    }
 }
 
 void
@@ -186,30 +186,30 @@
     Time beaconInterval)
 {
   FillBeaconInfo(interface, peerAddress, receivingTime, beaconInterval);
-   if(!meshBeacon)
-     return;
-   //BCA:
-   PeerManagerPluginMap::iterator plugin = m_plugins.find (interface);
-   NS_ASSERT(plugin != m_plugins.end ());
-   plugin->second->SetBeaconShift(GetNextBeaconShift(interface));
-   //PM STATE Machine
-   //Check that a given beacon is not from our interface
-   for(PeerManagerPluginMap::const_iterator i = m_plugins.begin (); i != m_plugins.end (); i ++)
-     if(i->second->GetAddress () == peerAddress)
-       return;
-   Ptr<PeerLink> peerLink = FindPeerLink(interface, peerAddress);
-   if(peerLink !=0)  
-   {
-     peerLink->SetBeaconTimingElement (timingElement);
-     peerLink->SetBeaconInformation (receivingTime, beaconInterval);
-   }
-   else
-   {
-     peerLink = InitiateLink (interface, peerAddress, Mac48Address::GetBroadcast (), receivingTime, beaconInterval);
-     peerLink->SetBeaconTimingElement (timingElement);
-     if (ShouldSendOpen (interface, peerAddress))
-       peerLink->MLMEActivePeerLinkOpen ();
-   }
+  if(!meshBeacon)
+    return;
+  //BCA:
+  PeerManagerPluginMap::iterator plugin = m_plugins.find (interface);
+  NS_ASSERT(plugin != m_plugins.end ());
+  plugin->second->SetBeaconShift(GetNextBeaconShift(interface));
+  //PM STATE Machine
+  //Check that a given beacon is not from our interface
+  for(PeerManagerPluginMap::const_iterator i = m_plugins.begin (); i != m_plugins.end (); i ++)
+    if(i->second->GetAddress () == peerAddress)
+      return;
+  Ptr<PeerLink> peerLink = FindPeerLink(interface, peerAddress);
+  if(peerLink !=0)  
+    {
+      peerLink->SetBeaconTimingElement (timingElement);
+      peerLink->SetBeaconInformation (receivingTime, beaconInterval);
+    }
+  else
+    {
+      peerLink = InitiateLink (interface, peerAddress, Mac48Address::GetBroadcast (), receivingTime, beaconInterval);
+      peerLink->SetBeaconTimingElement (timingElement);
+      if (ShouldSendOpen (interface, peerAddress))
+        peerLink->MLMEActivePeerLinkOpen ();
+    }
 }
 
 void
@@ -220,23 +220,23 @@
     uint16_t aid,
     IePeerManagement peerManagementElement,
     IeConfiguration meshConfig
-      )
+)
 {
   Ptr<PeerLink> peerLink = FindPeerLink(interface, peerAddress);
   if (peerManagementElement.SubtypeIsOpen ())
-  {
-    PmpReasonCode reasonCode;
-    bool reject = ! (ShouldAcceptOpen (interface, peerAddress,reasonCode));
-    if (peerLink == 0)
-      peerLink = InitiateLink (interface, peerAddress, peerMeshPointAddress, Simulator::Now (), Seconds(1.0));
-    if(!reject)
     {
-      peerLink->MLMEPassivePeerLinkOpen ();
-      peerLink->OpenAccept (peerManagementElement.GetLocalLinkId(), meshConfig, peerMeshPointAddress);
+      PmpReasonCode reasonCode;
+      bool reject = ! (ShouldAcceptOpen (interface, peerAddress,reasonCode));
+      if (peerLink == 0)
+        peerLink = InitiateLink (interface, peerAddress, peerMeshPointAddress, Simulator::Now (), Seconds(1.0));
+      if(!reject)
+        {
+          peerLink->MLMEPassivePeerLinkOpen ();
+          peerLink->OpenAccept (peerManagementElement.GetLocalLinkId(), meshConfig, peerMeshPointAddress);
+        }
+      else
+        peerLink->OpenReject (peerManagementElement.GetLocalLinkId(), meshConfig, peerMeshPointAddress, reasonCode);
     }
-    else
-      peerLink->OpenReject (peerManagementElement.GetLocalLinkId(), meshConfig, peerMeshPointAddress, reasonCode);
-  }
   if (peerLink == 0)
     return;
   if (peerManagementElement.SubtypeIsConfirm ())
@@ -251,7 +251,7 @@
         peerManagementElement.GetLocalLinkId(),
         peerManagementElement.GetPeerLinkId(),
         peerManagementElement.GetReasonCode()
-        );
+    );
 }
 
 void
@@ -259,16 +259,16 @@
 {
   Ptr<PeerLink> peerLink = FindPeerLink(interface, peerAddress);
   if(peerLink != 0)
-      peerLink->MLMECancelPeerLink (REASON11S_MESH_CAPABILITY_POLICY_VIOLATION);
+    peerLink->MLMECancelPeerLink (REASON11S_MESH_CAPABILITY_POLICY_VIOLATION);
 }
 
 Ptr<PeerLink>
 PeerManagementProtocol::InitiateLink (
-  uint32_t interface,
-  Mac48Address peerAddress,
-  Mac48Address peerMeshPointAddress,
-  Time lastBeacon,
-  Time beaconInterval)
+    uint32_t interface,
+    Mac48Address peerAddress,
+    Mac48Address peerMeshPointAddress,
+    Time lastBeacon,
+    Time beaconInterval)
 {
   Ptr<PeerLink> new_link = CreateObject<PeerLink> ();
   if (m_lastLocalLinkId == 0xff)
@@ -284,9 +284,9 @@
   beacon = beaconsOnInterface->second.find (peerAddress);
   //find a peer link  - it must not exist
   if(FindPeerLink(interface, peerAddress) != 0)
-  {
-    NS_ASSERT (false);
-  }
+    {
+      NS_FATAL_ERROR ("Peer link must not to exist.");
+    }
   // Plugin must exist
   PeerManagerPluginMap::iterator plugin = m_plugins.find (interface);
   NS_ASSERT(plugin != m_plugins.end ());
@@ -310,16 +310,16 @@
   NS_ASSERT (iface != m_peerLinks.end());
   for (PeerLinksOnInterface::iterator i = iface->second.begin (); i != iface->second.end(); i++)
     if ((*i)->GetPeerAddress () == peerAddress)
-    {
-      if((*i)->LinkIsIdle ())
       {
-        (*i) = 0;
-        (iface->second).erase(i);
-        return 0;
+        if((*i)->LinkIsIdle ())
+          {
+            (*i) = 0;
+            (iface->second).erase(i);
+            return 0;
+          }
+        else
+          return (*i);
       }
-      else
-        return (*i);
-    }
   return 0;
 }
 void
@@ -342,8 +342,8 @@
 PeerManagementProtocol::IsActiveLink (uint32_t interface, Mac48Address peerAddress)
 {
   Ptr<PeerLink> peerLink = FindPeerLink(interface, peerAddress);
-    if(peerLink != 0)
-      return (peerLink->LinkIsEstab ());
+  if(peerLink != 0)
+    return (peerLink->LinkIsEstab ());
   return false;
 }
 bool
@@ -445,27 +445,27 @@
 void
 PeerManagementProtocol::PeerLinkStatus (uint32_t interface, Mac48Address peerAddress, Mac48Address peerMeshPointAddress, bool status)
 {
-   PeerManagerPluginMap::iterator plugin = m_plugins.find (interface);
-   NS_ASSERT(plugin != m_plugins.end());
-   NS_LOG_DEBUG(
-       "Link between me:" << m_address <<
-       " my interface:" << plugin->second->GetAddress() <<
-       " and peer mesh point:" << peerMeshPointAddress <<
-       " and its interface:" << peerAddress <<
-       ", at my interface ID:" << interface <<
-       ". Status:" << status);
-   if(status)
-   {
-     m_stats.linksOpened ++;
-     m_numberOfActivePeers ++;
-   }
-   else
-   {
-     m_stats.linksClosed ++;
-     m_numberOfActivePeers --;
-   }
-   if(!m_peerStatusCallback.IsNull ())
-     m_peerStatusCallback (peerMeshPointAddress, peerAddress, interface, status);
+  PeerManagerPluginMap::iterator plugin = m_plugins.find (interface);
+  NS_ASSERT(plugin != m_plugins.end());
+  NS_LOG_DEBUG(
+      "Link between me:" << m_address <<
+      " my interface:" << plugin->second->GetAddress() <<
+      " and peer mesh point:" << peerMeshPointAddress <<
+      " and its interface:" << peerAddress <<
+      ", at my interface ID:" << interface <<
+      ". Status:" << status);
+  if(status)
+    {
+      m_stats.linksOpened ++;
+      m_numberOfActivePeers ++;
+    }
+  else
+    {
+      m_stats.linksClosed ++;
+      m_numberOfActivePeers --;
+    }
+  if(!m_peerStatusCallback.IsNull ())
+    m_peerStatusCallback (peerMeshPointAddress, peerAddress, interface, status);
 }
 uint8_t
 PeerManagementProtocol::GetNumberOfLinks ()
@@ -492,8 +492,8 @@
 PeerManagementProtocol::Statistics::Print (std::ostream & os) const
 {
   os << "<Statistics "
-    "linksOpened=\"" << linksOpened << "\" "
-    "linksClosed=\"" << linksClosed << "\"/>\n";
+  "linksOpened=\"" << linksOpened << "\" "
+  "linksClosed=\"" << linksClosed << "\"/>\n";
 }
 void
 PeerManagementProtocol::Report (std::ostream & os) const
@@ -501,15 +501,15 @@
   os << "<PeerManagementProtocol>\n";
   m_stats.Print (os);
   for(PeerManagerPluginMap::const_iterator plugins = m_plugins.begin (); plugins != m_plugins.end (); plugins ++)
-  {
-    //Take statistics from plugin:
-    plugins->second->Report (os);
-    //Print all active peer links:
-    PeerLinksMap::const_iterator iface = m_peerLinks.find (plugins->second->m_ifIndex);
-    NS_ASSERT (iface != m_peerLinks.end());
-    for (PeerLinksOnInterface::const_iterator i = iface->second.begin (); i != iface->second.end(); i++)
-      (*i)->Report (os);
-  }
+    {
+      //Take statistics from plugin:
+      plugins->second->Report (os);
+      //Print all active peer links:
+      PeerLinksMap::const_iterator iface = m_peerLinks.find (plugins->second->m_ifIndex);
+      NS_ASSERT (iface != m_peerLinks.end());
+      for (PeerLinksOnInterface::const_iterator i = iface->second.begin (); i != iface->second.end(); i++)
+        (*i)->Report (os);
+    }
   os << "</PeerManagementProtocol>\n";
 }
 void
--- a/src/devices/mesh/mesh-l2-routing-protocol.h	Wed Jun 10 20:26:44 2009 +0400
+++ b/src/devices/mesh/mesh-l2-routing-protocol.h	Mon Jun 15 13:10:56 2009 +0400
@@ -81,18 +81,18 @@
   /**
    * Request routing information, all packets must go through this request.
    * 
-   * Note that route discobery works async. -- RequestRoute returns immediately, while
-   * reply callback will be called when routing information will be avaliable.
+   * Note that route discovery works async. -- RequestRoute returns immediately, while
+   * reply callback will be called when routing information will be available.
    * \return true if valid route is already known
    * \param sourceIface the incoming interface of the packet
    * \param source        source address
    * \param destination   destination address
    * \param packet        the packet to be resolved (needed the whole packet, because
    *                      routing information is added as tags or headers). The packet
-   *                      will be retutned to reply callback. 
+   *                      will be returned to reply callback. 
    * \param protocolType  protocol ID, needed to form a proper MAC-layer header
    * \param routeReply    callback to be invoked after route discovery procedure, supposed 
-   *                      to really send packetusing routing information.
+   *                      to really send packet using routing information.
    */
   virtual bool RequestRoute (uint32_t sourceIface, const Mac48Address source, const Mac48Address destination, 
       Ptr<Packet> packet, uint16_t  protocolType, RouteReplyCallback routeReply ) = 0;
--- a/src/devices/mesh/mesh-point-device.cc	Wed Jun 10 20:26:44 2009 +0400
+++ b/src/devices/mesh/mesh-point-device.cc	Mon Jun 15 13:10:56 2009 +0400
@@ -304,7 +304,8 @@
   for(std::vector< Ptr<NetDevice> >::const_iterator i = m_ifaces.begin (); i != m_ifaces.end (); i ++)
     if((*i)->GetIfIndex() == n)
       return (*i);
-  NS_ASSERT(false);
+  
+  NS_FATAL_ERROR ("Mesh point interface is not found by index");
   return 0;
 }
 std::vector<Ptr<NetDevice> >
@@ -363,8 +364,6 @@
   m_routingProtocol = protocol;
   m_requestRoute = MakeCallback (&MeshL2RoutingProtocol::RequestRoute, protocol);
   m_myResponse = MakeCallback (&MeshPointDevice::DoSend, this);
-  
-  return;
 }
 
 Ptr<MeshL2RoutingProtocol>
--- a/src/devices/mesh/mesh-wifi-beacon.h	Wed Jun 10 20:26:44 2009 +0400
+++ b/src/devices/mesh/mesh-wifi-beacon.h	Mon Jun 15 13:10:56 2009 +0400
@@ -53,7 +53,12 @@
   /// Add information element
   void AddInformationElement (Ptr<WifiInformationElement> ie);
   
-  /// Create wifi header for beacon frame. \param address is sender address \param mpAddress is mesh point address
+  /** 
+   * Create wifi header for beacon frame. 
+   * 
+   * \param address is sender address 
+   * \param mpAddress is mesh point address
+   */
   WifiMacHeader CreateHeader (Mac48Address address, Mac48Address mpAddress);
   /// Create frame = { beacon header + all information elements sorted by ElementId () }
   Ptr<Packet> CreatePacket ();
--- a/src/devices/mesh/mesh-wifi-interface-mac.cc	Wed Jun 10 20:26:44 2009 +0400
+++ b/src/devices/mesh/mesh-wifi-interface-mac.cc	Mon Jun 15 13:10:56 2009 +0400
@@ -203,8 +203,6 @@
   m_phy = phy;
   m_dcfManager->SetupPhyListener (phy);
   m_low->SetPhy (phy);
-
-  NS_LOG_DEBUG("SetWifiPhy: Can switch channel now: " << CanSwitchChannel() ); // TMP
 }
 
 void
@@ -590,7 +588,7 @@
                    " microseconds");
 
       // update supported rates
-      if (beacon_hdr.GetSsid ().IsEqual(GetSsid()))
+      if (beacon_hdr.GetSsid ().IsEqual (GetSsid()))
         {
           SupportedRates rates = beacon_hdr.GetSupportedRates ();
           WifiRemoteStation * peerSta = m_stationManager->Lookup (hdr->GetAddr2 ());
--- a/src/helper/dot11s-helper.h	Wed Jun 10 20:26:44 2009 +0400
+++ b/src/helper/dot11s-helper.h	Mon Jun 15 13:10:56 2009 +0400
@@ -49,7 +49,7 @@
   void SetSpreadInterfaceChannels (bool); 
   
   /** 
-   * \brief Install 802.11s mesh device & protocols on given node
+   * \brief Install 802.11s mesh device & protocols on given node list
    * 
    * \param phy                 Wifi PHY helper
    * \param nodes               List of nodes to install