NetAnim: Add support for ipv4 address printing for non-p2p

This commit is contained in:
John Abraham
2012-10-11 12:21:17 -07:00
parent cc339df80b
commit 806f5e9026
3 changed files with 30 additions and 6 deletions

View File

@@ -255,7 +255,7 @@ main (int argc, char **argv)
{
LogComponentEnable ("UanCwExample", LOG_LEVEL_ALL);
LogComponentEnable ("AnimationInterface", LOG_LEVEL_ALL);
//LogComponentEnable ("AnimationInterface", LOG_LEVEL_ALL);
NetAnimExperiment exp;

View File

@@ -473,7 +473,8 @@ void AnimationInterface::StartAnimation (bool restart)
}
else
{
//NS_FATAL_ERROR ("Net animation currently only supports point-to-point links.");
NS_LOG_INFO ("Link:" << GetIpv4Address (dev) << " Channel Type:" << channelType);
WriteNonP2pLinkProperties (n->GetId (), GetIpv4Address (dev), channelType);
}
}
}
@@ -688,14 +689,20 @@ void AnimationInterface::WriteDummyPacket ()
double lbTx = now.GetSeconds ();
double fbRx = now.GetSeconds ();
double lbRx = now.GetSeconds ();
if (m_xml)
{
oss << GetXMLOpenClose_p ("p", 0, fbTx, lbTx, 0, fbRx, lbRx, "", "DummyPktIgnoreThis");
}
oss << GetXMLOpenClose_p ("p", 0, fbTx, lbTx, 0, fbRx, lbRx, "", "DummyPktIgnoreThis");
WriteN (oss.str ());
}
void AnimationInterface::WriteNonP2pLinkProperties (uint32_t id, std::string ipv4Address, std::string channelType)
{
std::ostringstream oss;
oss << GetXMLOpenClose_NonP2pLinkProperties (id, ipv4Address, channelType);
WriteN (oss.str ());
}
void AnimationInterface::DevTxTrace (std::string context, Ptr<const Packet> p,
Ptr<NetDevice> tx, Ptr<NetDevice> rx,
Time txTime, Time rxTime)
@@ -1739,6 +1746,19 @@ std::string AnimationInterface::GetXMLOpenClose_meta (std::string metaInfo)
return oss.str ();
}
std::string AnimationInterface::GetXMLOpenClose_NonP2pLinkProperties (uint32_t id, std::string ipv4Address, std::string channelType)
{
std::ostringstream oss;
oss << "<nonp2plinkproperties id=\""
<< id << "\""
<< " ipv4Address=\"" << ipv4Address << "\""
<< " channelType=\"" << channelType << "\""
<< "/>" << std::endl;
return oss.str ();
}
std::vector<std::string> AnimationInterface::GetElementsFromContext (std::string context)
{
std::vector <std::string> elements;

View File

@@ -552,6 +552,8 @@ private:
void StartNewTraceFile();
std::string GetIpv4Address (Ptr <NetDevice> nd);
void WriteNonP2pLinkProperties (uint32_t id, std::string ipv4Address, std::string channelType);
std::string GetNetAnimVersion ();
// XML helpers
@@ -578,6 +580,8 @@ private:
std::string GetXMLOpen_wpacket (uint32_t fromLp, uint32_t fromId, double fbTx, double lbTx, double range);
std::string GetXMLClose (std::string name) {return "</" + name + ">\n"; }
std::string GetXMLOpenClose_meta (std::string metaInfo);
std::string GetXMLOpenClose_NonP2pLinkProperties (uint32_t id, std::string ipv4Address, std::string channelType);
/// Provides uniform random variables.
Ptr<UniformRandomVariable> m_uniformRandomVariable;