A Discrete-Event Network Simulator
API
animation-interface.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License version 2 as
4  * published by the Free Software Foundation;
5  *
6  * This program is distributed in the hope that it will be useful,
7  * but WITHOUT ANY WARRANTY; without even the implied warranty of
8  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9  * GNU General Public License for more details.
10  *
11  * You should have received a copy of the GNU General Public License
12  * along with this program; if not, write to the Free Software
13  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14  *
15  * Author: George F. Riley<riley@ece.gatech.edu>
16  * Author: John Abraham <john.abraham@gatech.edu>
17  * Contributions: Eugene Kalishenko <ydginster@gmail.com> (Open Source and Linux Laboratory
18  * 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 "ns3/config.h"
27 #include "ns3/ipv4-l3-protocol.h"
28 #include "ns3/ipv4.h"
29 #include "ns3/log.h"
30 #include "ns3/lte-enb-net-device.h"
31 #include "ns3/lte-ue-net-device.h"
32 #include "ns3/mac48-address.h"
33 #include "ns3/net-device.h"
34 #include "ns3/node-container.h"
35 #include "ns3/node-list.h"
36 #include "ns3/nstime.h"
37 #include "ns3/ptr.h"
38 #include "ns3/random-variable-stream.h"
39 #include "ns3/rectangle.h"
40 #include "ns3/simulator.h"
41 #include "ns3/uan-phy-gen.h"
42 #include "ns3/wifi-phy.h"
43 
44 #include <cstdio>
45 #include <map>
46 #include <string>
47 
48 namespace ns3
49 {
50 
51 #define MAX_PKTS_PER_TRACE_FILE 100000
52 #define PURGE_INTERVAL 5
53 #define NETANIM_VERSION "netanim-3.108"
54 #define CHECK_STARTED_INTIMEWINDOW \
55  { \
56  if (!m_started || !IsInTimeWindow()) \
57  { \
58  return; \
59  } \
60  }
61 #define CHECK_STARTED_INTIMEWINDOW_TRACKPACKETS \
62  { \
63  if (!m_started || !IsInTimeWindow() || !m_trackPackets) \
64  { \
65  return; \
66  } \
67  }
68 
69 struct NodeSize;
70 class WifiPsdu;
71 
88 {
89  public:
95  AnimationInterface(const std::string filename);
96 
101  {
104  };
105 
111  typedef void (*AnimWriteCallback)(const char* str);
112 
118 
127  void EnableIpv4L3ProtocolCounters(Time startTime,
128  Time stopTime,
129  Time pollInterval = Seconds(1));
130 
139  void EnableQueueCounters(Time startTime, Time stopTime, Time pollInterval = Seconds(1));
140 
149  void EnableWifiMacCounters(Time startTime, Time stopTime, Time pollInterval = Seconds(1));
150 
159  void EnableWifiPhyCounters(Time startTime, Time stopTime, Time pollInterval = Seconds(1));
160 
172  AnimationInterface& EnableIpv4RouteTracking(std::string fileName,
173  Time startTime,
174  Time stopTime,
175  Time pollInterval = Seconds(5));
176 
189  AnimationInterface& EnableIpv4RouteTracking(std::string fileName,
190  Time startTime,
191  Time stopTime,
192  NodeContainer nc,
193  Time pollInterval = Seconds(5));
194 
201  static bool IsInitialized();
202 
209  void SetStartTime(Time t);
210 
217  void SetStopTime(Time t);
218 
227  void SetMaxPktsPerTraceFile(uint64_t maxPktsPerFile);
228 
238 
246 
251  void ResetAnimWriteCallback();
252 
261  static void SetConstantPosition(Ptr<Node> n, double x, double y, double z = 0);
262 
269  void UpdateNodeDescription(Ptr<Node> n, std::string descr);
270 
277  void UpdateNodeDescription(uint32_t nodeId, std::string descr);
278 
285  void UpdateNodeImage(uint32_t nodeId, uint32_t resourceId);
286 
294  void UpdateNodeSize(Ptr<Node> n, double width, double height);
295 
303  void UpdateNodeSize(uint32_t nodeId, double width, double height);
304 
313  void UpdateNodeColor(Ptr<Node> n, uint8_t r, uint8_t g, uint8_t b);
314 
323  void UpdateNodeColor(uint32_t nodeId, uint8_t r, uint8_t g, uint8_t b);
324 
332  void UpdateNodeCounter(uint32_t nodeCounterId, uint32_t nodeId, double counter);
333 
345  void SetBackgroundImage(std::string fileName,
346  double x,
347  double y,
348  double scaleX,
349  double scaleY,
350  double opacity);
351 
359  void UpdateLinkDescription(uint32_t fromNode, uint32_t toNode, std::string linkDescription);
360 
368  void UpdateLinkDescription(Ptr<Node> fromNode, Ptr<Node> toNode, std::string linkDescription);
369 
377  AnimationInterface& AddSourceDestination(uint32_t fromNodeId,
378  std::string destinationIpv4Address);
379 
385  bool IsStarted() const;
386 
391  void SkipPacketTracing();
392 
400  void EnablePacketMetadata(bool enable = true);
401 
408  uint64_t GetTracePktCount() const;
409 
418  uint32_t AddNodeCounter(std::string counterName, CounterType counterType);
419 
427  uint32_t AddResource(std::string resourcePath);
428 
436  double GetNodeEnergyFraction(Ptr<const Node> node) const;
437 
438  private:
443 
444  {
445  public:
446  AnimPacketInfo();
452  AnimPacketInfo(const AnimPacketInfo& pInfo);
460  AnimPacketInfo(Ptr<const NetDevice> tx_nd, const Time fbTx, uint32_t txNodeId = 0);
462  uint32_t m_txNodeId;
463  double m_fbTx;
464  double m_lbTx;
465  double m_fbRx;
466  double m_lbRx;
473  void ProcessRxBegin(Ptr<const NetDevice> nd, const double fbRx);
474  };
475 
477  struct Rgb
478  {
479  uint8_t r;
480  uint8_t g;
481  uint8_t b;
482  };
483 
486  {
487  uint32_t fromNode;
488  uint32_t toNode;
489  };
490 
493  {
494  std::string fromNodeDescription;
495  std::string toNodeDescription;
496  std::string linkDescription;
497  };
498 
501  {
510  {
511  // Check if they are the same node pairs but flipped
512  if (((first.fromNode == second.fromNode) && (first.toNode == second.toNode)) ||
513  ((first.fromNode == second.toNode) && (first.toNode == second.fromNode)))
514  {
515  return false;
516  }
517  std::ostringstream oss1;
518  oss1 << first.fromNode << first.toNode;
519  std::ostringstream oss2;
520  oss2 << second.fromNode << second.toNode;
521  return oss1.str() < oss2.str();
522  }
523  };
524 
527  {
528  std::string destination;
529  uint32_t fromNodeId;
530  };
531 
534  {
535  uint32_t nodeId;
536  std::string nextHop;
537  };
538 
541  {
548  WAVE
549  };
550 
552  struct NodeSize
553  {
554  double width;
555  double height;
556  };
557 
558  typedef std::map<P2pLinkNodeIdPair, LinkProperties, LinkPairCompare>
560  typedef std::map<uint32_t, std::string> NodeDescriptionsMap;
561  typedef std::map<uint32_t, Rgb> NodeColorsMap;
562  typedef std::map<uint64_t, AnimPacketInfo>
564  typedef std::map<uint32_t, double> EnergyFractionMap;
565  typedef std::vector<Ipv4RoutePathElement>
567  typedef std::multimap<uint32_t, std::string> NodeIdIpv4Map;
568  typedef std::multimap<uint32_t, std::string> NodeIdIpv6Map;
569  typedef std::pair<uint32_t, std::string> NodeIdIpv4Pair;
570  typedef std::pair<uint32_t, std::string> NodeIdIpv6Pair;
571 
572  // Node Counters
573  typedef std::map<uint32_t, uint64_t> NodeCounterMap64;
574 
577  {
578  public:
585  AnimXmlElement(std::string tagName, bool emptyElement = true);
586  template <typename T>
593  void AddAttribute(std::string attribute, T value, bool xmlEscape = false);
598  void SetText(std::string text);
603  void AppendChild(AnimXmlElement e);
609  std::string ToString(bool autoClose = true);
610 
611  private:
612  std::string m_tagName;
613  std::string m_text;
614  std::vector<std::string> m_attributes;
615  std::vector<std::string> m_children;
616  };
617 
618  // ##### State #####
619 
620  FILE* m_f;
621  FILE* m_routingF;
623  std::string m_outputFileName;
624  uint64_t gAnimUid;
626  bool m_started;
630  uint64_t m_maxPktsPerFile;
631  std::string m_originalFileName;
633  std::string m_routingFileName;
646 
647  // Counter ID
649 
653 
657 
662 
665 
673 
674  std::map<uint32_t, Vector> m_nodeLocation;
675  std::map<std::string, uint32_t> m_macToNodeIdMap;
676  std::map<std::string, uint32_t> m_ipv4ToNodeIdMap;
677  std::map<std::string, uint32_t> m_ipv6ToNodeIdMap;
680 
685  uint64_t m_currentPktCount;
686  std::vector<Ipv4RouteTrackElement> m_ipv4RouteTrackElements;
687  std::map<uint32_t, NodeSize> m_nodeSizes;
688  std::vector<std::string> m_resources;
689  std::vector<std::string> m_nodeCounters;
690 
691  /* Value-added custom counters */
708 
714  const std::vector<std::string> GetElementsFromContext(const std::string& context) const;
720  Ptr<Node> GetNodeFromContext(const std::string& context) const;
726  Ptr<NetDevice> GetNetDeviceFromContext(std::string context);
727 
728  // ##### General #####
734  void StartAnimation(bool restart = false);
741  void SetOutputFile(const std::string& fn, bool routing = false);
747  void StopAnimation(bool onlyAnimation = false);
753  std::string CounterTypeToString(CounterType counterType);
759  std::string GetPacketMetadata(Ptr<const Packet> p);
765  void AddByteTag(uint64_t animUid, Ptr<const Packet> p);
773  int WriteN(const char* data, uint32_t count, FILE* f);
780  int WriteN(const std::string& st, FILE* f);
786  std::string GetMacAddress(Ptr<NetDevice> nd);
792  std::string GetIpv4Address(Ptr<NetDevice> nd);
798  std::string GetIpv6Address(Ptr<NetDevice> nd);
804  std::vector<std::string> GetIpv4Addresses(Ptr<NetDevice> nd);
810  std::vector<std::string> GetIpv6Addresses(Ptr<NetDevice> nd);
811 
816  std::string GetNetAnimVersion();
818  void MobilityAutoCheck();
825  bool IsPacketPending(uint64_t animUid, ProtocolType protocolType);
830  void PurgePendingPackets(ProtocolType protocolType);
842  std::string ProtocolTypeToString(ProtocolType protocolType);
849  void AddPendingPacket(ProtocolType protocolType, uint64_t animUid, AnimPacketInfo pktInfo);
861  void AddToIpv4AddressNodeIdTable(std::string ipv4Address, uint32_t nodeId);
867  void AddToIpv4AddressNodeIdTable(std::vector<std::string> ipv4Addresses, uint32_t nodeId);
873  void AddToIpv6AddressNodeIdTable(std::string ipv6Address, uint32_t nodeId);
879  void AddToIpv6AddressNodeIdTable(std::vector<std::string> ipv6Addresses, uint32_t nodeId);
884  bool IsInTimeWindow();
887 
889  void TrackWifiPhyCounters();
891  void TrackWifiMacCounters();
895  void TrackQueueCounters();
896  // ##### Routing #####
898  void TrackIpv4Route();
900  void TrackIpv4RoutePaths();
906  std::string GetIpv4RoutingTable(Ptr<Node> n);
913  void RecursiveIpv4RoutePathSearch(std::string from,
914  std::string to,
915  Ipv4RoutePathElements& rpElements);
922  void WriteRoutePath(uint32_t nodeId, std::string destination, Ipv4RoutePathElements rpElements);
923 
924  // ##### Trace #####
930  void EnqueueTrace(std::string context, Ptr<const Packet>);
936  void DequeueTrace(std::string context, Ptr<const Packet>);
942  void QueueDropTrace(std::string context, Ptr<const Packet>);
950  void Ipv4TxTrace(std::string context,
952  Ptr<Ipv4> ipv4,
953  uint32_t interfaceIndex);
961  void Ipv4RxTrace(std::string context,
963  Ptr<Ipv4> ipv4,
964  uint32_t interfaceIndex);
974  void Ipv4DropTrace(std::string context,
975  const Ipv4Header& ipv4Header,
977  Ipv4L3Protocol::DropReason dropReason,
978  Ptr<Ipv4> ipv4,
979  uint32_t interfaceIndex);
980 
986  void WifiMacTxTrace(std::string context, Ptr<const Packet> p);
992  void WifiMacTxDropTrace(std::string context, Ptr<const Packet> p);
998  void WifiMacRxTrace(std::string context, Ptr<const Packet> p);
1004  void WifiMacRxDropTrace(std::string context, Ptr<const Packet> p);
1010  void WifiPhyTxDropTrace(std::string context, Ptr<const Packet> p);
1017  void WifiPhyRxDropTrace(std::string context,
1019  WifiPhyRxfailureReason reason);
1025  void LrWpanMacTxTrace(std::string context, Ptr<const Packet> p);
1031  void LrWpanMacTxDropTrace(std::string context, Ptr<const Packet> p);
1037  void LrWpanMacRxTrace(std::string context, Ptr<const Packet> p);
1043  void LrWpanMacRxDropTrace(std::string context, Ptr<const Packet> p);
1053  void DevTxTrace(std::string context,
1055  Ptr<NetDevice> tx,
1056  Ptr<NetDevice> rx,
1057  Time txTime,
1058  Time rxTime);
1066  void WifiPhyTxBeginTrace(std::string context,
1067  WifiConstPsduMap psduMap,
1068  WifiTxVector txVector,
1069  double txPowerW);
1077  void WifiPhyRxBeginTrace(std::string context,
1079  RxPowerWattPerChannelBand rxPowersW);
1085  void WavePhyTxBeginTrace(std::string context, Ptr<const Packet> p);
1092  void WavePhyRxBeginTrace(std::string context, Ptr<const Packet> p);
1099  void LrWpanPhyTxBeginTrace(std::string context, Ptr<const Packet> p);
1106  void LrWpanPhyRxBeginTrace(std::string context, Ptr<const Packet> p);
1113  void WimaxTxTrace(std::string context, Ptr<const Packet> p, const Mac48Address& m);
1120  void WimaxRxTrace(std::string context, Ptr<const Packet> p, const Mac48Address& m);
1126  void CsmaPhyTxBeginTrace(std::string context, Ptr<const Packet> p);
1133  void CsmaPhyTxEndTrace(std::string context, Ptr<const Packet> p);
1140  void CsmaPhyRxEndTrace(std::string context, Ptr<const Packet> p);
1147  void CsmaMacRxTrace(std::string context, Ptr<const Packet> p);
1154  void LteTxTrace(std::string context, Ptr<const Packet> p, const Mac48Address& m);
1161  void LteRxTrace(std::string context, Ptr<const Packet> p, const Mac48Address& m);
1167  void LteSpectrumPhyTxStart(std::string context, Ptr<const PacketBurst> pb);
1173  void LteSpectrumPhyRxStart(std::string context, Ptr<const PacketBurst> pb);
1179  void UanPhyGenTxTrace(std::string context, Ptr<const Packet>);
1185  void UanPhyGenRxTrace(std::string context, Ptr<const Packet>);
1192  void RemainingEnergyTrace(std::string context, double previousEnergy, double currentEnergy);
1199  void GenericWirelessTxTrace(std::string context,
1201  ProtocolType protocolType);
1208  void GenericWirelessRxTrace(std::string context,
1210  ProtocolType protocolType);
1211 
1213  void ConnectCallbacks();
1215  void ConnectLte();
1222  void ConnectLteUe(Ptr<Node> n, Ptr<LteUeNetDevice> nd, uint32_t devIndex);
1229  void ConnectLteEnb(Ptr<Node> n, Ptr<LteEnbNetDevice> nd, uint32_t devIndex);
1230 
1231  // ##### Mobility #####
1237  Vector GetPosition(Ptr<Node> n);
1243  Vector UpdatePosition(Ptr<Node> n);
1250  Vector UpdatePosition(Ptr<Node> n, Vector v);
1256  Vector UpdatePosition(Ptr<NetDevice> ndev);
1263  bool NodeHasMoved(Ptr<Node> n, Vector newLocation);
1268  std::vector<Ptr<Node>> GetMovedNodes();
1274 
1275  // ##### XML Helpers #####
1276 
1283  void WriteNonP2pLinkProperties(uint32_t id, std::string ipv4Address, std::string channelType);
1288  void WriteNodeUpdate(uint32_t nodeId);
1295  void OutputWirelessPacketTxInfo(Ptr<const Packet> p, AnimPacketInfo& pktInfo, uint64_t animUid);
1302  void OutputWirelessPacketRxInfo(Ptr<const Packet> p, AnimPacketInfo& pktInfo, uint64_t animUid);
1310  void WriteLinkProperties();
1312  void WriteIpv4Addresses();
1314  void WriteIpv6Addresses();
1316  void WriteNodes();
1318  void WriteNodeColors();
1320  void WriteNodeSizes();
1322  void WriteNodeEnergies();
1327  void WriteXmlAnim(bool routing = false);
1334  void WriteXmlUpdateNodePosition(uint32_t nodeId, double x, double y);
1342  void WriteXmlUpdateNodeColor(uint32_t nodeId, uint8_t r, uint8_t g, uint8_t b);
1347  void WriteXmlUpdateNodeDescription(uint32_t nodeId);
1354  void WriteXmlUpdateNodeSize(uint32_t nodeId, double width, double height);
1360  void WriteXmlAddResource(uint32_t resourceId, std::string resourcePath);
1367  void WriteXmlAddNodeCounter(uint32_t counterId,
1368  std::string counterName,
1369  CounterType counterType);
1375  void WriteXmlUpdateNodeImage(uint32_t nodeId, uint32_t resourceId);
1382  void WriteXmlUpdateNodeCounter(uint32_t counterId, uint32_t nodeId, double value);
1390  void WriteXmlNode(uint32_t id, uint32_t sysId, double locX, double locY);
1397  void WriteXmlLink(uint32_t fromId, uint32_t toLp, uint32_t toId);
1404  void WriteXmlUpdateLink(uint32_t fromId, uint32_t toId, std::string linkDescription);
1416  void WriteXmlP(std::string pktType,
1417  uint32_t fId,
1418  double fbTx,
1419  double lbTx,
1420  uint32_t tId,
1421  double fbRx,
1422  double lbRx,
1423  std::string metaInfo = "");
1432  void WriteXmlP(uint64_t animUid, std::string pktType, uint32_t fId, double fbTx, double lbTx);
1440  void WriteXmlPRef(uint64_t animUid, uint32_t fId, double fbTx, std::string metaInfo = "");
1446  void WriteXmlClose(std::string name, bool routing = false);
1453  void WriteXmlNonP2pLinkProperties(uint32_t id, std::string ipAddress, std::string channelType);
1459  void WriteXmlRouting(uint32_t id, std::string routingInfo);
1466  void WriteXmlRp(uint32_t nodeId, std::string destination, Ipv4RoutePathElements rpElements);
1476  void WriteXmlUpdateBackground(std::string fileName,
1477  double x,
1478  double y,
1479  double scaleX,
1480  double scaleY,
1481  double opacity);
1487  void WriteXmlIpv4Addresses(uint32_t nodeId, std::vector<std::string> ipv4Addresses);
1493  void WriteXmlIpv6Addresses(uint32_t nodeId, std::vector<std::string> ipv6Addresses);
1494 };
1495 
1506 class AnimByteTag : public Tag
1507 {
1508  public:
1513  static TypeId GetTypeId();
1514 
1519  TypeId GetInstanceTypeId() const override;
1520 
1525  uint32_t GetSerializedSize() const override;
1526 
1531  void Serialize(TagBuffer i) const override;
1532 
1537  void Deserialize(TagBuffer i) override;
1538 
1543  void Print(std::ostream& os) const override;
1544 
1549  void Set(uint64_t AnimUid);
1550 
1555  uint64_t Get() const;
1556 
1557  private:
1558  uint64_t m_AnimUid;
1559 };
1560 
1561 } // namespace ns3
1562 #endif
double f(double x, void *params)
Definition: 80211b.c:71
Byte tag using by Anim to uniquely identify packets.
TypeId GetInstanceTypeId() const override
Get Instance Type Id.
void Serialize(TagBuffer i) const override
Serialize function.
void Print(std::ostream &os) const override
Print tag info.
uint32_t GetSerializedSize() const override
Get Serialized Size.
uint64_t Get() const
Get Uid in tag.
static TypeId GetTypeId()
Get Type Id.
void Deserialize(TagBuffer i) override
Deserialize function.
uint64_t m_AnimUid
the UID
void Set(uint64_t AnimUid)
Set global Uid in tag.
Ptr< const NetDevice > m_txnd
transmit device
void ProcessRxBegin(Ptr< const NetDevice > nd, const double fbRx)
Process receive begin.
Ptr< const NetDevice > m_rxnd
receive device
void AppendChild(AnimXmlElement e)
Append child function.
std::vector< std::string > m_children
list of children
void SetText(std::string text)
Set text function.
std::vector< std::string > m_attributes
list of attributes
std::string ToString(bool autoClose=true)
Get text for the element function.
AnimXmlElement(std::string tagName, bool emptyElement=true)
Constructor.
void AddAttribute(std::string attribute, T value, bool xmlEscape=false)
Add attribute function.
Interface to network animator.
FILE * m_f
File handle for output (0 if none)
Time m_wifiMacCountersPollInterval
wifi MAC counters poll interval
void CsmaPhyRxEndTrace(std::string context, Ptr< const Packet > p)
CSMA Phy receive end trace function.
void WriteNodeSizes()
Write node sizes function.
uint32_t AddNodeCounter(std::string counterName, CounterType counterType)
Setup a node counter.
void TrackQueueCounters()
Track queue counters function.
void SetMobilityPollInterval(Time t)
Set mobility poll interval:WARNING: setting a low interval can cause slowness.
uint32_t m_wifiMacRxCounterId
wifi MAC receive counter ID
bool IsPacketPending(uint64_t animUid, ProtocolType protocolType)
Is packet pending function.
bool NodeHasMoved(Ptr< Node > n, Vector newLocation)
Node has moved function.
void LrWpanPhyTxBeginTrace(std::string context, Ptr< const Packet > p)
LR-WPAN Phy receive begin trace function.
uint32_t m_queueDropCounterId
queue drop counter ID
void WimaxTxTrace(std::string context, Ptr< const Packet > p, const Mac48Address &m)
WIMax transmit trace function.
void LrWpanPhyRxBeginTrace(std::string context, Ptr< const Packet > p)
LR-WPAN Phy receive begin trace function.
Time m_routingPollInterval
routing poll interval
void OutputCsmaPacket(Ptr< const Packet > p, AnimPacketInfo &pktInfo)
Output CSMA packet function.
uint64_t GetAnimUidFromPacket(Ptr< const Packet >)
Get anim UID from packet function.
EnergyFractionMap m_nodeEnergyFraction
node energy fraction
AnimUidPacketInfoMap m_pendingWavePackets
pending WAVE packets
void GenericWirelessTxTrace(std::string context, Ptr< const Packet > p, ProtocolType protocolType)
Generic wireless transmit trace function.
std::map< uint32_t, Rgb > NodeColorsMap
NodeColorsMap typedef.
void LteRxTrace(std::string context, Ptr< const Packet > p, const Mac48Address &m)
LTE receive trace function.
std::string ProtocolTypeToString(ProtocolType protocolType)
Protocol type to string function.
NodeCounterMap64 m_nodeLrWpanMacRx
node LR-WPAN MAC receive
std::string m_routingFileName
routing file name
NodeCounterMap64 m_nodeIpv4Tx
node IPv4 transmit
std::map< std::string, uint32_t > m_ipv6ToNodeIdMap
IPv6 to node ID map.
void MobilityAutoCheck()
Mobility auto check function.
void WriteXmlRouting(uint32_t id, std::string routingInfo)
Write XML routing function.
void WifiPhyRxDropTrace(std::string context, Ptr< const Packet > p, WifiPhyRxfailureReason reason)
wifi Phy receive drop trace function
void WifiMacRxDropTrace(std::string context, Ptr< const Packet > p)
wifi MAC receive drop trace function
NodeCounterMap64 m_nodeQueueDrop
node queue drop
void ConnectLteUe(Ptr< Node > n, Ptr< LteUeNetDevice > nd, uint32_t devIndex)
Connect LTE ue function.
void DequeueTrace(std::string context, Ptr< const Packet >)
Dequeue trace function.
void ConnectCallbacks()
Connect callbacks function.
void WriteRoutePath(uint32_t nodeId, std::string destination, Ipv4RoutePathElements rpElements)
Write route path function.
AnimUidPacketInfoMap * ProtocolTypeToPendingPackets(ProtocolType protocolType)
Protocol type to pending packets function.
void RemainingEnergyTrace(std::string context, double previousEnergy, double currentEnergy)
Remaining energy 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.
NodeColorsMap m_nodeColors
node colors
std::multimap< uint32_t, std::string > NodeIdIpv6Map
NodeIdIpv6Map typedef.
void UpdateNodeCounter(uint32_t nodeCounterId, uint32_t nodeId, double counter)
Helper function to update a node's counter referenced by the nodeCounterId.
void WifiPhyRxBeginTrace(std::string context, Ptr< const Packet > p, RxPowerWattPerChannelBand rxPowersW)
wifi Phy receive begin trace function
void LrWpanMacRxDropTrace(std::string context, Ptr< const Packet > p)
LR-WPAN MAC receive drop trace function.
void LteSpectrumPhyTxStart(std::string context, Ptr< const PacketBurst > pb)
LTE Spectrum Phy transmit start function.
NodeCounterMap64 m_nodeLrWpanMacTx
node LR-WPAN MAC transmit
void WriteXmlAddNodeCounter(uint32_t counterId, std::string counterName, CounterType counterType)
Write XML add node counter function.
void WriteXmlPRef(uint64_t animUid, uint32_t fId, double fbTx, std::string metaInfo="")
Write XMLP Ref function.
NodeCounterMap64 m_nodeWifiPhyTxDrop
node wifi Phy transmit drop
void WriteLinkProperties()
Write link properties function.
void WriteIpv4Addresses()
Write IPv4 Addresses function.
const std::vector< std::string > GetElementsFromContext(const std::string &context) const
Get elements from context.
void WriteXmlAddResource(uint32_t resourceId, std::string resourcePath)
Write XML add resource function.
void OutputWirelessPacketTxInfo(Ptr< const Packet > p, AnimPacketInfo &pktInfo, uint64_t animUid)
Output wireless packet transmit info.
void LteSpectrumPhyRxStart(std::string context, Ptr< const PacketBurst > pb)
LTE Spectrum Phy receive start function.
void SetOutputFile(const std::string &fn, bool routing=false)
Set output file function.
NodeCounterMap64 m_nodeWifiMacTx
node wifi MAC transmit
std::map< uint32_t, std::string > NodeDescriptionsMap
NodeDescriptionsMap typedef.
AnimUidPacketInfoMap m_pendingWimaxPackets
pending wimax packets
void LteTxTrace(std::string context, Ptr< const Packet > p, const Mac48Address &m)
LTE transmit trace function.
void EnableIpv4L3ProtocolCounters(Time startTime, Time stopTime, Time pollInterval=Seconds(1))
Enable tracking of Ipv4 L3 Protocol Counters such as Tx, Rx, Drop.
int WriteN(const char *data, uint32_t count, FILE *f)
WriteN function.
std::map< std::string, uint32_t > m_macToNodeIdMap
MAC to node ID map.
Ptr< Node > GetNodeFromContext(const std::string &context) const
Get node from context.
std::map< uint32_t, Vector > m_nodeLocation
node location
Ptr< NetDevice > GetNetDeviceFromContext(std::string context)
Get net device from context.
FILE * m_routingF
File handle for routing table output (0 if None);.
void UpdateNodeImage(uint32_t nodeId, uint32_t resourceId)
Helper function to update the image of a node.
void TrackWifiPhyCounters()
Track wifi phy counters function.
void WavePhyTxBeginTrace(std::string context, Ptr< const Packet > p)
WAVE Phy transmit begin trace function.
AnimUidPacketInfoMap m_pendingUanPackets
pending UAN packets
void TrackIpv4RoutePaths()
Track IPv4 route paths function.
double GetNodeEnergyFraction(Ptr< const Node > node) const
Get node's energy fraction (This used only for testing)
bool IsInTimeWindow()
Is in time window function.
void CsmaPhyTxBeginTrace(std::string context, Ptr< const Packet > p)
CSMA Phy transmit begin trace function.
bool m_enablePacketMetadata
enable packet metadata
void PurgePendingPackets(ProtocolType protocolType)
Purge pending packets function.
void SetMaxPktsPerTraceFile(uint64_t maxPktsPerFile)
Set Max packets per trace file.
uint64_t m_maxPktsPerFile
maximum packets per file
uint32_t m_ipv4L3ProtocolRxCounterId
IPv4 L3 protocol receive counter ID.
NodeCounterMap64 m_nodeIpv4Rx
node IPv4 receive
~AnimationInterface()
Destructor for the animator interface.
void AddToIpv4AddressNodeIdTable(std::string ipv4Address, uint32_t nodeId)
Add to IPv4 address node ID table function.
NodeIdIpv4Map m_nodeIdIpv4Map
node ID to IPv4 map
Time m_queueCountersPollInterval
queue counters poll interval
std::map< P2pLinkNodeIdPair, LinkProperties, LinkPairCompare > LinkPropertiesMap
LinkPropertiesMap typedef.
std::vector< std::string > GetIpv6Addresses(Ptr< NetDevice > nd)
Get IPv6 addresses.
void UpdateLinkDescription(uint32_t fromNode, uint32_t toNode, std::string linkDescription)
Helper function to update the description for a link.
void Ipv4RxTrace(std::string context, Ptr< const Packet > p, Ptr< Ipv4 > ipv4, uint32_t interfaceIndex)
IPv4 receive trace function.
NodeCounterMap64 m_nodeQueueEnqueue
node queue enqueue
void WriteXmlUpdateNodeCounter(uint32_t counterId, uint32_t nodeId, double value)
Write XML update node counter function.
std::vector< std::string > GetIpv4Addresses(Ptr< NetDevice > nd)
Get IPv4 addresses.
Time m_wifiPhyCountersPollInterval
wifi Phy counters poll interval
uint32_t m_queueDequeueCounterId
queue dequeue counter ID
NodeCounterMap64 m_nodeWifiMacRx
node wifi MAC receive
void AddToIpv6AddressNodeIdTable(std::string ipv6Address, uint32_t nodeId)
Add to IPv6 address node ID table function.
AnimationInterface & AddSourceDestination(uint32_t fromNodeId, std::string destinationIpv4Address)
Helper function to print the routing path from a source node to destination IP.
NodeCounterMap64 m_nodeIpv4Drop
node IPv4 drop
Time m_ipv4L3ProtocolCountersStopTime
IPv4 L3 protocol counters stop time.
uint32_t m_queueEnqueueCounterId
queue enqueue counter ID
void AddByteTag(uint64_t animUid, Ptr< const Packet > p)
Add byte tag function.
Time m_ipv4L3ProtocolCountersPollInterval
IPv4 L3 protocol counters poll interval.
void WriteNonP2pLinkProperties(uint32_t id, std::string ipv4Address, std::string channelType)
Write non P2P link properties function.
void StopAnimation(bool onlyAnimation=false)
Stop animation function.
std::vector< Ipv4RoutePathElement > Ipv4RoutePathElements
Ipv4RoutePathElements typedef.
void UanPhyGenTxTrace(std::string context, Ptr< const Packet >)
UAN Phy gen transmit trace function.
void WifiMacTxDropTrace(std::string context, Ptr< const Packet > p)
wifi MAC transmit drop trace function
uint32_t m_ipv4L3ProtocolTxCounterId
IPv4 L3 protocol transmit counter ID.
Time m_queueCountersStopTime
queue counters stop time
std::string CounterTypeToString(CounterType counterType)
Counter type to string function.
ProtocolType
ProtocolType enumeration.
std::string GetMacAddress(Ptr< NetDevice > nd)
Get MAC address function.
std::vector< Ptr< Node > > GetMovedNodes()
Get moved nodes function.
uint32_t m_wifiMacTxCounterId
wifi MAC transmit counter ID
void SkipPacketTracing()
Do not trace packets.
NodeCounterMap64 m_nodeWifiMacRxDrop
node wifi MAC receive drop
NodeDescriptionsMap m_nodeDescriptions
node description
void WriteXmlAnim(bool routing=false)
Write XML anim function.
std::map< uint32_t, double > EnergyFractionMap
EnergyFractionMap typedef.
void SetStartTime(Time t)
Specify the time at which capture should start.
uint32_t AddResource(std::string resourcePath)
Add a resource such as the path to an image file.
AnimationInterface(const std::string filename)
Constructor.
std::string GetIpv6Address(Ptr< NetDevice > nd)
Get IPv6 address.
void WriteNodeEnergies()
Write node energies function.
std::map< uint32_t, uint64_t > NodeCounterMap64
NodeCounterMap64 typedef.
static Rectangle * userBoundary
user boundary
void CsmaMacRxTrace(std::string context, Ptr< const Packet > p)
CSMA MAC receive trace function.
void WifiPhyTxBeginTrace(std::string context, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW)
wifi Phy transmit PSDU begin trace function
void UanPhyGenRxTrace(std::string context, Ptr< const Packet >)
UAN Phy gen receive trace function.
LinkPropertiesMap m_linkProperties
link properties
void WriteXmlUpdateNodeDescription(uint32_t nodeId)
Write XML update node description function.
void UpdateNodeSize(Ptr< Node > n, double width, double height)
Helper function to update the size of a node.
std::map< uint32_t, NodeSize > m_nodeSizes
node sizes
std::pair< uint32_t, std::string > NodeIdIpv6Pair
NodeIdIpv6Pair typedef.
void(* AnimWriteCallback)(const char *str)
typedef for WriteCallBack used for listening to AnimationInterface write messages
void ConnectLte()
Connect LTE function.
bool m_trackPackets
track packets
std::string GetNetAnimVersion()
Get netanim version function.
void WriteXmlNonP2pLinkProperties(uint32_t id, std::string ipAddress, std::string channelType)
Write XML non P2P link properties function.
AnimationInterface & EnableIpv4RouteTracking(std::string fileName, Time startTime, Time stopTime, Time pollInterval=Seconds(5))
Enable tracking of the Ipv4 routing table for all Nodes.
void WriteXmlClose(std::string name, bool routing=false)
Write XML close function.
uint64_t gAnimUid
Packet unique identifier used by AnimationInterface.
void CheckMaxPktsPerTraceFile()
Check maximum packets per trace file function.
NodeCounterMap64 m_nodeLrWpanMacTxDrop
node LR-WPAN MAC transmit drop
NodeIdIpv6Map m_nodeIdIpv6Map
node ID to IPv6 map
void TrackIpv4Route()
Track IPv4 router function.
void EnableWifiPhyCounters(Time startTime, Time stopTime, Time pollInterval=Seconds(1))
Enable tracking of Wifi Phy Counters such as TxDrop, RxDrop.
AnimUidPacketInfoMap m_pendingWifiPackets
pending wifi packets
void EnablePacketMetadata(bool enable=true)
Enable Packet metadata.
Time m_routingStopTime
routing stop time
void SetStopTime(Time t)
Specify the time at which capture should stop.
void MobilityCourseChangeTrace(Ptr< const MobilityModel > mob)
Mobility course change trace function.
void EnableWifiMacCounters(Time startTime, Time stopTime, Time pollInterval=Seconds(1))
Enable tracking of Wifi Mac Counters such as Tx, TxDrop, Rx, RxDrop.
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.
uint32_t m_wifiMacTxDropCounterId
wifi MAC transmit drop counter ID
void WriteXmlRp(uint32_t nodeId, std::string destination, Ipv4RoutePathElements rpElements)
Write XMLRP function.
AnimUidPacketInfoMap m_pendingLrWpanPackets
pending LR-WPAN packets
void WifiMacTxTrace(std::string context, Ptr< const Packet > p)
wifi MAC transmit trace function
void ResetAnimWriteCallback()
Reset the write callback function.
void WimaxRxTrace(std::string context, Ptr< const Packet > p, const Mac48Address &m)
WIMax receive trace function.
void LrWpanMacTxDropTrace(std::string context, Ptr< const Packet > p)
LR-WPAN MAC transmit drop trace function.
void LrWpanMacRxTrace(std::string context, Ptr< const Packet > p)
LR-WPAN MAC receive trace function.
std::vector< std::string > m_nodeCounters
node counters
void WriteXmlNode(uint32_t id, uint32_t sysId, double locX, double locY)
Write XML node function.
AnimWriteCallback m_writeCallback
write callback
NodeCounterMap64 m_nodeWifiMacTxDrop
node wifi MAC transmit drop
uint64_t m_currentPktCount
current packet count
std::string GetIpv4RoutingTable(Ptr< Node > n)
Get IPv4 routing table function.
void Ipv4TxTrace(std::string context, Ptr< const Packet > p, Ptr< Ipv4 > ipv4, uint32_t interfaceIndex)
IPv4 transmit trace function.
std::pair< uint32_t, std::string > NodeIdIpv4Pair
NodeIdIpv4Pair typedef.
void EnqueueTrace(std::string context, Ptr< const Packet >)
Enqueue trace function.
uint64_t GetTracePktCount() const
Get trace file packet count (This used only for testing)
void WriteXmlUpdateNodeColor(uint32_t nodeId, uint8_t r, uint8_t g, uint8_t b)
Write XML update node color function.
Vector UpdatePosition(Ptr< Node > n)
Update position function.
std::string m_outputFileName
output file name
void WriteIpv6Addresses()
Write IPv6 Addresses function.
void AddPendingPacket(ProtocolType protocolType, uint64_t animUid, AnimPacketInfo pktInfo)
Add pending packet function.
NodeCounterMap64 m_nodeWifiPhyRxDrop
node wifi Phy receive drop
void WriteXmlIpv4Addresses(uint32_t nodeId, std::vector< std::string > ipv4Addresses)
Write XML Ipv4 addresses function.
Vector GetPosition(Ptr< Node > n)
Get position function.
AnimUidPacketInfoMap m_pendingLtePackets
pending LTE packets
void SetBackgroundImage(std::string fileName, double x, double y, double scaleX, double scaleY, double opacity)
Helper function to set the background image.
void WriteNodes()
Write nodes function.
NodeCounterMap64 m_nodeLrWpanMacRxDrop
node LR-WPAN MAC receive drop
Time m_wifiMacCountersStopTime
wifi MAC counters stop time
void WriteNodeColors()
Write node colors function.
void RecursiveIpv4RoutePathSearch(std::string from, std::string to, Ipv4RoutePathElements &rpElements)
Recursive IPv4 route path search function.
static bool IsInitialized()
Check if AnimationInterface is initialized.
void LrWpanMacTxTrace(std::string context, Ptr< const Packet > p)
LR-WPAN MAC transmit trace function.
void WriteXmlUpdateBackground(std::string fileName, double x, double y, double scaleX, double scaleY, double opacity)
Write XML update background function.
void CsmaPhyTxEndTrace(std::string context, Ptr< const Packet > p)
CSMA Phy transmit end trace function.
void WriteXmlUpdateNodeSize(uint32_t nodeId, double width, double height)
Write XML update node size function.
uint32_t m_remainingEnergyCounterId
remaining energy counter ID
void WriteXmlUpdateNodeImage(uint32_t nodeId, uint32_t resourceId)
Write XML update node image function.
uint32_t m_wifiMacRxDropCounterId
wifi MAC receive drop counter ID
void TrackWifiMacCounters()
Track wifi MAC counters function.
void WriteNodeUpdate(uint32_t nodeId)
Write node update function.
std::string m_originalFileName
original file name
void UpdateNodeDescription(Ptr< Node > n, std::string descr)
Helper function to update the description for a given node.
void UpdateNodeColor(Ptr< Node > n, uint8_t r, uint8_t g, uint8_t b)
Helper function to update the node color.
static void SetConstantPosition(Ptr< Node > n, double x, double y, double z=0)
Helper function to set Constant Position for a given node.
NodeCounterMap64 m_nodeQueueDequeue
node queue dequeue
void WifiPhyTxDropTrace(std::string context, Ptr< const Packet > p)
wifi Phy transmit drop trace function
uint32_t m_wifiPhyRxDropCounterId
wifi Phy receive drop counter ID
void WriteXmlUpdateLink(uint32_t fromId, uint32_t toId, std::string linkDescription)
Write XML update link counter function.
void ConnectLteEnb(Ptr< Node > n, Ptr< LteEnbNetDevice > nd, uint32_t devIndex)
Connect LTE ENB function.
void GenericWirelessRxTrace(std::string context, Ptr< const Packet > p, ProtocolType protocolType)
Generic wireless receive trace function.
std::string GetPacketMetadata(Ptr< const Packet > p)
Get packet metadata function.
uint32_t m_wifiPhyTxDropCounterId
wifi Phy transmit drop counter ID
std::vector< Ipv4RouteTrackElement > m_ipv4RouteTrackElements
IPv route track elements.
std::multimap< uint32_t, std::string > NodeIdIpv4Map
NodeIdIpv4Map typedef.
void EnableQueueCounters(Time startTime, Time stopTime, Time pollInterval=Seconds(1))
Enable tracking of Queue Counters such as Enqueue, Dequeue, Queue Drops.
uint32_t m_ipv4L3ProtocolDropCounterId
IPv4 protocol drop counter ID.
Time m_wifiPhyCountersStopTime
wifi Phy counters stop time
Time m_mobilityPollInterval
mobility poll interval
void OutputWirelessPacketRxInfo(Ptr< const Packet > p, AnimPacketInfo &pktInfo, uint64_t animUid)
Output wireless packet receive info.
std::map< std::string, uint32_t > m_ipv4ToNodeIdMap
IPv4 to node ID map.
AnimUidPacketInfoMap m_pendingCsmaPackets
pending CSMA packets
std::vector< std::string > m_resources
resources
void TrackIpv4L3ProtocolCounters()
Track IPv4 L3 protocol counters function.
void WriteXmlUpdateNodePosition(uint32_t nodeId, double x, double y)
Write XML update node position function.
void StartAnimation(bool restart=false)
Start animation function.
void DevTxTrace(std::string context, Ptr< const Packet > p, Ptr< NetDevice > tx, Ptr< NetDevice > rx, Time txTime, Time rxTime)
Device transmit trace function.
std::string GetIpv4Address(Ptr< NetDevice > nd)
Get IPv4 address.
void WavePhyRxBeginTrace(std::string context, Ptr< const Packet > p)
WAVE Phy receive begin trace function.
void WifiMacRxTrace(std::string context, Ptr< const Packet > p)
wifi MAC receive trace function
bool IsStarted() const
Is AnimationInterface started.
void WriteXmlIpv6Addresses(uint32_t nodeId, std::vector< std::string > ipv6Addresses)
Write XML Ipv6 addresses function.
NodeContainer m_routingNc
routing node container
void SetAnimWriteCallback(AnimWriteCallback cb)
Set a callback function to listen to AnimationInterface write events.
void QueueDropTrace(std::string context, Ptr< const Packet >)
Queue trace function.
void WriteXmlLink(uint32_t fromId, uint32_t toLp, uint32_t toId)
Write XML link counter function.
std::map< uint64_t, AnimPacketInfo > AnimUidPacketInfoMap
AnimUidPacketInfoMap typedef.
Packet header for IPv4.
Definition: ipv4-header.h:34
DropReason
Reason why a packet has been dropped.
an EUI-48 address
Definition: mac48-address.h:46
keep track of a set of node pointers.
a 2d rectangle
Definition: rectangle.h:35
read and write tag data
Definition: tag-buffer.h:52
tag a set of bytes in a packet
Definition: tag.h:39
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:60
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
Time stopTime
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1336
WifiPhyRxfailureReason
Enumeration of the possible reception failure reasons.
Definition: first.py:1
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
std::map< WifiSpectrumBand, double > RxPowerWattPerChannelBand
A map of the received power (Watts) for each band.
Definition: phy-entity.h:78
Definition: second.py:1
value
Definition: second.py:41
uint8_t data[writeSize]
Ipv4RoutePathElement structure IPv4 route path element.
Ipv4RouteTrackElement structure IPv4 route track element.
NodeSize structure node size.
RGB structure RGB structure.