src/devices/mesh/mesh-wifi-interface-mac.cc
changeset 5014 3bfccc1d8e01
parent 5002 4ff127c1f6fa
child 5015 e460e29f9f78
--- a/src/devices/mesh/mesh-wifi-interface-mac.cc	Wed May 20 19:12:51 2009 +0400
+++ b/src/devices/mesh/mesh-wifi-interface-mac.cc	Wed May 20 20:08:35 2009 +0400
@@ -375,7 +375,8 @@
 {
   // 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 ());
@@ -563,6 +564,7 @@
     return;
   if (hdr->IsBeacon ())
     {
+      m_stats.recvBeacons ++;
       MgtBeaconHeader beacon_hdr;
       Mac48Address from = hdr->GetAddr2 ();
 
@@ -591,6 +593,11 @@
           }
         }
     }
+  else
+  {
+    m_stats.recvBytes += packet->GetSize ();
+    m_stats.recvFrames ++;
+  }
   // Filter frame through all installed plugins
   for (PluginList::iterator i = m_plugins.begin (); i != m_plugins.end(); ++i)
     {
@@ -635,7 +642,29 @@
 {
   return m_mpAddress;
 }
-
-
+//Statistics:
+void
+MeshWifiInterfaceMac::Statistics::Print (std::ostream & os) const
+{
+  os << "recvBeacons=\"" << recvBeacons << "\""
+    "sentFrames=\"" << sentFrames << "\""
+    "sentBytes=\"" << sentBytes / 1024 << "K\""
+    "recvFrames=\"" << recvFrames << "\""
+    "recvBytes=\"" << recvBytes / 1024 << "K\"\n";
+}
+void
+MeshWifiInterfaceMac::Report (std::ostream & os) const
+{
+  os << "<Interface>\n"
+    "address=\"" << m_address << "\" "
+    "\n";
+  m_stats.Print (os);
+  os << "</Interface>\n";
+}
+void
+MeshWifiInterfaceMac::ResetStats ()
+{
+  m_stats = Statistics::Statistics ();
+}
 } // namespace ns3