From 39d721981db94eed0618ea09e6e1c05267031674 Mon Sep 17 00:00:00 2001 From: John Abraham Date: Sat, 18 Jan 2014 20:03:20 -0800 Subject: [PATCH] NetAnim: Add ability to skip all packet tracing --- src/netanim/model/animation-interface.cc | 46 +++++++++++++----------- src/netanim/model/animation-interface.h | 7 ++++ 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/src/netanim/model/animation-interface.cc b/src/netanim/model/animation-interface.cc index a6a33217f..2a417c617 100644 --- a/src/netanim/model/animation-interface.cc +++ b/src/netanim/model/animation-interface.cc @@ -72,7 +72,8 @@ AnimationInterface::AnimationInterface (const std::string fn, bool enable3105, u m_enablePacketMetadata (false), m_startTime (Seconds (0)), m_stopTime (Seconds (3600 * 1000)), m_maxPktsPerFile (maxPktsPerFile), m_originalFileName (fn), m_routingStopTime (Seconds (0)), m_routingFileName (""), - m_routingPollInterval (Seconds (5)), m_enable3105 (enable3105) + m_routingPollInterval (Seconds (5)), m_enable3105 (enable3105), + m_trackPackets (true) { m_uniformRandomVariable = CreateObject (); initialized = true; @@ -88,6 +89,11 @@ AnimationInterface::~AnimationInterface () StopAnimation (); } +void AnimationInterface::SkipPacketTracing () +{ + m_trackPackets = false; +} + AnimationInterface & AnimationInterface::EnableIpv4RouteTracking (std::string fileName, Time startTime, Time stopTime, Time pollInterval) { m_routingFileName = fileName; @@ -1017,7 +1023,7 @@ void AnimationInterface::DevTxTrace (std::string context, Ptr p, Ptr tx, Ptr rx, Time txTime, Time rxTime) { - if (!m_started || !IsInTimeWindow ()) + if (!m_started || !IsInTimeWindow () || !m_trackPackets) return; NS_ASSERT (tx); NS_ASSERT (rx); @@ -1117,7 +1123,7 @@ uint64_t AnimationInterface::GetAnimUidFromPacket (Ptr p) void AnimationInterface::UanPhyGenTxTrace (std::string context, Ptr p) { - if (!m_started || !IsInTimeWindow ()) + if (!m_started || !IsInTimeWindow () || !m_trackPackets) return; Ptr ndev = GetNetDeviceFromContext (context); NS_ASSERT (ndev); @@ -1136,7 +1142,7 @@ void AnimationInterface::UanPhyGenTxTrace (std::string context, Ptr p) { - if (!m_started || !IsInTimeWindow ()) + if (!m_started || !IsInTimeWindow () || !m_trackPackets) return; Ptr ndev = GetNetDeviceFromContext (context); NS_ASSERT (ndev); @@ -1187,7 +1193,7 @@ void AnimationInterface::RemainingEnergyTrace (std::string context, double previ void AnimationInterface::WifiPhyTxBeginTrace (std::string context, Ptr p) { - if (!m_started || !IsInTimeWindow ()) + if (!m_started || !IsInTimeWindow () || !m_trackPackets) return; Ptr ndev = GetNetDeviceFromContext (context); NS_ASSERT (ndev); @@ -1217,7 +1223,7 @@ void AnimationInterface::WifiPhyTxEndTrace (std::string context, void AnimationInterface::WifiPhyTxDropTrace (std::string context, Ptr p) { - if (!m_started || !IsInTimeWindow ()) + if (!m_started || !IsInTimeWindow () || !m_trackPackets) return; Ptr ndev = GetNetDeviceFromContext (context); NS_ASSERT (ndev); @@ -1232,7 +1238,7 @@ void AnimationInterface::WifiPhyTxDropTrace (std::string context, void AnimationInterface::WifiPhyRxBeginTrace (std::string context, Ptr p) { - if (!m_started || !IsInTimeWindow ()) + if (!m_started || !IsInTimeWindow () || !m_trackPackets) return; Ptr ndev = GetNetDeviceFromContext (context); NS_ASSERT (ndev); @@ -1271,7 +1277,7 @@ void AnimationInterface::WifiPhyRxBeginTrace (std::string context, void AnimationInterface::WifiPhyRxEndTrace (std::string context, Ptr p) { - if (!m_started || !IsInTimeWindow ()) + if (!m_started || !IsInTimeWindow () || !m_trackPackets) return; Ptr ndev = GetNetDeviceFromContext (context); NS_ASSERT (ndev); @@ -1298,7 +1304,7 @@ void AnimationInterface::WifiPhyRxEndTrace (std::string context, void AnimationInterface::WifiMacRxTrace (std::string context, Ptr p) { - if (!m_started || !IsInTimeWindow ()) + if (!m_started || !IsInTimeWindow () || !m_trackPackets) return; Ptr ndev = GetNetDeviceFromContext (context); NS_ASSERT (ndev); @@ -1327,7 +1333,7 @@ void AnimationInterface::WifiPhyRxDropTrace (std::string context, void AnimationInterface::WimaxTxTrace (std::string context, Ptr p, const Mac48Address & m) { - if (!m_started || !IsInTimeWindow ()) + if (!m_started || !IsInTimeWindow () || !m_trackPackets) return; Ptr ndev = GetNetDeviceFromContext (context); NS_ASSERT (ndev); @@ -1346,7 +1352,7 @@ void AnimationInterface::WimaxTxTrace (std::string context, Ptr p, void AnimationInterface::WimaxRxTrace (std::string context, Ptr p, const Mac48Address & m) { - if (!m_started || !IsInTimeWindow ()) + if (!m_started || !IsInTimeWindow () || !m_trackPackets) return; Ptr ndev = GetNetDeviceFromContext (context); NS_ASSERT (ndev); @@ -1365,7 +1371,7 @@ void AnimationInterface::WimaxRxTrace (std::string context, Ptr p, void AnimationInterface::LteTxTrace (std::string context, Ptr p, const Mac48Address & m) { - if (!m_started || !IsInTimeWindow ()) + if (!m_started || !IsInTimeWindow () || !m_trackPackets) return; Ptr ndev = GetNetDeviceFromContext (context); NS_ASSERT (ndev); @@ -1384,7 +1390,7 @@ void AnimationInterface::LteTxTrace (std::string context, Ptr p, c void AnimationInterface::LteRxTrace (std::string context, Ptr p, const Mac48Address & m) { - if (!m_started || !IsInTimeWindow ()) + if (!m_started || !IsInTimeWindow () || !m_trackPackets) return; Ptr ndev = GetNetDeviceFromContext (context); NS_ASSERT (ndev); @@ -1407,7 +1413,7 @@ void AnimationInterface::LteRxTrace (std::string context, Ptr p, c void AnimationInterface::LteSpectrumPhyTxStart (std::string context, Ptr pb) { - if (!m_started || !IsInTimeWindow ()) + if (!m_started || !IsInTimeWindow () || !m_trackPackets) return; if (!pb) { @@ -1439,7 +1445,7 @@ void AnimationInterface::LteSpectrumPhyTxStart (std::string context, Ptr pb) { - if (!m_started || !IsInTimeWindow ()) + if (!m_started || !IsInTimeWindow () || !m_trackPackets) return; if (!pb) { @@ -1476,7 +1482,7 @@ void AnimationInterface::LteSpectrumPhyRxStart (std::string context, Ptr p) { - if (!m_started || !IsInTimeWindow ()) + if (!m_started || !IsInTimeWindow () || !m_trackPackets) return; Ptr ndev = GetNetDeviceFromContext (context); NS_ASSERT (ndev); @@ -1494,7 +1500,7 @@ void AnimationInterface::CsmaPhyTxBeginTrace (std::string context, Ptr p) { - if (!m_started || !IsInTimeWindow ()) + if (!m_started || !IsInTimeWindow () || !m_trackPackets) return; Ptr ndev = GetNetDeviceFromContext (context); NS_ASSERT (ndev); @@ -1516,7 +1522,7 @@ void AnimationInterface::CsmaPhyTxEndTrace (std::string context, Ptr p) { - if (!m_started || !IsInTimeWindow ()) + if (!m_started || !IsInTimeWindow () || !m_trackPackets) return; Ptr ndev = GetNetDeviceFromContext (context); NS_ASSERT (ndev); @@ -1545,7 +1551,7 @@ void AnimationInterface::CsmaPhyRxEndTrace (std::string context, Ptr p) { - if (!m_started || !IsInTimeWindow ()) + if (!m_started || !IsInTimeWindow () || !m_trackPackets) return; NS_LOG_FUNCTION (this); Ptr ndev = GetNetDeviceFromContext (context); @@ -1572,7 +1578,7 @@ void AnimationInterface::CsmaMacRxTrace (std::string context, void AnimationInterface::MobilityCourseChangeTrace (Ptr mobility) { - if (!m_started || !IsInTimeWindow ()) + if (!m_started || !IsInTimeWindow () || !m_trackPackets) return; Ptr n = mobility->GetObject (); NS_ASSERT (n); diff --git a/src/netanim/model/animation-interface.h b/src/netanim/model/animation-interface.h index 1423ef2bd..a089ca263 100644 --- a/src/netanim/model/animation-interface.h +++ b/src/netanim/model/animation-interface.h @@ -442,6 +442,12 @@ public: */ bool IsStarted (void); + /** + * \brief Do not trace packets. This helps reduce the trace file size if AnimationInterface is solely + * used for tracking mobility, routing paths and counters + */ + void SkipPacketTracing (); + /** * * \brief Enable Packet metadata @@ -721,6 +727,7 @@ private: static Rectangle * userBoundary; bool m_enable3105; + bool m_trackPackets; uint32_t m_remainingEnergyCounterId; std::string GetPacketMetadata (Ptr p);