diff --git a/src/devices/mesh/dot11s/dot11s-helper.cc b/src/devices/mesh/dot11s/dot11s-helper.cc index a8278ed95..acc4385a2 100644 --- a/src/devices/mesh/dot11s/dot11s-helper.cc +++ b/src/devices/mesh/dot11s/dot11s-helper.cc @@ -30,7 +30,6 @@ #include "ns3/mesh-wifi-interface-mac.h" #include "ns3/aarf-wifi-manager.h" #include "airtime-metric.h" -#include "ns3/log.h" namespace ns3 { namespace dot11s { @@ -159,7 +158,6 @@ MeshWifiHelper::Install (const WifiPhyHelper &phy, Ptr node, std::vector< void MeshWifiHelper::Report (const ns3::Ptr& device, std::ostream& os) { - NS_LOG_UNCOND("Report must be here:"); Ptr mp = device->GetObject (); NS_ASSERT (mp != 0); std::vector > ifaces = mp->GetInterfaces (); @@ -175,6 +173,7 @@ MeshWifiHelper::Report (const ns3::Ptr& device, std::ostream& os "BeaconInterval=\"" << mac->GetBeaconInterval ().GetSeconds() << "s\" " "Channel=\"" << mac->GetFrequencyChannel () << "\" " "/>\n"; + mac->Report(os); } os << "\n"; Ptr hwmp = mp->GetObject (); diff --git a/src/devices/mesh/dot11s/hwmp-protocol.cc b/src/devices/mesh/dot11s/hwmp-protocol.cc index 57f54ce94..6bdff3d46 100644 --- a/src/devices/mesh/dot11s/hwmp-protocol.cc +++ b/src/devices/mesh/dot11s/hwmp-protocol.cc @@ -313,7 +313,10 @@ HwmpProtocol::ForwardUnicast(uint32_t sourceIface, const Mac48Address source, c pkt.reply = routeReply; pkt.inInterface = sourceIface; if(QueuePacket (pkt)) + { + m_stats.totalQueued ++; return true; + } else { m_stats.totalDropped ++; diff --git a/src/devices/mesh/mesh-wifi-interface-mac.cc b/src/devices/mesh/mesh-wifi-interface-mac.cc index 9224ff50b..c5b596749 100644 --- a/src/devices/mesh/mesh-wifi-interface-mac.cc +++ b/src/devices/mesh/mesh-wifi-interface-mac.cc @@ -375,7 +375,8 @@ MeshWifiInterfaceMac::ForwardDown (Ptr const_packet, Mac48Address { // copy packet to allow modifications Ptr packet = const_packet->Copy (); - + m_stats.sentFrames ++; + m_stats.sentBytes += packet->GetSize (); WifiMacHeader hdr; hdr.SetTypeData (); hdr.SetAddr2 (GetAddress ()); @@ -563,6 +564,7 @@ MeshWifiInterfaceMac::Receive (Ptr packet, WifiMacHeader const *hdr) return; if (hdr->IsBeacon ()) { + m_stats.recvBeacons ++; MgtBeaconHeader beacon_hdr; Mac48Address from = hdr->GetAddr2 (); @@ -591,6 +593,11 @@ MeshWifiInterfaceMac::Receive (Ptr packet, WifiMacHeader const *hdr) } } } + 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 @@ MeshWifiInterfaceMac::GetMeshPointAddress () const { 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 << "\n" + "address=\"" << m_address << "\" " + "\n"; + m_stats.Print (os); + os << "\n"; +} +void +MeshWifiInterfaceMac::ResetStats () +{ + m_stats = Statistics::Statistics (); +} } // namespace ns3 diff --git a/src/devices/mesh/mesh-wifi-interface-mac.h b/src/devices/mesh/mesh-wifi-interface-mac.h index 44eba8c16..f8717a06b 100644 --- a/src/devices/mesh/mesh-wifi-interface-mac.h +++ b/src/devices/mesh/mesh-wifi-interface-mac.h @@ -157,6 +157,9 @@ public: uint32_t GetLinkMetric(Mac48Address peerAddress); Ptr GetStationManager (); ///\} + ///\brief Statistics: + void Report (std::ostream &) const; + void ResetStats (); private: /// Frame receive handler void Receive (Ptr packet, WifiMacHeader const *hdr); @@ -228,6 +231,27 @@ private: /// List of all installed plugins PluginList m_plugins; Callback > m_linkMetricCallback; + ///\name Statistics: + ///\{ + struct Statistics + { + uint16_t recvBeacons; + uint32_t sentFrames; + uint32_t sentBytes; + uint32_t recvFrames; + uint32_t recvBytes; + void Print (std::ostream & os) const; + Statistics () : + recvBeacons (0), + sentFrames (0), + sentBytes (0), + recvFrames (0), + recvBytes (0) + {} + }; + Statistics m_stats; + ///\} + }; } // namespace ns3