Added statistcs structures
authorKirill Andreev <andreev@iitp.ru>
Wed, 20 May 2009 12:44:58 +0400
changeset 5010 bc885417e41e
parent 5009 ac0ea6c1e012
child 5011 79b4af29924a
Added statistcs structures
src/devices/mesh/dot11s/hwmp-mac-plugin.h
src/devices/mesh/dot11s/hwmp-protocol.cc
src/devices/mesh/dot11s/hwmp-protocol.h
src/devices/mesh/dot11s/peer-management-plugin.h
--- a/src/devices/mesh/dot11s/hwmp-mac-plugin.h	Tue May 19 19:58:24 2009 +0400
+++ b/src/devices/mesh/dot11s/hwmp-mac-plugin.h	Wed May 20 12:44:58 2009 +0400
@@ -97,6 +97,40 @@
     std::vector<Mac48Address> receivers;
   };
   MyPerr m_myPerr;
+  ///\name Statistics:
+  ///\{
+    struct Statistics
+    {
+      uint16_t sentPreq;
+      uint16_t recvPreq;
+      uint16_t sentPrep;
+      uint16_t recvPrep;
+      uint16_t sentPerr;
+      uint16_t recvPerr;
+      uint16_t sentMgt;
+      uint32_t sentMgtBytes;
+      uint16_t recvMgt;
+      uint32_t recvMgtBytes;
+      uint16_t sentData;
+      uint32_t sentDataBytes;
+      
+      void Print (std::ostream & os) const;
+      Statistics () : 
+        sentPreq (0), 
+        recvPreq (0),
+        sentPrep (0),
+        recvPrep (0),
+        sentPerr (0),
+        recvPerr (0),
+        sentMgt (0),
+        sentMgtBytes (0),
+        recvMgt (0),
+        recvMgtBytes (0),
+        sentData (0),
+        sentDataBytes (0)
+      {}
+    };
+  ///\}
 };
 } //namespace dot11s
 } //namespace ns3
--- a/src/devices/mesh/dot11s/hwmp-protocol.cc	Tue May 19 19:58:24 2009 +0400
+++ b/src/devices/mesh/dot11s/hwmp-protocol.cc	Wed May 20 12:44:58 2009 +0400
@@ -209,11 +209,7 @@
     }
     //Filling TAG:
     if(destination == Mac48Address::GetBroadcast ())
-    {
       tag.SetSeqno (m_dataSeqno++);
-      if (m_dataSeqno == 0xffffffff)
-        m_dataSeqno = 0;
-    }
     tag.SetTtl (m_maxTtl+1);
   }
   else
@@ -272,6 +268,8 @@
   {
     //reply immediately:
     routeReply (true, packet, source, destination, protocolType, result.ifIndex);
+    m_stats.forwardedUnicast ++;
+    m_stats.forwardedBytes += packet->GetSize ();
     return true;
   }
   if (sourceIface != GetMeshPoint ()->GetIfIndex())
@@ -291,6 +289,7 @@
       std::vector<IePerr::FailedDestination> destinations = m_rtable->GetUnreachableDestinations (result.retransmitter);
       MakePathError (destinations);
     }
+    m_stats.totalDropped ++;
     return false;
   }
   //Request a destination:
@@ -311,7 +310,13 @@
   pkt.protocol = protocolType;
   pkt.reply = routeReply;
   pkt.inInterface = sourceIface;
-  return QueuePacket (pkt);
+  if(QueuePacket (pkt))
+    return true;
+  else
+  {
+    m_stats.totalDropped ++;
+    return false;
+  }
 }
 void
 HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, Mac48Address fromMp, uint32_t metric)
@@ -817,6 +822,7 @@
           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);
         }
       std::map<Mac48Address, EventId>::iterator i = m_preqTimeouts.find (dst);
@@ -857,8 +863,6 @@
   //By default: must answer
   preq.SetHopcount (0);
   preq.SetTTL (m_maxTtl);
-  if (m_preqId == 0xffffffff)
-    m_preqId = 0;
   preq.SetLifetime (m_dot11MeshHWMPactiveRootTimeout.GetMicroSeconds () /1024);
   //\attention: do not forget to set originator address, sequence
   //number and preq ID in HWMP-MAC plugin
@@ -899,8 +903,6 @@
 HwmpProtocol::GetNextPreqId ()
 {
   m_preqId ++;
-  if(m_preqId == 0xffffffff)
-    m_preqId = 0;
   return m_preqId;
 }
 uint32_t
@@ -926,5 +928,23 @@
 {
   return m_address;
 }
+//Statistics:
+void HwmpProtocol::Statistics::Print (std::ostream & os) const
+{
+  os << "<Statistics: "
+    "forwardedUnicast= \"" << forwardedUnicast << "\""
+    "forwardedBroadcast= \"" << forwardedBroadcast << "\""
+    "totalQueued= \"" << totalQueued << "\""
+    "totalDropped= \"" << totalDropped << "\"";
+}
+void
+HwmpProtocol::Report (std::ostream & os) const
+{
+  os << "<HWMP Protocol"
+    "address=\"" << m_address << "\" "
+    ">\n";
+  m_stats.Print (os);
+  os << "<HWMP>\n";
+}
 } //namespace dot11s
 } //namespace ns3
--- a/src/devices/mesh/dot11s/hwmp-protocol.h	Tue May 19 19:58:24 2009 +0400
+++ b/src/devices/mesh/dot11s/hwmp-protocol.h	Wed May 20 12:44:58 2009 +0400
@@ -73,6 +73,8 @@
   void SetRoot ();
   void UnsetRoot ();
   ///\}
+  ///\brief Statistics:
+  void Report (std::ostream &) const;
 private:
   friend class HwmpMacPlugin;
   
@@ -135,7 +137,21 @@
   void ReactivePathResolved (Mac48Address dst);
   void ProactivePathResolved ();
   //\}
-  
+  ///\name Statistics:
+  ///\{
+  struct Statistics
+  {
+    uint16_t forwardedUnicast;
+    uint16_t forwardedBroadcast;
+    uint32_t forwardedBytes;
+    uint16_t totalQueued;
+    uint16_t totalDropped;
+
+    void Print (std::ostream & os) const;
+    Statistics () : forwardedUnicast (0), forwardedBroadcast (0), totalQueued (0), totalDropped (0) {}
+  };
+  Statistics m_stats;
+  ///\}
   ///\name Methods responsible for path discovery retry procedure:
   //\{
   /** 
--- a/src/devices/mesh/dot11s/peer-management-plugin.h	Tue May 19 19:58:24 2009 +0400
+++ b/src/devices/mesh/dot11s/peer-management-plugin.h	Wed May 20 12:44:58 2009 +0400
@@ -109,6 +109,10 @@
     uint16_t received;
     uint16_t dropped;
     uint16_t brokenMgt;
+    uint16_t sentMgt;
+    uint32_t sentMgtBytes;
+    uint16_t recvMgt;
+    uint32_t recvMgtBytes;
     
     Statistics ();
     void Print (std::ostream & os) const;