From 698778fcf577fa1f24d906ae491c7ce8ddc5c68e Mon Sep 17 00:00:00 2001 From: John Abraham Date: Sun, 2 Dec 2012 18:08:59 -0800 Subject: [PATCH] NetAnim: Add support for tracking MAC addresses at link level --- src/netanim/model/animation-interface.cc | 16 +++++++--- src/netanim/model/animation-interface.h | 39 ++++++++++++------------ 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/src/netanim/model/animation-interface.cc b/src/netanim/model/animation-interface.cc index 70a97dd2c..6d799a3cc 100644 --- a/src/netanim/model/animation-interface.cc +++ b/src/netanim/model/animation-interface.cc @@ -358,6 +358,14 @@ void AnimationInterface::PurgePendingCsma () } +std::string AnimationInterface::GetMacAddress (Ptr nd) +{ + Address nodeAddr = nd->GetAddress(); + std::ostringstream oss; + oss << nodeAddr; + return oss.str ().substr (6); // Skip the first 6 chars to get the Mac +} + std::string AnimationInterface::GetIpv4Address (Ptr nd) { Ptr ipv4 = NodeList::GetNode (nd->GetNode ()->GetId ())->GetObject (); @@ -461,8 +469,8 @@ void AnimationInterface::StartAnimation (bool restart) if (n1Id < n2Id) { // ouptut the p2p link - NS_LOG_INFO ("Link:" << GetIpv4Address (dev) << "----" << GetIpv4Address (chDev)); - SetLinkDescription (n1Id, n2Id, "", GetIpv4Address (dev), GetIpv4Address (chDev)); + NS_LOG_INFO ("Link:" << GetIpv4Address (dev) << ":" << GetMacAddress (dev) << "----" << GetIpv4Address (chDev) << ":" << GetMacAddress (chDev) ); + SetLinkDescription (n1Id, n2Id, "", GetIpv4Address (dev) + "~" + GetMacAddress (dev), GetIpv4Address (chDev) + "~" + GetMacAddress (chDev)); std::ostringstream oss; if (m_xml) { @@ -478,8 +486,8 @@ void AnimationInterface::StartAnimation (bool restart) } else { - NS_LOG_INFO ("Link:" << GetIpv4Address (dev) << " Channel Type:" << channelType); - WriteNonP2pLinkProperties (n->GetId (), GetIpv4Address (dev), channelType); + NS_LOG_INFO ("Link:" << GetIpv4Address (dev) << " Channel Type:" << channelType << " Mac: " << GetMacAddress (dev)); + WriteNonP2pLinkProperties (n->GetId (), GetIpv4Address (dev) + "~" + GetMacAddress (dev), channelType); } } } diff --git a/src/netanim/model/animation-interface.h b/src/netanim/model/animation-interface.h index eb20e5766..f0bb0546b 100644 --- a/src/netanim/model/animation-interface.h +++ b/src/netanim/model/animation-interface.h @@ -160,25 +160,6 @@ public: */ void SetStopTime (Time t); - /** - * \brief Writes the topology information and sets up the appropriate - * animation packet tx callback - * - * Writes the topology information to the appropriate output, depending - * on prior calls to SetOutputFile, SetServerPort, or SetInternalAnimation. - * Then creates the callbacks needed for the animator to start processing - * packets. - * - * \param restart True when restarting animation - */ - void StartAnimation (bool restart = false); - - /** - * \brief Closes the interface to the animator. - * - */ - void StopAnimation (); - /** * \brief Set mobility poll interval:WARNING: setting a low interval can * cause slowness @@ -430,6 +411,25 @@ private: uint64_t m_maxPktsPerFile; std::string m_originalFileName; + /** + * \brief Writes the topology information and sets up the appropriate + * animation packet tx callback + * + * Writes the topology information to the appropriate output, depending + * on prior calls to SetOutputFile, SetServerPort, or SetInternalAnimation. + * Then creates the callbacks needed for the animator to start processing + * packets. + * + * \param restart True when restarting animation + */ + void StartAnimation (bool restart = false); + + /** + * \brief Closes the interface to the animator. + * + */ + void StopAnimation (); + void DevTxTrace (std::string context, Ptr p, Ptr tx, @@ -551,6 +551,7 @@ private: void StartNewTraceFile(); + std::string GetMacAddress (Ptr nd); std::string GetIpv4Address (Ptr nd); void WriteNonP2pLinkProperties (uint32_t id, std::string ipv4Address, std::string channelType);