merge with HEAD
This commit is contained in:
@@ -95,7 +95,7 @@ int main (int argc, char *argv[])
|
||||
std::string tr_name ("n-node-ppp.tr");
|
||||
std::string pcap_name ("n-node-ppp");
|
||||
std::string flow_name ("n-node-ppp.xml");
|
||||
std::string anim_name ("n-node-ppp.anim");
|
||||
std::string anim_name ("n-node-ppp.anim.xml");
|
||||
|
||||
std::string adj_mat_file_name ("examples/matrix-topology/adjacency_matrix.txt");
|
||||
std::string node_coordinates_file_name ("examples/matrix-topology/node_coordinates.txt");
|
||||
@@ -275,24 +275,12 @@ int main (int argc, char *argv[])
|
||||
|
||||
// Configure animator with default settings
|
||||
|
||||
bool animEnabled = false;
|
||||
AnimationInterface anim;
|
||||
if (anim.SetServerPort (9) && anim.SetOutputFile (anim_name.c_str ()))
|
||||
{
|
||||
NS_LOG_INFO ("Animation Interface Enabled.");
|
||||
animEnabled = true;
|
||||
anim.StartAnimation ();
|
||||
}
|
||||
|
||||
AnimationInterface anim (anim_name.c_str ());
|
||||
NS_LOG_INFO ("Run Simulation.");
|
||||
|
||||
Simulator::Stop (Seconds (SimTime));
|
||||
Simulator::Run ();
|
||||
// flowmon->SerializeToXmlFile (flow_name.c_str(), true, true);
|
||||
if (animEnabled)
|
||||
{
|
||||
anim.StopAnimation ();
|
||||
}
|
||||
Simulator::Destroy ();
|
||||
|
||||
// ---------- End of Simulation Monitoring ---------------------------------
|
||||
|
||||
@@ -306,15 +306,15 @@ UdpEchoClient::Send (void)
|
||||
|
||||
++m_sent;
|
||||
|
||||
if (InetSocketAddress::IsMatchingType (m_peerAddress))
|
||||
if (Ipv4Address::IsMatchingType (m_peerAddress))
|
||||
{
|
||||
NS_LOG_INFO ("Sent " << m_size << " bytes to " <<
|
||||
InetSocketAddress::ConvertFrom (m_peerAddress));
|
||||
NS_LOG_INFO ("Client sent " << m_size << " bytes to " <<
|
||||
Ipv4Address::ConvertFrom (m_peerAddress) << " port " << m_peerPort);
|
||||
}
|
||||
else if (Inet6SocketAddress::IsMatchingType (m_peerAddress))
|
||||
else if (Ipv6Address::IsMatchingType (m_peerAddress))
|
||||
{
|
||||
NS_LOG_INFO ("Sent " << m_size << " bytes to " <<
|
||||
Inet6SocketAddress::ConvertFrom (m_peerAddress));
|
||||
NS_LOG_INFO ("Client sent " << m_size << " bytes to " <<
|
||||
Ipv6Address::ConvertFrom (m_peerAddress) << " port " << m_peerPort);
|
||||
}
|
||||
|
||||
if (m_sent < m_count)
|
||||
@@ -333,13 +333,15 @@ UdpEchoClient::HandleRead (Ptr<Socket> socket)
|
||||
{
|
||||
if (InetSocketAddress::IsMatchingType (from))
|
||||
{
|
||||
NS_LOG_INFO ("Received " << packet->GetSize () << " bytes from " <<
|
||||
InetSocketAddress::ConvertFrom (from).GetIpv4 ());
|
||||
NS_LOG_INFO ("Client received " << packet->GetSize () << " bytes from " <<
|
||||
InetSocketAddress::ConvertFrom (from).GetIpv4 () << " port " <<
|
||||
InetSocketAddress::ConvertFrom (from).GetPort ());
|
||||
}
|
||||
else if (Inet6SocketAddress::IsMatchingType (from))
|
||||
{
|
||||
NS_LOG_INFO ("Received " << packet->GetSize () << " bytes from " <<
|
||||
Inet6SocketAddress::ConvertFrom (from).GetIpv6 ());
|
||||
NS_LOG_INFO ("Client received " << packet->GetSize () << " bytes from " <<
|
||||
Inet6SocketAddress::ConvertFrom (from).GetIpv6 () << " port " <<
|
||||
Inet6SocketAddress::ConvertFrom (from).GetPort ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,25 +147,34 @@ UdpEchoServer::HandleRead (Ptr<Socket> socket)
|
||||
{
|
||||
if (InetSocketAddress::IsMatchingType (from))
|
||||
{
|
||||
NS_LOG_INFO ("Received " << packet->GetSize () << " bytes from " <<
|
||||
InetSocketAddress::ConvertFrom (from).GetIpv4 ());
|
||||
|
||||
packet->RemoveAllPacketTags ();
|
||||
packet->RemoveAllByteTags ();
|
||||
|
||||
NS_LOG_LOGIC ("Echoing packet");
|
||||
socket->SendTo (packet, 0, from);
|
||||
NS_LOG_INFO ("Server received " << packet->GetSize () << " bytes from " <<
|
||||
InetSocketAddress::ConvertFrom (from).GetIpv4 () << " port " <<
|
||||
InetSocketAddress::ConvertFrom (from).GetPort ());
|
||||
}
|
||||
else if (Inet6SocketAddress::IsMatchingType (from))
|
||||
{
|
||||
NS_LOG_INFO ("Received " << packet->GetSize () << " bytes from " <<
|
||||
Inet6SocketAddress::ConvertFrom (from).GetIpv6 ());
|
||||
NS_LOG_INFO ("Server received " << packet->GetSize () << " bytes from " <<
|
||||
Inet6SocketAddress::ConvertFrom (from).GetIpv6 () << " port " <<
|
||||
InetSocketAddress::ConvertFrom (from).GetPort ());
|
||||
}
|
||||
|
||||
packet->RemoveAllPacketTags ();
|
||||
packet->RemoveAllByteTags ();
|
||||
packet->RemoveAllPacketTags ();
|
||||
packet->RemoveAllByteTags ();
|
||||
|
||||
NS_LOG_LOGIC ("Echoing packet");
|
||||
socket->SendTo (packet, 0, from);
|
||||
NS_LOG_LOGIC ("Echoing packet");
|
||||
socket->SendTo (packet, 0, from);
|
||||
|
||||
if (InetSocketAddress::IsMatchingType (from))
|
||||
{
|
||||
NS_LOG_INFO ("Server sent " << packet->GetSize () << " bytes to " <<
|
||||
InetSocketAddress::ConvertFrom (from).GetIpv4 () << " port " <<
|
||||
InetSocketAddress::ConvertFrom (from).GetPort ());
|
||||
}
|
||||
else if (Inet6SocketAddress::IsMatchingType (from))
|
||||
{
|
||||
NS_LOG_INFO ("Server sent " << packet->GetSize () << " bytes to " <<
|
||||
Inet6SocketAddress::ConvertFrom (from).GetIpv6 () << " port " <<
|
||||
InetSocketAddress::ConvertFrom (from).GetPort ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,6 +152,7 @@ main (int argc, char *argv[])
|
||||
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
|
||||
Simulator::Stop (Seconds (15.0));
|
||||
AnimationInterface anim ("wireless-animation.xml");
|
||||
anim.EnablePacketMetadata (true);
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
return 0;
|
||||
|
||||
@@ -64,7 +64,7 @@ AnimationInterface::AnimationInterface ()
|
||||
usingSockets (false), mport (0), outputfilename (""),
|
||||
OutputFileSet (false), ServerPortSet (false), gAnimUid (0),randomPosition (true),
|
||||
m_writeCallback (0), m_started (false),
|
||||
m_enablePacketMetadata (false)
|
||||
m_enablePacketMetadata (false), m_startTime (Seconds(0)), m_stopTime (Seconds(3600 * 1000))
|
||||
{
|
||||
initialized = true;
|
||||
StartAnimation ();
|
||||
@@ -75,7 +75,7 @@ AnimationInterface::AnimationInterface (const std::string fn, bool usingXML)
|
||||
usingSockets (false), mport (0), outputfilename (fn),
|
||||
OutputFileSet (false), ServerPortSet (false), gAnimUid (0), randomPosition (true),
|
||||
m_writeCallback (0), m_started (false),
|
||||
m_enablePacketMetadata (false)
|
||||
m_enablePacketMetadata (false), m_startTime (Seconds(0)), m_stopTime (Seconds(3600 * 1000))
|
||||
{
|
||||
initialized = true;
|
||||
StartAnimation ();
|
||||
@@ -86,7 +86,7 @@ AnimationInterface::AnimationInterface (const uint16_t port, bool usingXML)
|
||||
usingSockets (true), mport (port), outputfilename (""),
|
||||
OutputFileSet (false), ServerPortSet (false), gAnimUid (0), randomPosition (true),
|
||||
m_writeCallback (0), m_started (false),
|
||||
m_enablePacketMetadata (false)
|
||||
m_enablePacketMetadata (false), m_startTime (Seconds(0)), m_stopTime (Seconds(3600 * 1000))
|
||||
{
|
||||
initialized = true;
|
||||
StartAnimation ();
|
||||
@@ -103,6 +103,17 @@ void AnimationInterface::SetXMLOutput ()
|
||||
m_xml = true;
|
||||
}
|
||||
|
||||
|
||||
void AnimationInterface::SetStartTime (Time t)
|
||||
{
|
||||
m_startTime = t;
|
||||
}
|
||||
|
||||
void AnimationInterface::SetStopTime (Time t)
|
||||
{
|
||||
m_stopTime = t;
|
||||
}
|
||||
|
||||
bool AnimationInterface::SetOutputFile (const std::string& fn)
|
||||
{
|
||||
if (OutputFileSet)
|
||||
@@ -156,6 +167,15 @@ void AnimationInterface::ResetAnimWriteCallback ()
|
||||
m_writeCallback = 0;
|
||||
}
|
||||
|
||||
bool AnimationInterface::IsInTimeWindow ()
|
||||
{
|
||||
if ((Simulator::Now () >= m_startTime) &&
|
||||
(Simulator::Now () <= m_stopTime))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AnimationInterface::SetServerPort (uint16_t port)
|
||||
{
|
||||
#if defined(HAVE_SYS_SOCKET_H) && defined(HAVE_NETINET_IN_H)
|
||||
@@ -741,7 +761,7 @@ uint64_t AnimationInterface::GetAnimUidFromPacket (Ptr <const Packet> p)
|
||||
void AnimationInterface::WifiPhyTxBeginTrace (std::string context,
|
||||
Ptr<const Packet> p)
|
||||
{
|
||||
if (!m_started)
|
||||
if (!m_started || !IsInTimeWindow ())
|
||||
return;
|
||||
Ptr <NetDevice> ndev = GetNetDeviceFromContext (context);
|
||||
NS_ASSERT (ndev);
|
||||
@@ -771,7 +791,7 @@ void AnimationInterface::WifiPhyTxEndTrace (std::string context,
|
||||
void AnimationInterface::WifiPhyTxDropTrace (std::string context,
|
||||
Ptr<const Packet> p)
|
||||
{
|
||||
if (!m_started)
|
||||
if (!m_started || !IsInTimeWindow ())
|
||||
return;
|
||||
Ptr <NetDevice> ndev = GetNetDeviceFromContext (context);
|
||||
NS_ASSERT (ndev);
|
||||
@@ -786,7 +806,7 @@ void AnimationInterface::WifiPhyTxDropTrace (std::string context,
|
||||
void AnimationInterface::WifiPhyRxBeginTrace (std::string context,
|
||||
Ptr<const Packet> p)
|
||||
{
|
||||
if (!m_started)
|
||||
if (!m_started || !IsInTimeWindow ())
|
||||
return;
|
||||
Ptr <NetDevice> ndev = GetNetDeviceFromContext (context);
|
||||
NS_ASSERT (ndev);
|
||||
@@ -825,7 +845,7 @@ void AnimationInterface::WifiPhyRxBeginTrace (std::string context,
|
||||
void AnimationInterface::WifiPhyRxEndTrace (std::string context,
|
||||
Ptr<const Packet> p)
|
||||
{
|
||||
if (!m_started)
|
||||
if (!m_started || !IsInTimeWindow ())
|
||||
return;
|
||||
Ptr <NetDevice> ndev = GetNetDeviceFromContext (context);
|
||||
NS_ASSERT (ndev);
|
||||
@@ -852,7 +872,7 @@ void AnimationInterface::WifiPhyRxEndTrace (std::string context,
|
||||
void AnimationInterface::WifiMacRxTrace (std::string context,
|
||||
Ptr<const Packet> p)
|
||||
{
|
||||
if (!m_started)
|
||||
if (!m_started || !IsInTimeWindow ())
|
||||
return;
|
||||
Ptr <NetDevice> ndev = GetNetDeviceFromContext (context);
|
||||
NS_ASSERT (ndev);
|
||||
@@ -881,7 +901,7 @@ void AnimationInterface::WifiPhyRxDropTrace (std::string context,
|
||||
|
||||
void AnimationInterface::WimaxTxTrace (std::string context, Ptr<const Packet> p, const Mac48Address & m)
|
||||
{
|
||||
if (!m_started)
|
||||
if (!m_started || !IsInTimeWindow ())
|
||||
return;
|
||||
Ptr <NetDevice> ndev = GetNetDeviceFromContext (context);
|
||||
NS_ASSERT (ndev);
|
||||
@@ -900,7 +920,7 @@ void AnimationInterface::WimaxTxTrace (std::string context, Ptr<const Packet> p,
|
||||
|
||||
void AnimationInterface::WimaxRxTrace (std::string context, Ptr<const Packet> p, const Mac48Address & m)
|
||||
{
|
||||
if (!m_started)
|
||||
if (!m_started || !IsInTimeWindow ())
|
||||
return;
|
||||
Ptr <NetDevice> ndev = GetNetDeviceFromContext (context);
|
||||
NS_ASSERT (ndev);
|
||||
@@ -919,7 +939,7 @@ void AnimationInterface::WimaxRxTrace (std::string context, Ptr<const Packet> p,
|
||||
|
||||
void AnimationInterface::LteTxTrace (std::string context, Ptr<const Packet> p, const Mac48Address & m)
|
||||
{
|
||||
if (!m_started)
|
||||
if (!m_started || !IsInTimeWindow ())
|
||||
return;
|
||||
Ptr <NetDevice> ndev = GetNetDeviceFromContext (context);
|
||||
NS_ASSERT (ndev);
|
||||
@@ -938,7 +958,7 @@ void AnimationInterface::LteTxTrace (std::string context, Ptr<const Packet> p, c
|
||||
|
||||
void AnimationInterface::LteRxTrace (std::string context, Ptr<const Packet> p, const Mac48Address & m)
|
||||
{
|
||||
if (!m_started)
|
||||
if (!m_started || !IsInTimeWindow ())
|
||||
return;
|
||||
Ptr <NetDevice> ndev = GetNetDeviceFromContext (context);
|
||||
NS_ASSERT (ndev);
|
||||
@@ -962,7 +982,7 @@ void AnimationInterface::LteRxTrace (std::string context, Ptr<const Packet> p, c
|
||||
|
||||
void AnimationInterface::CsmaPhyTxBeginTrace (std::string context, Ptr<const Packet> p)
|
||||
{
|
||||
if (!m_started)
|
||||
if (!m_started || !IsInTimeWindow ())
|
||||
return;
|
||||
Ptr <NetDevice> ndev = GetNetDeviceFromContext (context);
|
||||
NS_ASSERT (ndev);
|
||||
@@ -980,7 +1000,7 @@ void AnimationInterface::CsmaPhyTxBeginTrace (std::string context, Ptr<const Pac
|
||||
|
||||
void AnimationInterface::CsmaPhyTxEndTrace (std::string context, Ptr<const Packet> p)
|
||||
{
|
||||
if (!m_started)
|
||||
if (!m_started || !IsInTimeWindow ())
|
||||
return;
|
||||
Ptr <NetDevice> ndev = GetNetDeviceFromContext (context);
|
||||
NS_ASSERT (ndev);
|
||||
@@ -1001,7 +1021,7 @@ void AnimationInterface::CsmaPhyTxEndTrace (std::string context, Ptr<const Packe
|
||||
|
||||
void AnimationInterface::CsmaPhyRxEndTrace (std::string context, Ptr<const Packet> p)
|
||||
{
|
||||
if (!m_started)
|
||||
if (!m_started || !IsInTimeWindow ())
|
||||
return;
|
||||
Ptr <NetDevice> ndev = GetNetDeviceFromContext (context);
|
||||
NS_ASSERT (ndev);
|
||||
@@ -1024,7 +1044,7 @@ void AnimationInterface::CsmaPhyRxEndTrace (std::string context, Ptr<const Packe
|
||||
void AnimationInterface::CsmaMacRxTrace (std::string context,
|
||||
Ptr<const Packet> p)
|
||||
{
|
||||
if (!m_started)
|
||||
if (!m_started || !IsInTimeWindow ())
|
||||
return;
|
||||
NS_LOG_FUNCTION (this);
|
||||
Ptr <NetDevice> ndev = GetNetDeviceFromContext (context);
|
||||
@@ -1051,7 +1071,7 @@ void AnimationInterface::CsmaMacRxTrace (std::string context,
|
||||
void AnimationInterface::MobilityCourseChangeTrace (Ptr <const MobilityModel> mobility)
|
||||
|
||||
{
|
||||
if (!m_started)
|
||||
if (!m_started || !IsInTimeWindow ())
|
||||
return;
|
||||
Ptr <Node> n = mobility->GetObject <Node> ();
|
||||
NS_ASSERT (n);
|
||||
@@ -1091,6 +1111,8 @@ bool AnimationInterface::NodeHasMoved (Ptr <Node> n, Vector newLocation)
|
||||
|
||||
void AnimationInterface::MobilityAutoCheck ()
|
||||
{
|
||||
if (!m_started || !IsInTimeWindow ())
|
||||
return;
|
||||
std::vector <Ptr <Node> > MovedNodes = RecalcTopoBounds ();
|
||||
std::ostringstream oss;
|
||||
oss << GetXMLOpen_topology (topo_minX, topo_minY, topo_maxX, topo_maxY);
|
||||
@@ -1132,39 +1154,31 @@ std::string AnimationInterface::GetPreamble ()
|
||||
Description of attributes:\n\
|
||||
=========================\n\
|
||||
anim\n\
|
||||
* lp = Logical Processor Id\n\
|
||||
topology\n\
|
||||
* minX = minimum X coordinate of the canvas\n\
|
||||
* minY = minimum Y coordinate of the canvas\n\
|
||||
* maxX = maximum X coordinate of the canvas\n\
|
||||
* maxY = maximum Y coordinate of the canvas\n\
|
||||
node\n\
|
||||
* lp = Logical Processor Id\n\
|
||||
* id = Node Id\n\
|
||||
* locX = X coordinate\n\
|
||||
* locY = Y coordinate\n\
|
||||
link\n\
|
||||
* fromLp = From logical processor Id\n\
|
||||
* fromId = From Node Id\n\
|
||||
* toLp = To logical processor Id\n\
|
||||
* toId = To Node Id\n\
|
||||
packet\n\
|
||||
* fromLp = From logical processor Id\n\
|
||||
* fbTx = First bit transmit time\n\
|
||||
* lbTx = Last bit transmit time\n\
|
||||
rx\n\
|
||||
* toLp = To logical processor Id\n\
|
||||
* toId = To Node Id\n\
|
||||
* fbRx = First bit Rx Time\n\
|
||||
* lbRx = Last bit Rx\n\
|
||||
wpacket\n\
|
||||
* fromLp = From logical processor Id\n\
|
||||
* fromId = From Node Id\n\
|
||||
* fbTx = First bit transmit time\n\
|
||||
* lbTx = Last bit transmit time\n\
|
||||
* range = Reception range\n\
|
||||
rx\n\
|
||||
* toLp = To logical processor Id\n\
|
||||
* toId = To Node Id\n\
|
||||
* fbRx = First bit Rx time\n\
|
||||
* lbRx = Last bit Rx time-->\n\
|
||||
@@ -1254,7 +1268,7 @@ std::string AnimationInterface::GetXMLOpenClose_node (uint32_t lp,uint32_t id,do
|
||||
std::string AnimationInterface::GetXMLOpenClose_link (uint32_t fromLp,uint32_t fromId, uint32_t toLp, uint32_t toId)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "<link fromLp=\"0\" fromId=\"" << fromId
|
||||
oss << "<link fromId=\"" << fromId
|
||||
<< "\" toLp=\"0\" toId=\"" << toId
|
||||
<< "\"/>" << std::endl;
|
||||
return oss.str ();
|
||||
@@ -1265,7 +1279,7 @@ std::string AnimationInterface::GetXMLOpen_packet (uint32_t fromLp,uint32_t from
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << std::setprecision (10);
|
||||
oss << "<packet fromLp=\"" << fromLp << "\" fromId=\"" << fromId
|
||||
oss << "<packet fromId=\"" << fromId
|
||||
<< "\" fbTx=\"" << fbTx
|
||||
<< "\" lbTx=\"" << lbTx
|
||||
<< (auxInfo.empty()?"":"\" aux=\"") << auxInfo.c_str ()
|
||||
@@ -1277,10 +1291,10 @@ std::string AnimationInterface::GetXMLOpen_wpacket (uint32_t fromLp,uint32_t fro
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << std::setprecision (10);
|
||||
oss << "<wpacket fromLp = \"" << fromLp << "\" fromId = \"" << fromId
|
||||
<< "\" fbTx = \"" << fbTx
|
||||
<< "\" lbTx = \"" << lbTx
|
||||
<< "\" range = \"" << range << "\">" << std::endl;
|
||||
oss << "<wpacket fromId=\"" << fromId
|
||||
<< "\" fbTx=\"" << fbTx
|
||||
<< "\" lbTx=\"" << lbTx
|
||||
<< "\" range= \"" << range << "\">" << std::endl;
|
||||
return oss.str ();
|
||||
|
||||
}
|
||||
@@ -1289,7 +1303,7 @@ std::string AnimationInterface::GetXMLOpenClose_rx (uint32_t toLp, uint32_t toId
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << std::setprecision (10);
|
||||
oss << "<rx toLp=\"" << toLp <<"\" toId=\"" << toId
|
||||
oss << "<rx toId=\"" << toId
|
||||
<< "\" fbRx=\"" << fbRx
|
||||
<< "\" lbRx=\"" << lbRx
|
||||
<< "\"/>" << std::endl;
|
||||
|
||||
@@ -127,6 +127,24 @@ public:
|
||||
*/
|
||||
void SetXMLOutput ();
|
||||
|
||||
/**
|
||||
* \brief Specify the time at which capture should start
|
||||
*
|
||||
* \param t The time at which AnimationInterface should begin capture of traffic info
|
||||
*
|
||||
* \returns none
|
||||
*/
|
||||
void SetStartTime (Time t);
|
||||
|
||||
/**
|
||||
* \brief Specify the time at which capture should stop
|
||||
*
|
||||
* \param t The time at which AnimationInterface should stop capture of traffic info
|
||||
*
|
||||
* \returns none
|
||||
*/
|
||||
void SetStopTime (Time t);
|
||||
|
||||
/**
|
||||
* \brief (Deprecated) Specify that animation commands are to be written to
|
||||
* a socket.
|
||||
@@ -249,6 +267,7 @@ private:
|
||||
std::string outputfilename;
|
||||
bool OutputFileSet;
|
||||
bool ServerPortSet;
|
||||
|
||||
void DevTxTrace (std::string context,
|
||||
Ptr<const Packet> p,
|
||||
Ptr<NetDevice> tx,
|
||||
@@ -344,8 +363,11 @@ private:
|
||||
|
||||
bool m_started;
|
||||
bool m_enablePacketMetadata;
|
||||
Time m_startTime;
|
||||
Time m_stopTime;
|
||||
|
||||
std::map <std::string, uint32_t> m_macToNodeIdMap;
|
||||
bool IsInTimeWindow ();
|
||||
|
||||
// Path helper
|
||||
std::vector<std::string> GetElementsFromContext (std::string context);
|
||||
|
||||
Reference in New Issue
Block a user