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.108"
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 
423  double GetNodeEnergyFraction (Ptr <const Node> node) const;
424 
425 private:
426 
431 
432  {
433  public:
434  AnimPacketInfo ();
440  AnimPacketInfo (const AnimPacketInfo & pInfo);
448  AnimPacketInfo(Ptr <const NetDevice> tx_nd, const Time fbTx, uint32_t txNodeId = 0);
450  uint32_t m_txNodeId;
451  double m_fbTx;
452  double m_lbTx;
453  double m_fbRx;
454  double m_lbRx;
456 
461  void ProcessRxBegin (Ptr <const NetDevice> nd, const double fbRx);
462  };
463 
465  typedef struct
466  {
467  uint8_t r;
468  uint8_t g;
469  uint8_t b;
470  } Rgb;
471 
473  typedef struct
474  {
475  uint32_t fromNode;
476  uint32_t toNode;
478 
480  typedef struct
481  {
482  std::string fromNodeDescription;
483  std::string toNodeDescription;
484  std::string linkDescription;
485  } LinkProperties;
486 
489  {
498  {
499  //Check if they are the same node pairs but flipped
500  if ( ((first.fromNode == second.fromNode) && (first.toNode == second.toNode)) ||
501  ((first.fromNode == second.toNode) && (first.toNode == second.fromNode)) )
502  {
503  return false;
504  }
505  std::ostringstream oss1;
506  oss1 << first.fromNode << first.toNode;
507  std::ostringstream oss2;
508  oss2 << second.fromNode << second.toNode;
509  return oss1.str () < oss2.str ();
510  }
511 
512  };
513 
515  typedef struct
516  {
517  std::string destination;
518  uint32_t fromNodeId;
520 
522  typedef struct
523  {
524  uint32_t nodeId;
525  std::string nextHop;
527 
529  typedef enum
530  {
538  } ProtocolType;
539 
541  typedef struct
542  {
543  double width;
544  double height;
545  } NodeSize;
546  typedef std::map <P2pLinkNodeIdPair, LinkProperties, LinkPairCompare> LinkPropertiesMap;
547  typedef std::map <uint32_t, std::string> NodeDescriptionsMap;
548  typedef std::map <uint32_t, Rgb> NodeColorsMap;
549  typedef std::map<uint64_t, AnimPacketInfo> AnimUidPacketInfoMap;
550  typedef std::map <uint32_t, double> EnergyFractionMap;
551  typedef std::vector <Ipv4RoutePathElement> Ipv4RoutePathElements;
552  typedef std::multimap <uint32_t, std::string> NodeIdIpv4Map;
553  typedef std::multimap <uint32_t, std::string> NodeIdIpv6Map;
554  typedef std::pair <uint32_t, std::string> NodeIdIpv4Pair;
555  typedef std::pair <uint32_t, std::string> NodeIdIpv6Pair;
556 
557 
558  // Node Counters
559  typedef std::map <uint32_t, uint64_t> NodeCounterMap64;
560 
561 
564  {
565  public:
572  AnimXmlElement (std::string tagName, bool emptyElement=true);
573  template <typename T>
580  void AddAttribute (std::string attribute, T value, bool xmlEscape=false);
585  void SetText(std::string text);
590  void AppendChild(AnimXmlElement e);
596  std::string ToString(bool autoClose = true);
597 
598  private:
599  std::string m_tagName;
600  std::string m_text;
601  std::vector<std::string> m_attributes;
602  std::vector<std::string> m_children;
603 
604  };
605 
606 
607 
608  // ##### State #####
609 
610  FILE * m_f;
611  FILE * m_routingF;
613  std::string m_outputFileName;
614  uint64_t gAnimUid ;
616  bool m_started;
620  uint64_t m_maxPktsPerFile;
621  std::string m_originalFileName;
623  std::string m_routingFileName;
636 
637  // Counter ID
639 
643 
647 
652 
655 
656  AnimUidPacketInfoMap m_pendingWifiPackets;
657  AnimUidPacketInfoMap m_pendingWimaxPackets;
658  AnimUidPacketInfoMap m_pendingLrWpanPackets;
659  AnimUidPacketInfoMap m_pendingLtePackets;
660  AnimUidPacketInfoMap m_pendingCsmaPackets;
661  AnimUidPacketInfoMap m_pendingUanPackets;
662  AnimUidPacketInfoMap m_pendingWavePackets;
663 
664  std::map <uint32_t, Vector> m_nodeLocation;
665  std::map <std::string, uint32_t> m_macToNodeIdMap;
666  std::map <std::string, uint32_t> m_ipv4ToNodeIdMap;
667  std::map <std::string, uint32_t> m_ipv6ToNodeIdMap;
668  NodeIdIpv4Map m_nodeIdIpv4Map;
669  NodeIdIpv6Map m_nodeIdIpv6Map;
670 
671  NodeColorsMap m_nodeColors;
672  NodeDescriptionsMap m_nodeDescriptions;
673  LinkPropertiesMap m_linkProperties;
674  EnergyFractionMap m_nodeEnergyFraction;
675  uint64_t m_currentPktCount;
676  std::vector <Ipv4RouteTrackElement> m_ipv4RouteTrackElements;
677  std::map <uint32_t, NodeSize> m_nodeSizes;
678  std::vector <std::string> m_resources;
679  std::vector <std::string> m_nodeCounters;
680 
681  /* Value-added custom counters */
682  NodeCounterMap64 m_nodeIpv4Drop;
683  NodeCounterMap64 m_nodeIpv4Tx;
684  NodeCounterMap64 m_nodeIpv4Rx;
685  NodeCounterMap64 m_nodeQueueEnqueue;
686  NodeCounterMap64 m_nodeQueueDequeue;
687  NodeCounterMap64 m_nodeQueueDrop;
688  NodeCounterMap64 m_nodeWifiMacTx;
689  NodeCounterMap64 m_nodeWifiMacTxDrop;
690  NodeCounterMap64 m_nodeWifiMacRx;
691  NodeCounterMap64 m_nodeWifiMacRxDrop;
692  NodeCounterMap64 m_nodeWifiPhyTxDrop;
693  NodeCounterMap64 m_nodeWifiPhyRxDrop;
694  NodeCounterMap64 m_nodeLrWpanMacTx;
695  NodeCounterMap64 m_nodeLrWpanMacTxDrop;
696  NodeCounterMap64 m_nodeLrWpanMacRx;
697  NodeCounterMap64 m_nodeLrWpanMacRxDrop;
698 
704  const std::vector<std::string> GetElementsFromContext (const std::string& context) const;
710  Ptr <Node> GetNodeFromContext (const std::string& context) const;
716  Ptr <NetDevice> GetNetDeviceFromContext (std::string context);
717 
718  // ##### General #####
724  void StartAnimation (bool restart = false);
731  void SetOutputFile (const std::string& fn, bool routing = false);
737  void StopAnimation (bool onlyAnimation = false);
743  std::string CounterTypeToString (CounterType counterType);
749  std::string GetPacketMetadata (Ptr<const Packet> p);
755  void AddByteTag (uint64_t animUid, Ptr<const Packet> p);
763  int WriteN (const char* data, uint32_t count, FILE * f);
770  int WriteN (const std::string& st, FILE * f);
776  std::string GetMacAddress (Ptr <NetDevice> nd);
782  std::string GetIpv4Address (Ptr <NetDevice> nd);
788  std::string GetIpv6Address(Ptr <NetDevice> nd);
794  std::vector<std::string> GetIpv4Addresses (Ptr <NetDevice> nd);
800  std::vector<std::string> GetIpv6Addresses (Ptr <NetDevice> nd);
801 
806  std::string GetNetAnimVersion ();
808  void MobilityAutoCheck ();
815  bool IsPacketPending (uint64_t animUid, ProtocolType protocolType);
820  void PurgePendingPackets (ProtocolType protocolType);
826  AnimUidPacketInfoMap * ProtocolTypeToPendingPackets (ProtocolType protocolType);
832  std::string ProtocolTypeToString (ProtocolType protocolType);
839  void AddPendingPacket (ProtocolType protocolType, uint64_t animUid, AnimPacketInfo pktInfo);
851  void AddToIpv4AddressNodeIdTable (std::string ipv4Address, uint32_t nodeId);
857  void AddToIpv4AddressNodeIdTable (std::vector<std::string> ipv4Addresses, uint32_t nodeId);
863  void AddToIpv6AddressNodeIdTable (std::string ipv6Address, uint32_t nodeId);
869  void AddToIpv6AddressNodeIdTable (std::vector<std::string> ipv6Addresses, uint32_t nodeId);
874  bool IsInTimeWindow ();
876  void CheckMaxPktsPerTraceFile ();
877 
879  void TrackWifiPhyCounters ();
881  void TrackWifiMacCounters ();
885  void TrackQueueCounters ();
886  // ##### Routing #####
888  void TrackIpv4Route ();
890  void TrackIpv4RoutePaths ();
896  std::string GetIpv4RoutingTable (Ptr <Node> n);
903  void RecursiveIpv4RoutePathSearch (std::string from, std::string to, Ipv4RoutePathElements &rpElements);
910  void WriteRoutePath (uint32_t nodeId, std::string destination, Ipv4RoutePathElements rpElements);
911 
912 
913  // ##### Trace #####
919  void EnqueueTrace (std::string context, Ptr<const Packet>);
925  void DequeueTrace (std::string context, Ptr<const Packet>);
931  void QueueDropTrace (std::string context, Ptr<const Packet>);
939  void Ipv4TxTrace (std::string context,
940  Ptr<const Packet> p, Ptr<Ipv4> ipv4,
941  uint32_t interfaceIndex);
949  void Ipv4RxTrace (std::string context,
951  uint32_t interfaceIndex);
961  void Ipv4DropTrace (std::string context,
962  const Ipv4Header & ipv4Header,
964  Ipv4L3Protocol::DropReason dropReason, Ptr<Ipv4> ipv4,
965  uint32_t interfaceIndex);
966 
972  void WifiMacTxTrace (std::string context, Ptr<const Packet> p);
978  void WifiMacTxDropTrace (std::string context, Ptr<const Packet> p);
984  void WifiMacRxTrace (std::string context, Ptr<const Packet> p);
990  void WifiMacRxDropTrace (std::string context, Ptr<const Packet> p);
996  void WifiPhyTxDropTrace (std::string context, Ptr<const Packet> p);
1002  void WifiPhyRxDropTrace (std::string context, Ptr<const Packet> p);
1008  void LrWpanMacTxTrace (std::string context,
1009  Ptr<const Packet> p);
1015  void LrWpanMacTxDropTrace (std::string context,
1016  Ptr<const Packet> p);
1022  void LrWpanMacRxTrace (std::string context,
1023  Ptr<const Packet> p);
1029  void LrWpanMacRxDropTrace (std::string context,
1030  Ptr<const Packet> p);
1040  void DevTxTrace (std::string context,
1042  Ptr<NetDevice> tx,
1043  Ptr<NetDevice> rx,
1044  Time txTime,
1045  Time rxTime);
1051  void WifiPhyTxBeginTrace (std::string context, Ptr<const Packet> p);
1058  void WifiPhyRxBeginTrace (std::string context, Ptr<const Packet> p);
1064  void WavePhyTxBeginTrace (std::string context,
1065  Ptr<const Packet> p);
1072  void WavePhyRxBeginTrace (std::string context,
1073  Ptr<const Packet> p);
1080  void LrWpanPhyTxBeginTrace (std::string context,
1081  Ptr<const Packet> p);
1088  void LrWpanPhyRxBeginTrace (std::string context,
1089  Ptr<const Packet> p);
1096  void WimaxTxTrace (std::string context,
1098  const Mac48Address & m);
1105  void WimaxRxTrace (std::string context,
1107  const Mac48Address & m);
1113  void CsmaPhyTxBeginTrace (std::string context, Ptr<const Packet> p);
1120  void CsmaPhyTxEndTrace (std::string context, Ptr<const Packet> p);
1127  void CsmaPhyRxEndTrace (std::string context, Ptr<const Packet> p);
1134  void CsmaMacRxTrace (std::string context, Ptr<const Packet> p);
1141  void LteTxTrace (std::string context,
1143  const Mac48Address & m);
1150  void LteRxTrace (std::string context,
1152  const Mac48Address & m);
1158  void LteSpectrumPhyTxStart (std::string context, Ptr<const PacketBurst> pb);
1164  void LteSpectrumPhyRxStart (std::string context, Ptr<const PacketBurst> pb);
1170  void UanPhyGenTxTrace (std::string context, Ptr<const Packet>);
1176  void UanPhyGenRxTrace (std::string context, Ptr<const Packet>);
1183  void RemainingEnergyTrace (std::string context, double previousEnergy, double currentEnergy);
1190  void GenericWirelessTxTrace (std::string context, Ptr<const Packet> p, ProtocolType protocolType);
1197  void GenericWirelessRxTrace (std::string context, Ptr<const Packet> p, ProtocolType protocolType);
1198 
1199 
1201  void ConnectCallbacks ();
1203  void ConnectLte ();
1210  void ConnectLteUe (Ptr <Node> n, Ptr <LteUeNetDevice> nd, uint32_t devIndex);
1217  void ConnectLteEnb (Ptr <Node> n, Ptr <LteEnbNetDevice> nd, uint32_t devIndex);
1218 
1219 
1220  // ##### Mobility #####
1226  Vector GetPosition (Ptr <Node> n);
1232  Vector UpdatePosition (Ptr <Node> n);
1239  Vector UpdatePosition (Ptr <Node> n, Vector v);
1245  Vector UpdatePosition (Ptr <NetDevice> ndev);
1252  bool NodeHasMoved (Ptr <Node> n, Vector newLocation);
1257  std::vector < Ptr <Node> > GetMovedNodes ();
1263 
1264 
1265  // ##### XML Helpers #####
1266 
1273  void WriteNonP2pLinkProperties (uint32_t id, std::string ipv4Address, std::string channelType);
1278  void WriteNodeUpdate (uint32_t nodeId);
1285  void OutputWirelessPacketTxInfo (Ptr<const Packet> p, AnimPacketInfo& pktInfo, uint64_t animUid);
1292  void OutputWirelessPacketRxInfo (Ptr<const Packet> p, AnimPacketInfo& pktInfo, uint64_t animUid);
1300  void WriteLinkProperties ();
1302  void WriteIpv4Addresses ();
1304  void WriteIpv6Addresses ();
1306  void WriteNodes ();
1308  void WriteNodeColors ();
1310  void WriteNodeSizes ();
1312  void WriteNodeEnergies ();
1317  void WriteXmlAnim (bool routing = false);
1324  void WriteXmlUpdateNodePosition (uint32_t nodeId, double x, double y);
1332  void WriteXmlUpdateNodeColor (uint32_t nodeId, uint8_t r, uint8_t g, uint8_t b);
1337  void WriteXmlUpdateNodeDescription (uint32_t nodeId);
1344  void WriteXmlUpdateNodeSize (uint32_t nodeId, double width, double height);
1350  void WriteXmlAddResource (uint32_t resourceId, std::string resourcePath);
1357  void WriteXmlAddNodeCounter (uint32_t counterId, std::string counterName, CounterType counterType);
1363  void WriteXmlUpdateNodeImage (uint32_t nodeId, uint32_t resourceId);
1370  void WriteXmlUpdateNodeCounter (uint32_t counterId, uint32_t nodeId, double value);
1378  void WriteXmlNode (uint32_t id, uint32_t sysId, double locX, double locY);
1385  void WriteXmlLink (uint32_t fromId, uint32_t toLp, uint32_t toId);
1392  void WriteXmlUpdateLink (uint32_t fromId, uint32_t toId, std::string linkDescription);
1404  void WriteXmlP (std::string pktType,
1405  uint32_t fId,
1406  double fbTx,
1407  double lbTx,
1408  uint32_t tId,
1409  double fbRx,
1410  double lbRx,
1411  std::string metaInfo = "");
1420  void WriteXmlP (uint64_t animUid, std::string pktType, uint32_t fId, double fbTx, double lbTx);
1428  void WriteXmlPRef (uint64_t animUid, uint32_t fId, double fbTx, std::string metaInfo = "");
1434  void WriteXmlClose (std::string name, bool routing = false);
1441  void WriteXmlNonP2pLinkProperties (uint32_t id, std::string ipAddress, std::string channelType);
1447  void WriteXmlRouting (uint32_t id, std::string routingInfo);
1454  void WriteXmlRp (uint32_t nodeId, std::string destination, Ipv4RoutePathElements rpElements);
1464  void WriteXmlUpdateBackground (std::string fileName, double x, double y, double scaleX, double scaleY, double opacity);
1470  void WriteXmlIpv4Addresses (uint32_t nodeId, std::vector<std::string> ipv4Addresses);
1476  void WriteXmlIpv6Addresses (uint32_t nodeId, std::vector<std::string> ipv6Addresses);
1477 
1478 };
1479 
1480 
1481 
1482 
1494 class AnimByteTag : public Tag
1495 {
1496 public:
1497 
1503  static TypeId GetTypeId (void);
1504 
1510  virtual TypeId GetInstanceTypeId (void) const;
1511 
1517  virtual uint32_t GetSerializedSize (void) const;
1518 
1524  virtual void Serialize (TagBuffer i) const;
1525 
1531  virtual void Deserialize (TagBuffer i);
1532 
1538  virtual void Print (std::ostream &os) const;
1539 
1545  void Set (uint64_t AnimUid);
1546 
1552  uint64_t Get (void) const;
1553 
1554 private:
1555  uint64_t m_AnimUid;
1556 };
1557 
1558 
1559 
1560 }
1561 #endif
1562 
void GenericWirelessTxTrace(std::string context, Ptr< const Packet > p, ProtocolType protocolType)
Generic wireless transmit trace function.
uint64_t GetAnimUidFromPacket(Ptr< const Packet >)
Get anim UID from packet function.
void Set(uint64_t AnimUid)
Set global Uid in tag.
uint64_t GetTracePktCount()
Get trace file packet count (This used only for testing)
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)
Write XMLRP function.
void AddPendingPacket(ProtocolType protocolType, uint64_t animUid, AnimPacketInfo pktInfo)
Add pending packet function.
void CsmaMacRxTrace(std::string context, Ptr< const Packet > p)
CSMA MAC receive trace function.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
void MobilityAutoCheck()
Mobility auto check function.
void WriteXmlUpdateLink(uint32_t fromId, uint32_t toId, std::string linkDescription)
Write XML update link counter function.
NodeCounterMap64 m_nodeQueueDequeue
node queue dequeue
void LteTxTrace(std::string context, Ptr< const Packet > p, const Mac48Address &m)
LTE transmit trace function.
std::map< P2pLinkNodeIdPair, LinkProperties, LinkPairCompare > LinkPropertiesMap
LinkPropertiesMap typedef.
void LrWpanMacTxDropTrace(std::string context, Ptr< const Packet > p)
LR-WPAN MAC transmit drop trace function.
Definition: second.py:1
std::vector< std::string > m_children
list of children
FILE * m_routingF
File handle for routing table output (0 if None);.
std::string GetIpv4Address(Ptr< NetDevice > nd)
Get IPv4 address.
std::string CounterTypeToString(CounterType counterType)
Counter type to string function.
AnimationInterface(const std::string filename)
Constructor.
std::map< uint32_t, std::string > NodeDescriptionsMap
NodeDescriptionsMap typedef.
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)
Write XML update node image function.
std::string GetIpv6Address(Ptr< NetDevice > nd)
Get IPv6 address.
NodeCounterMap64 m_nodeLrWpanMacRxDrop
node LR-WPAN MAC receive drop
std::map< std::string, uint32_t > m_ipv6ToNodeIdMap
IPv6 to node ID map.
static TypeId GetTypeId(void)
Get Type Id.
void WriteXmlIpv6Addresses(uint32_t nodeId, std::vector< std::string > ipv6Addresses)
Write XML Ipv6 addresses function.
void WriteNodes()
Write nodes function.
void TrackIpv4L3ProtocolCounters()
Track IPv4 L3 protocol counters function.
void CsmaPhyTxBeginTrace(std::string context, Ptr< const Packet > p)
CSMA Phy transmit begin trace function.
AnimUidPacketInfoMap m_pendingWifiPackets
pending wifi packets
void WriteXmlUpdateNodePosition(uint32_t nodeId, double x, double y)
Write XML update node position function.
NodeDescriptionsMap m_nodeDescriptions
node description
std::string ToString(bool autoClose=true)
Get text for the element function.
static bool IsInitialized(void)
Check if AnimationInterface is initialized.
uint32_t m_ipv4L3ProtocolTxCounterId
IPv4 L3 protocol transmit counter ID.
void WifiMacTxDropTrace(std::string context, Ptr< const Packet > p)
wifi MAC transmit drop trace function
void PurgePendingPackets(ProtocolType protocolType)
Purge pending packets function.
uint32_t m_queueEnqueueCounterId
queue enqueue counter ID
uint64_t m_maxPktsPerFile
maximum pakets per file
void QueueDropTrace(std::string context, Ptr< const Packet >)
Queue trace function.
void WifiMacRxTrace(std::string context, Ptr< const Packet > p)
wifi MAC receive trace function
std::map< std::string, uint32_t > m_macToNodeIdMap
MAC to node ID map.
Time m_ipv4L3ProtocolCountersPollInterval
IPv4 L3 protocol counters poll interval.
void LteSpectrumPhyRxStart(std::string context, Ptr< const PacketBurst > pb)
LTE Spectrum Phy receive start function.
void TrackQueueCounters()
Track queue counters function.
void TrackWifiPhyCounters()
Track wifi phy counters function.
Ptr< NetDevice > GetNetDeviceFromContext(std::string context)
Get net device from context.
void WifiPhyTxBeginTrace(std::string context, Ptr< const Packet > p)
wifi Phy transmit begin trace function
void EnableWifiPhyCounters(Time startTime, Time stopTime, Time pollInterval=Seconds(1))
Enable tracking of Wifi Phy Counters such as TxDrop, RxDrop.
void TrackIpv4RoutePaths()
Track IPv4 route paths function.
NodeContainer m_routingNc
routing node container
Time m_ipv4L3ProtocolCountersStopTime
IPv4 L3 protocol counters stop time.
void WriteXmlAnim(bool routing=false)
Write XML anim function.
uint64_t m_currentPktCount
current packet count
std::pair< uint32_t, std::string > NodeIdIpv6Pair
NodeIdIpv6Pair typedef.
void WimaxRxTrace(std::string context, Ptr< const Packet > p, const Mac48Address &m)
WIMax receive trace function.
NodeCounterMap64 m_nodeWifiPhyTxDrop
node wifi Phy transmit drop
void LrWpanMacRxDropTrace(std::string context, Ptr< const Packet > p)
LR-WPAN MAC receive drop trace function.
void Ipv4RxTrace(std::string context, Ptr< const Packet > p, Ptr< Ipv4 > ipv4, uint32_t interfaceIndex)
IPv4 receive trace function.
std::map< std::string, uint32_t > m_ipv4ToNodeIdMap
IPv4 to node ID map.
void WavePhyTxBeginTrace(std::string context, Ptr< const Packet > p)
WAVE Phy transmit begin trace function.
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)
Write XML add node counter function.
void ProcessRxBegin(Ptr< const NetDevice > nd, const double fbRx)
Process receive begin.
void ConnectLteEnb(Ptr< Node > n, Ptr< LteEnbNetDevice > nd, uint32_t devIndex)
Connect LTE ENB function.
std::string GetIpv4RoutingTable(Ptr< Node > n)
Get IPv4 routing table function.
void WriteXmlUpdateNodeSize(uint32_t nodeId, double width, double height)
Write XML update node size function.
void WriteXmlUpdateNodeColor(uint32_t nodeId, uint8_t r, uint8_t g, uint8_t b)
Write XML update node color function.
void WriteIpv6Addresses()
Write IPv6 Addresses function.
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()
Get moved nodes function.
LinkPropertiesMap m_linkProperties
link properties
Time m_queueCountersPollInterval
queue counters poll interval
void WifiPhyRxBeginTrace(std::string context, Ptr< const Packet > p)
wifi Phy receive begin trace function
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)
Write XML add resource function.
void ResetAnimWriteCallback()
Reset the write callback function.
NodeCounterMap64 m_nodeWifiMacTx
node wifi MAC transmit
AnimWriteCallback m_writeCallback
write callback
void WifiPhyRxDropTrace(std::string context, Ptr< const Packet > p)
wifi Phy recieve drop trace function
void UanPhyGenTxTrace(std::string context, Ptr< const Packet >)
UAN Phy gen transmit trace function.
static void SetConstantPosition(Ptr< Node > n, double x, double y, double z=0)
Helper function to set Constant Position for a given node.
std::map< uint32_t, uint64_t > NodeCounterMap64
NodeCounterMap64 typedef.
void CheckMaxPktsPerTraceFile()
Check maximum packets per trace file function.
void AddToIpv6AddressNodeIdTable(std::string ipv6Address, uint32_t nodeId)
Add to IPv6 address node ID table function.
void ConnectLteUe(Ptr< Node > n, Ptr< LteUeNetDevice > nd, uint32_t devIndex)
Connect LTE ue function.
void WriteNodeColors()
Write node colors function.
std::map< uint32_t, Vector > m_nodeLocation
node location
virtual void Print(std::ostream &os) const
Print tag info.
Packet header for IPv4.
Definition: ipv4-header.h:33
std::multimap< uint32_t, std::string > NodeIdIpv6Map
NodeIdIpv6Map typedef.
void SetBackgroundImage(std::string fileName, double x, double y, double scaleX, double scaleY, double opacity)
Helper function to set the background image.
void LteRxTrace(std::string context, Ptr< const Packet > p, const Mac48Address &m)
LTE receive trace function.
uint32_t m_ipv4L3ProtocolRxCounterId
IPv4 L3 protocol receive counter ID.
void CsmaPhyRxEndTrace(std::string context, Ptr< const Packet > p)
CSMA Phy receive end trace function.
NodeIdIpv6Map m_nodeIdIpv6Map
node ID to IPv6 map
void RemainingEnergyTrace(std::string context, double previousEnergy, double currentEnergy)
Remaining energy trace function.
uint32_t m_wifiPhyTxDropCounterId
wifi Phy transmit drop counter ID
void WriteXmlClose(std::string name, bool routing=false)
Write XML close function.
void OutputWirelessPacketTxInfo(Ptr< const Packet > p, AnimPacketInfo &pktInfo, uint64_t animUid)
Output wireless packet transmit info.
int WriteN(const char *data, uint32_t count, FILE *f)
WriteN functon.
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
queue drop counter ID
uint32_t AddNodeCounter(std::string counterName, CounterType counterType)
Setup a node counter.
~AnimationInterface()
Destructor for the animator interface.
AnimUidPacketInfoMap m_pendingWimaxPackets
pending wimax packets
std::vector< std::string > GetIpv4Addresses(Ptr< NetDevice > nd)
Get IPv4 addresses.
EnergyFractionMap m_nodeEnergyFraction
node energy fraction
bool m_trackPackets
track packets
void SkipPacketTracing()
Do not trace packets.
double startTime
uint8_t data[writeSize]
std::string GetNetAnimVersion()
Get netanim version function.
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
Get node from context.
void WriteNodeUpdate(uint32_t nodeId)
Write node update function.
void RecursiveIpv4RoutePathSearch(std::string from, std::string to, Ipv4RoutePathElements &rpElements)
Recursive IPv4 route path search function.
void WriteXmlNonP2pLinkProperties(uint32_t id, std::string ipAddress, std::string channelType)
Write XML non P2P link properties function.
std::string m_outputFileName
output file name
FILE * m_f
File handle for output (0 if none)
void DequeueTrace(std::string context, Ptr< const Packet >)
Dequeue trace function.
NodeCounterMap64 m_nodeIpv4Drop
node IPv4 drop
void UanPhyGenRxTrace(std::string context, Ptr< const Packet >)
UAN Phy gen receive trace function.
std::pair< uint32_t, std::string > NodeIdIpv4Pair
NodeIdIpv4Pair typedef.
void WriteXmlP(std::string pktType, uint32_t fId, double fbTx, double lbTx, uint32_t tId, double fbRx, double lbRx, std::string metaInfo="")
Write XMLP function.
void StartAnimation(bool restart=false)
Start animation function.
void WriteXmlNode(uint32_t id, uint32_t sysId, double locX, double locY)
Write XML node function.
std::vector< Ipv4RoutePathElement > Ipv4RoutePathElements
Ipv4RoutePathElements typedef.
void Ipv4TxTrace(std::string context, Ptr< const Packet > p, Ptr< Ipv4 > ipv4, uint32_t interfaceIndex)
IPv4 transmit trace function.
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)
Constructor.
AnimUidPacketInfoMap m_pendingLrWpanPackets
pending LR-WPAN packets
std::map< uint32_t, NodeSize > m_nodeSizes
node sizes
void WifiPhyTxDropTrace(std::string context, Ptr< const Packet > p)
wifi Phy transmit drop trace function
std::map< uint32_t, double > EnergyFractionMap
EnergyFractionMap typedef.
void WavePhyRxBeginTrace(std::string context, Ptr< const Packet > p)
WAVE Phy receive begin trace function.
void CsmaPhyTxEndTrace(std::string context, Ptr< const Packet > p)
CSMA Phy transmit end trace function.
std::string GetPacketMetadata(Ptr< const Packet > p)
Get packet metadata function.
Time m_wifiMacCountersPollInterval
wifi MAC counters poll interval
std::vector< std::string > m_resources
resources
void WriteXmlIpv4Addresses(uint32_t nodeId, std::vector< std::string > ipv4Addresses)
Write XML Ipv4 addresses function.
NodeIdIpv4Map m_nodeIdIpv4Map
node ID to IPv4 map
void DevTxTrace(std::string context, Ptr< const Packet > p, Ptr< NetDevice > tx, Ptr< NetDevice > rx, Time txTime, Time rxTime)
Device transmit trace function.
Time m_wifiPhyCountersPollInterval
wifi Phy counters poll interval
double f(double x, void *params)
Definition: 80211b.c:72
tag a set of bytes in a packet
Definition: tag.h:36
NodeColorsMap m_nodeColors
node colors
void WriteXmlRouting(uint32_t id, std::string routingInfo)
Write XML routing function.
NodeCounterMap64 m_nodeLrWpanMacTxDrop
node LR-WPAN MAC transmit drop
void WriteXmlPRef(uint64_t animUid, uint32_t fId, double fbTx, std::string metaInfo="")
Write XMLP Ref function.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint32_t m_wifiMacRxDropCounterId
wifi MAC receive drop counter ID
std::vector< std::string > m_attributes
list of attributes
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.
uint64_t m_AnimUid
the UID
NodeCounterMap64 m_nodeLrWpanMacTx
node LR-WPAN MAC transmit
void ConnectCallbacks()
Connect callbacks function.
void SetMaxPktsPerTraceFile(uint64_t maxPktsPerFile)
Set Max packets per trace file.
bool NodeHasMoved(Ptr< Node > n, Vector newLocation)
Node has moved function.
void WriteNodeEnergies()
Write node energies function.
uint64_t gAnimUid
Packet unique identifier used by AnimationInterface.
std::vector< std::string > GetIpv6Addresses(Ptr< NetDevice > nd)
Get IPv6 addresses.
void AddToIpv4AddressNodeIdTable(std::string ipv4Address, uint32_t nodeId)
Add to IPv4 address node ID table function.
an EUI-48 address
Definition: mac48-address.h:43
Time m_routingPollInterval
routing poll interval
NodeCounterMap64 m_nodeQueueDrop
node queue drop
uint32_t m_wifiMacRxCounterId
wifi MAC receive counter ID
void LrWpanPhyRxBeginTrace(std::string context, Ptr< const Packet > p)
LR-WPAN Phy receive begin trace function.
AnimUidPacketInfoMap m_pendingLtePackets
pending LTE packets
void TrackWifiMacCounters()
Track wifi MAC counters function.
void EnablePacketMetadata(bool enable=true)
Enable Packet metadata.
std::map< uint64_t, AnimPacketInfo > AnimUidPacketInfoMap
AnimUidPacketInfoMap typedef.
virtual void Serialize(TagBuffer i) const
Serialize function.
const std::vector< std::string > GetElementsFromContext(const std::string &context) const
Get elements from context.
void WriteXmlUpdateNodeDescription(uint32_t nodeId)
Write XML update node description function.
void AppendChild(AnimXmlElement e)
Append child function.
void EnqueueTrace(std::string context, Ptr< const Packet >)
Enqueue trace function.
Byte tag using by Anim to uniquely identify packets.
uint32_t m_wifiMacTxCounterId
wifi MAC transmit counter ID
virtual TypeId GetInstanceTypeId(void) const
Get Instance Type Id.
void StopAnimation(bool onlyAnimation=false)
Stop animation function.
void WriteXmlUpdateNodeCounter(uint32_t counterId, uint32_t nodeId, double value)
Write XML update node counter function.
AnimUidPacketInfoMap m_pendingWavePackets
pending WAVE packets
Vector UpdatePosition(Ptr< Node > n)
Update position function.
void LrWpanMacRxTrace(std::string context, Ptr< const Packet > p)
LR-WPAN MAC receive trace function.
Ptr< const NetDevice > m_rxnd
receive device
uint64_t Get(void) const
Get Uid in tag.
void WriteNodeSizes()
Write node sizes function.
void GenericWirelessRxTrace(std::string context, Ptr< const Packet > p, ProtocolType protocolType)
Generic wireless receive trace function.
NodeCounterMap64 m_nodeIpv4Rx
node IPv4 receive
std::vector< Ipv4RouteTrackElement > m_ipv4RouteTrackElements
IPv route track elements.
NodeCounterMap64 m_nodeWifiMacRxDrop
node wifi MAC receive drop
void MobilityCourseChangeTrace(Ptr< const MobilityModel > mob)
Mobility course change trace function.
void WimaxTxTrace(std::string context, Ptr< const Packet > p, const Mac48Address &m)
WIMax transmit trace function.
read and write tag data
Definition: tag-buffer.h:51
NodeCounterMap64 m_nodeWifiPhyRxDrop
node wifi Phy receive drop
std::string m_routingFileName
routing file name
bool IsPacketPending(uint64_t animUid, ProtocolType protocolType)
Is packet pending function.
void SetText(std::string text)
Set text function.
std::multimap< uint32_t, std::string > NodeIdIpv4Map
NodeIdIpv4Map typedef.
uint32_t m_queueDequeueCounterId
queue dequeue counter ID
std::string GetMacAddress(Ptr< NetDevice > nd)
Get MAC address function.
NodeCounterMap64 m_nodeIpv4Tx
node IPv4 transmit
NodeCounterMap64 m_nodeWifiMacRx
node wifi MAC receive
AnimUidPacketInfoMap m_pendingUanPackets
pending UAN packets
static Rectangle * userBoundary
user boundary
std::string ProtocolTypeToString(ProtocolType protocolType)
Protocol type to string function.
void AddByteTag(uint64_t animUid, Ptr< const Packet > p)
Add byte tag function.
void ConnectLte()
Connect LTE function.
void WifiMacTxTrace(std::string context, Ptr< const Packet > p)
wifi MAC transmit trace function
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:993
void WriteXmlUpdateBackground(std::string fileName, double x, double y, double scaleX, double scaleY, double opacity)
Write XML update background function.
virtual uint32_t GetSerializedSize(void) const
Get Serialized Size.
Interface to network animator.
void WriteNonP2pLinkProperties(uint32_t id, std::string ipv4Address, std::string channelType)
Write non P2P link properties function.
bool m_enablePacketMetadata
enable packet metadata
Ptr< const NetDevice > m_txnd
transmit device
uint32_t m_wifiMacTxDropCounterId
wifi MAC transmit drop counter ID
NodeCounterMap64 m_nodeLrWpanMacRx
node LR-WPAN MAC receive
Time m_wifiPhyCountersStopTime
wifi Phy counters stop time
void OutputWirelessPacketRxInfo(Ptr< const Packet > p, AnimPacketInfo &pktInfo, uint64_t animUid)
Output wireless packet receive info.
void LrWpanMacTxTrace(std::string context, Ptr< const Packet > p)
LR-WPAN MAC transmit trace function.
void Ipv4DropTrace(std::string context, const Ipv4Header &ipv4Header, Ptr< const Packet > p, Ipv4L3Protocol::DropReason dropReason, Ptr< Ipv4 > ipv4, uint32_t interfaceIndex)
IPv4 drop trace function.
DropReason
Reason why a packet has been dropped.
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.
std::map< uint32_t, Rgb > NodeColorsMap
NodeColorsMap typedef.
NodeCounterMap64 m_nodeQueueEnqueue
node queue enqueue
uint32_t m_wifiPhyRxDropCounterId
wifi Phy receive drop counter ID
Time m_wifiMacCountersStopTime
wifi MAC counters stop time
void LrWpanPhyTxBeginTrace(std::string context, Ptr< const Packet > p)
LR-WPAN Phy receive begin trace function.
void WriteRoutePath(uint32_t nodeId, std::string destination, Ipv4RoutePathElements rpElements)
Write route path function.
void WriteLinkProperties()
Write link properties function.
Time m_mobilityPollInterval
mobility poll interval
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)
Protocol type to pending packets function.
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)
Add attribute function.
uint32_t m_remainingEnergyCounterId
remaining energy counter ID
void WriteIpv4Addresses()
Write IPv4 Addresses function.
Vector GetPosition(Ptr< Node > n)
Get position function.
bool IsInTimeWindow()
Is in time window function.
a unique identifier for an interface.
Definition: type-id.h:58
NodeCounterMap64 m_nodeWifiMacTxDrop
node wifi MAC transmit drop
a 2d rectangle
Definition: rectangle.h:34
std::vector< std::string > m_nodeCounters
node counters
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)
Output CSMA packet function.
Time m_routingStopTime
routing stop time
uint32_t m_ipv4L3ProtocolDropCounterId
IPv4 protocol drop counter ID.
ProtocolType
ProtocolType enumeration.
Time m_queueCountersStopTime
queue counters stop time
void SetOutputFile(const std::string &fn, bool routing=false)
Set output file function.
void LteSpectrumPhyTxStart(std::string context, Ptr< const PacketBurst > pb)
LTE Spectrum Phy transmit start function.
AnimUidPacketInfoMap m_pendingCsmaPackets
pending CSMA packets
void WifiMacRxDropTrace(std::string context, Ptr< const Packet > p)
wifi MAC receive drop trace function
void WriteXmlLink(uint32_t fromId, uint32_t toLp, uint32_t toId)
Write XML link counter function.
std::string m_originalFileName
original file name
void TrackIpv4Route()
Track IPv4 router function.