NetAnim: Add support for tracking MAC addresses at link level

This commit is contained in:
John Abraham
2012-12-02 18:08:59 -08:00
parent 19b51bfe74
commit 698778fcf5
2 changed files with 32 additions and 23 deletions

View File

@@ -358,6 +358,14 @@ void AnimationInterface::PurgePendingCsma ()
}
std::string AnimationInterface::GetMacAddress (Ptr <NetDevice> 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 <NetDevice> nd)
{
Ptr<Ipv4> ipv4 = NodeList::GetNode (nd->GetNode ()->GetId ())->GetObject <Ipv4> ();
@@ -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);
}
}
}

View File

@@ -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<const Packet> p,
Ptr<NetDevice> tx,
@@ -551,6 +551,7 @@ private:
void StartNewTraceFile();
std::string GetMacAddress (Ptr <NetDevice> nd);
std::string GetIpv4Address (Ptr <NetDevice> nd);
void WriteNonP2pLinkProperties (uint32_t id, std::string ipv4Address, std::string channelType);