Statistics fixed
authorKirill Andreev <andreev@iitp.ru>
Thu, 21 May 2009 16:35:55 +0400
changeset 5015 e460e29f9f78
parent 5014 3bfccc1d8e01
child 5016 058f21f91233
Statistics fixed
src/devices/mesh/dot11s/dot11s-helper.cc
src/devices/mesh/dot11s/dot11s-helper.h
src/devices/mesh/dot11s/hwmp-mac-plugin.cc
src/devices/mesh/dot11s/hwmp-protocol.cc
src/devices/mesh/dot11s/peer-link.cc
src/devices/mesh/dot11s/peer-link.h
src/devices/mesh/dot11s/peer-management-plugin.cc
src/devices/mesh/dot11s/peer-management-plugin.h
src/devices/mesh/dot11s/peer-management-protocol.cc
src/devices/mesh/mesh-wifi-interface-mac.cc
src/devices/mesh/mesh-wifi-interface-mac.h
--- a/src/devices/mesh/dot11s/dot11s-helper.cc	Wed May 20 20:08:35 2009 +0400
+++ b/src/devices/mesh/dot11s/dot11s-helper.cc	Thu May 21 16:35:55 2009 +0400
@@ -161,21 +161,15 @@
   Ptr <MeshPointDevice> mp = device->GetObject<MeshPointDevice> ();
   NS_ASSERT (mp != 0);
   std::vector<Ptr<NetDevice> > ifaces = mp->GetInterfaces ();
-  os << "<MeshPointDevice ReportTime=\"" << Simulator::Now().GetSeconds() << "s\">\n";
+  os << "<MeshPointDevice ReportTime=\"" << Simulator::Now().GetSeconds() << "s\" MpAddress=\"" << mp->GetAddress () << "\">\n";
   for (std::vector<Ptr<NetDevice> >::const_iterator i = ifaces.begin(); i != ifaces.end(); ++i)
   {
     Ptr<WifiNetDevice> device = (*i)->GetObject<WifiNetDevice> ();
     NS_ASSERT (device != 0);
     Ptr<MeshWifiInterfaceMac> mac = device->GetMac()->GetObject<MeshWifiInterfaceMac> ();
     NS_ASSERT (mac != 0);
-    os << "<Interface "
-      "Index=\"" << device->GetIfIndex () << "\" "
-      "BeaconInterval=\"" << mac->GetBeaconInterval ().GetSeconds() << "s\" "
-      "Channel=\"" << mac->GetFrequencyChannel () << "\" "
-      "/>\n";
     mac->Report(os);
   }
-  os << "</MeshPointDevice>\n";
   Ptr <HwmpProtocol> hwmp = mp->GetObject<HwmpProtocol> ();
   NS_ASSERT(hwmp != 0);
   hwmp->Report (os);
@@ -183,8 +177,30 @@
   Ptr <PeerManagementProtocol> pmp = mp->GetObject<PeerManagementProtocol> ();
   NS_ASSERT(pmp != 0);
   pmp->Report (os);
+  os << "</MeshPointDevice>\n";
 }
+void
+MeshWifiHelper::ResetStats (const ns3::Ptr<ns3::NetDevice>& device)
+{
+  Ptr <MeshPointDevice> mp = device->GetObject<MeshPointDevice> ();
+  NS_ASSERT (mp != 0);
+  std::vector<Ptr<NetDevice> > ifaces = mp->GetInterfaces ();
+  for (std::vector<Ptr<NetDevice> >::const_iterator i = ifaces.begin(); i != ifaces.end(); ++i)
+  {
+    Ptr<WifiNetDevice> device = (*i)->GetObject<WifiNetDevice> ();
+    NS_ASSERT (device != 0);
+    Ptr<MeshWifiInterfaceMac> mac = device->GetMac()->GetObject<MeshWifiInterfaceMac> ();
+    NS_ASSERT (mac != 0);
+    mac->ResetStats ();
+  }
+  Ptr <HwmpProtocol> hwmp = mp->GetObject<HwmpProtocol> ();
+  NS_ASSERT(hwmp != 0);
+  hwmp->ResetStats ();
 
+  Ptr <PeerManagementProtocol> pmp = mp->GetObject<PeerManagementProtocol> ();
+  NS_ASSERT(pmp != 0);
+  pmp->ResetStats ();
+}
 } // namespace dot11s
 } //namespace ns3
 
--- a/src/devices/mesh/dot11s/dot11s-helper.h	Wed May 20 20:08:35 2009 +0400
+++ b/src/devices/mesh/dot11s/dot11s-helper.h	Thu May 21 16:35:55 2009 +0400
@@ -80,6 +80,7 @@
    */ 
   NetDeviceContainer Install (const WifiPhyHelper &phy, Ptr<Node> node,  std::vector<uint32_t> roots = std::vector<uint32_t> (), uint32_t nInterfaces = 1) const;
   static void Report (const ns3::Ptr<ns3::NetDevice>&, std::ostream&);
+  static void ResetStats (const ns3::Ptr<ns3::NetDevice>&);
 private:
   Ssid m_ssid;
   Time m_randomStartDelay;
--- a/src/devices/mesh/dot11s/hwmp-mac-plugin.cc	Wed May 20 20:08:35 2009 +0400
+++ b/src/devices/mesh/dot11s/hwmp-mac-plugin.cc	Thu May 21 16:35:55 2009 +0400
@@ -314,25 +314,27 @@
 void
 HwmpMacPlugin::Statistics::Print (std::ostream & os) const
 {
-  os <<"sentPreq= \"" << sentPreq << "\""
-    "sentPrep=\"" << sentPrep << "\""
-    "sentPerr=\"" << sentPerr << "\""
-    "recvPreq=\"" << recvPreq << "\""
-    "recvPrep=\"" << recvPrep << "\""
-    "recvPerr=\"" << recvPerr << "\""
-    "sentMgt=\"" << sentMgt << "\""
-    "sentMgtBytes=\"" << sentMgtBytes  / 1024 << "K\""
-    "recvMgt=\"" << recvMgt << "\""
-    "recvMgtBytes=\"" << recvMgtBytes / 1204 << "K\""
-    "sentData=\"" << sentData << "\""
-    "sentDataBytes=\"" << sentDataBytes / 1024 << "K\""
-    "recvData=\"" << recvData << "\""
-    "recvDataBytes=\"" << recvDataBytes / 1024 << "K\"\n";
+  os << "<Statistics "
+    "sentPreq= \"" << sentPreq << "\"\n"
+    "sentPrep=\"" << sentPrep << "\"\n"
+    "sentPerr=\"" << sentPerr << "\"\n"
+    "recvPreq=\"" << recvPreq << "\"\n"
+    "recvPrep=\"" << recvPrep << "\"\n"
+    "recvPerr=\"" << recvPerr << "\"\n"
+    "sentMgt=\"" << sentMgt << "\"\n"
+    "sentMgtBytes=\"" << (double)sentMgtBytes  / 1024.0 << "K\"\n"
+    "recvMgt=\"" << recvMgt << "\"\n"
+    "recvMgtBytes=\"" << (double)recvMgtBytes / 1204.0 << "K\"\n"
+    "sentData=\"" << sentData << "\"\n"
+    "sentDataBytes=\"" << (double)sentDataBytes / 1024.0 << "K\"\n"
+    "recvData=\"" << recvData << "\"\n"
+    "recvDataBytes=\"" << (double)recvDataBytes / 1024.0 << "K\"/>\n";
 }
 void
 HwmpMacPlugin::Report (std::ostream & os) const
 {
-  os << "<HwmpMacPlugin index=\""<< m_ifIndex <<"\">\n";
+  os << "<HwmpMacPlugin\n"
+    "address =\""<< m_parent->GetAddress () <<"\">\n";
   m_stats.Print(os);
   os << "</HwmpMacPlugin>\n";
 }
--- a/src/devices/mesh/dot11s/hwmp-protocol.cc	Wed May 20 20:08:35 2009 +0400
+++ b/src/devices/mesh/dot11s/hwmp-protocol.cc	Thu May 21 16:35:55 2009 +0400
@@ -939,18 +939,34 @@
 //Statistics:
 void HwmpProtocol::Statistics::Print (std::ostream & os) const
 {
-  os << "forwardedUnicast=\"" << forwardedUnicast << "\""
-    "forwardedBroadcast=\"" << forwardedBroadcast << "\""
-    "forwardedBytes=\"" << forwardedBytes / 1024 << "K\""
-    "totalQueued=\"" << totalQueued << "\""
-    "totalDropped=\"" << totalDropped << "\"\n";
+  os << "<Statistics "
+    "forwardedUnicast=\"" << forwardedUnicast << "\" "
+    "forwardedBroadcast=\"" << forwardedBroadcast << "\" "
+    "forwardedBytes=\"" << forwardedBytes / 1024 << "K\" "
+    "totalQueued=\"" << totalQueued << "\" "
+    "totalDropped=\"" << totalDropped << "\"/>\n";
 }
 void
 HwmpProtocol::Report (std::ostream & os) const
 {
-  os << "<Hwmp>\n"
-    "address=\"" << m_address << "\" "
-    "\n";
+  os << "<Hwmp "
+    "address=\"" << m_address << "\"\n"
+    "maxQueueSize=\"" << m_maxQueueSize << "\"\n"
+    "dot11MeshHWMPmaxPREQretries=\"" << (uint16_t)m_dot11MeshHWMPmaxPREQretries << "\"\n"
+    "dot11MeshHWMPnetDiameterTraversalTime=\"" << m_dot11MeshHWMPnetDiameterTraversalTime.GetMilliSeconds () << "ms\"\n"
+    "dot11MeshHWMPpreqMinInterval=\"" << m_dot11MeshHWMPpreqMinInterval.GetMilliSeconds () << "ms\"\n"
+    "dot11MeshHWMPperrMinInterval=\"" << m_dot11MeshHWMPperrMinInterval.GetMilliSeconds () << "ms\"\n"
+    "dot11MeshHWMPactiveRootTimeout=\"" << m_dot11MeshHWMPactiveRootTimeout.GetMilliSeconds () << "ms\"\n"
+    "dot11MeshHWMPactivePathTimeout=\"" << m_dot11MeshHWMPactivePathTimeout.GetMilliSeconds () << "ms\"\n"
+    "dot11MeshHWMPpathToRootInterval=\"" << m_dot11MeshHWMPpathToRootInterval.GetMilliSeconds () << "ms\"\n"
+    "dot11MeshHWMPrannInterval=\"" << m_dot11MeshHWMPrannInterval.GetMilliSeconds () << "ms\"\n"
+    "isRoot=\"" << m_isRoot << "\"\n"
+    "maxTtl=\"" << (uint16_t)m_maxTtl << "\"\n"
+    "unicastPerrThreshold=\"" << (uint16_t)m_unicastPerrThreshold << "\"\n"
+    "unicastPreqThreshold=\"" << (uint16_t)m_unicastPreqThreshold << "\"\n"
+    "unicastDataThreshold=\"" << (uint16_t)m_unicastDataThreshold << "\"\n"
+    "doFlag=\"" << m_doFlag << "\"\n"
+    "rfFlag=\"" << m_rfFlag << "\">\n";
   m_stats.Print (os);
   for(HwmpPluginMap::const_iterator plugin = m_interfaces.begin (); plugin != m_interfaces.end (); plugin ++)
   {
@@ -962,6 +978,8 @@
 HwmpProtocol::ResetStats ()
 {
   m_stats = Statistics::Statistics ();
+  for(HwmpPluginMap::const_iterator plugin = m_interfaces.begin (); plugin != m_interfaces.end (); plugin ++)
+    plugin->second->ResetStats ();
 }
 
 } //namespace dot11s
--- a/src/devices/mesh/dot11s/peer-link.cc	Wed May 20 20:08:35 2009 +0400
+++ b/src/devices/mesh/dot11s/peer-link.cc	Thu May 21 16:35:55 2009 +0400
@@ -569,7 +569,27 @@
 PeerLink::ConfirmTimeout ()
 {
   StateMachine (TOC);
-}  
+}
+void
+PeerLink::Report (std::ostream & os) const
+{
+  if(m_state != ESTAB)
+    return;
+  os << "<PeerLink\n"
+    "localAddress=\"" << m_macPlugin->GetAddress () << "\"\n"
+    "peerInterfaceAddress=\"" << m_peerAddress << "\"\n"
+    "peerMeshPointAddress=\"" << m_peerMeshPointAddress << "\"\n"
+    "metricOfTheLink=\"" << m_macPlugin->GetLinkMetric(m_peerAddress) << "\"\n"
+    "m_lastBeacon=\"" << m_lastBeacon.GetMilliSeconds () << "ms\"\n"
+    "m_localLinkId=\"" << m_localLinkId << "\"\n"
+    "m_peerLinkId=\"" << m_peerLinkId << "\"\n"
+    "m_assocId=\"" << m_assocId << "\"\n"
+    "dot11MeshMaxRetries=\"" << m_dot11MeshMaxRetries << "\"\n"
+    "dot11MeshRetryTimeout=\"" << m_dot11MeshRetryTimeout.GetMilliSeconds () << "ms\"\n"
+    "dot11MeshHoldingTimeout=\"" << m_dot11MeshHoldingTimeout.GetMilliSeconds () << "ms\"\n"
+    "dot11MeshConfirmTimeout=\"" << m_dot11MeshConfirmTimeout.GetMilliSeconds () << "ms\"\n"
+    "/>\n";
+}
 } // namespace dot11s
 } //namespace ns3
 
--- a/src/devices/mesh/dot11s/peer-link.h	Wed May 20 20:08:35 2009 +0400
+++ b/src/devices/mesh/dot11s/peer-link.h	Thu May 21 16:35:55 2009 +0400
@@ -94,6 +94,8 @@
   /// Set callback
   void MLMESetSignalStatusCallback (SignalStatusCallback);
   //\}
+  ///\brief Statistics
+  void Report (std::ostream & os) const;
 private:
   /**
    * \name Link response to received management frames
--- a/src/devices/mesh/dot11s/peer-management-plugin.cc	Wed May 20 20:08:35 2009 +0400
+++ b/src/devices/mesh/dot11s/peer-management-plugin.cc	Thu May 21 16:35:55 2009 +0400
@@ -271,33 +271,39 @@
 void
 PeerManagerMacPlugin::Statistics::Print (std::ostream & os) const
 {
-  os << "sendOpen=\"" << sendOpen << "\""
-    "sendConfirm=\"" << sendConfirm << "\""
-    "sendClose=\"" << sendClose << "\""
-    "recvOpen=\"" << recvOpen << "\""
-    "recvConfirm=\"" << recvConfirm << "\""
-    "recvClose=\"" << recvClose << "\""
-    "dropped=\"" << dropped << "\""
-    "brokenMgt=\"" << brokenMgt << "\""
-    "sentMgt=\"" << sentMgt << "\""
-    "sentMgtBytes=\"" << sentMgtBytes << "\""
-    "recvMgt=\"" << recvMgt << "\""
-    "recvMgtBytes=\"" << recvMgtBytes << "\""
-    "beaconShift=\"" << beaconShift << "\"\n";
+  os << "<Statistics "
+    "sendOpen=\"" << sendOpen << "\"\n"
+    "sendConfirm=\"" << sendConfirm << "\"\n"
+    "sendClose=\"" << sendClose << "\"\n"
+    "recvOpen=\"" << recvOpen << "\"\n"
+    "recvConfirm=\"" << recvConfirm << "\"\n"
+    "recvClose=\"" << recvClose << "\"\n"
+    "dropped=\"" << dropped << "\"\n"
+    "brokenMgt=\"" << brokenMgt << "\"\n"
+    "sentMgt=\"" << sentMgt << "\"\n"
+    "sentMgtBytes=\"" << (double)sentMgtBytes /1024.0 << "\"\n"
+    "recvMgt=\"" << recvMgt << "\"\n"
+    "recvMgtBytes=\"" << (double)recvMgtBytes / 1024.0 << "K\"\n"
+    "beaconShift=\"" << beaconShift << "\"/>\n";
 }
 void
 PeerManagerMacPlugin::Report (std::ostream & os) const
 {
-  os << "<PMP-MAC "
-    "index=\"" << m_ifIndex << "\">\n";
+  os << "<PeerManagerPlugin "
+    "address=\"" << m_parent->GetAddress () << "\">\n";
   m_stats.Print (os);
-  os << "</PMP MAC>\n";
+  os << "</PeerManagerPlugin>\n";
 }
 void
 PeerManagerMacPlugin::ResetStats ()
 {
   m_stats = Statistics::Statistics ();
 }
+uint32_t
+PeerManagerMacPlugin::GetLinkMetric (Mac48Address peerAddress)
+{
+  return m_parent->GetLinkMetric (peerAddress);
+}
 } // namespace dot11s
 } //namespace ns3
 
--- a/src/devices/mesh/dot11s/peer-management-plugin.h	Wed May 20 20:08:35 2009 +0400
+++ b/src/devices/mesh/dot11s/peer-management-plugin.h	Thu May 21 16:35:55 2009 +0400
@@ -51,9 +51,13 @@
   bool UpdateOutcomingFrame (Ptr<Packet> packet, WifiMacHeader & header, Mac48Address from, Mac48Address to);
   void UpdateBeacon (MeshWifiBeacon & beacon) const;
   ///\}
-  ///\brief Statistics:
+  ///\name Statistics:
+  ///\{
   void Report (std::ostream &) const;
   void ResetStats ();
+  uint32_t GetLinkMetric (Mac48Address peerAddress);
+  uint32_t GetIfIndex () {return m_ifIndex;};
+  ///\}
 private:
   friend class PeerManagementProtocol;
   friend class PeerLink; 
--- a/src/devices/mesh/dot11s/peer-management-protocol.cc	Wed May 20 20:08:35 2009 +0400
+++ b/src/devices/mesh/dot11s/peer-management-protocol.cc	Thu May 21 16:35:55 2009 +0400
@@ -475,22 +475,33 @@
 void
 PeerManagementProtocol::Statistics::Print (std::ostream & os) const
 {
-os << "linksOpened=\"" << linksOpened << "\""
-    "linksClosed=\"" << linksClosed << "\"\n";
+  os << "<Statistics "
+    "linksOpened=\"" << linksOpened << "\" "
+    "linksClosed=\"" << linksClosed << "\"/>\n";
 }
 void
 PeerManagementProtocol::Report (std::ostream & os) const
 {
-  os << "<PMP>\n";
+  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);
-  os << "</PMP>\n";
+    //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
 PeerManagementProtocol::ResetStats ()
 {
   m_stats = Statistics::Statistics ();
+  for(PeerManagerPluginMap::const_iterator plugins = m_plugins.begin (); plugins != m_plugins.end (); plugins ++)
+    plugins->second->ResetStats ();
 }
 
 } // namespace dot11s
--- a/src/devices/mesh/mesh-wifi-interface-mac.cc	Wed May 20 20:08:35 2009 +0400
+++ b/src/devices/mesh/mesh-wifi-interface-mac.cc	Thu May 21 16:35:55 2009 +0400
@@ -375,8 +375,6 @@
 {
   // copy packet to allow modifications
   Ptr<Packet> packet = const_packet->Copy ();
-  m_stats.sentFrames ++;
-  m_stats.sentBytes += packet->GetSize ();
   WifiMacHeader hdr;
   hdr.SetTypeData ();
   hdr.SetAddr2 (GetAddress ());
@@ -411,6 +409,8 @@
         }
       destination->RecordDisassociated ();
     }
+  m_stats.sentFrames ++;
+  m_stats.sentBytes += packet->GetSize ();
   m_BE->Queue (packet, hdr);
 }
 
@@ -424,7 +424,8 @@
       bool drop = ! ((*i)->UpdateOutcomingFrame(packet, header, Mac48Address (), Mac48Address ()));
       if (drop) return; // plugin drops frame
     }
-
+  m_stats.sentFrames ++;
+  m_stats.sentBytes += packet->GetSize ();
   m_VO->Queue (packet, header);
 }
 
@@ -646,18 +647,20 @@
 void
 MeshWifiInterfaceMac::Statistics::Print (std::ostream & os) const
 {
-  os << "recvBeacons=\"" << recvBeacons << "\""
-    "sentFrames=\"" << sentFrames << "\""
-    "sentBytes=\"" << sentBytes / 1024 << "K\""
-    "recvFrames=\"" << recvFrames << "\""
-    "recvBytes=\"" << recvBytes / 1024 << "K\"\n";
+  os << "<Statistics "
+    "recvBeacons=\"" << recvBeacons << "\" "
+    "sentFrames=\"" << sentFrames << "\" "
+    "sentBytes=\"" << (double)sentBytes / 1024.0 << "K\" "
+    "recvFrames=\"" << recvFrames << "\" "
+    "recvBytes=\"" << (double)recvBytes / 1024.0 << "K\"/>\n";
 }
 void
 MeshWifiInterfaceMac::Report (std::ostream & os) const
 {
-  os << "<Interface>\n"
-    "address=\"" << m_address << "\" "
-    "\n";
+  os << "<Interface "
+    "BeaconInterval=\"" << GetBeaconInterval ().GetSeconds() << "s\" "
+    "Channel=\"" << GetFrequencyChannel () << "\" "
+    "Address = \"" << GetAddress () << "\">\n";
   m_stats.Print (os);
   os << "</Interface>\n";
 }
--- a/src/devices/mesh/mesh-wifi-interface-mac.h	Wed May 20 20:08:35 2009 +0400
+++ b/src/devices/mesh/mesh-wifi-interface-mac.h	Thu May 21 16:35:55 2009 +0400
@@ -129,7 +129,7 @@
   
   /** \name Channel switching
    * 
-   * Channel center frequency = Channel starting frequency + 5 × nch (MHz), 
+   * Channel center frequency = Channel starting frequency + 5 * channel_id (MHz), 
    * where Starting channel frequency is standard-dependent as defined in IEEE 802.11-2007 17.3.8.3.2.
    * 
    * Number of channels to use must be limited elsewhere.