A Discrete-Event Network Simulator
API
animation-interface.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License version 2 as
5  * published by the Free Software Foundation;
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15  *
16  * Author: George F. Riley<riley@ece.gatech.edu>
17  * Author: John Abraham <john.abraham@gatech.edu>
18  * Contributions: Eugene Kalishenko <ydginster@gmail.com> (Open Source and Linux Laboratory http://dev.osll.ru/)
19  */
20 
21 // Interface between ns3 and the network animator
22 
23 #ifndef ANIMATION_INTERFACE__H
24 #define ANIMATION_INTERFACE__H
25 
26 #include <string>
27 #include <cstdio>
28 #include <map>
29 
30 #include "ns3/ptr.h"
31 #include "ns3/net-device.h"
32 #include "ns3/node-container.h"
33 #include "ns3/nstime.h"
34 #include "ns3/log.h"
35 #include "ns3/node-list.h"
36 #include "ns3/random-variable-stream.h"
37 #include "ns3/simulator.h"
38 #include "ns3/config.h"
39 #include "ns3/mac48-address.h"
40 #include "ns3/lte-ue-net-device.h"
41 #include "ns3/lte-enb-net-device.h"
42 #include "ns3/uan-phy-gen.h"
43 #include "ns3/rectangle.h"
44 #include "ns3/ipv4.h"
45 #include "ns3/ipv4-l3-protocol.h"
46 
47 namespace ns3 {
48 
49 #define MAX_PKTS_PER_TRACE_FILE 100000
50 #define PURGE_INTERVAL 5
51 #define NETANIM_VERSION "netanim-3.106"
52 #define CHECK_STARTED_INTIMEWINDOW {if (!m_started || !IsInTimeWindow ()) return;}
53 #define CHECK_STARTED_INTIMEWINDOW_TRACKPACKETS {if (!m_started || !IsInTimeWindow () || !m_trackPackets) return;}
54 
55 
56 struct NodeSize;
57 
73 {
74 public:
75 
81  AnimationInterface (const std::string filename);
82 
86  typedef enum
87  {
90  } CounterType;
91 
97  typedef void (*AnimWriteCallback) (const char * str);
98 
104 
115 
125  void EnableQueueCounters (Time startTime, Time stopTime, Time pollInterval = Seconds (1));
126 
136  void EnableWifiMacCounters (Time startTime, Time stopTime, Time pollInterval = Seconds (1));
137 
147  void EnableWifiPhyCounters (Time startTime, Time stopTime, Time pollInterval = Seconds (1));
148 
160  AnimationInterface & EnableIpv4RouteTracking (std::string fileName, Time startTime, Time stopTime, Time pollInterval = Seconds (5));
161 
174  AnimationInterface & EnableIpv4RouteTracking (std::string fileName, Time startTime, Time stopTime, NodeContainer nc, Time pollInterval = Seconds (5));
175 
182  static bool IsInitialized (void);
183 
191  void SetStartTime (Time t);
192 
200  void SetStopTime (Time t);
201 
211  void SetMaxPktsPerTraceFile (uint64_t maxPktsPerFile);
212 
222  void SetMobilityPollInterval (Time t);
223 
232 
238  void ResetAnimWriteCallback ();
239 
249  static void SetConstantPosition (Ptr <Node> n, double x, double y, double z=0);
250 
258  void UpdateNodeDescription (Ptr <Node> n, std::string descr);
259 
267  void UpdateNodeDescription (uint32_t nodeId, std::string descr);
268 
276  void UpdateNodeImage (uint32_t nodeId, uint32_t resourceId);
277 
286  void UpdateNodeSize (uint32_t nodeId, double width, double height);
287 
297  void UpdateNodeColor (Ptr <Node> n, uint8_t r, uint8_t g, uint8_t b);
298 
308  void UpdateNodeColor (uint32_t nodeId, uint8_t r, uint8_t g, uint8_t b);
309 
318  void UpdateNodeCounter (uint32_t nodeCounterId, uint32_t nodeId, double counter);
319 
332  void SetBackgroundImage (std::string fileName, double x, double y, double scaleX, double scaleY, double opacity);
333 
342  void UpdateLinkDescription (uint32_t fromNode, uint32_t toNode,
343  std::string linkDescription);
344 
353  void UpdateLinkDescription (Ptr <Node> fromNode, Ptr <Node> toNode,
354  std::string linkDescription);
355 
363  AnimationInterface & AddSourceDestination (uint32_t fromNodeId, std::string destinationIpv4Address);
364 
370  bool IsStarted (void);
371 
377  void SkipPacketTracing ();
378 
387  void EnablePacketMetadata (bool enable = true);
388 
395  uint64_t GetTracePktCount ();
396 
405  uint32_t AddNodeCounter (std::string counterName, CounterType counterType);
406 
414  uint32_t AddResource (std::string resourcePath);
415 
422  double GetNodeEnergyFraction (Ptr <const Node> node) const;
423 
424 private:
425 
427 
428  {
429  public:
430  AnimPacketInfo ();
431  AnimPacketInfo (const AnimPacketInfo & pInfo);
432  AnimPacketInfo(Ptr <const NetDevice> tx_nd, const Time fbTx, uint32_t txNodeId = 0);
434  uint32_t m_txNodeId;
435  double m_fbTx;
436  double m_lbTx;
437  double m_fbRx;
438  double m_lbRx;
440  void ProcessRxBegin (Ptr <const NetDevice> nd, const double fbRx);
441  };
442 
443  typedef struct
444  {
445  uint8_t r;
446  uint8_t g;
447  uint8_t b;
448  } Rgb;
449 
450  typedef struct
451  {
452  uint32_t fromNode;
453  uint32_t toNode;
455 
456  typedef struct
457  {
458  std::string fromNodeDescription;
459  std::string toNodeDescription;
460  std::string linkDescription;
461  } LinkProperties;
462 
464  {
466  {
467  //Check if they are the same node pairs but flipped
468  if ( ((first.fromNode == second.fromNode) && (first.toNode == second.toNode)) ||
469  ((first.fromNode == second.toNode) && (first.toNode == second.fromNode)) )
470  {
471  return false;
472  }
473  std::ostringstream oss1;
474  oss1 << first.fromNode << first.toNode;
475  std::ostringstream oss2;
476  oss2 << second.fromNode << second.toNode;
477  return oss1.str () < oss2.str ();
478  }
479 
480  };
481 
482  typedef struct
483  {
484  std::string destination;
485  uint32_t fromNodeId;
487 
488  typedef struct
489  {
490  uint32_t nodeId;
491  std::string nextHop;
493 
494  typedef enum
495  {
501  } ProtocolType;
502 
503  typedef struct
504  {
505  double width;
506  double height;
507  } NodeSize;
508  typedef std::map <P2pLinkNodeIdPair, LinkProperties, LinkPairCompare> LinkPropertiesMap;
509  typedef std::map <uint32_t, std::string> NodeDescriptionsMap;
510  typedef std::map <uint32_t, Rgb> NodeColorsMap;
511  typedef std::map<uint64_t, AnimPacketInfo> AnimUidPacketInfoMap;
512  typedef std::map <uint32_t, double> EnergyFractionMap;
513  typedef std::vector <Ipv4RoutePathElement> Ipv4RoutePathElements;
514 
515 
516  // Node Counters
517  typedef std::map <uint32_t, uint64_t> NodeCounterMap64;
518 
519 
521  {
522  public:
523  AnimXmlElement (std::string tagName, bool emptyElement=true);
524  template <typename T>
525  void AddAttribute (std::string attribute, T value, bool xmlEscape=false);
526  void Close ();
527  void CloseElement ();
528  void CloseTag ();
529  void AddLineBreak ();
530  void Add (AnimXmlElement e);
531  std::string GetElementString ();
532  private:
533  std::string m_tagName;
534  std::string m_elementString;
536 
537  };
538 
539 
540  // ##### State #####
541 
542  FILE * m_f; // File handle for output (0 if none)
543  FILE * m_routingF; // File handle for routing table output (0 if None);
545  std::string m_outputFileName;
546  uint64_t gAnimUid ; // Packet unique identifier used by AnimationInterface
548  bool m_started;
553  std::string m_originalFileName;
555  std::string m_routingFileName;
568 
569  // Counter ID
571 
575 
579 
584 
587 
588  AnimUidPacketInfoMap m_pendingWifiPackets;
589  AnimUidPacketInfoMap m_pendingWimaxPackets;
590  AnimUidPacketInfoMap m_pendingLtePackets;
591  AnimUidPacketInfoMap m_pendingCsmaPackets;
592  AnimUidPacketInfoMap m_pendingUanPackets;
593  std::map <uint32_t, Vector> m_nodeLocation;
594  std::map <std::string, uint32_t> m_macToNodeIdMap;
595  std::map <std::string, uint32_t> m_ipv4ToNodeIdMap;
596  NodeColorsMap m_nodeColors;
597  NodeDescriptionsMap m_nodeDescriptions;
598  LinkPropertiesMap m_linkProperties;
599  EnergyFractionMap m_nodeEnergyFraction;
601  std::vector <Ipv4RouteTrackElement> m_ipv4RouteTrackElements;
602  std::map <uint32_t, NodeSize> m_nodeSizes;
603  std::vector <std::string> m_resources;
604  std::vector <std::string> m_nodeCounters;
605 
606  /* Value-added custom counters */
607  NodeCounterMap64 m_nodeIpv4Drop;
608  NodeCounterMap64 m_nodeIpv4Tx;
609  NodeCounterMap64 m_nodeIpv4Rx;
610  NodeCounterMap64 m_nodeQueueEnqueue;
611  NodeCounterMap64 m_nodeQueueDequeue;
612  NodeCounterMap64 m_nodeQueueDrop;
613  NodeCounterMap64 m_nodeWifiMacTx;
614  NodeCounterMap64 m_nodeWifiMacTxDrop;
615  NodeCounterMap64 m_nodeWifiMacRx;
616  NodeCounterMap64 m_nodeWifiMacRxDrop;
617  NodeCounterMap64 m_nodeWifiPhyTxDrop;
618  NodeCounterMap64 m_nodeWifiPhyRxDrop;
619 
620  const std::vector<std::string> GetElementsFromContext (const std::string& context) const;
621  Ptr <Node> GetNodeFromContext (const std::string& context) const;
622  Ptr <NetDevice> GetNetDeviceFromContext (std::string context);
623 
624  // ##### General #####
625  void StartAnimation (bool restart = false);
626  void SetOutputFile (const std::string& fn, bool routing = false);
627  void StopAnimation (bool onlyAnimation = false);
628  std::string CounterTypeToString (CounterType counterType);
629  std::string GetPacketMetadata (Ptr<const Packet> p);
630  void AddByteTag (uint64_t animUid, Ptr<const Packet> p);
631  int WriteN (const char*, uint32_t, FILE * f);
632  int WriteN (const std::string&, FILE * f);
633  std::string GetMacAddress (Ptr <NetDevice> nd);
634  std::string GetIpv4Address (Ptr <NetDevice> nd);
635  std::string GetNetAnimVersion ();
636  void MobilityAutoCheck ();
637  bool IsPacketPending (uint64_t animUid, ProtocolType protocolType);
638  void PurgePendingPackets (ProtocolType protocolType);
639  AnimUidPacketInfoMap * ProtocolTypeToPendingPackets (ProtocolType protocolType);
640  std::string ProtocolTypeToString (ProtocolType protocolType);
641  void AddPendingPacket (ProtocolType protocolType, uint64_t animUid, AnimPacketInfo pktInfo);
643  void AddToIpv4AddressNodeIdTable (std::string, uint32_t);
644  bool IsInTimeWindow ();
645  void CheckMaxPktsPerTraceFile ();
646 
647  void TrackWifiPhyCounters ();
648  void TrackWifiMacCounters ();
650  void TrackQueueCounters ();
651  // ##### Routing #####
652  void TrackIpv4Route ();
653  void TrackIpv4RoutePaths ();
654  std::string GetIpv4RoutingTable (Ptr <Node> n);
655  void RecursiveIpv4RoutePathSearch (std::string fromIpv4, std::string toIpv4, Ipv4RoutePathElements &);
656  void WriteRoutePath (uint32_t nodeId, std::string destination, Ipv4RoutePathElements rpElements);
657 
658 
659  // ##### Trace #####
660  void EnqueueTrace (std::string context,
662  void DequeueTrace (std::string context,
664  void QueueDropTrace (std::string context,
666  void Ipv4TxTrace (std::string context,
668  uint32_t);
669  void Ipv4RxTrace (std::string context,
671  uint32_t);
672  void Ipv4DropTrace (std::string context,
673  const Ipv4Header &,
676  uint32_t);
677 
678  void WifiMacTxTrace (std::string context,
680  void WifiMacTxDropTrace (std::string context,
682  void WifiMacRxTrace (std::string context,
684  void WifiMacRxDropTrace (std::string context,
686  void WifiPhyTxDropTrace (std::string context,
688  void WifiPhyRxDropTrace (std::string context,
690  void DevTxTrace (std::string context,
692  Ptr<NetDevice> tx,
693  Ptr<NetDevice> rx,
694  Time txTime,
695  Time rxTime);
696  void WifiPhyTxBeginTrace (std::string context,
698  void WifiPhyRxBeginTrace (std::string context,
700  void WimaxTxTrace (std::string context,
702  const Mac48Address &);
703  void WimaxRxTrace (std::string context,
705  const Mac48Address &);
706  void CsmaPhyTxBeginTrace (std::string context,
708  void CsmaPhyTxEndTrace (std::string context,
710  void CsmaPhyRxEndTrace (std::string context,
712  void CsmaMacRxTrace (std::string context,
714  void LteTxTrace (std::string context,
716  const Mac48Address &);
717  void LteRxTrace (std::string context,
719  const Mac48Address &);
720  void LteSpectrumPhyTxStart (std::string context,
722  void LteSpectrumPhyRxStart (std::string context,
724  void UanPhyGenTxTrace (std::string context,
726  void UanPhyGenRxTrace (std::string context,
728  void RemainingEnergyTrace (std::string context, double previousEnergy, double currentEnergy);
729  void GenericWirelessTxTrace (std::string context, Ptr<const Packet>, ProtocolType protocolType);
730  void GenericWirelessRxTrace (std::string context, Ptr<const Packet>, ProtocolType protocolType);
731 
732 
733  void ConnectCallbacks ();
734  void ConnectLte ();
735  void ConnectLteUe (Ptr <Node> n, Ptr <LteUeNetDevice> nd, uint32_t devIndex);
736  void ConnectLteEnb (Ptr <Node> n, Ptr <LteEnbNetDevice> nd, uint32_t devIndex);
737 
738 
739  // ##### Mobility #####
740  Vector GetPosition (Ptr <Node> n);
741  Vector UpdatePosition (Ptr <Node> n);
742  Vector UpdatePosition (Ptr <Node> n, Vector v);
743  Vector UpdatePosition (Ptr <NetDevice> ndev);
744  bool NodeHasMoved (Ptr <Node> n, Vector newLocation);
745  std::vector < Ptr <Node> > GetMovedNodes ();
747 
748 
749  // ##### XML Helpers #####
750 
751  void WriteNonP2pLinkProperties (uint32_t id, std::string ipv4Address, std::string channelType);
752  void WriteNodeUpdate (uint32_t nodeId);
753  void OutputWirelessPacketTxInfo (Ptr<const Packet> p, AnimPacketInfo& pktInfo, uint64_t animUid);
754  void OutputWirelessPacketRxInfo (Ptr<const Packet> p, AnimPacketInfo& pktInfo, uint64_t animUid);
756  void WriteLinkProperties ();
757  void WriteNodes ();
758  void WriteNodeColors ();
759  void WriteNodeSizes ();
760  void WriteNodeEnergies ();
761  void WriteXmlAnim (bool routing = false);
762  void WriteXmlUpdateNodePosition (uint32_t nodeId, double x, double y);
763  void WriteXmlUpdateNodeColor (uint32_t nodeId, uint8_t r, uint8_t g, uint8_t b);
764  void WriteXmlUpdateNodeDescription (uint32_t nodeId);
765  void WriteXmlUpdateNodeSize (uint32_t nodeId, double width, double height);
766  void WriteXmlAddResource (uint32_t resourceId, std::string resourcePath);
767  void WriteXmlAddNodeCounter (uint32_t counterId, std::string counterName, CounterType counterType);
768  void WriteXmlUpdateNodeImage (uint32_t nodeId, uint32_t resourceId);
769  void WriteXmlUpdateNodeCounter (uint32_t counterId, uint32_t nodeId, double value);
770  void WriteXmlNode (uint32_t id, uint32_t sysId, double locX, double locY);
771  void WriteXmlLink (uint32_t fromId, uint32_t toLp, uint32_t toId);
772  void WriteXmlUpdateLink (uint32_t fromId, uint32_t toId, std::string);
773  void WriteXmlP (std::string pktType,
774  uint32_t fId,
775  double fbTx,
776  double lbTx,
777  uint32_t tId,
778  double fbRx,
779  double lbRx,
780  std::string metaInfo = "");
781  void WriteXmlP (uint64_t animUid, std::string pktType, uint32_t fId, double fbTx, double lbTx);
782  void WriteXmlPRef (uint64_t animUid, uint32_t fId, double fbTx, std::string metaInfo = "");
783  void WriteXmlClose (std::string name, bool routing = false);
784  void WriteXmlNonP2pLinkProperties (uint32_t id, std::string ipv4Address, std::string channelType);
785  void WriteXmlRouting (uint32_t id, std::string routingInfo);
786  void WriteXmlRp (uint32_t nodeId, std::string destination, Ipv4RoutePathElements rpElements);
787  void WriteXmlUpdateBackground (std::string fileName, double x, double y, double scaleX, double scaleY, double opacity);
788 
789 };
790 
791 
792 
793 
805 class AnimByteTag : public Tag
806 {
807 public:
808 
814  static TypeId GetTypeId (void);
815 
821  virtual TypeId GetInstanceTypeId (void) const;
822 
828  virtual uint32_t GetSerializedSize (void) const;
829 
835  virtual void Serialize (TagBuffer i) const;
836 
842  virtual void Deserialize (TagBuffer i);
843 
849  virtual void Print (std::ostream &os) const;
850 
856  void Set (uint64_t AnimUid);
857 
863  uint64_t Get (void) const;
864 
865 private:
866  uint64_t m_AnimUid;
867 };
868 
869 
870 
871 }
872 #endif
873 
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.
Definition: nstime.h:102
NodeCounterMap64 m_nodeQueueDequeue
std::map< P2pLinkNodeIdPair, LinkProperties, LinkPairCompare > LinkPropertiesMap
Definition: second.py:1
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 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.
void PurgePendingPackets(ProtocolType protocolType)
void QueueDropTrace(std::string context, Ptr< const Packet >)
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)
void EnableWifiPhyCounters(Time startTime, Time stopTime, Time pollInterval=Seconds(1))
Enable tracking of Wifi Phy Counters such as TxDrop, RxDrop.
void WriteXmlAnim(bool routing=false)
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
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.
double stopTime
void WriteXmlAddResource(uint32_t resourceId, std::string resourcePath)
void ResetAnimWriteCallback()
Reset the write callback function.
NodeCounterMap64 m_nodeWifiMacTx
AnimWriteCallback m_writeCallback
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 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.
Packet header for IPv4.
Definition: ipv4-header.h:33
void SetBackgroundImage(std::string fileName, double x, double y, double scaleX, double scaleY, double opacity)
Helper function to set the background image.
void CsmaPhyRxEndTrace(std::string context, Ptr< const Packet > p)
void RemainingEnergyTrace(std::string context, double previousEnergy, double currentEnergy)
void WifiMacRxDropTrace(std::string context, Ptr< const Packet >)
void WriteXmlClose(std::string name, bool routing=false)
void GenericWirelessTxTrace(std::string context, Ptr< const Packet >, ProtocolType protocolType)
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 AddNodeCounter(std::string counterName, CounterType counterType)
Setup a node counter.
~AnimationInterface()
Destructor for the animator interface.
AnimUidPacketInfoMap m_pendingWimaxPackets
EnergyFractionMap m_nodeEnergyFraction
void SkipPacketTracing()
Do not trace packets.
double startTime
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)
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.
AnimXmlElement(std::string tagName, bool emptyElement=true)
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)
std::vector< std::string > m_resources
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)
double f(double x, void *params)
Definition: 80211b.c:60
tag a set of bytes in a packet
Definition: tag.h:36
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.
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.
void SetMaxPktsPerTraceFile(uint64_t maxPktsPerFile)
Set Max packets per trace file.
bool NodeHasMoved(Ptr< Node > n, Vector newLocation)
an EUI-48 address
Definition: mac48-address.h:43
NodeCounterMap64 m_nodeQueueDrop
AnimUidPacketInfoMap m_pendingLtePackets
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.
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)
uint64_t Get(void) const
Get Uid in tag.
std::vector< Ipv4RouteTrackElement > m_ipv4RouteTrackElements
NodeCounterMap64 m_nodeWifiMacRxDrop
void WifiMacTxDropTrace(std::string context, Ptr< const Packet >)
void MobilityCourseChangeTrace(Ptr< const MobilityModel > mob)
read and write tag data
Definition: tag-buffer.h:51
NodeCounterMap64 m_nodeWifiPhyRxDrop
bool IsPacketPending(uint64_t animUid, ProtocolType protocolType)
std::string GetMacAddress(Ptr< NetDevice > nd)
NodeCounterMap64 m_nodeWifiMacRx
AnimUidPacketInfoMap m_pendingUanPackets
static Rectangle * userBoundary
std::string ProtocolTypeToString(ProtocolType protocolType)
void AddByteTag(uint64_t animUid, Ptr< const Packet > p)
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:895
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)
void OutputWirelessPacketRxInfo(Ptr< const Packet > p, AnimPacketInfo &pktInfo, uint64_t animUid)
DropReason
Reason why a packet has been dropped.
void GenericWirelessRxTrace(std::string context, Ptr< const Packet >, ProtocolType protocolType)
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
void WriteRoutePath(uint32_t nodeId, std::string destination, Ipv4RoutePathElements rpElements)
Definition: first.py:1
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.
void AddAttribute(std::string attribute, T value, bool xmlEscape=false)
void WifiPhyRxDropTrace(std::string context, Ptr< const Packet >)
Vector GetPosition(Ptr< Node > n)
a unique identifier for an interface.
Definition: type-id.h:58
NodeCounterMap64 m_nodeWifiMacTxDrop
a 2d rectangle
Definition: rectangle.h:34
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)
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 &)