22 #ifndef ANIMATION_INTERFACE__H
23 #define ANIMATION_INTERFACE__H
29 #include "ns3/net-device.h"
30 #include "ns3/node-container.h"
31 #include "ns3/nstime.h"
33 #include "ns3/node-list.h"
34 #include "ns3/random-variable-stream.h"
35 #include "ns3/simulator.h"
36 #include "ns3/config.h"
37 #include "ns3/animation-interface-helper.h"
38 #include "ns3/mac48-address.h"
39 #include "ns3/lte-ue-net-device.h"
40 #include "ns3/lte-enb-net-device.h"
41 #include "ns3/uan-phy-gen.h"
42 #include "ns3/rectangle.h"
46 #define MAX_PKTS_PER_TRACE_FILE 100000
73 std::ostringstream oss1;
75 std::ostringstream oss2;
77 return oss1.str () < oss2.str ();
273 void ShowNode (uint32_t nodeId,
bool show =
true);
315 void UpdateNodeSize (uint32_t nodeId,
double width,
double height);
335 void UpdateNodeColor (uint32_t nodeId, uint8_t r, uint8_t g, uint8_t b);
356 void UpdateNodeCounter (uint32_t nodeCounterId, uint32_t nodeId,
double counter);
368 void SetBackgroundImage (std::string fileName,
double x,
double y,
double scaleX,
double scaleY,
double opacity);
380 std::string linkDescription,
381 std::string fromNodeDescription =
"",
382 std::string toNodeDescription =
"");
394 std::string linkDescription,
395 std::string fromNodeDescription =
"",
396 std::string toNodeDescription =
"");
407 std::string linkDescription);
417 std::string linkDescription);
501 int WriteN (
const char*, uint32_t, FILE * f);
623 int WriteN (
const std::string&, FILE * f);
692 static std::map <P2pLinkNodeIdPair, LinkProperties, LinkPairCompare>
linkProperties;
736 std::string
GetXMLOpenClose_link (uint32_t fromLp, uint32_t fromId, uint32_t toLp, uint32_t toId);
738 std::string
GetXMLOpen_packet (uint32_t fromLp, uint32_t fromId,
double fbTx,
double lbTx, std::string auxInfo =
"");
739 std::string
GetXMLOpenClose_p (std::string pktType, uint32_t fId,
double fbTx,
double lbTx, uint32_t tId,
double fbRx,
double lbRx,
740 std::string metaInfo =
"", std::string auxInfo =
"");
741 std::string
GetXMLOpenClose_rx (uint32_t toLp, uint32_t toId,
double fbRx,
double lbRx);
742 std::string
GetXMLOpen_wpacket (uint32_t fromLp, uint32_t fromId,
double fbTx,
double lbTx,
double range);
743 std::string
GetXMLClose (std::string name) {
return "</" + name +
">\n"; }
837 virtual void Print (std::ostream &os)
const;
844 void Set (uint64_t AnimUid);
851 uint64_t
Get (
void)
const;
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)
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)
std::vector< Ptr< Node > > RecalcTopoBounds()
void AddPendingWifiPacket(uint64_t AnimUid, AnimPacketInfo &)
std::string GetPreamble(void)
bool LtePacketIsPending(uint64_t AnimUid)
std::string GetIpv4Address(Ptr< NetDevice > nd)
std::string CounterTypeToString(CounterType counterType)
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)
void CsmaPhyTxBeginTrace(std::string context, Ptr< const Packet > p)
static void SetNodeColor(Ptr< Node > n, uint8_t r, uint8_t g, uint8_t b)
Helper function to set the node color.
static bool IsInitialized(void)
Check if AnimationInterface is initialized.
std::string GetXMLClose(std::string name)
uint64_t m_maxPktsPerFile
void WifiMacRxTrace(std::string context, Ptr< const Packet > p)
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)
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)
uint64_t m_currentPktCount
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 &)
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 ConnectLteEnb(Ptr< Node > n, Ptr< LteEnbNetDevice > nd, uint32_t devIndex)
std::string GetIpv4RoutingTable(Ptr< Node > n)
void SetStartTime(Time t)
Specify the time at which capture should start.
void SetStopTime(Time t)
Specify the time at which capture should stop.
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 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)
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.
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.
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.
void SetXMLOutput()
Specify that animation commands are to be written in XML format.
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)
bool operator()(P2pLinkNodeIdPair first, P2pLinkNodeIdPair second) const
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.
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.
std::string GetNetAnimVersion()
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.
std::string m_outputFileName
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 >)
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)
std::map< uint32_t, double > EnergyFractionMap
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)
void DevTxTrace(std::string context, Ptr< const Packet > p, Ptr< NetDevice > tx, Ptr< NetDevice > rx, Time txTime, Time rxTime)
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.
void AppendXMLRemainingEnergy(std::ostream &ostream, uint32_t id) const
void AddPendingWimaxPacket(uint64_t AnimUid, AnimPacketInfo &)
bool NodeHasMoved(Ptr< Node > n, Vector newLocation)
std::string linkDescription
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.
void EnablePacketMetadata(bool enable=true)
Enable Packet metadata.
virtual void Serialize(TagBuffer i) const
Serialize function.
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.
Vector UpdatePosition(Ptr< Node > n)
std::string GetXMLOpenCloseUpdateNodeSize(uint32_t nodeId, double width, double height)
std::string GetXMLOpenCloseAddResource(uint32_t resourceId, std::string resourcePath)
uint64_t Get(void) const
Get Uid in tag.
std::vector< Ipv4RouteTrackElement > m_ipv4RouteTrackElements
void MobilityCourseChangeTrace(Ptr< const MobilityModel > mob)
std::string m_routingFileName
std::map< uint64_t, AnimPacketInfo > m_pendingWifiPackets
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)
std::string GetMacAddress(Ptr< NetDevice > nd)
#define MAX_PKTS_PER_TRACE_FILE
std::string GetXMLOpenCloseAddNodeCounter(uint32_t counterId, std::string counterName, CounterType counterType)
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
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
bool WimaxPacketIsPending(uint64_t AnimUid)
Vector GetPosition(Ptr< Node > n)
a unique identifier for an interface.
static std::map< uint32_t, std::string > nodeDescriptions
std::string GetXMLOpenClose_link(uint32_t fromLp, uint32_t fromId, uint32_t toLp, uint32_t toId)
std::string GetXMLOpen_topology(double minX, double minY, double maxX, double maxY)
std::vector< std::string > m_nodeCounters
void(* AnimWriteCallback)(const char *str)
typedef for WriteCallBack used for listening to AnimationInterface write messages ...
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 LteSpectrumPhyTxStart(std::string context, Ptr< const PacketBurst > pb)
void WimaxTxTrace(std::string context, Ptr< const Packet > p, const Mac48Address &)
std::string m_originalFileName
AnimPacketInfo helper class.