22 #ifndef ANIMATION_INTERFACE__H
23 #define ANIMATION_INTERFACE__H
30 #include "ns3/net-device.h"
31 #include "ns3/node-container.h"
32 #include "ns3/nstime.h"
34 #include "ns3/node-list.h"
35 #include "ns3/random-variable-stream.h"
36 #include "ns3/simulator.h"
37 #include "ns3/config.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"
44 #include "ns3/ipv4-l3-protocol.h"
48 #define MAX_PKTS_PER_TRACE_FILE 100000
49 #define PURGE_INTERVAL 5
50 #define NETANIM_VERSION "netanim-3.106"
283 void UpdateNodeSize (uint32_t nodeId,
double width,
double height);
305 void UpdateNodeColor (uint32_t nodeId, uint8_t r, uint8_t g, uint8_t b);
315 void UpdateNodeCounter (uint32_t nodeCounterId, uint32_t nodeId,
double counter);
329 void SetBackgroundImage (std::string fileName,
double x,
double y,
double scaleX,
double scaleY,
double opacity);
340 std::string linkDescription);
351 std::string linkDescription);
470 std::ostringstream oss1;
472 std::ostringstream oss2;
474 return oss1.str () < oss2.str ();
521 template <
typename T>
621 void SetOutputFile (
const std::string& fn,
bool routing =
false);
626 int WriteN (
const char*, uint32_t, FILE * f);
627 int WriteN (
const std::string&, FILE * f);
650 void WriteRoutePath (uint32_t nodeId, std::string destination, Ipv4RoutePathElements rpElements);
761 void WriteXmlNode (uint32_t
id, uint32_t sysId,
double locX,
double locY);
762 void WriteXmlLink (uint32_t fromId, uint32_t toLp, uint32_t toId);
771 std::string metaInfo =
"");
772 void WriteXmlP (uint64_t animUid, std::string pktType, uint32_t fId,
double fbTx,
double lbTx);
773 void WriteXmlPRef (uint64_t animUid, uint32_t fId,
double fbTx, std::string metaInfo =
"");
777 void WriteXmlRp (uint32_t nodeId, std::string destination, Ipv4RoutePathElements rpElements);
840 virtual void Print (std::ostream &os)
const;
847 void Set (uint64_t AnimUid);
854 uint64_t
Get (
void)
const;
uint64_t GetAnimUidFromPacket(Ptr< const Packet >)
void Set(uint64_t AnimUid)
Set global Uid in tag.
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.
void WriteXmlRp(uint32_t nodeId, std::string destination, Ipv4RoutePathElements rpElements)
void AddPendingPacket(ProtocolType protocolType, uint64_t animUid, AnimPacketInfo pktInfo)
void WriteXmlNonP2pLinkProperties(uint32_t id, std::string ipv4Address, std::string channelType)
void CsmaMacRxTrace(std::string context, Ptr< const Packet > p)
Simulation virtual time values and global simulation resolution.
CounterType
Counter Types.
NodeCounterMap64 m_nodeQueueDequeue
std::map< P2pLinkNodeIdPair, LinkProperties, LinkPairCompare > LinkPropertiesMap
void WifiMacRxTrace(std::string context, Ptr< const Packet >)
std::string GetIpv4Address(Ptr< NetDevice > nd)
std::string CounterTypeToString(CounterType counterType)
AnimationInterface(const std::string filename)
Constructor.
std::map< uint32_t, std::string > NodeDescriptionsMap
AnimationInterface & AddSourceDestination(uint32_t fromNodeId, std::string destinationIpv4Address)
Helper function to print the routing path from a source node to destination IP.
void WriteXmlUpdateNodeImage(uint32_t nodeId, uint32_t resourceId)
static TypeId GetTypeId(void)
Get Type Id.
void TrackIpv4L3ProtocolCounters()
void CsmaPhyTxBeginTrace(std::string context, Ptr< const Packet > p)
AnimUidPacketInfoMap m_pendingWifiPackets
void WriteXmlUpdateNodePosition(uint32_t nodeId, double x, double y)
NodeDescriptionsMap m_nodeDescriptions
static bool IsInitialized(void)
Check if AnimationInterface is initialized.
uint32_t m_ipv4L3ProtocolTxCounterId
void PurgePendingPackets(ProtocolType protocolType)
uint32_t m_queueEnqueueCounterId
uint64_t m_maxPktsPerFile
void QueueDropTrace(std::string context, Ptr< const Packet >)
std::map< std::string, uint32_t > m_macToNodeIdMap
Time m_ipv4L3ProtocolCountersPollInterval
void LteSpectrumPhyRxStart(std::string context, Ptr< const PacketBurst > pb)
void TrackQueueCounters()
void TrackWifiPhyCounters()
Ptr< NetDevice > GetNetDeviceFromContext(std::string context)
void WifiPhyTxBeginTrace(std::string context, Ptr< const Packet > p)
void EnableWifiPhyCounters(Time startTime, Time stopTime, Time pollInterval=Seconds(1))
Enable tracking of Wifi Phy Counters such as TxDrop, RxDrop.
void TrackIpv4RoutePaths()
NodeContainer m_routingNc
Time m_ipv4L3ProtocolCountersStopTime
void WriteXmlAnim(bool routing=false)
uint64_t m_currentPktCount
NodeCounterMap64 m_nodeWifiPhyTxDrop
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 WriteXmlAddNodeCounter(uint32_t counterId, std::string counterName, CounterType counterType)
void ProcessRxBegin(Ptr< const NetDevice > nd, const double fbRx)
void ConnectLteEnb(Ptr< Node > n, Ptr< LteEnbNetDevice > nd, uint32_t devIndex)
std::string GetIpv4RoutingTable(Ptr< Node > n)
void WriteXmlUpdateNodeSize(uint32_t nodeId, double width, double height)
void WriteXmlUpdateNodeColor(uint32_t nodeId, uint8_t r, uint8_t g, uint8_t b)
void SetStartTime(Time t)
Specify the time at which capture should start.
void SetStopTime(Time t)
Specify the time at which capture should stop.
std::vector< Ptr< Node > > GetMovedNodes()
LinkPropertiesMap m_linkProperties
Time m_queueCountersPollInterval
void WifiPhyRxBeginTrace(std::string context, Ptr< const Packet > p)
void Ipv4TxTrace(std::string context, Ptr< const Packet >, Ptr< Ipv4 >, uint32_t)
void UpdateNodeColor(Ptr< Node > n, uint8_t r, uint8_t g, uint8_t b)
Helper function to update the node color.
void WriteXmlAddResource(uint32_t resourceId, std::string resourcePath)
void ResetAnimWriteCallback()
Reset the write callback function.
NodeCounterMap64 m_nodeWifiMacTx
AnimWriteCallback m_writeCallback
void AddAttribute(std::string attribute, T value)
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 WriteXmlUpdateLink(uint32_t fromId, uint32_t toId, std::string)
std::map< uint32_t, uint64_t > NodeCounterMap64
void CheckMaxPktsPerTraceFile()
DropReason
Reason why a packet has been dropped.
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.
void SetBackgroundImage(std::string fileName, double x, double y, double scaleX, double scaleY, double opacity)
Helper function to set the background image.
uint32_t m_ipv4L3ProtocolRxCounterId
void Add(AnimXmlElement e)
void CsmaPhyRxEndTrace(std::string context, Ptr< const Packet > p)
void RemainingEnergyTrace(std::string context, double previousEnergy, double currentEnergy)
uint32_t m_wifiPhyTxDropCounterId
void WifiMacRxDropTrace(std::string context, Ptr< const Packet >)
void WriteXmlClose(std::string name, bool routing=false)
void OutputWirelessPacketTxInfo(Ptr< const Packet > p, AnimPacketInfo &pktInfo, uint64_t animUid)
void EnableWifiMacCounters(Time startTime, Time stopTime, Time pollInterval=Seconds(1))
Enable tracking of Wifi Mac Counters such as Tx, TxDrop, Rx, RxDrop.
void UpdateNodeCounter(uint32_t nodeCounterId, uint32_t nodeId, double counter)
Helper function to update a node's counter referenced by the nodeCounterId.
uint32_t m_queueDropCounterId
uint32_t AddNodeCounter(std::string counterName, CounterType counterType)
Setup a node counter.
std::string GetElementString()
~AnimationInterface()
Destructor for the animator interface.
AnimUidPacketInfoMap m_pendingWimaxPackets
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)
std::string m_outputFileName
void DequeueTrace(std::string context, Ptr< const Packet >)
NodeCounterMap64 m_nodeIpv4Drop
void UanPhyGenRxTrace(std::string context, Ptr< const Packet >)
void WriteXmlP(std::string pktType, uint32_t fId, double fbTx, double lbTx, uint32_t tId, double fbRx, double lbRx, std::string metaInfo="")
void WifiMacTxTrace(std::string context, Ptr< const Packet >)
void StartAnimation(bool restart=false)
void WriteXmlNode(uint32_t id, uint32_t sysId, double locX, double locY)
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.
std::map< uint32_t, NodeSize > m_nodeSizes
std::map< uint32_t, double > EnergyFractionMap
void CsmaPhyTxEndTrace(std::string context, Ptr< const Packet > p)
std::string GetPacketMetadata(Ptr< const Packet > p)
Time m_wifiMacCountersPollInterval
std::vector< std::string > m_resources
int WriteN(const char *, uint32_t, FILE *f)
AnimXmlElement(std::string tagName)
void DevTxTrace(std::string context, Ptr< const Packet > p, Ptr< NetDevice > tx, Ptr< NetDevice > rx, Time txTime, Time rxTime)
Time m_wifiPhyCountersPollInterval
tag a set of bytes in a packet
NodeColorsMap m_nodeColors
void WriteXmlRouting(uint32_t id, std::string routingInfo)
void Ipv4RxTrace(std::string context, Ptr< const Packet >, Ptr< Ipv4 >, uint32_t)
void WriteXmlPRef(uint64_t animUid, uint32_t fId, double fbTx, std::string metaInfo="")
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint32_t m_wifiMacRxDropCounterId
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.
void(* AnimWriteCallback)(const char *str)
typedef for WriteCallBack used for listening to AnimationInterface write messages ...
uint32_t AddResource(std::string resourcePath)
Add a resource such as the path to an image file.
std::string fromNodeDescription
void SetMaxPktsPerTraceFile(uint64_t maxPktsPerFile)
Set Max packets per trace file.
bool NodeHasMoved(Ptr< Node > n, Vector newLocation)
Time m_routingPollInterval
NodeCounterMap64 m_nodeQueueDrop
uint32_t m_wifiMacRxCounterId
AnimUidPacketInfoMap m_pendingLtePackets
void TrackWifiMacCounters()
void EnablePacketMetadata(bool enable=true)
Enable Packet metadata.
std::map< uint64_t, AnimPacketInfo > AnimUidPacketInfoMap
virtual void Serialize(TagBuffer i) const
Serialize function.
const std::vector< std::string > GetElementsFromContext(const std::string &context) const
void WriteXmlUpdateNodeDescription(uint32_t nodeId)
void EnqueueTrace(std::string context, Ptr< const Packet >)
Byte tag using by Anim to uniquely identify packets.
uint32_t m_wifiMacTxCounterId
virtual TypeId GetInstanceTypeId(void) const
Get Instance Type Id.
void StopAnimation(bool onlyAnimation=false)
void WriteXmlUpdateNodeCounter(uint32_t counterId, uint32_t nodeId, double value)
Vector UpdatePosition(Ptr< Node > n)
Ptr< const NetDevice > m_rxnd
std::string m_elementString
uint64_t Get(void) const
Get Uid in tag.
std::string toNodeDescription
NodeCounterMap64 m_nodeIpv4Rx
std::vector< Ipv4RouteTrackElement > m_ipv4RouteTrackElements
NodeCounterMap64 m_nodeWifiMacRxDrop
void WifiMacTxDropTrace(std::string context, Ptr< const Packet >)
void MobilityCourseChangeTrace(Ptr< const MobilityModel > mob)
NodeCounterMap64 m_nodeWifiPhyRxDrop
std::string m_routingFileName
bool IsPacketPending(uint64_t animUid, ProtocolType protocolType)
uint32_t m_queueDequeueCounterId
std::string GetMacAddress(Ptr< NetDevice > nd)
NodeCounterMap64 m_nodeIpv4Tx
NodeCounterMap64 m_nodeWifiMacRx
AnimUidPacketInfoMap m_pendingUanPackets
static Rectangle * userBoundary
void AddByteTag(uint64_t animUid, Ptr< const Packet > p)
Time Seconds(double value)
Construct a Time in the indicated unit.
void WriteXmlUpdateBackground(std::string fileName, double x, double y, double scaleX, double scaleY, double opacity)
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
Ptr< const NetDevice > m_txnd
uint32_t m_wifiMacTxDropCounterId
Time m_wifiPhyCountersStopTime
void OutputWirelessPacketRxInfo(Ptr< const Packet > p, AnimPacketInfo &pktInfo, uint64_t animUid)
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 Ipv4DropTrace(std::string context, const Ipv4Header &, Ptr< const Packet >, Ipv4L3Protocol::DropReason, Ptr< Ipv4 >, uint32_t)
std::map< uint32_t, Rgb > NodeColorsMap
NodeCounterMap64 m_nodeQueueEnqueue
uint32_t m_wifiPhyRxDropCounterId
Time m_wifiMacCountersStopTime
void WriteRoutePath(uint32_t nodeId, std::string destination, Ipv4RoutePathElements rpElements)
void WriteLinkProperties()
Time m_mobilityPollInterval
bool IsStarted(void)
Is AnimationInterface started.
void EnableIpv4L3ProtocolCounters(Time startTime, Time stopTime, Time pollInterval=Seconds(1))
Enable tracking of Ipv4 L3 Protocol Counters such as Tx, Rx, Drop.
AnimUidPacketInfoMap * ProtocolTypeToPendingPackets(ProtocolType protocolType)
void EnableQueueCounters(Time startTime, Time stopTime, Time pollInterval=Seconds(1))
Enable tracking of Queue Counters such as Enqueue, Dequeue, Queue Drops.
uint32_t m_remainingEnergyCounterId
void WifiPhyRxDropTrace(std::string context, Ptr< const Packet >)
std::string linkDescription
Vector GetPosition(Ptr< Node > n)
a unique identifier for an interface.
bool operator()(P2pLinkNodeIdPair first, P2pLinkNodeIdPair second) const
NodeCounterMap64 m_nodeWifiMacTxDrop
std::vector< std::string > m_nodeCounters
void WifiPhyTxDropTrace(std::string context, Ptr< const Packet >)
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 OutputCsmaPacket(Ptr< const Packet > p, AnimPacketInfo &pktInfo)
uint32_t m_ipv4L3ProtocolDropCounterId
Time m_queueCountersStopTime
void SetOutputFile(const std::string &fn, bool routing=false)
void LteSpectrumPhyTxStart(std::string context, Ptr< const PacketBurst > pb)
AnimUidPacketInfoMap m_pendingCsmaPackets
void WriteXmlLink(uint32_t fromId, uint32_t toLp, uint32_t toId)
void WimaxTxTrace(std::string context, Ptr< const Packet > p, const Mac48Address &)
std::string m_originalFileName