Interface stats added
This commit is contained in:
@@ -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> node, std::vector<
|
||||
void
|
||||
MeshWifiHelper::Report (const ns3::Ptr<ns3::NetDevice>& device, std::ostream& os)
|
||||
{
|
||||
NS_LOG_UNCOND("Report must be here:");
|
||||
Ptr <MeshPointDevice> mp = device->GetObject<MeshPointDevice> ();
|
||||
NS_ASSERT (mp != 0);
|
||||
std::vector<Ptr<NetDevice> > ifaces = mp->GetInterfaces ();
|
||||
@@ -175,6 +173,7 @@ MeshWifiHelper::Report (const ns3::Ptr<ns3::NetDevice>& device, std::ostream& os
|
||||
"BeaconInterval=\"" << mac->GetBeaconInterval ().GetSeconds() << "s\" "
|
||||
"Channel=\"" << mac->GetFrequencyChannel () << "\" "
|
||||
"/>\n";
|
||||
mac->Report(os);
|
||||
}
|
||||
os << "</MeshPointDevice>\n";
|
||||
Ptr <HwmpProtocol> hwmp = mp->GetObject<HwmpProtocol> ();
|
||||
|
||||
@@ -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 ++;
|
||||
|
||||
@@ -375,7 +375,8 @@ MeshWifiInterfaceMac::ForwardDown (Ptr<const Packet> const_packet, Mac48Address
|
||||
{
|
||||
// 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 @@ MeshWifiInterfaceMac::Receive (Ptr<Packet> 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> 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 << "<Interface>\n"
|
||||
"address=\"" << m_address << "\" "
|
||||
"\n";
|
||||
m_stats.Print (os);
|
||||
os << "</Interface>\n";
|
||||
}
|
||||
void
|
||||
MeshWifiInterfaceMac::ResetStats ()
|
||||
{
|
||||
m_stats = Statistics::Statistics ();
|
||||
}
|
||||
} // namespace ns3
|
||||
|
||||
|
||||
@@ -157,6 +157,9 @@ public:
|
||||
uint32_t GetLinkMetric(Mac48Address peerAddress);
|
||||
Ptr<WifiRemoteStationManager> GetStationManager ();
|
||||
///\}
|
||||
///\brief Statistics:
|
||||
void Report (std::ostream &) const;
|
||||
void ResetStats ();
|
||||
private:
|
||||
/// Frame receive handler
|
||||
void Receive (Ptr<Packet> packet, WifiMacHeader const *hdr);
|
||||
@@ -228,6 +231,27 @@ private:
|
||||
/// List of all installed plugins
|
||||
PluginList m_plugins;
|
||||
Callback<uint32_t, Mac48Address, Ptr<MeshWifiInterfaceMac> > 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
|
||||
|
||||
Reference in New Issue
Block a user