src/devices/mesh/dot11s/hwmp-protocol.cc
changeset 5012 c81291702113
parent 5010 bc885417e41e
child 5013 290579bb1c1b
--- a/src/devices/mesh/dot11s/hwmp-protocol.cc	Wed May 20 14:03:26 2009 +0400
+++ b/src/devices/mesh/dot11s/hwmp-protocol.cc	Wed May 20 18:30:27 2009 +0400
@@ -225,6 +225,8 @@
   }
   if (destination == Mac48Address::GetBroadcast ())
   {
+    m_stats.forwardedBroadcast ++;
+    m_stats.forwardedBytes += packet->GetSize ();
     //channel IDs where we have already sent broadcast:
     std::vector<uint16_t> channels;
     for(HwmpPluginMap::const_iterator plugin = m_interfaces.begin (); plugin != m_interfaces.end (); plugin ++)
@@ -595,11 +597,11 @@
   for (std::vector<Ptr<NetDevice> >::const_iterator i = interfaces.begin (); i != interfaces.end(); i++)
     {
       // Checking for compatible net device
-      const WifiNetDevice * wifiNetDev = dynamic_cast<const WifiNetDevice *> (PeekPointer (*i));
-      if (wifiNetDev == NULL)
+      Ptr<WifiNetDevice> wifiNetDev = (*i)->GetObject<WifiNetDevice> ();
+      if (wifiNetDev == 0)
         return false;
-      MeshWifiInterfaceMac * mac = dynamic_cast<MeshWifiInterfaceMac *> (PeekPointer (wifiNetDev->GetMac ()));
-      if (mac == NULL)
+      Ptr<MeshWifiInterfaceMac>  mac = wifiNetDev->GetMac ()->GetObject<MeshWifiInterfaceMac> ();
+      if (mac == 0)
         return false;
       // Installing plugins:
       Ptr<HwmpMacPlugin> hwmpMac = Create<HwmpMacPlugin> (wifiNetDev->GetIfIndex (), this);
@@ -761,6 +763,8 @@
     packet.pkt->RemovePacketTag(tag);
     tag.SetAddress (result.retransmitter);
     packet.pkt->AddPacketTag (tag);
+    m_stats.forwardedUnicast ++;
+    m_stats.forwardedBytes += packet.pkt->GetSize ();
     packet.reply (true, packet.pkt, packet.src, packet.dst, packet.protocol, result.ifIndex);
   }
 }
@@ -781,9 +785,10 @@
     NS_ASSERT (packet.pkt->PeekPacketTag(tag));
     tag.SetAddress (result.retransmitter);
     packet.pkt->AddPacketTag (tag);
+    m_stats.forwardedUnicast ++;
+    m_stats.forwardedBytes += packet.pkt->GetSize ();
     packet.reply (true, packet.pkt, packet.src, packet.dst, packet.protocol, result.ifIndex);
   }
-
 }
 
 bool
@@ -931,20 +936,24 @@
 //Statistics:
 void HwmpProtocol::Statistics::Print (std::ostream & os) const
 {
-  os << "<Statistics: "
-    "forwardedUnicast= \"" << forwardedUnicast << "\""
-    "forwardedBroadcast= \"" << forwardedBroadcast << "\""
-    "totalQueued= \"" << totalQueued << "\""
-    "totalDropped= \"" << totalDropped << "\"";
+  os << "forwardedUnicast=\"" << forwardedUnicast << "\""
+    "forwardedBroadcast=\"" << forwardedBroadcast << "\""
+    "forwardedBytes=\"" << forwardedBytes / 1024 << "K\""
+    "totalQueued=\"" << totalQueued << "\""
+    "totalDropped=\"" << totalDropped << "\"\n";
 }
 void
 HwmpProtocol::Report (std::ostream & os) const
 {
-  os << "<HWMP Protocol"
+  os << "<Hwmp>\n"
     "address=\"" << m_address << "\" "
-    ">\n";
+    "\n";
   m_stats.Print (os);
-  os << "<HWMP>\n";
+  for(HwmpPluginMap::const_iterator plugin = m_interfaces.begin (); plugin != m_interfaces.end (); plugin ++)
+  {
+    plugin->second->Report(os);
+  }
+  os << "</Hwmp>\n";
 }
 } //namespace dot11s
 } //namespace ns3