RX/TX/FWD stats in MeshPointDevice
This commit is contained in:
@@ -71,6 +71,8 @@ Dot11sStack::InstallStack (Ptr<MeshPointDevice> mp)
|
||||
void
|
||||
Dot11sStack::Report (const Ptr<MeshPointDevice> mp, std::ostream& os)
|
||||
{
|
||||
mp->Report (os);
|
||||
|
||||
std::vector<Ptr<NetDevice> > ifaces = mp->GetInterfaces ();
|
||||
for (std::vector<Ptr<NetDevice> >::const_iterator i = ifaces.begin(); i != ifaces.end(); ++i)
|
||||
{
|
||||
@@ -89,6 +91,8 @@ Dot11sStack::Report (const Ptr<MeshPointDevice> mp, std::ostream& os)
|
||||
void
|
||||
Dot11sStack::ResetStats (const Ptr<MeshPointDevice> mp)
|
||||
{
|
||||
mp->ResetStats ();
|
||||
|
||||
std::vector<Ptr<NetDevice> > ifaces = mp->GetInterfaces ();
|
||||
for (std::vector<Ptr<NetDevice> >::const_iterator i = ifaces.begin(); i != ifaces.end(); ++i)
|
||||
{
|
||||
|
||||
@@ -95,6 +95,9 @@ MeshPointDevice::ReceiveFromDevice (Ptr<NetDevice> incomingPort, Ptr<const Packe
|
||||
{
|
||||
m_rxCallback (this, packet_copy, realProtocol, src);
|
||||
Forward (incomingPort, packet, protocol, src48, dst48);
|
||||
|
||||
m_rxStats.broadcastData ++;
|
||||
m_rxStats.broadcastDataBytes += packet->GetSize ();
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -104,6 +107,9 @@ MeshPointDevice::ReceiveFromDevice (Ptr<NetDevice> incomingPort, Ptr<const Packe
|
||||
if(m_removeRoutingStuff (incomingPort->GetIfIndex (), src48, dst48, packet_copy, realProtocol))
|
||||
{
|
||||
m_rxCallback (this, packet_copy, realProtocol, src);
|
||||
|
||||
m_rxStats.unicastData ++;
|
||||
m_rxStats.unicastDataBytes += packet->GetSize ();
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -390,7 +396,22 @@ MeshPointDevice::DoSend (bool success, Ptr<Packet> packet, Mac48Address src, Mac
|
||||
NS_LOG_DEBUG ("Resolve failed");
|
||||
return;
|
||||
}
|
||||
// Ok, now I know the route, just SendFrom
|
||||
|
||||
// Count statistics
|
||||
Statistics * stats = ((src == m_address) ? & m_txStats : & m_fwdStats);
|
||||
|
||||
if (dst.IsBroadcast ())
|
||||
{
|
||||
stats->broadcastData ++;
|
||||
stats->broadcastDataBytes += packet->GetSize ();
|
||||
}
|
||||
else
|
||||
{
|
||||
stats->unicastData ++;
|
||||
stats->unicastDataBytes += packet->GetSize ();
|
||||
}
|
||||
|
||||
// Send
|
||||
if (outIface != 0xffffffff)
|
||||
GetInterface (outIface)->SendFrom(packet, src, dst, protocol);
|
||||
else
|
||||
@@ -398,4 +419,31 @@ MeshPointDevice::DoSend (bool success, Ptr<Packet> packet, Mac48Address src, Mac
|
||||
(*i) -> SendFrom (packet->Copy (), src, dst, protocol);
|
||||
}
|
||||
|
||||
void
|
||||
MeshPointDevice::Report (std::ostream & os) const
|
||||
{
|
||||
os << "<Statistics \n"
|
||||
"txUnicastData=\"" << m_txStats.unicastData << "\"\n"
|
||||
"txUnicastDataBytes=\"" << (double)m_txStats.unicastDataBytes / 1024 << "K\"\n"
|
||||
"txBroadcastData=\"" << m_txStats.broadcastData << "\"\n"
|
||||
"txBroadcastDataBytes=\"" << (double)m_txStats.broadcastDataBytes / 1024 << "K\"\n"
|
||||
"rxUnicastData=\"" << m_rxStats.unicastData << "\"\n"
|
||||
"rxUnicastDataBytes=\"" << (double)m_rxStats.unicastDataBytes / 1024 << "K\"\n"
|
||||
"rxBroadcastData=\"" << m_rxStats.broadcastData << "\"\n"
|
||||
"rxBroadcastDataBytes=\"" << (double)m_rxStats.broadcastDataBytes / 1024 << "K\"\n"
|
||||
"fwdUnicastData=\"" << m_fwdStats.unicastData << "\"\n"
|
||||
"fwdUnicastDataBytes=\"" << (double)m_fwdStats.unicastDataBytes / 1024 << "K\"\n"
|
||||
"fwdBroadcastData=\"" << m_fwdStats.broadcastData << "\"\n"
|
||||
"fwdBroadcastDataBytes=\"" << (double)m_fwdStats.broadcastDataBytes / 1024 << "K\"\n"
|
||||
"/>\n";
|
||||
}
|
||||
|
||||
void
|
||||
MeshPointDevice::ResetStats ()
|
||||
{
|
||||
m_rxStats = Statistics ();
|
||||
m_txStats = Statistics ();
|
||||
m_fwdStats = Statistics ();
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -118,6 +118,14 @@ public:
|
||||
virtual void DoDispose ();
|
||||
//\}
|
||||
|
||||
///\name Statistics
|
||||
//\{
|
||||
/// Print statistics counters
|
||||
void Report (std::ostream & os) const;
|
||||
/// Reset statistics counters
|
||||
void ResetStats ();
|
||||
//\}
|
||||
|
||||
private:
|
||||
/// Receive packet from interface
|
||||
void ReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet> packet, uint16_t protocol,
|
||||
@@ -170,6 +178,24 @@ private:
|
||||
MeshL2RoutingProtocol::RouteReplyCallback m_myResponse;
|
||||
/// Current routing protocol, used mainly by GetRoutingProtocol
|
||||
Ptr<MeshL2RoutingProtocol> m_routingProtocol;
|
||||
|
||||
/// Device statistics counters
|
||||
struct Statistics
|
||||
{
|
||||
uint32_t unicastData;
|
||||
uint32_t unicastDataBytes;
|
||||
uint32_t broadcastData;
|
||||
uint32_t broadcastDataBytes;
|
||||
|
||||
Statistics () : unicastData (0),
|
||||
unicastDataBytes (0),
|
||||
broadcastData (0),
|
||||
broadcastDataBytes (0)
|
||||
{
|
||||
}
|
||||
};
|
||||
/// Counters
|
||||
Statistics m_rxStats, m_txStats, m_fwdStats;
|
||||
};
|
||||
} //namespace ns3
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user