25 #include "ns3/animation-interface.h"
26 #include "ns3/channel.h"
27 #include "ns3/config.h"
29 #include "ns3/mobility-model.h"
30 #include "ns3/packet.h"
31 #include "ns3/simulator.h"
32 #include "ns3/animation-interface-helper.h"
33 #include "ns3/wifi-mac-header.h"
34 #include "ns3/wimax-mac-header.h"
35 #include "ns3/wifi-net-device.h"
36 #include "ns3/wifi-mac.h"
37 #include "ns3/constant-position-mobility-model.h"
38 #include "ns3/lte-ue-phy.h"
39 #include "ns3/lte-enb-phy.h"
40 #include "ns3/uan-net-device.h"
41 #include "ns3/uan-mac.h"
43 #include "ns3/ipv4-routing-protocol.h"
44 #include "ns3/energy-source-container.h"
58 #define PURGE_INTERVAL 5
67 : m_routingF (0), m_mobilityPollInterval (Seconds (0.25)),
68 m_outputFileName (fn),
69 m_outputFileSet (false), gAnimUid (0), m_randomPosition (true),
70 m_writeCallback (0), m_started (false),
71 m_enablePacketMetadata (false), m_startTime (Seconds (0)), m_stopTime (Seconds (3600 * 1000)),
72 m_maxPktsPerFile (maxPktsPerFile), m_originalFileName (fn),
73 m_routingStopTime (Seconds (0)), m_routingFileName (
""),
74 m_routingPollInterval (Seconds (5)), m_enable3105 (enable3105),
119 std::stringstream stream;
122 return stream.str ();
128 NS_LOG_INFO (
"RecursiveIpv4RoutePathSearch from:" << from.c_str () <<
" to:" << to.c_str ());
129 if ((from ==
"0.0.0.0") || (from ==
"127.0.0.1"))
131 NS_LOG_INFO (
"Got " << from.c_str () <<
" End recursion");
139 rpElements.push_back (elem);
174 std::ostringstream oss;
180 rpElements.push_back (elem);
184 rpElements.push_back (elem2);
190 rpElements.push_back (elem);
235 rpElements.push_back (elem);
239 std::ostringstream oss;
245 rpElements.push_back (elem);
249 rpElements.push_back (elem2);
255 rpElements.push_back (elem);
260 rpElements.push_back (elem);
299 std::ostringstream oss;
315 return "netanim-3.105";
332 std::ostringstream oss;
342 std::ostringstream oss;
354 NS_LOG_INFO (
"Creating new trace file:" << fn.c_str ());
355 m_f = std::fopen (fn.c_str (),
"w");
464 NS_LOG_UNCOND (
"AnimationInterface WARNING:Node:" << n->
GetId () <<
" Does not have a mobility model. Use SetConstantPosition if it is stationary");
465 Vector deterministicVector (100,100,0);
500 std::vector <uint64_t> purgeList;
510 purgeList.push_back (i->first);
514 for (std::vector <uint64_t>::iterator i = purgeList.begin ();
515 i != purgeList.end ();
527 std::vector <uint64_t> purgeList;
537 purgeList.push_back (i->first);
541 for (std::vector <uint64_t>::iterator i = purgeList.begin ();
542 i != purgeList.end ();
555 std::vector <uint64_t> purgeList;
565 purgeList.push_back (i->first);
569 for (std::vector <uint64_t>::iterator i = purgeList.begin ();
570 i != purgeList.end ();
581 std::vector <uint64_t> purgeList;
591 purgeList.push_back (i->first);
595 for (std::vector <uint64_t>::iterator i = purgeList.begin ();
596 i != purgeList.end ();
606 Address nodeAddr = nd->GetAddress ();
607 std::ostringstream oss;
609 return oss.str ().substr (6);
617 NS_LOG_WARN (
"Node: " << nd->GetNode ()->GetId () <<
" No ipv4 object found");
620 int32_t ifIndex = ipv4->GetInterfaceForDevice (nd);
623 NS_LOG_WARN (
"Node :" << nd->GetNode ()->GetId () <<
" Could not find index of NetDevice");
627 std::ostringstream oss;
652 struct Rgb rgb = {255, 0, 0};
660 std::ostringstream oss;
668 std::ostringstream oss;
679 uint32_t n1Id = n->
GetId ();
681 for (uint32_t i = 0; i < nDev; ++i)
690 if ((dev->GetInstanceTypeId ().GetName () ==
"ns3::LteUeNetDevice") ||
691 (dev->GetInstanceTypeId ().GetName () ==
"ns3::LteEnbNetDevice")||
692 (dev->GetInstanceTypeId ().GetName () ==
"ns3::VirtualNetDevice"))
699 std::string channelType = ch->GetInstanceTypeId ().GetName ();
701 if (channelType == std::string (
"ns3::PointToPointChannel"))
704 uint32_t nChDev = ch->GetNDevices ();
705 for (uint32_t j = 0; j < nChDev; ++j)
708 uint32_t n2Id = chDev->GetNode ()->GetId ();
716 std::ostringstream oss;
781 std::ostringstream oss;
783 oss <<
"NodeList/" << n->
GetId () <<
"/DeviceList/" << devIndex <<
"/";
804 std::ostringstream oss;
806 oss <<
"NodeList/" << n->
GetId () <<
"/DeviceList/" << devIndex <<
"/";
827 for (uint32_t devIndex = 0; devIndex < nDevices; ++devIndex)
851 Config::Connect (
"NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxBegin",
853 Config::Connect (
"NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxBegin",
865 Config::Connect (
"/NodeList/*/DeviceList/*/$ns3::CsmaNetDevice/PhyTxBegin",
867 Config::Connect (
"/NodeList/*/DeviceList/*/$ns3::CsmaNetDevice/PhyTxEnd",
869 Config::Connect (
"/NodeList/*/DeviceList/*/$ns3::CsmaNetDevice/PhyRxEnd",
873 Config::Connect (
"/NodeList/*/DeviceList/*/$ns3::UanNetDevice/Phy/PhyTxBegin",
875 Config::Connect (
"/NodeList/*/DeviceList/*/$ns3::UanNetDevice/Phy/PhyRxBegin",
877 Config::Connect (
"/NodeList/*/$ns3::BasicEnergySource/RemainingEnergy",
914 return WriteN (st.c_str (), st.length (), f);
919 std::vector < Ptr <Node> > MovedNodes;
942 MovedNodes.push_back (n);
960 uint32_t nLeft = count;
961 const char* p =
data;
962 uint32_t written = 0;
965 int n = std::fwrite (p, 1, nLeft, f);
980 std::ostringstream oss;
985 oss <<
GetXMLOpenClose_p (
"p", 0, fbTx, lbTx, 0, fbRx, lbRx,
"",
"DummyPktIgnoreThis");
993 NS_LOG_INFO (
"Writing Route Path From :" << nodeId <<
" To: " << destination.c_str ());
1009 std::ostringstream oss;
1023 std::ostringstream oss;
1025 double lbTx = (now + txTime).GetSeconds ();
1026 double fbRx = (now + rxTime - txTime).GetSeconds ();
1027 double lbRx = (now + rxTime).GetSeconds ();
1028 oss <<
GetXMLOpenClose_p (
"p", tx->GetNode ()->GetId (), fbTx, lbTx, rx->GetNode ()->GetId (),
1059 return n->
GetDevice (atoi (elements.at (3).c_str ()));
1144 NS_LOG_INFO (
"UanPhyGenRxTrace for packet:" << AnimUid);
1147 NS_LOG_WARN (
"UanPhyGenRxBeginTrace: unknown Uid");
1162 const uint32_t nodeId = node->GetId ();
1164 NS_LOG_INFO (
"Remaining energy on one of sources on node " << nodeId <<
": " << currentEnergy);
1170 const double energyFraction = currentEnergy / energySource->GetInitialEnergy ();
1172 NS_LOG_INFO (
"Total energy fraction on node " << nodeId <<
": " << energyFraction);
1203 Mac48Address nodeAddr = netDevice->GetMac ()->GetAddress ();
1204 std::ostringstream oss;
1224 NS_LOG_INFO (
"TxDropTrace for packet:" << AnimUid);
1240 NS_LOG_INFO (
"Wifi RxBeginTrace for packet:" << AnimUid);
1244 std::ostringstream oss;
1260 NS_LOG_WARN (
"WifiPhyRxBegin: unknown Uid, but we are adding a wifi packet");
1291 NS_LOG_INFO (
"MacRxTrace for packet:" << AnimUid <<
" complete");
1316 NS_LOG_INFO (
"MacRxTrace for packet:" << AnimUid <<
" complete");
1354 NS_LOG_INFO (
"WimaxRxTrace for packet:" << AnimUid);
1415 context =
"/" + context;
1421 std::list <Ptr <Packet> > pbList = pb->GetPackets ();
1447 context =
"/" + context;
1453 std::list <Ptr <Packet> > pbList = pb->GetPackets ();
1463 NS_LOG_WARN (
"LteSpectrumPhyRxTrace: unknown Uid");
1502 NS_LOG_INFO (
"CsmaPhyTxEndTrace for packet:" << AnimUid);
1508 NS_LOG_WARN (
"Unknown Uid, but adding Csma Packet anyway");
1533 NS_LOG_INFO (
"CsmaPhyRxEndTrace for packet:" << AnimUid);
1537 NS_LOG_INFO (
"CsmaPhyRxEndTrace for packet:" << AnimUid <<
" complete");
1564 NS_LOG_INFO (
"MacRxTrace for packet:" << AnimUid <<
" complete");
1584 v = mobility->GetPosition ();
1588 std::ostringstream oss;
1604 if ((ceil (oldLocation.
x) == ceil (newLocation.
x)) &&
1605 (ceil (oldLocation.
y) == ceil (newLocation.
y)))
1621 std::ostringstream oss;
1622 for (uint32_t i = 0; i < MovedNodes.size (); i++)
1656 NS_LOG_INFO (
"Setting node image for Node Id:" << nodeId);
1659 NS_FATAL_ERROR (
"Resource Id:" << resourceId <<
" not found. Did you use AddResource?");
1661 std::ostringstream oss;
1669 std::ostringstream oss;
1681 const EnergyFractionMap::const_iterator fractionIter =
m_nodeEnergyFraction.find (node->GetId ());
1684 return fractionIter->second;
1699 std::string typeString =
"unknown";
1700 switch (counterType)
1704 typeString =
"UINT32";
1709 typeString =
"DOUBLE";
1720 "<information><!-- \n\
1721 Description of attributes:\n\
1722 =========================\n\
1724 * ver = Current version\n\
1726 * minX = minimum X coordinate of the canvas\n\
1727 * minY = minimum Y coordinate of the canvas\n\
1728 * maxX = maximum X coordinate of the canvas\n\
1729 * maxY = maximum Y coordinate of the canvas\n\
1732 * locX = X coordinate\n\
1733 * locY = Y coordinate\n\
1734 * r = Red component\n\
1735 * g = Green component\n\
1736 * b = Blue component\n\
1738 * fromId = From Node Id\n\
1739 * toId = To Node Id\n\
1740 * fd = From Node description (for IP Address)\n\
1741 * td = To Node description (for IP Address)\n\
1742 * ld = Link description (for Bandwidth, delay etc)\n\
1744 * t = Simulation time\n\
1745 * ld = Link description (for Bandwidth, delay etc)\n\
1747 * t = Simulation time\n\
1748 * descr = Node description\n\
1749 * r = Red component\n\
1750 * g = Green component\n\
1751 * b = Blue component\n\
1752 * visible = Node visibility\n\
1753 * rc = Residual energy (between 0 and 1)\n\
1755 * fId = From Node Id\n\
1756 * fbTx = First bit transmit time\n\
1757 * lbTx = Last bit transmit time\n\
1758 * tId = To Node Id\n\
1759 * fbRx = First bit Rx Time\n\
1760 * lbRx = Last bit Rx\n\
1761 * meta-info = Packet meta data\n\
1763 * fId = From Node Id\n\
1764 * fbTx = First bit transmit time\n\
1765 * lbTx = Last bit transmit time\n\
1766 * range = Reception range\n\
1767 * tId = To Node Id\n\
1768 * fbRx = First bit Rx time\n\
1769 * meta-info = Packet meta data\n\
1770 * lbRx = Last bit Rx time-->\n\
1778 std::ostringstream oss;
1779 uint32_t nodeId = 0;
1781 nodeId = pktInfo.
m_txnd->GetNode ()->GetId ();
1786 uint32_t rxId = pktrxInfo.
m_rxnd->GetNode ()->GetId ();
1796 std::ostringstream oss;
1798 uint32_t nodeId = pktInfo.
m_txnd->GetNode ()->GetId ();
1799 uint32_t rxId = pktrxInfo.
m_rxnd->GetNode ()->GetId ();
1812 hubLoc = CreateObject<ConstantPositionMobilityModel> ();
1816 hubLoc->SetPosition (hubVec);
1817 NS_LOG_INFO (
"Node:" << n->
GetId () <<
" Position set to:(" << x <<
"," << y <<
"," << z <<
")");
1825 NS_FATAL_ERROR (
"NodeCounter Id:" << nodeCounterId <<
" not found. Did you use AddNodeCounter?");
1827 std::ostringstream oss;
1834 if ((opacity < 0) || (opacity > 1))
1838 std::ostringstream oss;
1847 NS_FATAL_ERROR (
"SetNodeColor must be used prior to creating the AnimationInterface object");
1850 struct Rgb rgb = {r, g, b};
1857 NS_LOG_INFO (
"Setting node visibility for Node Id:" << nodeId);
1868 std::ostringstream oss;
1877 std::ostringstream oss;
1891 NS_LOG_INFO (
"Setting node color for Node Id:" << nodeId);
1892 struct Rgb rgb = {r, g, b};
1900 std::ostringstream oss;
1910 for (uint32_t i = 0; i < nc.
GetN (); ++i)
1920 std::string linkDescription)
1922 std::ostringstream oss;
1928 std::string linkDescription)
1932 std::ostringstream oss;
1938 std::string linkDescription,
1939 std::string fromNodeDescription,
1940 std::string toNodeDescription)
1946 LinkProperties lp = { fromNodeDescription, toNodeDescription, linkDescription };
1962 std::string linkDescription,
1963 std::string fromNodeDescription,
1964 std::string toNodeDescription)
1975 NS_FATAL_ERROR (
"SetNodeDescription must be used prior to creating the AnimationInterface object");
1989 std::ostringstream oss;
2006 NS_FATAL_ERROR (
"SetNodeDescription must be used prior to creating the AnimationInterface object");
2007 for (uint32_t i = 0; i < nc.
GetN (); ++i)
2020 std::ostringstream oss;
2027 std::ostringstream oss;
2028 oss <<
"<nodeupdate id=\"" <<
id <<
"\"";
2031 oss <<
" visible=\"" << 1 <<
"\"";
2033 oss <<
" visible=\"" << 0 <<
"\"";
2046 std::ostringstream oss;
2047 oss <<
"<node id=\"" <<
id <<
"\"";
2049 oss <<
" locX = \"" << locX <<
"\" " <<
"locY = \"" << locY <<
"\"";
2059 std::ostringstream oss;
2060 oss <<
"<node id = \"" <<
id <<
"\"";
2062 oss <<
" locX=\"" << locX <<
"\" " <<
"locY=\"" << locY <<
"\"";
2073 std::ostringstream oss;
2075 <<
" fromId=\"" << fromId
2076 <<
"\" toId=\"" << toId
2079 oss <<
" ld=\"" << linkDescription <<
"\""
2087 std::ostringstream oss;
2088 oss <<
"<link fromId=\"" << fromId
2089 <<
"\" toId=\"" << toId
2118 std::ostringstream oss;
2119 oss << std::setprecision (10);
2120 oss <<
"<p fId=\"" << fromId
2121 <<
"\" fbTx=\"" << fbTx
2122 <<
"\" lbTx=\"" << lbTx
2123 << (auxInfo.empty ()?
"":
"\" aux=\"") << auxInfo.c_str () <<
"\">";
2129 std::ostringstream oss;
2131 <<
" id=\"" << nodeId <<
"\""
2132 <<
" info=\"" << routingInfo.c_str () <<
"\""
2133 <<
"/>" << std::endl;
2139 std::ostringstream oss;
2141 <<
" id=\"" << nodeId <<
"\"" <<
" d=\"" << destination.c_str () <<
"\""
2142 <<
" c=\"" << rpElements.size () <<
"\"" <<
">" << std::endl;
2143 for (Ipv4RoutePathElements::const_iterator i = rpElements.begin ();
2144 i != rpElements.end ();
2148 oss <<
"<rpe" <<
" n=\"" << rpElement.
nodeId <<
"\"" <<
" nH=\"" << rpElement.
nextHop.c_str () <<
"\"" <<
"/>" << std::endl;
2150 oss <<
"</rp>" << std::endl;
2156 uint32_t tId,
double fbRx,
double lbRx, std::string metaInfo,
2157 std::string auxInfo)
2159 std::ostringstream oss;
2160 oss << std::setprecision (10);
2161 oss <<
"<" << pktType <<
" fId=\"" << fId
2162 <<
"\" fbTx=\"" << fbTx
2163 <<
"\" lbTx=\"" << lbTx <<
"\"";
2164 if (!auxInfo.empty ())
2166 oss <<
" aux=\"" << auxInfo.c_str () <<
"\"";
2168 if (!metaInfo.empty ())
2170 oss <<
" meta-info=\"" << metaInfo.c_str () <<
"\"";
2172 oss <<
" tId=\"" << tId <<
"\" fbRx=\"" << fbRx <<
"\" lbRx=\"" << lbRx <<
"\">" << std::endl;
2180 std::ostringstream oss;
2181 oss << std::setprecision (10);
2182 oss <<
"<wpacket fromId=\"" << fromId
2183 <<
"\" fbTx=\"" << fbTx
2184 <<
"\" lbTx=\"" << lbTx
2185 <<
"\" range=\"" << range <<
"\">" << std::endl;
2192 std::ostringstream oss;
2193 oss << std::setprecision (10);
2194 oss <<
"<rx toId=\"" << toId
2195 <<
"\" fbRx=\"" << fbRx
2196 <<
"\" lbRx=\"" << lbRx
2197 <<
"\"/>" << std::endl;
2203 std::ostringstream oss;
2204 oss <<
"<meta info=\""
2205 << metaInfo <<
"\" />" << std::endl;
2211 std::ostringstream oss;
2212 oss <<
"<ncs ncId=\"" << nodeCounterId <<
"\""
2213 <<
" n=\"" << counterName <<
"\""
2215 <<
" />" << std::endl;
2221 std::ostringstream oss;
2222 oss <<
"<res rid=\"" << resourceId <<
"\""
2223 <<
" p=\"" << resourcePath <<
"\""
2224 <<
"/>" << std::endl;
2230 std::ostringstream oss;
2231 oss <<
"<nu p=\"i\""
2233 <<
" id=\"" << nodeId <<
"\""
2234 <<
" rid=\"" << resourceId <<
"\""
2235 <<
"/>" << std::endl;
2241 std::ostringstream oss;
2242 oss << std::setprecision (10);
2243 oss <<
"<nu p=\"s\""
2245 <<
" id=\"" << nodeId <<
"\""
2246 <<
" w=\"" << width <<
"\""
2247 <<
" h=\"" << height <<
"\""
2248 <<
"/>" << std::endl;
2254 std::ostringstream oss;
2255 oss <<
"<nu p=\"p\""
2257 <<
" id=\"" << nodeId <<
"\""
2258 <<
" x=\"" << x <<
"\""
2259 <<
" y=\"" << y <<
"\""
2260 <<
"/>" << std::endl;
2266 std::ostringstream oss;
2267 oss <<
"<nu p=\"c\""
2269 <<
" id=\"" << nodeId <<
"\""
2270 <<
" r=\"" << (uint32_t)r <<
"\""
2271 <<
" g=\"" << (uint32_t)g <<
"\""
2272 <<
" b=\"" << (uint32_t)b <<
"\""
2273 <<
"/>" << std::endl;
2279 std::ostringstream oss;
2280 oss <<
"<nu p=\"d\""
2282 <<
" id=\"" << nodeId <<
"\"";
2289 oss <<
" descr=\"\"";
2292 oss <<
"/>" << std::endl;
2299 std::ostringstream oss;
2300 oss <<
"<nc c=\"" << nodeCounterId <<
"\""
2301 <<
" i=\"" << nodeId <<
"\""
2303 <<
" v=\"" << counterValue <<
"\""
2304 <<
" />" << std::endl;
2310 std::ostringstream oss;
2311 oss <<
"<bg f=\"" << fileName <<
"\""
2312 <<
" x=\"" << x <<
"\""
2313 <<
" y=\"" << y <<
"\""
2314 <<
" sx=\"" << scaleX <<
"\""
2315 <<
" sy=\"" << scaleY <<
"\""
2316 <<
" o=\"" << opacity <<
"\""
2317 <<
"/>" << std::endl;
2324 std::ostringstream oss;
2325 oss <<
"<nonp2plinkproperties id=\""
2327 <<
" ipv4Address=\"" << ipv4Address <<
"\""
2328 <<
" channelType=\"" << channelType <<
"\""
2329 <<
"/>" << std::endl;
2336 std::vector <std::string> elements;
2337 size_t pos1=0, pos2;
2338 while (pos1 != context.npos)
2340 pos1 = context.find (
"/",pos1);
2341 pos2 = context.find (
"/",pos1+1);
2342 elements.push_back (context.substr (pos1+1,pos2-(pos1+1)));
2344 pos2 = context.npos;
2357 ostream <<
" descr=\"\"";
2363 const uint8_t r = color.
r;
2364 const uint8_t g = color.
g;
2365 const uint8_t b = color.
b;
2367 ostream <<
" r=\"" << (uint32_t)r <<
"\" "
2368 <<
" g=\"" << (uint32_t)g <<
"\" "
2369 <<
" b=\"" << (uint32_t)b <<
"\" ";
2377 ostream <<
"rc = \"" << fractionIter->second <<
"\" ";
2379 ostream <<
"rc = \"1\" ";
2387 .AddConstructor<AnimByteTag> ()
2400 return sizeof (uint64_t);
uint64_t GetAnimUidFromPacket(Ptr< const Packet >)
void Set(uint64_t AnimUid)
Set global Uid in tag.
std::string GetXMLOpenClose_nodeupdate(uint32_t id, bool visible=true)
uint64_t GetTracePktCount()
Get trace file packet count (This used only for testing)
void AddToIpv4AddressNodeIdTable(std::string, uint32_t)
void UpdateNodeImage(uint32_t nodeId, uint32_t resourceId)
Helper function to update the image of a node.
bool WifiPacketIsPending(uint64_t AnimUid)
double x
x coordinate of vector
void CsmaMacRxTrace(std::string context, Ptr< const Packet > p)
Simulation virtual time values and global simulation resolution.
std::string GetXMLOpen_anim(uint32_t lp)
bool CsmaPacketIsPending(uint64_t AnimUid)
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream.
AnimRxInfo GetRxInfo(Ptr< const NetDevice > nd)
GetRxInfo.
static uint32_t GetNNodes(void)
std::vector< Ptr< Node > > RecalcTopoBounds()
void AddPendingWifiPacket(uint64_t AnimUid, AnimPacketInfo &)
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
std::string GetPreamble(void)
bool LtePacketIsPending(uint64_t AnimUid)
Ipv4Address GetLocal(void) const
Get the local address.
std::string GetIpv4Address(Ptr< NetDevice > nd)
std::string CounterTypeToString(CounterType counterType)
void WriteU64(uint64_t v)
static Ptr< Node > GetNode(uint32_t n)
AnimationInterface & AddSourceDestination(uint32_t fromNodeId, std::string destinationIpv4Address)
Helper function to print the routing path from a source node to destination IP.
static TypeId GetTypeId(void)
Get Type Id.
std::string GetXMLOpenClose_NonP2pLinkProperties(uint32_t id, std::string ipv4Address, std::string channelType)
Energy source base class.
void CsmaPhyTxBeginTrace(std::string context, Ptr< const Packet > p)
Ptr< LteEnbPhy > GetPhy(void) const
static void SetNodeColor(Ptr< Node > n, uint8_t r, uint8_t g, uint8_t b)
Helper function to set the node color.
Mobility model for which the current position does not change once it has been set and until it is se...
bool ProcessRxEnd(Ptr< const NetDevice > nd, const Time &fbRx, Vector rxLoc)
Process RxEnd notifications.
static bool IsInitialized(void)
Check if AnimationInterface is initialized.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
std::string GetXMLClose(std::string name)
uint64_t m_maxPktsPerFile
void WifiMacRxTrace(std::string context, Ptr< const Packet > p)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
void OutputCsmaPacket(Ptr< const Packet > p, AnimPacketInfo &pktInfo, AnimRxInfo pktrxInfo)
std::map< std::string, uint32_t > m_macToNodeIdMap
void LteSpectrumPhyRxStart(std::string context, Ptr< const PacketBurst > pb)
Ptr< NetDevice > GetNetDeviceFromContext(std::string context)
Vector GetPosition(void) const
void WifiPhyTxBeginTrace(std::string context, Ptr< const Packet > p)
std::map< uint64_t, AnimPacketInfo > m_pendingWimaxPackets
void TrackIpv4RoutePaths()
NodeContainer m_routingNc
bool SetRoutingOutputFile(const std::string &fn)
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
uint64_t m_currentPktCount
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_FATAL_ERROR(msg)
fatal error handling
A structure to store the width and height of a node`.
std::string GetXMLOpenClose_rx(uint32_t toLp, uint32_t toId, double fbRx, double lbRx)
void LteTxTrace(std::string context, Ptr< const Packet > p, const Mac48Address &)
void WimaxRxTrace(std::string context, Ptr< const Packet > p, const Mac48Address &)
std::map< std::string, uint32_t > m_ipv4ToNodeIdMap
void RecursiveIpv4RoutePathSearch(std::string fromIpv4, std::string toIpv4, Ipv4RoutePathElements &)
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
void UpdateNodeSize(uint32_t nodeId, double width, double height)
Helper function to update the size of a node.
virtual void Deserialize(TagBuffer i)
Deserialize function.
void Connect(std::string path, const CallbackBase &cb)
void ConnectLteEnb(Ptr< Node > n, Ptr< LteEnbNetDevice > nd, uint32_t devIndex)
std::string GetIpv4RoutingTable(Ptr< Node > n)
void Print(std::ostream &os) const
Print the packet contents.
SocketErrno
Enumeration of the possible errors returned by a socket.
void SetStartTime(Time t)
Specify the time at which capture should start.
void SetStopTime(Time t)
Specify the time at which capture should stop.
virtual Ptr< Ipv4RoutingProtocol > GetRoutingProtocol(void) const =0
Get the routing protocol to be used by this Ipv4 stack.
void WifiPhyRxBeginTrace(std::string context, Ptr< const Packet > p)
void UpdateNodeColor(Ptr< Node > n, uint8_t r, uint8_t g, uint8_t b)
Helper function to update the node color.
void ProcessRxBegin(Ptr< const NetDevice > nd, const Time &fbRx)
Process RxBegin notifications.
void ResetAnimWriteCallback()
Reset the write callback function.
std::string GetXMLOpenClose_node(uint32_t lp, uint32_t id, double locX, double locY)
AnimWriteCallback m_writeCallback
void WifiPhyRxDropTrace(std::string context, Ptr< const Packet > p)
a polymophic address class
void UanPhyGenTxTrace(std::string context, Ptr< const Packet >)
static void SetConstantPosition(Ptr< Node > n, double x, double y, double z=0)
Helper function to set Constant Position for a given node.
uint32_t GetN(void) const
Get the number of Ptr stored in this container.
void ConnectLteUe(Ptr< Node > n, Ptr< LteUeNetDevice > nd, uint32_t devIndex)
std::map< uint32_t, Vector > m_nodeLocation
virtual void Print(std::ostream &os) const
Print tag info.
Keep track of the current position and velocity of an object.
static void SetLinkDescription(uint32_t fromNode, uint32_t toNode, std::string linkDescription, std::string fromNodeDescription="", std::string toNodeDescription="")
Helper function to set the description for a link.
double GetSeconds(void) const
void SetBackgroundImage(std::string fileName, double x, double y, double scaleX, double scaleY, double opacity)
Helper function to set the background image.
std::string GetXMLOpen_packet(uint32_t fromLp, uint32_t fromId, double fbTx, double lbTx, std::string auxInfo="")
void CsmaPhyRxEndTrace(std::string context, Ptr< const Packet > p)
Identifies a byte tag and a set of bytes within a packet to which the tag applies.
void RemainingEnergyTrace(std::string context, double previousEnergy, double currentEnergy)
std::string GetXMLOpenClose_p(std::string pktType, uint32_t fId, double fbTx, double lbTx, uint32_t tId, double fbRx, double lbRx, std::string metaInfo="", std::string auxInfo="")
void UpdateNodeCounter(uint32_t nodeCounterId, uint32_t nodeId, double counter)
Helper function to update a node's counter referenced by the nodeCounterId.
static void EnablePrinting(void)
Enable printing packets metadata.
void SetRandomPosition(bool setRandPos)
Set random position if a Mobility Model does not exists for the node.
uint32_t AddNodeCounter(std::string counterName, CounterType counterType)
Setup a node counter.
~AnimationInterface()
Destructor for the animator interface.
EnergyFractionMap m_nodeEnergyFraction
void SkipPacketTracing()
Do not trace packets.
static Iterator End(void)
std::string GetNetAnimVersion()
Ptr< const NetDevice > m_rxnd
Ptr to receiving NetDevice.
double GetNodeEnergyFraction(Ptr< const Node > node) const
Get node's energy fraction (This used only for testing)
Ptr< Node > GetNodeFromContext(const std::string &context) const
void WriteNodeUpdate(uint32_t nodeId)
Ptr< UniformRandomVariable > m_uniformRandomVariable
Provides uniform random variables.
double m_fbRx
First bit receive time.
std::string m_outputFileName
double firstlastbitDelta
Time delta between First bit Rx and Last bit Rx.
static void SetNodeDescription(Ptr< Node > n, std::string descr)
Helper function to set a brief description for a given node.
void UanPhyGenRxTrace(std::string context, Ptr< const Packet >)
Ptr< NetDevice > GetDevice(uint32_t index) const
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
ByteTagIterator GetByteTagIterator(void) const
Retiurns an iterator over the set of byte tags included in this packet.
std::map< uint64_t, AnimPacketInfo > m_pendingLtePackets
std::string GetXMLOpenCloseUpdateNodeImage(uint32_t nodeId, uint32_t resourceId)
void StartAnimation(bool restart=false)
Writes the topology information and sets up the appropriate animation packet tx callback.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
std::vector< Ipv4RoutePathElement > Ipv4RoutePathElements
AnimationInterface & EnableIpv4RouteTracking(std::string fileName, Time startTime, Time stopTime, Time pollInterval=Seconds(5))
Enable tracking of the Ipv4 routing table for all Nodes.
void OutputWirelessPacket(Ptr< const Packet > p, AnimPacketInfo &pktInfo, AnimRxInfo pktrxInfo)
std::string GetXMLOpenCloseUpdateNodePosition(uint32_t nodeId, double x, double y)
static std::map< uint32_t, Rgb > nodeColors
std::map< uint32_t, NodeSize > m_nodeSizes
void WifiPhyTxDropTrace(std::string context, Ptr< const Packet > p)
void AggregateObject(Ptr< Object > other)
Ipv4Address GetGateway(void) const
std::string GetXMLOpenCloseUpdateNodeColor(uint32_t nodeId, uint8_t r, uint8_t g, uint8_t b)
std::map< uint64_t, AnimPacketInfo > m_pendingCsmaPackets
void CsmaPhyTxEndTrace(std::string context, Ptr< const Packet > p)
CounterType
Counter Types.
std::string GetPacketMetadata(Ptr< const Packet > p)
std::vector< std::string > m_resources
std::string GetXMLOpen_wpacket(uint32_t fromLp, uint32_t fromId, double fbTx, double lbTx, double range)
int WriteN(const char *, uint32_t, FILE *f)
double m_lbTx
Last bit transmission time.
Access to the Ipv4 forwarding table, interfaces, and configuration.
void DevTxTrace(std::string context, Ptr< const Packet > p, Ptr< NetDevice > tx, Ptr< NetDevice > rx, Time txTime, Time rxTime)
uint32_t GetNDevices(void) const
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
uint32_t m_txNodeId
Tx Node Id if NetDevice is unknown.
tag a set of bytes in a packet
void AddPendingUanPacket(uint64_t AnimUid, AnimPacketInfo &)
keep track of a set of node pointers.
void UpdateLinkDescription(uint32_t fromNode, uint32_t toNode, std::string linkDescription)
Helper function to update the description for a link.
uint32_t AddResource(std::string resourcePath)
Add a resource such as the path to an image file.
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
void AppendXMLRemainingEnergy(std::ostream &ostream, uint32_t id) const
void AddPendingWimaxPacket(uint64_t AnimUid, AnimPacketInfo &)
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
bool NodeHasMoved(Ptr< Node > n, Vector newLocation)
Iterator over the set of byte tags in a packet.
std::string linkDescription
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionaly.
Time m_routingPollInterval
std::string GetXMLOpenCloseUpdateNodeDescription(uint32_t nodeId)
AnimationInterface(const std::string filename, bool enable3105=true, uint64_t maxPktsPerFile=MAX_PKTS_PER_TRACE_FILE)
Constructor.
double y
y coordinate of vector
void EnablePacketMetadata(bool enable=true)
Enable Packet metadata.
TypeId GetTypeId(void) const
virtual void Serialize(TagBuffer i) const
Serialize function.
static Time Now(void)
Return the "current simulation time".
bool UanPacketIsPending(uint64_t AnimUid)
const std::vector< std::string > GetElementsFromContext(const std::string &context) const
bool SetOutputFile(const std::string &fn)
Specify that animation commands are to be written to the specified output file.
Byte tag using by Anim to uniquely identify packets.
virtual TypeId GetInstanceTypeId(void) const
Get Instance Type Id.
void StopAnimation(bool onlyAnimation=false)
Closes the interface to the animator.
double m_lbRx
Last bit receive time.
void GetTag(Tag &tag) const
Read the requested tag and store it in the user-provided tag instance.
Vector UpdatePosition(Ptr< Node > n)
std::string GetXMLOpenCloseUpdateNodeSize(uint32_t nodeId, double width, double height)
std::string GetXMLOpenCloseAddResource(uint32_t resourceId, std::string resourcePath)
bool IsPhyRxComplete()
Check if Wifi Phy Rx is Complete.
uint64_t Get(void) const
Get Uid in tag.
Ipv4 addresses are stored in host order in this class.
std::vector< Ipv4RouteTrackElement > m_ipv4RouteTrackElements
void MobilityCourseChangeTrace(Ptr< const MobilityModel > mob)
std::string m_routingFileName
std::map< uint64_t, AnimPacketInfo > m_pendingWifiPackets
uint32_t GetId(void) const
a class to store IPv4 address information on an interface
std::map< uint64_t, AnimPacketInfo > m_pendingUanPackets
std::string GetXMLOpenClose_linkupdate(uint32_t fromId, uint32_t toId, std::string)
std::string GetXMLOpenClose_routing(uint32_t id, std::string routingInfo)
Ptr< const NetDevice > m_txnd
Ptr to NetDevice that is transmitting.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
std::string GetMacAddress(Ptr< NetDevice > nd)
static Iterator Begin(void)
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
std::string GetXMLOpenCloseAddNodeCounter(uint32_t counterId, std::string counterName, CounterType counterType)
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
std::string GetXMLOpenClose_rp(uint32_t nodeId, std::string destination, Ipv4RoutePathElements rpElements)
std::string GetXMLOpenCloseUpdateNodeCounter(uint32_t counterId, uint32_t nodeId, double value)
void WifiPhyTxEndTrace(std::string context, Ptr< const Packet > p)
virtual uint32_t GetSerializedSize(void) const
Get Serialized Size.
Interface to network animator.
void WriteNonP2pLinkProperties(uint32_t id, std::string ipv4Address, std::string channelType)
bool m_enablePacketMetadata
void WifiPhyRxEndTrace(std::string context, Ptr< const Packet > p)
std::string GetXMLOpenCloseUpdateBackground(std::string fileName, double x, double y, double scaleX, double scaleY, double opacity)
std::string fromNodeDescription
static std::map< P2pLinkNodeIdPair, LinkProperties, LinkPairCompare > linkProperties
double m_fbTx
First bit transmission time.
static bool IsFinished(void)
If there are no more events lefts to be scheduled, or if simulation time has already reached the "sto...
void SetAnimWriteCallback(AnimWriteCallback cb)
Set a callback function to listen to AnimationInterface write events.
void SetMobilityPollInterval(Time t)
Set mobility poll interval:WARNING: setting a low interval can cause slowness.
void AddPendingLtePacket(uint64_t AnimUid, AnimPacketInfo &)
void AddPendingCsmaPacket(uint64_t AnimUid, AnimPacketInfo &)
void AppendXMLNodeDescription(std::ostream &ostream, uint32_t id) const
void AppendXMLNodeColor(std::ostream &ostream, const Rgb &color) const
void WriteRoutePath(uint32_t nodeId, std::string destination, Ipv4RoutePathElements rpElements)
A structure to store red, blue and green components for entities such as nodes.
std::string toNodeDescription
Time m_mobilityPollInterval
std::string GetXMLOpenClose_meta(std::string metaInfo)
void ShowNode(uint32_t nodeId, bool show=true)
Helper function to show/hide a node.
bool IsStarted(void)
Is AnimationInterface started.
uint32_t m_remainingEnergyCounterId
Ptr< T > GetObject(void) const
bool WimaxPacketIsPending(uint64_t AnimUid)
Vector GetPosition(Ptr< Node > n)
a unique identifier for an interface.
static std::map< uint32_t, std::string > nodeDescriptions
TypeId SetParent(TypeId tid)
std::string GetXMLOpenClose_link(uint32_t fromLp, uint32_t fromId, uint32_t toLp, uint32_t toId)
std::vector< std::string > m_nodeCounters
void LteRxTrace(std::string context, Ptr< const Packet > p, const Mac48Address &)
void UpdateNodeDescription(Ptr< Node > n, std::string descr)
Helper function to update the description for a given node.
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
void LteSpectrumPhyTxStart(std::string context, Ptr< const PacketBurst > pb)
void WimaxTxTrace(std::string context, Ptr< const Packet > p, const Mac48Address &)
std::string m_originalFileName
void AddByteTag(const Tag &tag) const
Tag each byte included in this packet with a new byte tag.
AnimPacketInfo helper class.