A Discrete-Event Network Simulator
API
animation-interface.cc
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  * Modified by: John Abraham <john.abraham@gatech.edu>
18  * Contributions: Eugene Kalishenko <ydginster@gmail.com> (Open Source and Linux Laboratory http://dev.osll.ru/)
19  * Tommaso Pecorella <tommaso.pecorella@unifi.it>
20  * Pavel Vasilyev <pavel.vasilyev@sredasolutions.com>
21  */
22 
23 // Interface between ns-3 and the network animator
24 
25 
26 
27 #include <cstdio>
28 #ifndef WIN32
29 #include <unistd.h>
30 #endif
31 #include <sstream>
32 #include <fstream>
33 #include <string>
34 #include <iomanip>
35 #include <map>
36 
37 // ns3 includes
38 #include "ns3/animation-interface.h"
39 #include "ns3/channel.h"
40 #include "ns3/config.h"
41 #include "ns3/node.h"
42 #include "ns3/mobility-model.h"
43 #include "ns3/packet.h"
44 #include "ns3/simulator.h"
45 #include "ns3/wifi-mac-header.h"
46 #include "ns3/wimax-mac-header.h"
47 #include "ns3/wifi-net-device.h"
48 #include "ns3/wifi-mac.h"
49 #include "ns3/wifi-psdu.h"
50 #include "ns3/lr-wpan-mac-header.h"
51 #include "ns3/lr-wpan-net-device.h"
52 #include "ns3/constant-position-mobility-model.h"
53 #include "ns3/lte-ue-phy.h"
54 #include "ns3/lte-enb-phy.h"
55 #include "ns3/uan-net-device.h"
56 #include "ns3/uan-mac.h"
57 #include "ns3/double.h"
58 #include "ns3/ipv4.h"
59 #include "ns3/ipv6.h"
60 #include "ns3/ipv4-routing-protocol.h"
61 #include "ns3/energy-source-container.h"
62 #include "animation-interface.h"
63 
64 namespace ns3 {
65 
66 NS_LOG_COMPONENT_DEFINE ("AnimationInterface");
67 
68 // Globals
69 
70 static bool initialized = false;
71 
72 
73 // Public methods
74 
76  : m_f (0),
77  m_routingF (0),
78  m_mobilityPollInterval (Seconds (0.25)),
79  m_outputFileName (fn),
80  gAnimUid (0),
81  m_writeCallback (0),
82  m_started (false),
83  m_enablePacketMetadata (false),
84  m_startTime (Seconds (0)),
85  m_stopTime (Seconds (3600 * 1000)),
86  m_maxPktsPerFile (MAX_PKTS_PER_TRACE_FILE),
87  m_originalFileName (fn),
88  m_routingStopTime (Seconds (0)),
89  m_routingFileName (""),
90  m_routingPollInterval (Seconds (5)),
91  m_trackPackets (true)
92 {
93  initialized = true;
94  StartAnimation ();
95 }
96 
98 {
99  StopAnimation ();
100 }
101 
102 void
104 {
105  m_trackPackets = false;
106 }
107 
108 void
110 {
112  m_wifiPhyCountersPollInterval = pollInterval;
115  for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
116  {
117  Ptr<Node> n = *i;
118  m_nodeWifiPhyTxDrop[n->GetId ()] = 0;
119  m_nodeWifiPhyRxDrop[n->GetId ()] = 0;
122  }
124 
125 }
126 
127 void
129 {
131  m_wifiMacCountersPollInterval = pollInterval;
136  for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
137  {
138  Ptr<Node> n = *i;
139  m_nodeWifiMacTx[n->GetId ()] = 0;
140  m_nodeWifiMacTxDrop[n->GetId ()] = 0;
141  m_nodeWifiMacRx[n->GetId ()] = 0;
142  m_nodeWifiMacRxDrop[n->GetId ()] = 0;
143  UpdateNodeCounter (m_wifiMacTxCounterId, n->GetId (), 0);
145  UpdateNodeCounter (m_wifiMacRxCounterId, n->GetId (), 0);
147  }
149 }
150 
151 void
153 {
155  m_queueCountersPollInterval = pollInterval;
159  for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
160  {
161  Ptr<Node> n = *i;
162  m_nodeQueueEnqueue[n->GetId ()] = 0;
163  m_nodeQueueDequeue[n->GetId ()] = 0;
164  m_nodeQueueDrop[n->GetId ()] = 0;
167  UpdateNodeCounter (m_queueDropCounterId, n->GetId (), 0);
168  }
170 }
171 
172 void
174 {
180  for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
181  {
182  Ptr<Node> n = *i;
183  m_nodeIpv4Tx[n->GetId ()] = 0;
184  m_nodeIpv4Rx[n->GetId ()] = 0;
185  m_nodeIpv4Drop[n->GetId ()] = 0;
189  }
191 }
192 
195 {
196  SetOutputFile (fileName, true);
198  m_routingPollInterval = pollInterval;
199  WriteXmlAnim (true);
201  return *this;
202 }
203 
206 {
207  m_routingNc = nc;
208  return EnableIpv4RouteTracking (fileName, startTime, stopTime, pollInterval);
209 }
210 
212 AnimationInterface::AddSourceDestination (uint32_t fromNodeId, std::string ipv4Address)
213 {
214  Ipv4RouteTrackElement element = { ipv4Address, fromNodeId };
215  m_ipv4RouteTrackElements.push_back (element);
216  return *this;
217 }
218 
219 void
221 {
222  m_startTime = t;
223 }
224 
225 void
227 {
228  m_stopTime = t;
229 }
230 
231 void
232 AnimationInterface::SetMaxPktsPerTraceFile (uint64_t maxPacketsPerFile)
233 {
234  m_maxPktsPerFile = maxPacketsPerFile;
235 }
236 
237 uint32_t
238 AnimationInterface::AddNodeCounter (std::string counterName, CounterType counterType)
239 {
240  m_nodeCounters.push_back (counterName);
241  uint32_t counterId = m_nodeCounters.size () - 1; // counter ID is zero-indexed
242  WriteXmlAddNodeCounter (counterId, counterName, counterType);
243  return counterId;
244 }
245 
246 uint32_t
247 AnimationInterface::AddResource (std::string resourcePath)
248 {
249  m_resources.push_back (resourcePath);
250  uint32_t resourceId = m_resources.size () - 1; // resource ID is zero-indexed
251  WriteXmlAddResource (resourceId, resourcePath);
252  return resourceId;
253 }
254 
255 void
257 {
258  m_enablePacketMetadata = enable;
259  if (enable)
260  {
262  }
263 }
264 
265 bool
267 {
268  return initialized;
269 }
270 
271 bool
273 {
274  return m_started;
275 }
276 
277 void
279 {
280  m_writeCallback = cb;
281 }
282 
283 void
285 {
286  m_writeCallback = 0;
287 }
288 
289 void
291 {
293 }
294 
295 
296 void
298 {
299  NS_ASSERT (n);
301  if (loc == 0)
302  {
303  loc = CreateObject<ConstantPositionMobilityModel> ();
304  n->AggregateObject (loc);
305  }
306  Vector hubVec (x, y, z);
307  loc->SetPosition (hubVec);
308  NS_LOG_INFO ("Node:" << n->GetId () << " Position set to:(" << x << "," << y << "," << z << ")");
309 
310 }
311 
312 void
313 AnimationInterface::UpdateNodeImage (uint32_t nodeId, uint32_t resourceId)
314 {
315  NS_LOG_INFO ("Setting node image for Node Id:" << nodeId);
316  if (resourceId > (m_resources.size () - 1))
317  {
318  NS_FATAL_ERROR ("Resource Id:" << resourceId << " not found. Did you use AddResource?");
319  }
320  WriteXmlUpdateNodeImage (nodeId, resourceId);
321 }
322 
323 void
324 AnimationInterface::UpdateNodeCounter (uint32_t nodeCounterId, uint32_t nodeId, double counter)
325 {
326  if (nodeCounterId > (m_nodeCounters.size () - 1))
327  {
328  NS_FATAL_ERROR ("NodeCounter Id:" << nodeCounterId << " not found. Did you use AddNodeCounter?");
329  }
330  WriteXmlUpdateNodeCounter (nodeCounterId, nodeId, counter);
331 }
332 
333 void
334 AnimationInterface::SetBackgroundImage (std::string fileName, double x, double y, double scaleX, double scaleY, double opacity)
335 {
336  if ((opacity < 0) || (opacity > 1))
337  {
338  NS_FATAL_ERROR ("Opacity must be between 0.0 and 1.0");
339  }
340  WriteXmlUpdateBackground (fileName, x, y, scaleX, scaleY, opacity);
341 }
342 
343 void
344 AnimationInterface::UpdateNodeSize (uint32_t nodeId, double width, double height)
345 {
346  AnimationInterface::NodeSize s = { width, height };
347  m_nodeSizes[nodeId] = s;
348  WriteXmlUpdateNodeSize (nodeId, s.width, s.height);
349 }
350 
351 void
352 AnimationInterface::UpdateNodeColor (Ptr <Node> n, uint8_t r, uint8_t g, uint8_t b)
353 {
354  UpdateNodeColor (n->GetId (), r, g, b);
355 }
356 
357 void
358 AnimationInterface::UpdateNodeColor (uint32_t nodeId, uint8_t r, uint8_t g, uint8_t b)
359 {
360  NS_ASSERT (NodeList::GetNode (nodeId));
361  NS_LOG_INFO ("Setting node color for Node Id:" << nodeId);
362  Rgb rgb = {r, g, b};
363  m_nodeColors[nodeId] = rgb;
364  WriteXmlUpdateNodeColor (nodeId, r, g, b);
365 }
366 
367 void
368 AnimationInterface::UpdateLinkDescription (uint32_t fromNode, uint32_t toNode,
369  std::string linkDescription)
370 {
371  WriteXmlUpdateLink (fromNode, toNode, linkDescription);
372 }
373 
374 void
376  std::string linkDescription)
377 {
378  NS_ASSERT (fromNode);
379  NS_ASSERT (toNode);
380  WriteXmlUpdateLink (fromNode->GetId (), toNode->GetId (), linkDescription);
381 }
382 
383 void
385 {
386  UpdateNodeDescription (n->GetId (), descr);
387 }
388 
389 void
390 AnimationInterface::UpdateNodeDescription (uint32_t nodeId, std::string descr)
391 {
392  NS_ASSERT (NodeList::GetNode (nodeId));
393  m_nodeDescriptions[nodeId] = descr;
395 }
396 
397 // Private methods
398 
399 
400 double
402 {
403  const EnergyFractionMap::const_iterator fractionIter = m_nodeEnergyFraction.find (node->GetId ());
404  NS_ASSERT (fractionIter != m_nodeEnergyFraction.end ());
405  return fractionIter->second;
406 }
407 
408 void
410 {
412  Ptr <Node> n = mobility->GetObject <Node> ();
413  NS_ASSERT (n);
414  Vector v;
415  if (!mobility)
416  {
417  v = GetPosition (n);
418  }
419  else
420  {
421  v = mobility->GetPosition ();
422  }
423  UpdatePosition (n, v);
424  WriteXmlUpdateNodePosition (n->GetId (), v.x, v.y);
425 }
426 
427 bool
429 {
430  Vector oldLocation = GetPosition (n);
431  bool moved = true;
432  if ((ceil (oldLocation.x) == ceil (newLocation.x))
433  && (ceil (oldLocation.y) == ceil (newLocation.y)))
434  {
435  moved = false;
436  }
437  else
438  {
439  moved = true;
440  }
441  return moved;
442 }
443 
444 void
446 {
448  std::vector <Ptr <Node> > MovedNodes = GetMovedNodes ();
449  for (uint32_t i = 0; i < MovedNodes.size (); i++)
450  {
451  Ptr <Node> n = MovedNodes [i];
452  NS_ASSERT (n);
453  Vector v = GetPosition (n);
454  WriteXmlUpdateNodePosition (n->GetId (), v.x, v.y);
455  }
456  if (!Simulator::IsFinished ())
457  {
465  }
466 }
467 
468 std::vector <Ptr <Node> >
470 {
471  std::vector < Ptr <Node> > movedNodes;
472  for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
473  {
474  Ptr<Node> n = *i;
475  NS_ASSERT (n);
476  Ptr <MobilityModel> mobility = n->GetObject <MobilityModel> ();
477  Vector newLocation;
478  if (!mobility)
479  {
480  newLocation = GetPosition (n);
481  }
482  else
483  {
484  newLocation = mobility->GetPosition ();
485  }
486  if (!NodeHasMoved (n, newLocation))
487  {
488  continue; //Location has not changed
489  }
490  else
491  {
492  UpdatePosition (n, newLocation);
493  movedNodes.push_back (n);
494  }
495  }
496  return movedNodes;
497 }
498 
499 int
500 AnimationInterface::WriteN (const std::string& st, FILE * f)
501 {
502  if (!f)
503  {
504  return 0;
505  }
506  if (m_writeCallback)
507  {
508  m_writeCallback (st.c_str ());
509  }
510  return WriteN (st.c_str (), st.length (), f);
511 }
512 
513 int
514 AnimationInterface::WriteN (const char* data, uint32_t count, FILE * f)
515 {
516  if (!f)
517  {
518  return 0;
519  }
520  // Write count bytes to h from data
521  uint32_t nLeft = count;
522  const char* p = data;
523  uint32_t written = 0;
524  while (nLeft)
525  {
526  int n = std::fwrite (p, 1, nLeft, f);
527  if (n <= 0)
528  {
529  return written;
530  }
531  written += n;
532  nLeft -= n;
533  p += n;
534  }
535  return written;
536 }
537 
538 void
539 AnimationInterface::WriteRoutePath (uint32_t nodeId, std::string destination, Ipv4RoutePathElements rpElements)
540 {
541  NS_LOG_INFO ("Writing Route Path From :" << nodeId << " To: " << destination.c_str ());
542  WriteXmlRp (nodeId, destination, rpElements);
543  /*for (Ipv4RoutePathElements::const_iterator i = rpElements.begin ();
544  i != rpElements.end ();
545  ++i)
546  {
547  Ipv4RoutePathElement rpElement = *i;
548  NS_LOG_INFO ("Node:" << rpElement.nodeId << "-->" << rpElement.nextHop.c_str ());
549  WriteN (GetXmlRp (rpElement.node, GetIpv4RoutingTable (n)), m_routingF);
550 
551  }
552  */
553 }
554 
555 void
556 AnimationInterface::WriteNonP2pLinkProperties (uint32_t id, std::string ipv4Address, std::string channelType)
557 {
558  WriteXmlNonP2pLinkProperties (id, ipv4Address, channelType);
559 }
560 
561 const std::vector<std::string>
562 AnimationInterface::GetElementsFromContext (const std::string& context) const
563 {
564  std::vector <std::string> elements;
565  std::size_t pos1 = 0, pos2;
566  while (pos1 != context.npos)
567  {
568  pos1 = context.find ("/",pos1);
569  pos2 = context.find ("/",pos1 + 1);
570  elements.push_back (context.substr (pos1 + 1,pos2 - (pos1 + 1)));
571  pos1 = pos2;
572  pos2 = context.npos;
573  }
574  return elements;
575 }
576 
578 AnimationInterface::GetNodeFromContext (const std::string& context) const
579 {
580  // Use "NodeList/*/ as reference
581  // where element [1] is the Node Id
582 
583  std::vector <std::string> elements = GetElementsFromContext (context);
584  Ptr <Node> n = NodeList::GetNode (atoi (elements.at (1).c_str ()));
585  NS_ASSERT (n);
586 
587  return n;
588 }
589 
592 {
593  // Use "NodeList/*/DeviceList/*/ as reference
594  // where element [1] is the Node Id
595  // element [2] is the NetDevice Id
596 
597  std::vector <std::string> elements = GetElementsFromContext (context);
598  Ptr <Node> n = GetNodeFromContext (context);
599 
600  return n->GetDevice (atoi (elements.at (3).c_str ()));
601 }
602 
603 uint64_t
605 {
606  AnimByteTag tag;
607  TypeId tid = tag.GetInstanceTypeId ();
609  bool found = false;
610  while (i.HasNext ())
611  {
612  ByteTagIterator::Item item = i.Next ();
613  if (tid == item.GetTypeId ())
614  {
615  item.GetTag (tag);
616  found = true;
617  }
618  }
619  if (found)
620  {
621  return tag.Get ();
622  }
623  else
624  {
625  return 0;
626  }
627 }
628 
629 void
631 {
632  AnimByteTag tag;
633  tag.Set (animUid);
634  p->AddByteTag (tag);
635 }
636 
637 void
638 AnimationInterface::RemainingEnergyTrace (std::string context, double previousEnergy, double currentEnergy)
639 {
641  const Ptr <const Node> node = GetNodeFromContext (context);
642  const uint32_t nodeId = node->GetId ();
643 
644  NS_LOG_INFO ("Remaining energy on one of sources on node " << nodeId << ": " << currentEnergy);
645 
646  const Ptr<EnergySource> energySource = node->GetObject<EnergySource> ();
647 
648  NS_ASSERT (energySource);
649  // Don't call GetEnergyFraction () because of recursion
650  const double energyFraction = currentEnergy / energySource->GetInitialEnergy ();
651 
652  NS_LOG_INFO ("Total energy fraction on node " << nodeId << ": " << energyFraction);
653 
654  m_nodeEnergyFraction[nodeId] = energyFraction;
655  UpdateNodeCounter (m_remainingEnergyCounterId, nodeId, energyFraction);
656 }
657 
658 void
660 {
661  const Ptr <const Node> node = GetNodeFromContext (context);
662  ++m_nodeWifiPhyTxDrop[node->GetId ()];
663 }
664 
665 void
667 {
668  const Ptr <const Node> node = GetNodeFromContext (context);
669  ++m_nodeWifiPhyRxDrop[node->GetId ()];
670 }
671 
672 void
674 {
675  const Ptr <const Node> node = GetNodeFromContext (context);
676  ++m_nodeWifiMacTx[node->GetId ()];
677 }
678 
679 void
681 {
682  const Ptr <const Node> node = GetNodeFromContext (context);
683  ++m_nodeWifiMacTxDrop[node->GetId ()];
684 }
685 
686 void
688 {
689  const Ptr <const Node> node = GetNodeFromContext (context);
690  ++m_nodeWifiMacRx[node->GetId ()];
691 }
692 
693 void
695 {
696  const Ptr <const Node> node = GetNodeFromContext (context);
697  ++m_nodeWifiMacRxDrop[node->GetId ()];
698 }
699 
700 void
702 {
703  const Ptr <const Node> node = GetNodeFromContext (context);
704  ++m_nodeLrWpanMacTx[node->GetId ()];
705 }
706 
707 void
709 {
710  const Ptr <const Node> node = GetNodeFromContext (context);
711  ++m_nodeLrWpanMacTxDrop[node->GetId ()];
712 }
713 
714 void
716 {
717  const Ptr <const Node> node = GetNodeFromContext (context);
718  ++m_nodeLrWpanMacRx[node->GetId ()];
719 }
720 
721 void
723 {
724  const Ptr <const Node> node = GetNodeFromContext (context);
725  ++m_nodeLrWpanMacRxDrop[node->GetId ()];
726 }
727 
728 void
729 AnimationInterface::Ipv4TxTrace (std::string context, Ptr<const Packet> p, Ptr<Ipv4> ipv4, uint32_t interfaceIndex)
730 {
731  const Ptr <const Node> node = GetNodeFromContext (context);
732  ++m_nodeIpv4Tx[node->GetId ()];
733 }
734 
735 void
736 AnimationInterface::Ipv4RxTrace (std::string context, Ptr<const Packet> p, Ptr<Ipv4> ipv4, uint32_t interfaceIndex)
737 {
738  const Ptr <const Node> node = GetNodeFromContext (context);
739  ++m_nodeIpv4Rx[node->GetId ()];
740 }
741 
742 void
744  const Ipv4Header & ipv4Header,
746  Ipv4L3Protocol::DropReason dropReason,
747  Ptr<Ipv4> ipv4,
748  uint32_t)
749 {
750  const Ptr <const Node> node = GetNodeFromContext (context);
751  ++m_nodeIpv4Drop[node->GetId ()];
752 }
753 
754 void
755 AnimationInterface::EnqueueTrace (std::string context,
757 {
758  const Ptr <const Node> node = GetNodeFromContext (context);
759  ++m_nodeQueueEnqueue[node->GetId ()];
760 }
761 
762 void
763 AnimationInterface::DequeueTrace (std::string context,
765 {
766  const Ptr <const Node> node = GetNodeFromContext (context);
767  ++m_nodeQueueDequeue[node->GetId ()];
768 }
769 
770 void
773 {
774  const Ptr <const Node> node = GetNodeFromContext (context);
775  ++m_nodeQueueDrop[node->GetId ()];
776 }
777 
778 void
779 AnimationInterface::DevTxTrace (std::string context,
781  Ptr<NetDevice> tx,
782  Ptr<NetDevice> rx,
783  Time txTime,
784  Time rxTime)
785 {
786  NS_LOG_FUNCTION (this);
788  NS_ASSERT (tx);
789  NS_ASSERT (rx);
790  Time now = Simulator::Now ();
791  double fbTx = now.GetSeconds ();
792  double lbTx = (now + txTime).GetSeconds ();
793  double fbRx = (now + rxTime - txTime).GetSeconds ();
794  double lbRx = (now + rxTime).GetSeconds ();
796  WriteXmlP ("p",
797  tx->GetNode ()->GetId (),
798  fbTx,
799  lbTx,
800  rx->GetNode ()->GetId (),
801  fbRx,
802  lbRx,
804 }
805 
806 void
808 {
809  NS_LOG_FUNCTION (this);
811  Ptr <NetDevice> ndev = GetNetDeviceFromContext (context);
812  NS_ASSERT (ndev);
813  UpdatePosition (ndev);
814 
815  ++gAnimUid;
816  NS_LOG_INFO (ProtocolTypeToString (protocolType).c_str () << " GenericWirelessTxTrace for packet:" << gAnimUid);
817  AddByteTag (gAnimUid, p);
818  AnimPacketInfo pktInfo (ndev, Simulator::Now ());
819  AddPendingPacket (protocolType, gAnimUid, pktInfo);
820 
821  Ptr<WifiNetDevice> netDevice = DynamicCast<WifiNetDevice> (ndev);
822  if (netDevice)
823  {
824  Mac48Address nodeAddr = netDevice->GetMac ()->GetAddress ();
825  std::ostringstream oss;
826  oss << nodeAddr;
827  Ptr <Node> n = netDevice->GetNode ();
828  NS_ASSERT (n);
829  m_macToNodeIdMap[oss.str ()] = n->GetId ();
830  NS_LOG_INFO ("Added Mac" << oss.str () << " node:" << m_macToNodeIdMap[oss.str ()]);
831  }
832  AnimUidPacketInfoMap * pendingPackets = ProtocolTypeToPendingPackets (protocolType);
833  OutputWirelessPacketTxInfo (p, pendingPackets->at (gAnimUid), gAnimUid);
834 }
835 
836 void
838 {
839  NS_LOG_FUNCTION (this);
841  Ptr <NetDevice> ndev = GetNetDeviceFromContext (context);
842  NS_ASSERT (ndev);
843  UpdatePosition (ndev);
844  uint64_t animUid = GetAnimUidFromPacket (p);
845  NS_LOG_INFO (ProtocolTypeToString (protocolType).c_str () << " for packet:" << animUid);
846  if (!IsPacketPending (animUid, protocolType))
847  {
848  NS_LOG_WARN (ProtocolTypeToString (protocolType).c_str () << " GenericWirelessRxTrace: unknown Uid");
849  return;
850  }
851  AnimUidPacketInfoMap * pendingPackets = ProtocolTypeToPendingPackets (protocolType);
852  pendingPackets->at (animUid).ProcessRxBegin (ndev, Simulator::Now ().GetSeconds ());
853  OutputWirelessPacketRxInfo (p, pendingPackets->at (animUid), animUid);
854 }
855 
856 void
858 {
859  NS_LOG_FUNCTION (this);
860  return GenericWirelessTxTrace (context, p, AnimationInterface::UAN);
861 }
862 
863 void
865 {
866  NS_LOG_FUNCTION (this);
867  return GenericWirelessRxTrace (context, p, AnimationInterface::UAN);
868 }
869 
870 void
871 AnimationInterface::WifiPhyTxBeginTrace (std::string context, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW)
872 {
873  NS_LOG_FUNCTION (this);
874  NS_UNUSED (txVector);
876  Ptr<NetDevice> ndev = GetNetDeviceFromContext (context);
877  NS_ASSERT (ndev);
878  UpdatePosition (ndev);
879 
880  AnimPacketInfo pktInfo (ndev, Simulator::Now ());
882  for (auto& psdu : psduMap)
883  {
884  for (auto& mpdu : *PeekPointer (psdu.second))
885  {
886  ++gAnimUid;
887  NS_LOG_INFO ("WifiPhyTxTrace for MPDU:" << gAnimUid);
888  AddByteTag (gAnimUid, mpdu->GetPacket ()); //the underlying MSDU/A-MSDU should be handed off
889  AddPendingPacket (WIFI, gAnimUid, pktInfo);
890  OutputWirelessPacketTxInfo (mpdu->GetProtocolDataUnit (), pendingPackets->at (gAnimUid), gAnimUid); //PDU should be considered in order to have header
891  }
892  }
893 
894  Ptr<WifiNetDevice> netDevice = DynamicCast<WifiNetDevice> (ndev);
895  if (netDevice)
896  {
897  Mac48Address nodeAddr = netDevice->GetMac ()->GetAddress ();
898  std::ostringstream oss;
899  oss << nodeAddr;
900  Ptr<Node> n = netDevice->GetNode ();
901  NS_ASSERT (n);
902  m_macToNodeIdMap[oss.str ()] = n->GetId ();
903  NS_LOG_INFO ("Added Mac" << oss.str () << " node:" << m_macToNodeIdMap[oss.str ()]);
904  }
905  else
906  {
907  NS_ABORT_MSG ("This NetDevice should be a Wi-Fi network device");
908  }
909 }
910 
911 void
913 {
914  NS_LOG_FUNCTION (this);
916  Ptr <NetDevice> ndev = GetNetDeviceFromContext (context);
917  NS_ASSERT (ndev);
918  UpdatePosition (ndev);
919  uint64_t animUid = GetAnimUidFromPacket (p);
920  NS_LOG_INFO ("Wifi RxBeginTrace for packet: " << animUid);
922  {
923  NS_ASSERT_MSG (false, "WifiPhyRxBeginTrace: unknown Uid");
924  std::ostringstream oss;
925  WifiMacHeader hdr;
926  if (!p->PeekHeader (hdr))
927  {
928  NS_LOG_WARN ("WifiMacHeader not present");
929  return;
930  }
931  oss << hdr.GetAddr2 ();
932  if (m_macToNodeIdMap.find (oss.str ()) == m_macToNodeIdMap.end ())
933  {
934  NS_LOG_WARN ("Transmitter Mac address " << oss.str () << " never seen before. Skipping");
935  return;
936  }
937  Ptr <Node> txNode = NodeList::GetNode (m_macToNodeIdMap[oss.str ()]);
938  UpdatePosition (txNode);
939  AnimPacketInfo pktInfo (0, Simulator::Now (), m_macToNodeIdMap[oss.str ()]);
940  AddPendingPacket (AnimationInterface::WIFI, animUid, pktInfo);
941  NS_LOG_WARN ("WifiPhyRxBegin: unknown Uid, but we are adding a wifi packet");
942  }
944  m_pendingWifiPackets[animUid].ProcessRxBegin (ndev, Simulator::Now ().GetSeconds ());
945  OutputWirelessPacketRxInfo (p, m_pendingWifiPackets[animUid], animUid);
946 }
947 
948 void
951 {
952  NS_LOG_FUNCTION (this);
954 
955  Ptr <NetDevice> ndev = GetNetDeviceFromContext (context);
956  NS_ASSERT (ndev);
957  Ptr<LrWpanNetDevice> netDevice = DynamicCast<LrWpanNetDevice> (ndev);
958 
959  Ptr <Node> n = ndev->GetNode ();
960  NS_ASSERT (n);
961 
962  UpdatePosition (n);
963 
964  LrWpanMacHeader hdr;
965  if (!p->PeekHeader (hdr))
966  {
967  NS_LOG_WARN ("LrWpanMacHeader not present");
968  return;
969  }
970 
971  std::ostringstream oss;
972  if (hdr.GetSrcAddrMode () == 2)
973  {
974  Mac16Address nodeAddr = netDevice->GetMac ()->GetShortAddress ();
975  oss << nodeAddr;
976  }
977  else if (hdr.GetSrcAddrMode () == 3)
978  {
979  Mac64Address nodeAddr = netDevice->GetMac ()->GetExtendedAddress ();
980  oss << nodeAddr;
981  }
982  else
983  {
984  NS_LOG_WARN ("LrWpanMacHeader without source address");
985  return;
986  }
987  m_macToNodeIdMap[oss.str ()] = n->GetId ();
988  NS_LOG_INFO ("Added Mac" << oss.str () << " node:" << m_macToNodeIdMap[oss.str ()]);
989 
990  ++gAnimUid;
991  NS_LOG_INFO ("LrWpan TxBeginTrace for packet:" << gAnimUid);
992  AddByteTag (gAnimUid, p);
993 
994  AnimPacketInfo pktInfo (ndev, Simulator::Now ());
996 
998 }
999 
1000 void
1003 {
1004  NS_LOG_FUNCTION (this);
1006  Ptr <NetDevice> ndev = GetNetDeviceFromContext (context);
1007  NS_ASSERT (ndev);
1008  Ptr <Node> n = ndev->GetNode ();
1009  NS_ASSERT (n);
1010 
1011  AnimByteTag tag;
1012  if (!p->FindFirstMatchingByteTag (tag))
1013  {
1014  return;
1015  }
1016 
1017  uint64_t animUid = GetAnimUidFromPacket (p);
1018  NS_LOG_INFO ("LrWpan RxBeginTrace for packet:" << animUid);
1020  {
1021  NS_LOG_WARN ("LrWpanPhyRxBeginTrace: unknown Uid - most probably it's an ACK.");
1022  }
1023 
1024  UpdatePosition (n);
1025  m_pendingLrWpanPackets[animUid].ProcessRxBegin (ndev, Simulator::Now ().GetSeconds ());
1026  OutputWirelessPacketRxInfo (p, m_pendingLrWpanPackets[animUid], animUid);
1027 }
1028 
1029 void
1031 {
1032  NS_LOG_FUNCTION (this);
1033  return GenericWirelessTxTrace (context, p, AnimationInterface::WAVE);
1034 }
1035 
1036 void
1038 {
1039  NS_LOG_FUNCTION (this);
1041  Ptr <NetDevice> ndev = GetNetDeviceFromContext (context);
1042  NS_ASSERT (ndev);
1043  UpdatePosition (ndev);
1044  uint64_t animUid = GetAnimUidFromPacket (p);
1045  NS_LOG_INFO ("Wave RxBeginTrace for packet:" << animUid);
1046  if (!IsPacketPending (animUid, AnimationInterface::WAVE))
1047  {
1048  NS_ASSERT_MSG (false, "WavePhyRxBeginTrace: unknown Uid");
1049  std::ostringstream oss;
1050  WifiMacHeader hdr;
1051  if (!p->PeekHeader (hdr))
1052  {
1053  NS_LOG_WARN ("WaveMacHeader not present");
1054  return;
1055  }
1056  oss << hdr.GetAddr2 ();
1057  if (m_macToNodeIdMap.find (oss.str ()) == m_macToNodeIdMap.end ())
1058  {
1059  NS_LOG_WARN ("Transmitter Mac address " << oss.str () << " never seen before. Skipping");
1060  return;
1061  }
1062  Ptr <Node> txNode = NodeList::GetNode (m_macToNodeIdMap[oss.str ()]);
1063  UpdatePosition (txNode);
1064  AnimPacketInfo pktInfo (0, Simulator::Now (), m_macToNodeIdMap[oss.str ()]);
1065  AddPendingPacket (AnimationInterface::WAVE, animUid, pktInfo);
1066  NS_LOG_WARN ("WavePhyRxBegin: unknown Uid, but we are adding a wave packet");
1067  }
1069  m_pendingWavePackets[animUid].ProcessRxBegin (ndev, Simulator::Now ().GetSeconds ());
1070  OutputWirelessPacketRxInfo (p, m_pendingWavePackets[animUid], animUid);
1071 }
1072 
1073 
1074 void
1076 {
1077  NS_LOG_FUNCTION (this);
1079 }
1080 
1081 
1082 void
1084 {
1085  NS_LOG_FUNCTION (this);
1087 }
1088 
1089 void
1091 {
1092  NS_LOG_FUNCTION (this);
1093  return GenericWirelessTxTrace (context, p, AnimationInterface::LTE);
1094 }
1095 
1096 void
1098 {
1099  NS_LOG_FUNCTION (this);
1100  return GenericWirelessRxTrace (context, p, AnimationInterface::LTE);
1101 }
1102 
1103 void
1105 {
1106  NS_LOG_FUNCTION (this);
1108  if (!pb)
1109  {
1110  NS_LOG_WARN ("pb == 0. Not yet supported");
1111  return;
1112  }
1113  context = "/" + context;
1114  Ptr <NetDevice> ndev = GetNetDeviceFromContext (context);
1115  NS_ASSERT (ndev);
1116  UpdatePosition (ndev);
1117 
1118  std::list <Ptr <Packet> > pbList = pb->GetPackets ();
1119  for (std::list <Ptr <Packet> >::iterator i = pbList.begin ();
1120  i != pbList.end ();
1121  ++i)
1122  {
1123  Ptr <Packet> p = *i;
1124  ++gAnimUid;
1125  NS_LOG_INFO ("LteSpectrumPhyTxTrace for packet:" << gAnimUid);
1126  AnimPacketInfo pktInfo (ndev, Simulator::Now ());
1127  AddByteTag (gAnimUid, p);
1129  OutputWirelessPacketTxInfo (p, pktInfo, gAnimUid);
1130  }
1131 }
1132 
1133 void
1135 {
1136  NS_LOG_FUNCTION (this);
1138  if (!pb)
1139  {
1140  NS_LOG_WARN ("pb == 0. Not yet supported");
1141  return;
1142  }
1143  context = "/" + context;
1144  Ptr <NetDevice> ndev = GetNetDeviceFromContext (context);
1145  NS_ASSERT (ndev);
1146  UpdatePosition (ndev);
1147 
1148  std::list <Ptr <Packet> > pbList = pb->GetPackets ();
1149  for (std::list <Ptr <Packet> >::iterator i = pbList.begin ();
1150  i != pbList.end ();
1151  ++i)
1152  {
1153  Ptr <Packet> p = *i;
1154  uint64_t animUid = GetAnimUidFromPacket (p);
1155  NS_LOG_INFO ("LteSpectrumPhyRxTrace for packet:" << gAnimUid);
1156  if (!IsPacketPending (animUid, AnimationInterface::LTE))
1157  {
1158  NS_LOG_WARN ("LteSpectrumPhyRxTrace: unknown Uid");
1159  return;
1160  }
1161  AnimPacketInfo& pktInfo = m_pendingLtePackets[animUid];
1162  pktInfo.ProcessRxBegin (ndev, Simulator::Now ().GetSeconds ());
1163  OutputWirelessPacketRxInfo (p, pktInfo, animUid);
1164  }
1165 }
1166 
1167 void
1169 {
1170  NS_LOG_FUNCTION (this);
1172  Ptr <NetDevice> ndev = GetNetDeviceFromContext (context);
1173  NS_ASSERT (ndev);
1174  UpdatePosition (ndev);
1175  ++gAnimUid;
1176  NS_LOG_INFO ("CsmaPhyTxBeginTrace for packet:" << gAnimUid);
1177  AddByteTag (gAnimUid, p);
1178  UpdatePosition (ndev);
1179  AnimPacketInfo pktInfo (ndev, Simulator::Now ());
1181 
1182 
1183 }
1184 
1185 void
1187 {
1188  NS_LOG_FUNCTION (this);
1190  Ptr <NetDevice> ndev = GetNetDeviceFromContext (context);
1191  NS_ASSERT (ndev);
1192  UpdatePosition (ndev);
1193  uint64_t animUid = GetAnimUidFromPacket (p);
1194  NS_LOG_INFO ("CsmaPhyTxEndTrace for packet:" << animUid);
1195  if (!IsPacketPending (animUid, AnimationInterface::CSMA))
1196  {
1197  NS_LOG_WARN ("CsmaPhyTxEndTrace: unknown Uid");
1198  NS_FATAL_ERROR ("CsmaPhyTxEndTrace: unknown Uid");
1199  AnimPacketInfo pktInfo (ndev, Simulator::Now ());
1200  AddPendingPacket (AnimationInterface::CSMA, animUid, pktInfo);
1201  NS_LOG_WARN ("Unknown Uid, but adding Csma Packet anyway");
1202  }
1204  AnimPacketInfo& pktInfo = m_pendingCsmaPackets[animUid];
1205  pktInfo.m_lbTx = Simulator::Now ().GetSeconds ();
1206 }
1207 
1208 void
1210 {
1211  NS_LOG_FUNCTION (this);
1213  Ptr <NetDevice> ndev = GetNetDeviceFromContext (context);
1214  NS_ASSERT (ndev);
1215  UpdatePosition (ndev);
1216  uint64_t animUid = GetAnimUidFromPacket (p);
1217  if (!IsPacketPending (animUid, AnimationInterface::CSMA))
1218  {
1219  NS_LOG_WARN ("CsmaPhyRxEndTrace: unknown Uid");
1220  return;
1221  }
1223  AnimPacketInfo& pktInfo = m_pendingCsmaPackets[animUid];
1224  pktInfo.ProcessRxBegin (ndev, Simulator::Now ().GetSeconds ());
1225  NS_LOG_INFO ("CsmaPhyRxEndTrace for packet:" << animUid);
1226  NS_LOG_INFO ("CsmaPhyRxEndTrace for packet:" << animUid << " complete");
1227  OutputCsmaPacket (p, pktInfo);
1228 }
1229 
1230 void
1233 {
1234  NS_LOG_FUNCTION (this);
1236  Ptr <NetDevice> ndev = GetNetDeviceFromContext (context);
1237  NS_ASSERT (ndev);
1238  uint64_t animUid = GetAnimUidFromPacket (p);
1239  if (!IsPacketPending (animUid, AnimationInterface::CSMA))
1240  {
1241  NS_LOG_WARN ("CsmaMacRxTrace: unknown Uid");
1242  return;
1243  }
1245  AnimPacketInfo& pktInfo = m_pendingCsmaPackets[animUid];
1246  NS_LOG_INFO ("MacRxTrace for packet:" << animUid << " complete");
1247  OutputCsmaPacket (p, pktInfo);
1248 }
1249 
1250 void
1252 {
1254  uint32_t nodeId = 0;
1255  if (pktInfo.m_txnd)
1256  {
1257  nodeId = pktInfo.m_txnd->GetNode ()->GetId ();
1258  }
1259  else
1260  {
1261  nodeId = pktInfo.m_txNodeId;
1262  }
1263  WriteXmlPRef (animUid, nodeId, pktInfo.m_fbTx, m_enablePacketMetadata ? GetPacketMetadata (p) : "");
1264 }
1265 
1266 void
1268 {
1270  uint32_t rxId = pktInfo.m_rxnd->GetNode ()->GetId ();
1271  WriteXmlP (animUid, "wpr", rxId, pktInfo.m_fbRx, pktInfo.m_lbRx);
1272 }
1273 
1274 void
1276 {
1278  NS_ASSERT (pktInfo.m_txnd);
1279  uint32_t nodeId = pktInfo.m_txnd->GetNode ()->GetId ();
1280  uint32_t rxId = pktInfo.m_rxnd->GetNode ()->GetId ();
1281 
1282  WriteXmlP ("p",
1283  nodeId,
1284  pktInfo.m_fbTx,
1285  pktInfo.m_lbTx,
1286  rxId,
1287  pktInfo.m_fbRx,
1288  pktInfo.m_lbRx,
1290 }
1291 
1292 void
1293 AnimationInterface::AddPendingPacket (ProtocolType protocolType, uint64_t animUid, AnimPacketInfo pktInfo)
1294 {
1295  AnimUidPacketInfoMap * pendingPackets = ProtocolTypeToPendingPackets (protocolType);
1296  NS_ASSERT (pendingPackets);
1297  pendingPackets->insert (AnimUidPacketInfoMap::value_type (animUid, pktInfo));
1298 }
1299 
1300 bool
1302 {
1303  AnimUidPacketInfoMap * pendingPackets = ProtocolTypeToPendingPackets (protocolType);
1304  NS_ASSERT (pendingPackets);
1305  return (pendingPackets->find (animUid) != pendingPackets->end ());
1306 }
1307 
1308 void
1310 {
1311  AnimUidPacketInfoMap * pendingPackets = ProtocolTypeToPendingPackets (protocolType);
1312  NS_ASSERT (pendingPackets);
1313  if (pendingPackets->empty ())
1314  {
1315  return;
1316  }
1317  std::vector <uint64_t> purgeList;
1318  for (AnimUidPacketInfoMap::iterator i = pendingPackets->begin ();
1319  i != pendingPackets->end ();
1320  ++i)
1321  {
1322 
1323  AnimPacketInfo pktInfo = i->second;
1324  double delta = (Simulator::Now ().GetSeconds () - pktInfo.m_fbTx);
1325  if (delta > PURGE_INTERVAL)
1326  {
1327  purgeList.push_back (i->first);
1328  }
1329  }
1330  for (std::vector <uint64_t>::iterator i = purgeList.begin ();
1331  i != purgeList.end ();
1332  ++i)
1333  {
1334  pendingPackets->erase (*i);
1335  }
1336 }
1337 
1340 {
1341  AnimUidPacketInfoMap * pendingPackets = 0;
1342  switch (protocolType)
1343  {
1345  {
1346  pendingPackets = &m_pendingWifiPackets;
1347  break;
1348  }
1350  {
1351  pendingPackets = &m_pendingUanPackets;
1352  break;
1353  }
1355  {
1356  pendingPackets = &m_pendingCsmaPackets;
1357  break;
1358  }
1360  {
1361  pendingPackets = &m_pendingWimaxPackets;
1362  break;
1363  }
1365  {
1366  pendingPackets = &m_pendingLtePackets;
1367  break;
1368  }
1370  {
1371  pendingPackets = &m_pendingLrWpanPackets;
1372  break;
1373  }
1375  {
1376  pendingPackets = &m_pendingWavePackets;
1377  break;
1378  }
1379  }
1380  return pendingPackets;
1381 
1382 }
1383 
1384 std::string
1386 {
1387  std::string result = "Unknown";
1388  switch (protocolType)
1389  {
1391  {
1392  result = "WIFI";
1393  break;
1394  }
1396  {
1397  result = "UAN";
1398  break;
1399  }
1401  {
1402  result = "CSMA";
1403  break;
1404  }
1406  {
1407  result = "WIMAX";
1408  break;
1409  }
1411  {
1412  result = "LTE";
1413  break;
1414  }
1416  {
1417  result = "LRWPAN";
1418  break;
1419  }
1421  {
1422  result = "WAVE";
1423  break;
1424  }
1425  }
1426  return result;
1427 }
1428 
1429 // Counters
1430 
1431 std::string
1433 {
1434  std::string typeString = "unknown";
1435  switch (counterType)
1436  {
1437  case UINT32_COUNTER:
1438  {
1439  typeString = "UINT32";
1440  break;
1441  }
1442  case DOUBLE_COUNTER:
1443  {
1444  typeString = "DOUBLE";
1445  break;
1446  }
1447  }
1448  return typeString;
1449 }
1450 
1451 // General
1452 
1453 std::string
1455 {
1456  std::ostringstream oss;
1457  p->Print (oss);
1458  return oss.str ();
1459 }
1460 
1461 uint64_t
1463 {
1464  return m_currentPktCount;
1465 }
1466 
1467 void
1469 {
1470  m_started = false;
1471  NS_LOG_INFO ("Stopping Animation");
1473  if (m_f)
1474  {
1475  // Terminate the anim element
1476  WriteXmlClose ("anim");
1477  std::fclose (m_f);
1478  m_f = 0;
1479  }
1480  if (onlyAnimation)
1481  {
1482  return;
1483  }
1484  if (m_routingF)
1485  {
1486  WriteXmlClose ("anim", true);
1487  std::fclose (m_routingF);
1488  m_routingF = 0;
1489  }
1490 }
1491 
1492 void
1494 {
1495  m_currentPktCount = 0;
1496  m_started = true;
1498  WriteXmlAnim ();
1499  WriteNodes ();
1500  WriteNodeColors ();
1502  WriteIpv4Addresses ();
1503  WriteIpv6Addresses ();
1504  WriteNodeSizes ();
1505  WriteNodeEnergies ();
1506  if (!restart)
1507  {
1509  ConnectCallbacks ();
1510  }
1511 }
1512 
1513 void
1514 AnimationInterface::AddToIpv4AddressNodeIdTable (std::string ipv4Address, uint32_t nodeId)
1515 {
1516  m_ipv4ToNodeIdMap[ipv4Address] = nodeId;
1517  m_nodeIdIpv4Map.insert (NodeIdIpv4Pair (nodeId, ipv4Address));
1518 }
1519 
1520 void
1521 AnimationInterface::AddToIpv4AddressNodeIdTable (std::vector<std::string> ipv4Addresses, uint32_t nodeId)
1522 {
1523  for (std::vector<std::string>::const_iterator i = ipv4Addresses.begin ();
1524  i != ipv4Addresses.end ();
1525  ++i)
1526  {
1527  AddToIpv4AddressNodeIdTable (*i, nodeId);
1528  }
1529 }
1530 
1531 void
1532 AnimationInterface::AddToIpv6AddressNodeIdTable (std::string ipv6Address, uint32_t nodeId)
1533 {
1534  m_ipv6ToNodeIdMap[ipv6Address] = nodeId;
1535  m_nodeIdIpv6Map.insert (NodeIdIpv6Pair (nodeId, ipv6Address));
1536 }
1537 
1538 void
1539 AnimationInterface::AddToIpv6AddressNodeIdTable (std::vector<std::string> ipv6Addresses, uint32_t nodeId)
1540 {
1541  for (std::vector<std::string>::const_iterator i = ipv6Addresses.begin ();
1542  i != ipv6Addresses.end ();
1543  ++i)
1544  {
1545  AddToIpv6AddressNodeIdTable (*i, nodeId);
1546  }
1547 }
1548 
1549 // Callbacks
1550 void
1552 {
1553 
1554  Ptr<LteEnbPhy> lteEnbPhy = nd->GetPhy ();
1555  Ptr<LteSpectrumPhy> dlPhy = lteEnbPhy->GetDownlinkSpectrumPhy ();
1556  Ptr<LteSpectrumPhy> ulPhy = lteEnbPhy->GetUplinkSpectrumPhy ();
1557  std::ostringstream oss;
1558  //NodeList/*/DeviceList/*/
1559  oss << "NodeList/" << n->GetId () << "/DeviceList/" << devIndex << "/";
1560  if (dlPhy)
1561  {
1562  dlPhy->TraceConnect ("TxStart", oss.str (), MakeCallback (&AnimationInterface::LteSpectrumPhyTxStart, this));
1563  dlPhy->TraceConnect ("RxStart", oss.str (), MakeCallback (&AnimationInterface::LteSpectrumPhyRxStart, this));
1564  }
1565  if (ulPhy)
1566  {
1567  ulPhy->TraceConnect ("TxStart", oss.str (), MakeCallback (&AnimationInterface::LteSpectrumPhyTxStart, this));
1568  ulPhy->TraceConnect ("RxStart", oss.str (), MakeCallback (&AnimationInterface::LteSpectrumPhyRxStart, this));
1569  }
1570 }
1571 
1572 
1573 
1574 void
1576 {
1577 
1578  Ptr<LteUePhy> lteUePhy = nd->GetPhy ();
1579  Ptr<LteSpectrumPhy> dlPhy = lteUePhy->GetDownlinkSpectrumPhy ();
1580  Ptr<LteSpectrumPhy> ulPhy = lteUePhy->GetUplinkSpectrumPhy ();
1581  std::ostringstream oss;
1582  //NodeList/*/DeviceList/*/
1583  oss << "NodeList/" << n->GetId () << "/DeviceList/" << devIndex << "/";
1584  if (dlPhy)
1585  {
1586  dlPhy->TraceConnect ("TxStart", oss.str (), MakeCallback (&AnimationInterface::LteSpectrumPhyTxStart, this));
1587  dlPhy->TraceConnect ("RxStart", oss.str (), MakeCallback (&AnimationInterface::LteSpectrumPhyRxStart, this));
1588  }
1589  if (ulPhy)
1590  {
1591  ulPhy->TraceConnect ("TxStart", oss.str (), MakeCallback (&AnimationInterface::LteSpectrumPhyTxStart, this));
1592  ulPhy->TraceConnect ("RxStart", oss.str (), MakeCallback (&AnimationInterface::LteSpectrumPhyRxStart, this));
1593  }
1594 }
1595 
1596 void
1598 {
1599 
1600  for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
1601  {
1602  Ptr<Node> n = *i;
1603  NS_ASSERT (n);
1604  uint32_t nDevices = n->GetNDevices ();
1605  for (uint32_t devIndex = 0; devIndex < nDevices; ++devIndex)
1606  {
1607  Ptr <NetDevice> nd = n->GetDevice (devIndex);
1608  if (!nd)
1609  {
1610  continue;
1611  }
1612  Ptr<LteUeNetDevice> lteUeNetDevice = DynamicCast<LteUeNetDevice> (nd);
1613  if (lteUeNetDevice)
1614  {
1615  ConnectLteUe (n, lteUeNetDevice, devIndex);
1616  continue;
1617  }
1618  Ptr<LteEnbNetDevice> lteEnbNetDevice = DynamicCast<LteEnbNetDevice> (nd);
1619  if (lteEnbNetDevice)
1620  {
1621  ConnectLteEnb (n, lteEnbNetDevice, devIndex);
1622  }
1623  }
1624 
1625  }
1626 }
1627 
1628 void
1630 {
1631  // Connect the callbacks
1632  Config::ConnectFailSafe ("/ChannelList/*/TxRxPointToPoint",
1634  Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxPsduBegin",
1636  Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxBegin",
1638  Config::ConnectWithoutContextFailSafe ("/NodeList/*/$ns3::MobilityModel/CourseChange",
1640  Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::WimaxNetDevice/Tx",
1642  Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::WimaxNetDevice/Rx",
1644  Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::LteNetDevice/Tx",
1646  Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::LteNetDevice/Rx",
1648  Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::CsmaNetDevice/PhyTxBegin",
1650  Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::CsmaNetDevice/PhyTxEnd",
1652  Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::CsmaNetDevice/PhyRxEnd",
1654  Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::CsmaNetDevice/MacRx",
1656  Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::UanNetDevice/Phy/PhyTxBegin",
1658  Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::UanNetDevice/Phy/PhyRxBegin",
1660  Config::ConnectFailSafe ("/NodeList/*/$ns3::BasicEnergySource/RemainingEnergy",
1662 
1663  ConnectLte ();
1664 
1665  Config::ConnectFailSafe ("/NodeList/*/$ns3::Ipv4L3Protocol/Tx",
1667  Config::ConnectFailSafe ("/NodeList/*/$ns3::Ipv4L3Protocol/Rx",
1669  Config::ConnectFailSafe ("/NodeList/*/$ns3::Ipv4L3Protocol/Drop",
1671 
1672  // Queue Enqueues
1673 
1674  Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::AlohaNoackNetDevice/Queue/Enqueue",
1676  Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::CsmaNetDevice/TxQueue/Enqueue",
1678  Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::PointToPointNetDevice/TxQueue/Enqueue",
1680 
1681  // Queue Dequeues
1682 
1683  Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::AlohaNoackNetDevice/Queue/Dequeue",
1685  Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::CsmaNetDevice/TxQueue/Dequeue",
1687  Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::PointToPointNetDevice/TxQueue/Dequeue",
1689 
1690  // Queue Drops
1691 
1692  Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::AlohaNoackNetDevice/Queue/Drop",
1694  Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::CsmaNetDevice/TxQueue/Drop",
1696  Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::PointToPointNetDevice/TxQueue/Drop",
1698 
1699 
1700  // Wifi Mac
1701  Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/MacTx",
1703  Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/MacTxDrop",
1705  Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/MacRx",
1707  Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/MacRxDrop",
1709 
1710  // Wifi Phy
1711  Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxDrop",
1713  Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxDrop",
1715 
1716  // LrWpan
1717  Config::ConnectFailSafe ("NodeList/*/DeviceList/*/$ns3::LrWpanNetDevice/Phy/PhyTxBegin",
1719  Config::ConnectFailSafe ("NodeList/*/DeviceList/*/$ns3::LrWpanNetDevice/Phy/PhyRxBegin",
1721  Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::LrWpanNetDevice/Mac/MacTx",
1723  Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::LrWpanNetDevice/Mac/MacTxDrop",
1725  Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::LrWpanNetDevice/Mac/MacRx",
1727  Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::LrWpanNetDevice/Mac/MacRxDrop",
1729 
1730  // Wave
1731  Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::WaveNetDevice/PhyEntities/*/$ns3::WifiPhy/PhyTxBegin",
1733  Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::WaveNetDevice/PhyEntities/*/$ns3::WifiPhy/PhyRxBegin",
1735 }
1736 
1737 Vector
1739 {
1740  Ptr<MobilityModel> loc = n->GetObject<MobilityModel> ();
1741  if (loc)
1742  {
1743  m_nodeLocation[n->GetId ()] = loc->GetPosition ();
1744  }
1745  else
1746  {
1747  NS_LOG_UNCOND ( "AnimationInterface WARNING:Node:" << n->GetId () << " Does not have a mobility model. Use SetConstantPosition if it is stationary");
1748  Ptr<UniformRandomVariable> x = CreateObject<UniformRandomVariable> ();
1749  x->SetAttribute ("Min", DoubleValue (0));
1750  x->SetAttribute ("Max", DoubleValue (100));
1751  Ptr<UniformRandomVariable> y = CreateObject<UniformRandomVariable> ();
1752  y->SetAttribute ("Min", DoubleValue (0));
1753  y->SetAttribute ("Max", DoubleValue (100));
1754  m_nodeLocation[n->GetId ()] = Vector (int (x->GetValue ()), int (y->GetValue ()), 0);
1755  }
1756  return m_nodeLocation[n->GetId ()];
1757 }
1758 
1759 Vector
1761 {
1762  m_nodeLocation[n->GetId ()] = v;
1763  return v;
1764 }
1765 
1766 Vector
1768 {
1769  Ptr <Node> n = ndev->GetNode ();
1770  NS_ASSERT (n);
1771  return UpdatePosition (n);
1772 }
1773 
1774 Vector
1776 {
1777  if (m_nodeLocation.find (n->GetId ()) == m_nodeLocation.end ())
1778  {
1779  NS_FATAL_ERROR ("Node:" << n->GetId () << " not found in Location table");
1780  }
1781  return m_nodeLocation[n->GetId ()];
1782 }
1783 
1784 
1785 std::string
1787 {
1788  Address nodeAddr = nd->GetAddress ();
1789  std::ostringstream oss;
1790  oss << nodeAddr;
1791  return oss.str ().substr (6); // Skip the first 6 chars to get the Mac
1792 }
1793 
1794 std::string
1796 {
1797  Ptr<Ipv4> ipv4 = NodeList::GetNode (nd->GetNode ()->GetId ())->GetObject <Ipv4> ();
1798  if (!ipv4)
1799  {
1800  NS_LOG_WARN ("Node: " << nd->GetNode ()->GetId () << " No ipv4 object found");
1801  return "0.0.0.0";
1802  }
1803  int32_t ifIndex = ipv4->GetInterfaceForDevice (nd);
1804  if (ifIndex == -1)
1805  {
1806  NS_LOG_WARN ("Node :" << nd->GetNode ()->GetId () << " Could not find index of NetDevice");
1807  return "0.0.0.0";
1808  }
1809  Ipv4InterfaceAddress addr = ipv4->GetAddress (ifIndex, 0);
1810  std::ostringstream oss;
1811  oss << addr.GetLocal ();
1812  return oss.str ();
1813 }
1814 
1815 std::string
1817 {
1818  Ptr<Ipv6> ipv6 = NodeList::GetNode (nd->GetNode ()->GetId ())->GetObject <Ipv6> ();
1819  if (!ipv6)
1820  {
1821  NS_LOG_WARN ("Node: " << nd->GetNode ()->GetId () << " No ipv4 object found");
1822  return "::";
1823  }
1824  int32_t ifIndex = ipv6->GetInterfaceForDevice (nd);
1825  if (ifIndex == -1)
1826  {
1827  NS_LOG_WARN ("Node :" << nd->GetNode ()->GetId () << " Could not find index of NetDevice");
1828  return "::";
1829  }
1830  bool nonLinkLocalFound = false;
1831  uint32_t nAddresses = ipv6->GetNAddresses (ifIndex);
1832  Ipv6InterfaceAddress addr;
1833  for (uint32_t addressIndex = 0; addressIndex < nAddresses; ++addressIndex)
1834  {
1835  addr = ipv6->GetAddress (ifIndex, addressIndex);
1836  if (!addr.GetAddress ().IsLinkLocal ())
1837  {
1838  nonLinkLocalFound = true;
1839  break;
1840  }
1841  }
1842  if (!nonLinkLocalFound)
1843  {
1844  addr = ipv6->GetAddress (ifIndex, 0);
1845  }
1846  std::ostringstream oss;
1847  oss << addr.GetAddress ();
1848  return oss.str ();
1849 }
1850 
1851 
1852 
1853 std::vector<std::string>
1855 {
1856  std::vector<std::string> ipv4Addresses;
1857  Ptr<Ipv4> ipv4 = NodeList::GetNode (nd->GetNode ()->GetId ())->GetObject <Ipv4> ();
1858  if (!ipv4)
1859  {
1860  NS_LOG_WARN ("Node: " << nd->GetNode ()->GetId () << " No ipv4 object found");
1861  return ipv4Addresses;
1862  }
1863  int32_t ifIndex = ipv4->GetInterfaceForDevice (nd);
1864  if (ifIndex == -1)
1865  {
1866  NS_LOG_WARN ("Node :" << nd->GetNode ()->GetId () << " Could not find index of NetDevice");
1867  return ipv4Addresses;
1868  }
1869  for (uint32_t index = 0; index < ipv4->GetNAddresses (ifIndex); ++index)
1870  {
1871  Ipv4InterfaceAddress addr = ipv4->GetAddress (ifIndex, index);
1872  std::ostringstream oss;
1873  oss << addr.GetLocal ();
1874  ipv4Addresses.push_back (oss.str ());
1875  }
1876  return ipv4Addresses;
1877 }
1878 
1879 std::vector<std::string>
1881 {
1882  std::vector<std::string> ipv6Addresses;
1883  Ptr<Ipv6> ipv6 = NodeList::GetNode (nd->GetNode ()->GetId ())->GetObject <Ipv6> ();
1884  if (!ipv6)
1885  {
1886  NS_LOG_WARN ("Node: " << nd->GetNode ()->GetId () << " No ipv6 object found");
1887  return ipv6Addresses;
1888  }
1889  int32_t ifIndex = ipv6->GetInterfaceForDevice (nd);
1890  if (ifIndex == -1)
1891  {
1892  NS_LOG_WARN ("Node :" << nd->GetNode ()->GetId () << " Could not find index of NetDevice");
1893  return ipv6Addresses;
1894  }
1895  for (uint32_t index = 0; index < ipv6->GetNAddresses (ifIndex); ++index)
1896  {
1897  Ipv6InterfaceAddress addr = ipv6->GetAddress (ifIndex, index);
1898  std::ostringstream oss;
1899  oss << addr.GetAddress ();
1900  ipv6Addresses.push_back (oss.str ());
1901  }
1902  return ipv6Addresses;
1903 }
1904 
1905 
1906 void
1908 {
1909  for (NodeIdIpv4Map::const_iterator i = m_nodeIdIpv4Map.begin ();
1910  i != m_nodeIdIpv4Map.end ();
1911  ++i)
1912  {
1913  std::vector <std::string> ipv4Addresses;
1914  std::pair<NodeIdIpv4Map::const_iterator, NodeIdIpv4Map::const_iterator> iterPair = m_nodeIdIpv4Map.equal_range (i->first);
1915  for (NodeIdIpv4Map::const_iterator it = iterPair.first;
1916  it != iterPair.second;
1917  ++it)
1918  {
1919  ipv4Addresses.push_back (it->second);
1920  }
1921  WriteXmlIpv4Addresses (i->first, ipv4Addresses);
1922  }
1923 }
1924 
1925 void
1927 {
1928  for (NodeIdIpv6Map::const_iterator i = m_nodeIdIpv6Map.begin ();
1929  i != m_nodeIdIpv6Map.end ();
1930  i = m_nodeIdIpv6Map.upper_bound (i->first))
1931  {
1932  std::vector <std::string> ipv6Addresses;
1933  std::pair<NodeIdIpv6Map::const_iterator, NodeIdIpv6Map::const_iterator> iterPair = m_nodeIdIpv6Map.equal_range (i->first);
1934  for (NodeIdIpv6Map::const_iterator it = iterPair.first;
1935  it != iterPair.second;
1936  ++it)
1937  {
1938  ipv6Addresses.push_back (it->second);
1939  }
1940  WriteXmlIpv6Addresses (i->first, ipv6Addresses);
1941  }
1942 }
1943 
1944 void
1946 {
1947  for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
1948  {
1949  Ptr<Node> n = *i;
1950  UpdatePosition (n);
1951  uint32_t n1Id = n->GetId ();
1952  uint32_t nDev = n->GetNDevices (); // Number of devices
1953  for (uint32_t i = 0; i < nDev; ++i)
1954  {
1955  Ptr<NetDevice> dev = n->GetDevice (i);
1956  NS_ASSERT (dev);
1957  Ptr<Channel> ch = dev->GetChannel ();
1958  std::string channelType = "Unknown channel";
1959  if (ch)
1960  {
1961  channelType = ch->GetInstanceTypeId ().GetName ();
1962  }
1963  NS_LOG_DEBUG ("Got ChannelType" << channelType);
1964 
1965  if (!ch || (channelType != std::string ("ns3::PointToPointChannel")))
1966  {
1967  NS_LOG_DEBUG ("No channel can't be a p2p device");
1968  /*
1969  // Try to see if it is an LTE NetDevice, which does not return a channel
1970  if ((dev->GetInstanceTypeId ().GetName () == "ns3::LteUeNetDevice") ||
1971  (dev->GetInstanceTypeId ().GetName () == "ns3::LteEnbNetDevice")||
1972  (dev->GetInstanceTypeId ().GetName () == "ns3::VirtualNetDevice"))
1973  {
1974  WriteNonP2pLinkProperties (n->GetId (), GetIpv4Address (dev) + "~" + GetMacAddress (dev), channelType);
1975  AddToIpv4AddressNodeIdTable (GetIpv4Address (dev), n->GetId ());
1976  }
1977  */
1978  std::vector<std::string> ipv4Addresses = GetIpv4Addresses (dev);
1979  AddToIpv4AddressNodeIdTable (ipv4Addresses, n->GetId ());
1980  std::vector<std::string> ipv6Addresses = GetIpv6Addresses (dev);
1981  AddToIpv6AddressNodeIdTable (ipv6Addresses, n->GetId ());
1982  if (!ipv4Addresses.empty ())
1983  {
1984  NS_LOG_INFO ("Writing Ipv4 link");
1985  WriteNonP2pLinkProperties (n->GetId (), GetIpv4Address (dev) + "~" + GetMacAddress (dev), channelType);
1986  }
1987  else if (!ipv6Addresses.empty ())
1988  {
1989  NS_LOG_INFO ("Writing Ipv6 link");
1990  WriteNonP2pLinkProperties (n->GetId (), GetIpv6Address (dev) + "~" + GetMacAddress (dev), channelType);
1991  }
1992  continue;
1993  }
1994 
1995  else if (channelType == std::string ("ns3::PointToPointChannel"))
1996  { // Since these are duplex links, we only need to dump
1997  // if srcid < dstid
1998  std::size_t nChDev = ch->GetNDevices ();
1999  for (std::size_t j = 0; j < nChDev; ++j)
2000  {
2001  Ptr<NetDevice> chDev = ch->GetDevice (j);
2002  uint32_t n2Id = chDev->GetNode ()->GetId ();
2003  if (n1Id < n2Id)
2004  {
2005 
2006  std::vector<std::string> ipv4Addresses = GetIpv4Addresses (dev);
2007  AddToIpv4AddressNodeIdTable (ipv4Addresses, n1Id);
2008  ipv4Addresses = GetIpv4Addresses (chDev);
2009  AddToIpv4AddressNodeIdTable (ipv4Addresses, n2Id);
2010  std::vector<std::string> ipv6Addresses = GetIpv6Addresses (dev);
2011  AddToIpv6AddressNodeIdTable (ipv6Addresses, n1Id);
2012  ipv6Addresses = GetIpv6Addresses (chDev);
2013  AddToIpv6AddressNodeIdTable (ipv6Addresses, n2Id);
2014 
2015  P2pLinkNodeIdPair p2pPair;
2016  p2pPair.fromNode = n1Id;
2017  p2pPair.toNode = n2Id;
2018  if (!ipv4Addresses.empty ())
2019  {
2020  LinkProperties lp = { GetIpv4Address (dev) + "~" + GetMacAddress (dev), GetIpv4Address (chDev) + "~" + GetMacAddress (chDev), "" };
2021  m_linkProperties[p2pPair] = lp;
2022  }
2023  else if (!ipv6Addresses.empty ())
2024  {
2025  LinkProperties lp = { GetIpv6Address (dev) + "~" + GetMacAddress (dev), GetIpv6Address (chDev) + "~" + GetMacAddress (chDev), "" };
2026  m_linkProperties[p2pPair] = lp;
2027  }
2028  WriteXmlLink (n1Id, 0, n2Id);
2029  }
2030  }
2031  }
2032  }
2033  }
2034  m_linkProperties.clear ();
2035 }
2036 
2037 void
2039 {
2040  for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
2041  {
2042  Ptr<Node> n = *i;
2043  NS_LOG_INFO ("Update Position for Node: " << n->GetId ());
2044  Vector v = UpdatePosition (n);
2045  WriteXmlNode (n->GetId (), n->GetSystemId (), v.x, v.y);
2046  }
2047 }
2048 
2049 void
2051 {
2052  for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
2053  {
2054  Ptr<Node> n = *i;
2055  Rgb rgb = {255, 0, 0};
2056  if (m_nodeColors.find (n->GetId ()) == m_nodeColors.end ())
2057  {
2058  m_nodeColors[n->GetId ()] = rgb;
2059  }
2060  UpdateNodeColor (n, rgb.r, rgb.g, rgb.b);
2061  }
2062 }
2063 
2064 void
2066 {
2067  for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
2068  {
2069  Ptr<Node> n = *i;
2070  NS_LOG_INFO ("Update Size for Node: " << n->GetId ());
2071  AnimationInterface::NodeSize s = { 1, 1 };
2072  m_nodeSizes[n->GetId ()] = s;
2073  UpdateNodeSize (n->GetId (), s.width, s.height);
2074  }
2075 }
2076 
2077 void
2079 {
2081  for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
2082  {
2083  Ptr<Node> n = *i;
2084  if (NodeList::GetNode (n->GetId ())->GetObject<EnergySource> ())
2085  {
2087  }
2088  }
2089 }
2090 
2091 bool
2093 {
2094  if ((Simulator::Now () >= m_startTime)
2095  && (Simulator::Now () <= m_stopTime))
2096  {
2097  return true;
2098  }
2099  else
2100  {
2101  return false;
2102  }
2103 }
2104 
2105 void
2106 AnimationInterface::SetOutputFile (const std::string& fn, bool routing)
2107 {
2108  if (!routing && m_f)
2109  {
2110  return;
2111  }
2112  if (routing && m_routingF)
2113  {
2114  NS_FATAL_ERROR ("SetRoutingOutputFile already used once");
2115  return;
2116  }
2117 
2118  NS_LOG_INFO ("Creating new trace file:" << fn.c_str ());
2119  FILE * f = 0;
2120  f = std::fopen (fn.c_str (), "w");
2121  if (!f)
2122  {
2123  NS_FATAL_ERROR ("Unable to open output file:" << fn.c_str ());
2124  return; // Can't open output file
2125  }
2126  if (routing)
2127  {
2128  m_routingF = f;
2129  m_routingFileName = fn;
2130  }
2131  else
2132  {
2133  m_f = f;
2134  m_outputFileName = fn;
2135  }
2136  return;
2137 }
2138 
2139 void
2141 {
2142  // Start a new trace file if the current packet count exceeded nax packets per file
2145  {
2146  return;
2147  }
2148  NS_LOG_UNCOND ("Max Packets per trace file exceeded");
2149  StopAnimation (true);
2150 }
2151 
2152 std::string
2154 {
2155  return NETANIM_VERSION;
2156 }
2157 
2158 
2159 void
2161 {
2163  {
2164  NS_LOG_INFO ("TrackQueueCounters Completed");
2165  return;
2166  }
2167  for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
2168  {
2169  uint32_t nodeId = Ptr <Node> (*i)->GetId ();
2173  }
2175 }
2176 
2177 void
2179 {
2181  {
2182  NS_LOG_INFO ("TrackWifiMacCounters Completed");
2183  return;
2184  }
2185  for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
2186  {
2187  uint32_t nodeId = Ptr <Node> (*i)->GetId ();
2192  }
2194 }
2195 
2196 void
2198 {
2200  {
2201  NS_LOG_INFO ("TrackWifiPhyCounters Completed");
2202  return;
2203  }
2204  for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
2205  {
2206  uint32_t nodeId = Ptr <Node> (*i)->GetId ();
2209  }
2211 }
2212 
2213 void
2215 {
2217  {
2218  NS_LOG_INFO ("TrackIpv4L3ProtocolCounters Completed");
2219  return;
2220  }
2221  for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
2222  {
2223  uint32_t nodeId = Ptr <Node> (*i)->GetId ();
2227  }
2229 }
2230 
2231 
2232 
2233 
2234 
2235 /***** Routing-related *****/
2236 
2237 void
2239 {
2240  if (m_ipv4RouteTrackElements.empty ())
2241  {
2242  return;
2243  }
2244  for (std::vector <Ipv4RouteTrackElement>::const_iterator i = m_ipv4RouteTrackElements.begin ();
2245  i != m_ipv4RouteTrackElements.end ();
2246  ++i)
2247  {
2248  Ipv4RouteTrackElement trackElement = *i;
2249  Ptr <Node> fromNode = NodeList::GetNode (trackElement.fromNodeId);
2250  if (!fromNode)
2251  {
2252  NS_FATAL_ERROR ("Node: " << trackElement.fromNodeId << " Not found");
2253  continue;
2254  }
2255  Ptr <ns3::Ipv4> ipv4 = fromNode->GetObject <ns3::Ipv4> ();
2256  if (!ipv4)
2257  {
2258  NS_LOG_WARN ("ipv4 object not found");
2259  continue;
2260  }
2262  if (!rp)
2263  {
2264  NS_LOG_WARN ("Routing protocol object not found");
2265  continue;
2266  }
2267  NS_LOG_INFO ("Begin Track Route for: " << trackElement.destination.c_str () << " From:" << trackElement.fromNodeId);
2268  Ptr<Packet> pkt = Create<Packet> ();
2269  Ipv4Header header;
2270  header.SetDestination (Ipv4Address (trackElement.destination.c_str ()));
2271  Socket::SocketErrno sockerr;
2272  Ptr <Ipv4Route> rt = rp->RouteOutput (pkt, header, 0, sockerr);
2273  Ipv4RoutePathElements rpElements;
2274  if (!rt)
2275  {
2276  NS_LOG_INFO ("No route to :" << trackElement.destination.c_str ());
2277  Ipv4RoutePathElement elem = { trackElement.fromNodeId, "-1" };
2278  rpElements.push_back (elem);
2279  WriteRoutePath (trackElement.fromNodeId, trackElement.destination, rpElements);
2280  continue;
2281  }
2282  std::ostringstream oss;
2283  oss << rt->GetGateway ();
2284  NS_LOG_INFO ("Node:" << trackElement.fromNodeId << "-->" << rt->GetGateway ());
2285  if (rt->GetGateway () == "0.0.0.0")
2286  {
2287  Ipv4RoutePathElement elem = { trackElement.fromNodeId, "C" };
2288  rpElements.push_back (elem);
2289  if ( m_ipv4ToNodeIdMap.find (trackElement.destination) != m_ipv4ToNodeIdMap.end ())
2290  {
2291  Ipv4RoutePathElement elem2 = { m_ipv4ToNodeIdMap[trackElement.destination], "L" };
2292  rpElements.push_back (elem2);
2293  }
2294  }
2295  else if (rt->GetGateway () == "127.0.0.1")
2296  {
2297  Ipv4RoutePathElement elem = { trackElement.fromNodeId, "-1" };
2298  rpElements.push_back (elem);
2299  }
2300  else
2301  {
2302  Ipv4RoutePathElement elem = { trackElement.fromNodeId, oss.str () };
2303  rpElements.push_back (elem);
2304  }
2305  RecursiveIpv4RoutePathSearch (oss.str (), trackElement.destination, rpElements);
2306  WriteRoutePath (trackElement.fromNodeId, trackElement.destination, rpElements);
2307  }
2308 
2309 }
2310 
2311 void
2313 {
2315  {
2316  NS_LOG_INFO ("TrackIpv4Route completed");
2317  return;
2318  }
2319  if (m_routingNc.GetN ())
2320  {
2321  for (NodeContainer::Iterator i = m_routingNc.Begin (); i != m_routingNc.End (); ++i)
2322  {
2323  Ptr <Node> n = *i;
2324  WriteXmlRouting (n->GetId (), GetIpv4RoutingTable (n));
2325  }
2326  }
2327  else
2328  {
2329  for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
2330  {
2331  Ptr <Node> n = *i;
2332  WriteXmlRouting (n->GetId (), GetIpv4RoutingTable (n));
2333  }
2334  }
2337 }
2338 
2339 std::string
2341 {
2342 
2343  NS_ASSERT (n);
2344  Ptr <ns3::Ipv4> ipv4 = n->GetObject <ns3::Ipv4> ();
2345  if (!ipv4)
2346  {
2347  NS_LOG_WARN ("Node " << n->GetId () << " Does not have an Ipv4 object");
2348  return "";
2349  }
2350  std::stringstream stream;
2351  Ptr<OutputStreamWrapper> routingstream = Create<OutputStreamWrapper> (&stream);
2352  ipv4->GetRoutingProtocol ()->PrintRoutingTable (routingstream);
2353  return stream.str ();
2354 
2355 }
2356 
2357 void
2358 AnimationInterface::RecursiveIpv4RoutePathSearch (std::string from, std::string to, Ipv4RoutePathElements & rpElements)
2359 {
2360  NS_LOG_INFO ("RecursiveIpv4RoutePathSearch from:" << from.c_str () << " to:" << to.c_str ());
2361  if ((from == "0.0.0.0") || (from == "127.0.0.1"))
2362  {
2363  NS_LOG_INFO ("Got " << from.c_str () << " End recursion");
2364  return;
2365  }
2366  Ptr <Node> fromNode = NodeList::GetNode (m_ipv4ToNodeIdMap[from]);
2368  if (fromNode->GetId () == toNode->GetId ())
2369  {
2370  Ipv4RoutePathElement elem = { fromNode->GetId (), "L" };
2371  rpElements.push_back (elem);
2372  return;
2373  }
2374  if (!fromNode)
2375  {
2376  NS_FATAL_ERROR ("Node: " << m_ipv4ToNodeIdMap[from] << " Not found");
2377  return;
2378  }
2379  if (!toNode)
2380  {
2381  NS_FATAL_ERROR ("Node: " << m_ipv4ToNodeIdMap[to] << " Not found");
2382  return;
2383  }
2384  Ptr <ns3::Ipv4> ipv4 = fromNode->GetObject <ns3::Ipv4> ();
2385  if (!ipv4)
2386  {
2387  NS_LOG_WARN ("ipv4 object not found");
2388  return;
2389  }
2391  if (!rp)
2392  {
2393  NS_LOG_WARN ("Routing protocol object not found");
2394  return;
2395  }
2396  Ptr<Packet> pkt = Create<Packet> ();
2397  Ipv4Header header;
2398  header.SetDestination (Ipv4Address (to.c_str ()));
2399  Socket::SocketErrno sockerr;
2400  Ptr <Ipv4Route> rt = rp->RouteOutput (pkt, header, 0, sockerr);
2401  if (!rt)
2402  {
2403  return;
2404  }
2405  NS_LOG_DEBUG ("Node: " << fromNode->GetId () << " G:" << rt->GetGateway ());
2406  std::ostringstream oss;
2407  oss << rt->GetGateway ();
2408  if (oss.str () == "0.0.0.0" && (sockerr != Socket::ERROR_NOROUTETOHOST))
2409  {
2410  NS_LOG_INFO ("Null gw");
2411  Ipv4RoutePathElement elem = { fromNode->GetId (), "C" };
2412  rpElements.push_back (elem);
2413  if ( m_ipv4ToNodeIdMap.find (to) != m_ipv4ToNodeIdMap.end ())
2414  {
2415  Ipv4RoutePathElement elem2 = { m_ipv4ToNodeIdMap[to], "L" };
2416  rpElements.push_back (elem2);
2417  }
2418  return;
2419  }
2420  NS_LOG_INFO ("Node:" << fromNode->GetId () << "-->" << rt->GetGateway ());
2421  Ipv4RoutePathElement elem = { fromNode->GetId (), oss.str () };
2422  rpElements.push_back (elem);
2423  RecursiveIpv4RoutePathSearch (oss.str (), to, rpElements);
2424 
2425 }
2426 
2427 
2428 
2429 /***** WriteXml *****/
2430 
2431 void
2433 {
2434  AnimXmlElement element ("anim");
2435  element.AddAttribute ("ver", GetNetAnimVersion ());
2436  FILE * f = m_f;
2437  if (!routing)
2438  {
2439  element.AddAttribute ("filetype", "animation");
2440  }
2441  else
2442  {
2443  element.AddAttribute ("filetype", "routing");
2444  f = m_routingF;
2445  }
2446  WriteN (element.ToString (false) + ">\n", f);
2447 }
2448 
2449 void
2450 AnimationInterface::WriteXmlClose (std::string name, bool routing)
2451 {
2452  std::string closeString = "</" + name + ">\n";
2453  if (!routing)
2454  {
2455  WriteN (closeString, m_f);
2456  }
2457  else
2458  {
2459  WriteN (closeString, m_routingF);
2460  }
2461 }
2462 
2463 void
2464 AnimationInterface::WriteXmlNode (uint32_t id, uint32_t sysId, double locX, double locY)
2465 {
2466  AnimXmlElement element ("node");
2467  element.AddAttribute ("id", id);
2468  element.AddAttribute ("sysId", sysId);
2469  element.AddAttribute ("locX", locX);
2470  element.AddAttribute ("locY", locY);
2471  WriteN (element.ToString (), m_f);
2472 }
2473 
2474 void
2475 AnimationInterface::WriteXmlUpdateLink (uint32_t fromId, uint32_t toId, std::string linkDescription)
2476 {
2477  AnimXmlElement element ("linkupdate");
2478  element.AddAttribute ("t", Simulator::Now ().GetSeconds ());
2479  element.AddAttribute ("fromId", fromId);
2480  element.AddAttribute ("toId", toId);
2481  element.AddAttribute ("ld", linkDescription, true);
2482  WriteN (element.ToString (), m_f);
2483 }
2484 
2485 void
2486 AnimationInterface::WriteXmlLink (uint32_t fromId, uint32_t toLp, uint32_t toId)
2487 {
2488  AnimXmlElement element ("link");
2489  element.AddAttribute ("fromId", fromId);
2490  element.AddAttribute ("toId", toId);
2491 
2492  LinkProperties lprop;
2493  lprop.fromNodeDescription = "";
2494  lprop.toNodeDescription = "";
2495  lprop.linkDescription = "";
2496 
2497  P2pLinkNodeIdPair p1 = { fromId, toId };
2498  P2pLinkNodeIdPair p2 = { toId, fromId };
2499  if (m_linkProperties.find (p1) != m_linkProperties.end ())
2500  {
2501  lprop = m_linkProperties[p1];
2502  }
2503  else if (m_linkProperties.find (p2) != m_linkProperties.end ())
2504  {
2505  lprop = m_linkProperties[p2];
2506  }
2507 
2508  element.AddAttribute ("fd", lprop.fromNodeDescription, true);
2509  element.AddAttribute ("td", lprop.toNodeDescription, true);
2510  element.AddAttribute ("ld", lprop.linkDescription, true);
2511  WriteN (element.ToString (), m_f);
2512 }
2513 
2514 void
2515 AnimationInterface::WriteXmlIpv4Addresses (uint32_t nodeId, std::vector<std::string> ipv4Addresses)
2516 {
2517  AnimXmlElement element ("ip");
2518  element.AddAttribute ("n", nodeId);
2519  for (std::vector<std::string>::const_iterator i = ipv4Addresses.begin ();
2520  i != ipv4Addresses.end ();
2521  ++i)
2522  {
2523  AnimXmlElement valueElement ("address");
2524  valueElement.SetText (*i);
2525  element.AppendChild (valueElement);
2526  }
2527  WriteN (element.ToString (), m_f);
2528 }
2529 
2530 void
2531 AnimationInterface::WriteXmlIpv6Addresses (uint32_t nodeId, std::vector<std::string> ipv6Addresses)
2532 {
2533  AnimXmlElement element ("ipv6");
2534  element.AddAttribute ("n", nodeId);
2535  for (std::vector<std::string>::const_iterator i = ipv6Addresses.begin ();
2536  i != ipv6Addresses.end ();
2537  ++i)
2538  {
2539  AnimXmlElement valueElement ("address");
2540  valueElement.SetText (*i);
2541  element.AppendChild (valueElement);
2542  }
2543  WriteN (element.ToString (), m_f);
2544 }
2545 
2546 void
2547 AnimationInterface::WriteXmlRouting (uint32_t nodeId, std::string routingInfo)
2548 {
2549  AnimXmlElement element ("rt");
2550  element.AddAttribute ("t", Simulator::Now ().GetSeconds ());
2551  element.AddAttribute ("id", nodeId);
2552  element.AddAttribute ("info", routingInfo.c_str (), true);
2553  WriteN (element.ToString (), m_routingF);
2554 }
2555 
2556 void
2557 AnimationInterface::WriteXmlRp (uint32_t nodeId, std::string destination, Ipv4RoutePathElements rpElements)
2558 {
2559  std::string tagName = "rp";
2560  AnimXmlElement element (tagName, false);
2561  element.AddAttribute ("t", Simulator::Now ().GetSeconds ());
2562  element.AddAttribute ("id", nodeId);
2563  element.AddAttribute ("d", destination.c_str ());
2564  element.AddAttribute ("c", rpElements.size ());
2565  for (Ipv4RoutePathElements::const_iterator i = rpElements.begin ();
2566  i != rpElements.end ();
2567  ++i)
2568  {
2569  Ipv4RoutePathElement rpElement = *i;
2570  AnimXmlElement rpeElement ("rpe");
2571  rpeElement.AddAttribute ("n", rpElement.nodeId);
2572  rpeElement.AddAttribute ("nH", rpElement.nextHop.c_str ());
2573  element.AppendChild (rpeElement);
2574  }
2575  WriteN (element.ToString (), m_routingF);
2576 }
2577 
2578 
2579 void
2580 AnimationInterface::WriteXmlPRef (uint64_t animUid, uint32_t fId, double fbTx, std::string metaInfo)
2581 {
2582  AnimXmlElement element ("pr");
2583  element.AddAttribute ("uId", animUid);
2584  element.AddAttribute ("fId", fId);
2585  element.AddAttribute ("fbTx", fbTx);
2586  if (!metaInfo.empty ())
2587  {
2588  element.AddAttribute ("meta-info", metaInfo.c_str (), true);
2589  }
2590  WriteN (element.ToString (), m_f);
2591 }
2592 
2593 void
2594 AnimationInterface::WriteXmlP (uint64_t animUid, std::string pktType, uint32_t tId, double fbRx, double lbRx)
2595 {
2596  AnimXmlElement element (pktType);
2597  element.AddAttribute ("uId", animUid);
2598  element.AddAttribute ("tId", tId);
2599  element.AddAttribute ("fbRx", fbRx);
2600  element.AddAttribute ("lbRx", lbRx);
2601  WriteN (element.ToString (), m_f);
2602 }
2603 
2604 void
2605 AnimationInterface::WriteXmlP (std::string pktType, uint32_t fId, double fbTx, double lbTx,
2606  uint32_t tId, double fbRx, double lbRx, std::string metaInfo)
2607 {
2608  AnimXmlElement element (pktType);
2609  element.AddAttribute ("fId", fId);
2610  element.AddAttribute ("fbTx", fbTx);
2611  element.AddAttribute ("lbTx", lbTx);
2612  if (!metaInfo.empty ())
2613  {
2614  element.AddAttribute ("meta-info", metaInfo.c_str (), true);
2615  }
2616  element.AddAttribute ("tId", tId);
2617  element.AddAttribute ("fbRx", fbRx);
2618  element.AddAttribute ("lbRx", lbRx);
2619  WriteN (element.ToString (), m_f);
2620 }
2621 
2622 void
2623 AnimationInterface::WriteXmlAddNodeCounter (uint32_t nodeCounterId, std::string counterName, CounterType counterType)
2624 {
2625  AnimXmlElement element ("ncs");
2626  element.AddAttribute ("ncId", nodeCounterId);
2627  element.AddAttribute ("n", counterName);
2628  element.AddAttribute ("t", CounterTypeToString (counterType));
2629  WriteN (element.ToString (), m_f);
2630 }
2631 
2632 void
2633 AnimationInterface::WriteXmlAddResource (uint32_t resourceId, std::string resourcePath)
2634 {
2635  AnimXmlElement element ("res");
2636  element.AddAttribute ("rid", resourceId);
2637  element.AddAttribute ("p", resourcePath);
2638  WriteN (element.ToString (), m_f);
2639 }
2640 
2641 void
2642 AnimationInterface::WriteXmlUpdateNodeImage (uint32_t nodeId, uint32_t resourceId)
2643 {
2644  AnimXmlElement element ("nu");
2645  element.AddAttribute ("p", "i");
2646  element.AddAttribute ("t", Simulator::Now ().GetSeconds ());
2647  element.AddAttribute ("id", nodeId);
2648  element.AddAttribute ("rid", resourceId);
2649  WriteN (element.ToString (), m_f);
2650 }
2651 
2652 void
2653 AnimationInterface::WriteXmlUpdateNodeSize (uint32_t nodeId, double width, double height)
2654 {
2655  AnimXmlElement element ("nu");
2656  element.AddAttribute ("p", "s");
2657  element.AddAttribute ("t", Simulator::Now ().GetSeconds ());
2658  element.AddAttribute ("id", nodeId);
2659  element.AddAttribute ("w", width);
2660  element.AddAttribute ("h", height);
2661  WriteN (element.ToString (), m_f);
2662 }
2663 
2664 void
2665 AnimationInterface::WriteXmlUpdateNodePosition (uint32_t nodeId, double x, double y)
2666 {
2667  AnimXmlElement element ("nu");
2668  element.AddAttribute ("p", "p");
2669  element.AddAttribute ("t", Simulator::Now ().GetSeconds ());
2670  element.AddAttribute ("id", nodeId);
2671  element.AddAttribute ("x", x);
2672  element.AddAttribute ("y", y);
2673  WriteN (element.ToString (), m_f);
2674 }
2675 
2676 void
2677 AnimationInterface::WriteXmlUpdateNodeColor (uint32_t nodeId, uint8_t r, uint8_t g, uint8_t b)
2678 {
2679  AnimXmlElement element ("nu");
2680  element.AddAttribute ("p", "c");
2681  element.AddAttribute ("t", Simulator::Now ().GetSeconds ());
2682  element.AddAttribute ("id", nodeId);
2683  element.AddAttribute ("r", (uint32_t) r);
2684  element.AddAttribute ("g", (uint32_t) g);
2685  element.AddAttribute ("b", (uint32_t) b);
2686  WriteN (element.ToString (), m_f);
2687 }
2688 
2689 void
2691 {
2692  AnimXmlElement element ("nu");
2693  element.AddAttribute ("p", "d");
2694  element.AddAttribute ("t", Simulator::Now ().GetSeconds ());
2695  element.AddAttribute ("id", nodeId);
2696  if (m_nodeDescriptions.find (nodeId) != m_nodeDescriptions.end ())
2697  {
2698  element.AddAttribute ("descr", m_nodeDescriptions[nodeId], true);
2699  }
2700  WriteN (element.ToString (), m_f);
2701 }
2702 
2703 
2704 void
2705 AnimationInterface::WriteXmlUpdateNodeCounter (uint32_t nodeCounterId, uint32_t nodeId, double counterValue)
2706 {
2707  AnimXmlElement element ("nc");
2708  element.AddAttribute ("c", nodeCounterId);
2709  element.AddAttribute ("i", nodeId);
2710  element.AddAttribute ("t", Simulator::Now ().GetSeconds ());
2711  element.AddAttribute ("v", counterValue);
2712  WriteN (element.ToString (), m_f);
2713 }
2714 
2715 void
2716 AnimationInterface::WriteXmlUpdateBackground (std::string fileName, double x, double y, double scaleX, double scaleY, double opacity)
2717 {
2718  AnimXmlElement element ("bg");
2719  element.AddAttribute ("f", fileName);
2720  element.AddAttribute ("x", x);
2721  element.AddAttribute ("y", y);
2722  element.AddAttribute ("sx", scaleX);
2723  element.AddAttribute ("sy", scaleY);
2724  element.AddAttribute ("o", opacity);
2725  WriteN (element.ToString (), m_f);
2726 }
2727 
2728 void
2729 AnimationInterface::WriteXmlNonP2pLinkProperties (uint32_t id, std::string ipAddress, std::string channelType)
2730 {
2731  AnimXmlElement element ("nonp2plinkproperties");
2732  element.AddAttribute ("id", id);
2733  element.AddAttribute ("ipAddress", ipAddress);
2734  element.AddAttribute ("channelType", channelType);
2735  WriteN (element.ToString (), m_f);
2736 }
2737 
2738 
2739 
2740 /***** AnimXmlElement *****/
2741 
2742 AnimationInterface::AnimXmlElement::AnimXmlElement (std::string tagName, bool emptyElement)
2743  : m_tagName (tagName),
2744  m_text ("")
2745 {
2746 }
2747 
2748 template <typename T>
2749 void
2750 AnimationInterface::AnimXmlElement::AddAttribute (std::string attribute, T value, bool xmlEscape)
2751 {
2752  std::ostringstream oss;
2753  oss << std::setprecision (10);
2754  oss << value;
2755  std::string attributeString = attribute.c_str ();
2756  if (xmlEscape)
2757  {
2758  attributeString += "=\"";
2759  std::string valueStr = oss.str ();
2760  for (std::string::iterator it = valueStr.begin (); it != valueStr.end (); ++it)
2761  {
2762  switch (*it)
2763  {
2764  case '&':
2765  attributeString += "&amp;";
2766  break;
2767  case '\"':
2768  attributeString += "&quot;";
2769  break;
2770  case '\'':
2771  attributeString += "&apos;";
2772  break;
2773  case '<':
2774  attributeString += "&lt;";
2775  break;
2776  case '>':
2777  attributeString += "&gt;";
2778  break;
2779  default:
2780  attributeString += *it;
2781  break;
2782  }
2783  }
2784  attributeString += "\" ";
2785  }
2786  else
2787  {
2788  attributeString += "=\"" + oss.str () + "\" ";
2789  }
2790  m_attributes.push_back (attributeString);
2791 }
2792 
2793 void
2795 {
2796  m_children.push_back (e.ToString ());
2797 }
2798 
2799 void
2801 {
2802  m_text = text;
2803 }
2804 
2805 std::string
2807 {
2808  std::string elementString = "<" + m_tagName + " ";
2809 
2810 
2811  for (std::vector<std::string>::const_iterator i = m_attributes.begin ();
2812  i != m_attributes.end ();
2813  ++i)
2814  {
2815  elementString += *i;
2816  }
2817  if (m_children.empty () && m_text.empty ())
2818  {
2819  if (autoClose)
2820  {
2821  elementString += "/>";
2822  }
2823  }
2824  else
2825  {
2826  elementString += ">";
2827  if (!m_text.empty ())
2828  {
2829  elementString += m_text;
2830  }
2831  if (!m_children.empty ())
2832  {
2833  elementString += "\n";
2834  for (std::vector<std::string>::const_iterator i = m_children.begin ();
2835  i != m_children.end ();
2836  ++i)
2837  {
2838  elementString += *i + "\n";
2839  }
2840 
2841  }
2842  if (autoClose)
2843  {
2844  elementString += "</" + m_tagName + ">";
2845  }
2846  }
2847 
2848 
2849  return elementString + ((autoClose) ? "\n" : "");
2850 }
2851 
2852 
2853 
2854 
2855 
2856 /***** AnimByteTag *****/
2857 
2858 TypeId
2860 {
2861  static TypeId tid = TypeId ("ns3::AnimByteTag")
2862  .SetParent<Tag> ()
2863  .SetGroupName ("NetAnim")
2864  .AddConstructor<AnimByteTag> ()
2865  ;
2866  return tid;
2867 }
2868 
2869 TypeId
2871 {
2872  return GetTypeId ();
2873 }
2874 
2875 uint32_t
2877 {
2878  return sizeof (uint64_t);
2879 }
2880 
2881 void
2883 {
2884  i.WriteU64 (m_AnimUid);
2885 }
2886 
2887 void
2889 {
2890  m_AnimUid = i.ReadU64 ();
2891 }
2892 
2893 void
2894 AnimByteTag::Print (std::ostream &os) const
2895 {
2896  os << "AnimUid=" << m_AnimUid;
2897 }
2898 
2899 void
2900 AnimByteTag::Set (uint64_t AnimUid)
2901 {
2902  m_AnimUid = AnimUid;
2903 }
2904 
2905 uint64_t
2906 AnimByteTag::Get (void) const
2907 {
2908  return m_AnimUid;
2909 }
2910 
2912  : m_txnd (0),
2913  m_txNodeId (0),
2914  m_fbTx (0),
2915  m_lbTx (0),
2916  m_lbRx (0)
2917 {
2918 }
2919 
2921 {
2922  m_txnd = pInfo.m_txnd;
2923  m_txNodeId = pInfo.m_txNodeId;
2924  m_fbTx = pInfo.m_fbTx;
2925  m_lbTx = pInfo.m_lbTx;
2926  m_lbRx = pInfo.m_lbRx;
2927 }
2928 
2930  const Time fbTx,
2931  uint32_t txNodeId)
2932  : m_txnd (txnd),
2933  m_txNodeId (0),
2934  m_fbTx (fbTx.GetSeconds ()),
2935  m_lbTx (0),
2936  m_lbRx (0)
2937 {
2938  if (!m_txnd)
2939  {
2940  m_txNodeId = txNodeId;
2941  }
2942 }
2943 
2944 void
2946 {
2947  Ptr <Node> n = nd->GetNode ();
2948  m_fbRx = fbRx;
2949  m_rxnd = nd;
2950 }
2951 
2952 } // namespace ns3
ns3::AnimationInterface::WriteRoutePath
void WriteRoutePath(uint32_t nodeId, std::string destination, Ipv4RoutePathElements rpElements)
Write route path function.
Definition: animation-interface.cc:539
ns3::AnimationInterface::EnableQueueCounters
void EnableQueueCounters(Time startTime, Time stopTime, Time pollInterval=Seconds(1))
Enable tracking of Queue Counters such as Enqueue, Dequeue, Queue Drops.
Definition: animation-interface.cc:152
ns3::AnimationInterface::WriteNonP2pLinkProperties
void WriteNonP2pLinkProperties(uint32_t id, std::string ipv4Address, std::string channelType)
Write non P2P link properties function.
Definition: animation-interface.cc:556
ns3::AnimationInterface::WavePhyRxBeginTrace
void WavePhyRxBeginTrace(std::string context, Ptr< const Packet > p)
WAVE Phy receive begin trace function.
Definition: animation-interface.cc:1037
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
ns3::AnimationInterface::m_queueCountersPollInterval
Time m_queueCountersPollInterval
queue counters poll interval
Definition: animation-interface.h:630
ns3::Ipv4Header
Packet header for IPv4.
Definition: ipv4-header.h:34
ns3::AnimationInterface::m_routingPollInterval
Time m_routingPollInterval
routing poll interval
Definition: animation-interface.h:625
ns3::AnimationInterface::EnableWifiMacCounters
void EnableWifiMacCounters(Time startTime, Time stopTime, Time pollInterval=Seconds(1))
Enable tracking of Wifi Mac Counters such as Tx, TxDrop, Rx, RxDrop.
Definition: animation-interface.cc:128
ns3::AnimationInterface::m_wifiPhyTxDropCounterId
uint32_t m_wifiPhyTxDropCounterId
wifi Phy transmit drop counter ID
Definition: animation-interface.h:654
ns3::AnimationInterface::NodeSize
NodeSize structure.
Definition: animation-interface.h:543
rgb::b
uint8_t b
blue
Definition: colors-link-description.cc:37
ns3::AnimationInterface::PurgePendingPackets
void PurgePendingPackets(ProtocolType protocolType)
Purge pending packets function.
Definition: animation-interface.cc:1309
ns3::Ipv6InterfaceAddress
IPv6 address associated with an interface.
Definition: ipv6-interface-address.h:38
ns3::AnimationInterface::UINT32_COUNTER
@ UINT32_COUNTER
Definition: animation-interface.h:90
ns3::AnimationInterface::WriteNodeColors
void WriteNodeColors()
Write node colors function.
Definition: animation-interface.cc:2050
ns3::AnimationInterface::ConnectLteUe
void ConnectLteUe(Ptr< Node > n, Ptr< LteUeNetDevice > nd, uint32_t devIndex)
Connect LTE ue function.
Definition: animation-interface.cc:1575
ns3::AnimationInterface::WriteNodeSizes
void WriteNodeSizes()
Write node sizes function.
Definition: animation-interface.cc:2065
ns3::AnimationInterface::WIMAX
@ WIMAX
Definition: animation-interface.h:535
ns3::AnimationInterface::UpdateNodeColor
void UpdateNodeColor(Ptr< Node > n, uint8_t r, uint8_t g, uint8_t b)
Helper function to update the node color.
Definition: animation-interface.cc:352
stopTime
Time stopTime
Definition: tcp-linux-reno.cc:52
NS_ASSERT
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:67
ns3::AnimationInterface::m_nodeWifiMacTxDrop
NodeCounterMap64 m_nodeWifiMacTxDrop
node wifi MAC transmit drop
Definition: animation-interface.h:690
ns3::AnimationInterface::SetMaxPktsPerTraceFile
void SetMaxPktsPerTraceFile(uint64_t maxPktsPerFile)
Set Max packets per trace file.
Definition: animation-interface.cc:232
ns3::AnimationInterface::WriteXmlIpv6Addresses
void WriteXmlIpv6Addresses(uint32_t nodeId, std::vector< std::string > ipv6Addresses)
Write XML Ipv6 addresses function.
Definition: animation-interface.cc:2531
ns3::AnimationInterface::m_linkProperties
LinkPropertiesMap m_linkProperties
link properties
Definition: animation-interface.h:674
ns3::AnimationInterface::CheckMaxPktsPerTraceFile
void CheckMaxPktsPerTraceFile()
Check maximum packets per trace file function.
Definition: animation-interface.cc:2140
ns3::Packet::PeekHeader
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Definition: packet.cc:290
ns3::AnimationInterface::Ipv4RouteTrackElement::fromNodeId
uint32_t fromNodeId
from node ID
Definition: animation-interface.h:519
ns3::AnimationInterface::AnimPacketInfo::ProcessRxBegin
void ProcessRxBegin(Ptr< const NetDevice > nd, const double fbRx)
Process receive begin.
Definition: animation-interface.cc:2945
ns3::ByteTagIterator::Item::GetTypeId
TypeId GetTypeId(void) const
Definition: packet.cc:34
ns3::AnimationInterface::UpdateNodeCounter
void UpdateNodeCounter(uint32_t nodeCounterId, uint32_t nodeId, double counter)
Helper function to update a node's counter referenced by the nodeCounterId.
Definition: animation-interface.cc:324
ns3::AnimationInterface::GetPacketMetadata
std::string GetPacketMetadata(Ptr< const Packet > p)
Get packet metadata function.
Definition: animation-interface.cc:1454
ns3::AnimationInterface::AnimXmlElement::AppendChild
void AppendChild(AnimXmlElement e)
Append child function.
Definition: animation-interface.cc:2794
ns3::AnimationInterface::WriteXmlUpdateBackground
void WriteXmlUpdateBackground(std::string fileName, double x, double y, double scaleX, double scaleY, double opacity)
Write XML update background function.
Definition: animation-interface.cc:2716
ns3::AnimationInterface::ConnectCallbacks
void ConnectCallbacks()
Connect callbacks function.
Definition: animation-interface.cc:1629
ns3::AnimationInterface::AnimXmlElement::ToString
std::string ToString(bool autoClose=true)
Get text for the element function.
Definition: animation-interface.cc:2806
ns3::NodeList::Begin
static Iterator Begin(void)
Definition: node-list.cc:229
ns3::AnimationInterface::WriteXmlLink
void WriteXmlLink(uint32_t fromId, uint32_t toLp, uint32_t toId)
Write XML link counter function.
Definition: animation-interface.cc:2486
ns3::AnimationInterface::EnableWifiPhyCounters
void EnableWifiPhyCounters(Time startTime, Time stopTime, Time pollInterval=Seconds(1))
Enable tracking of Wifi Phy Counters such as TxDrop, RxDrop.
Definition: animation-interface.cc:109
ns3::AnimationInterface::m_nodeIpv4Rx
NodeCounterMap64 m_nodeIpv4Rx
node IPv4 receive
Definition: animation-interface.h:685
ns3::AnimationInterface::NodeIdIpv6Pair
std::pair< uint32_t, std::string > NodeIdIpv6Pair
NodeIdIpv6Pair typedef.
Definition: animation-interface.h:556
ns3::Node::GetId
uint32_t GetId(void) const
Definition: node.cc:109
ns3::Socket::SocketErrno
SocketErrno
Enumeration of the possible errors returned by a socket.
Definition: socket.h:82
ns3::AnimationInterface::m_nodeLrWpanMacRx
NodeCounterMap64 m_nodeLrWpanMacRx
node LR-WPAN MAC receive
Definition: animation-interface.h:697
ns3::AnimationInterface::DequeueTrace
void DequeueTrace(std::string context, Ptr< const Packet >)
Dequeue trace function.
Definition: animation-interface.cc:763
ns3::NetDevice::GetAddress
virtual Address GetAddress(void) const =0
ns3::AnimationInterface::ProtocolType
ProtocolType
ProtocolType enumeration.
Definition: animation-interface.h:531
ns3::ConstantPositionMobilityModel
Mobility model for which the current position does not change once it has been set and until it is se...
Definition: constant-position-mobility-model.h:33
ns3::AnimationInterface::m_nodeIpv4Tx
NodeCounterMap64 m_nodeIpv4Tx
node IPv4 transmit
Definition: animation-interface.h:684
ns3::Simulator::Now
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:195
ns3::AnimationInterface::m_macToNodeIdMap
std::map< std::string, uint32_t > m_macToNodeIdMap
MAC to node ID map.
Definition: animation-interface.h:666
ns3::AnimationInterface::QueueDropTrace
void QueueDropTrace(std::string context, Ptr< const Packet >)
Queue trace function.
Definition: animation-interface.cc:771
ns3::AnimationInterface::TrackIpv4Route
void TrackIpv4Route()
Track IPv4 router function.
Definition: animation-interface.cc:2312
ns3::ByteTagIterator::Item::GetTag
void GetTag(Tag &tag) const
Read the requested tag and store it in the user-provided tag instance.
Definition: packet.cc:49
ns3::AnimationInterface::Ipv4RoutePathElement::nextHop
std::string nextHop
next hop
Definition: animation-interface.h:526
ns3::AnimationInterface::m_stopTime
Time m_stopTime
stop time
Definition: animation-interface.h:620
ns3::AnimByteTag::Deserialize
virtual void Deserialize(TagBuffer i)
Deserialize function.
Definition: animation-interface.cc:2888
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Ipv6InterfaceAddress::GetAddress
Ipv6Address GetAddress() const
Get the IPv6 address.
Definition: ipv6-interface-address.cc:89
ns3::AnimationInterface::gAnimUid
uint64_t gAnimUid
Packet unique identifier used by AnimationInterface.
Definition: animation-interface.h:615
PURGE_INTERVAL
#define PURGE_INTERVAL
Definition: animation-interface.h:52
ns3::AnimationInterface::AnimPacketInfo::m_fbTx
double m_fbTx
fb transmit
Definition: animation-interface.h:452
ns3::AnimationInterface::Ipv4RoutePathElements
std::vector< Ipv4RoutePathElement > Ipv4RoutePathElements
Ipv4RoutePathElements typedef.
Definition: animation-interface.h:552
ns3::AnimationInterface::m_nodeQueueEnqueue
NodeCounterMap64 m_nodeQueueEnqueue
node queue enqueue
Definition: animation-interface.h:686
ns3::ByteTagIterator::Next
Item Next(void)
Definition: packet.cc:70
ns3::AnimationInterface::LteRxTrace
void LteRxTrace(std::string context, Ptr< const Packet > p, const Mac48Address &m)
LTE receive trace function.
Definition: animation-interface.cc:1097
ns3::AnimationInterface::IsInitialized
static bool IsInitialized(void)
Check if AnimationInterface is initialized.
Definition: animation-interface.cc:266
ns3::AnimationInterface::m_wifiMacTxDropCounterId
uint32_t m_wifiMacTxDropCounterId
wifi MAC transmit drop counter ID
Definition: animation-interface.h:650
ns3::AnimationInterface::AddSourceDestination
AnimationInterface & AddSourceDestination(uint32_t fromNodeId, std::string destinationIpv4Address)
Helper function to print the routing path from a source node to destination IP.
Definition: animation-interface.cc:212
ns3::initialized
static bool initialized
Initialization flag.
Definition: animation-interface.cc:70
ns3::AnimationInterface::WriteN
int WriteN(const char *data, uint32_t count, FILE *f)
WriteN function.
Definition: animation-interface.cc:514
ns3::AnimationInterface::WriteXmlAddResource
void WriteXmlAddResource(uint32_t resourceId, std::string resourcePath)
Write XML add resource function.
Definition: animation-interface.cc:2633
ns3::Mac16Address
This class can contain 16 bit addresses.
Definition: mac16-address.h:42
ns3::AnimationInterface::IsPacketPending
bool IsPacketPending(uint64_t animUid, ProtocolType protocolType)
Is packet pending function.
Definition: animation-interface.cc:1301
ns3::AnimationInterface::GetIpv6Addresses
std::vector< std::string > GetIpv6Addresses(Ptr< NetDevice > nd)
Get IPv6 addresses.
Definition: animation-interface.cc:1880
ns3::AnimationInterface::m_pendingWavePackets
AnimUidPacketInfoMap m_pendingWavePackets
pending WAVE packets
Definition: animation-interface.h:663
ns3::AnimationInterface::EnableIpv4L3ProtocolCounters
void EnableIpv4L3ProtocolCounters(Time startTime, Time stopTime, Time pollInterval=Seconds(1))
Enable tracking of Ipv4 L3 Protocol Counters such as Tx, Rx, Drop.
Definition: animation-interface.cc:173
ns3::AnimationInterface::LrWpanMacTxTrace
void LrWpanMacTxTrace(std::string context, Ptr< const Packet > p)
LR-WPAN MAC transmit trace function.
Definition: animation-interface.cc:701
ns3::Object::GetObject
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:470
ns3::Packet::EnablePrinting
static void EnablePrinting(void)
Enable printing packets metadata.
Definition: packet.cc:572
ns3::AnimationInterface::m_remainingEnergyCounterId
uint32_t m_remainingEnergyCounterId
remaining energy counter ID
Definition: animation-interface.h:639
ns3::AnimationInterface::SetBackgroundImage
void SetBackgroundImage(std::string fileName, double x, double y, double scaleX, double scaleY, double opacity)
Helper function to set the background image.
Definition: animation-interface.cc:334
ns3::AnimationInterface::GetIpv6Address
std::string GetIpv6Address(Ptr< NetDevice > nd)
Get IPv6 address.
Definition: animation-interface.cc:1816
ns3::Node
A network Node.
Definition: node.h:57
ns3::AnimationInterface::UpdatePosition
Vector UpdatePosition(Ptr< Node > n)
Update position function.
Definition: animation-interface.cc:1738
ns3::AnimationInterface::m_nodeWifiPhyTxDrop
NodeCounterMap64 m_nodeWifiPhyTxDrop
node wifi Phy transmit drop
Definition: animation-interface.h:693
ns3::AnimationInterface::Ipv4RoutePathElement::nodeId
uint32_t nodeId
node ID
Definition: animation-interface.h:525
ns3::AnimationInterface::m_outputFileName
std::string m_outputFileName
output file name
Definition: animation-interface.h:614
ns3::AnimationInterface::m_nodeLrWpanMacRxDrop
NodeCounterMap64 m_nodeLrWpanMacRxDrop
node LR-WPAN MAC receive drop
Definition: animation-interface.h:698
NS_LOG_WARN
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:265
ns3::AnimationInterface::m_nodeWifiMacTx
NodeCounterMap64 m_nodeWifiMacTx
node wifi MAC transmit
Definition: animation-interface.h:689
ns3::AnimationInterface::m_pendingCsmaPackets
AnimUidPacketInfoMap m_pendingCsmaPackets
pending CSMA packets
Definition: animation-interface.h:661
ns3::AnimationInterface::AnimPacketInfo::m_rxnd
Ptr< const NetDevice > m_rxnd
receive device
Definition: animation-interface.h:456
ns3::AnimationInterface::m_nodeSizes
std::map< uint32_t, NodeSize > m_nodeSizes
node sizes
Definition: animation-interface.h:678
ns3::AnimationInterface::m_started
bool m_started
started
Definition: animation-interface.h:617
rgb
RGB structure.
Definition: colors-link-description.cc:34
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
ns3::AnimationInterface::m_wifiMacCountersPollInterval
Time m_wifiMacCountersPollInterval
wifi MAC counters poll interval
Definition: animation-interface.h:632
ns3::Channel::GetDevice
virtual Ptr< NetDevice > GetDevice(std::size_t i) const =0
ns3::AnimationInterface::WriteXmlNode
void WriteXmlNode(uint32_t id, uint32_t sysId, double locX, double locY)
Write XML node function.
Definition: animation-interface.cc:2464
ns3::NodeContainer::GetN
uint32_t GetN(void) const
Get the number of Ptr<Node> stored in this container.
Definition: node-container.cc:88
ns3::AnimByteTag
Byte tag using by Anim to uniquely identify packets.
Definition: animation-interface.h:1500
ns3::AnimationInterface::WriteXmlUpdateNodeDescription
void WriteXmlUpdateNodeDescription(uint32_t nodeId)
Write XML update node description function.
Definition: animation-interface.cc:2690
ns3::AnimationInterface
Interface to network animator.
Definition: animation-interface.h:76
ns3::Mac48Address
an EUI-48 address
Definition: mac48-address.h:44
ns3::AnimationInterface::GetIpv4RoutingTable
std::string GetIpv4RoutingTable(Ptr< Node > n)
Get IPv4 routing table function.
Definition: animation-interface.cc:2340
ns3::AnimationInterface::SetConstantPosition
static void SetConstantPosition(Ptr< Node > n, double x, double y, double z=0)
Helper function to set Constant Position for a given node.
Definition: animation-interface.cc:297
ns3::AnimationInterface::EnqueueTrace
void EnqueueTrace(std::string context, Ptr< const Packet >)
Enqueue trace function.
Definition: animation-interface.cc:755
ns3::ObjectBase::SetAttribute
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:185
ns3::Channel::GetNDevices
virtual std::size_t GetNDevices(void) const =0
ns3::WifiTxVector
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
Definition: wifi-tx-vector.h:71
ns3::AnimByteTag::GetInstanceTypeId
virtual TypeId GetInstanceTypeId(void) const
Get Instance Type Id.
Definition: animation-interface.cc:2870
animation-interface.h
ns3::AnimationInterface::WifiPhyTxDropTrace
void WifiPhyTxDropTrace(std::string context, Ptr< const Packet > p)
wifi Phy transmit drop trace function
Definition: animation-interface.cc:659
ns3::AnimationInterface::WriteXmlAddNodeCounter
void WriteXmlAddNodeCounter(uint32_t counterId, std::string counterName, CounterType counterType)
Write XML add node counter function.
Definition: animation-interface.cc:2623
ns3::AnimationInterface::LrWpanPhyRxBeginTrace
void LrWpanPhyRxBeginTrace(std::string context, Ptr< const Packet > p)
LR-WPAN Phy receive begin trace function.
Definition: animation-interface.cc:1001
ns3::AnimationInterface::CsmaMacRxTrace
void CsmaMacRxTrace(std::string context, Ptr< const Packet > p)
CSMA MAC receive trace function.
Definition: animation-interface.cc:1231
ns3::AnimationInterface::m_trackPackets
bool m_trackPackets
track packets
Definition: animation-interface.h:636
ns3::WifiConstPsduMap
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
Definition: he-frame-exchange-manager.h:43
ns3::AnimationInterface::m_nodeIdIpv4Map
NodeIdIpv4Map m_nodeIdIpv4Map
node ID to IPv4 map
Definition: animation-interface.h:669
ns3::Simulator::Schedule
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:557
ns3::Ipv4L3Protocol::DropReason
DropReason
Reason why a packet has been dropped.
Definition: ipv4-l3-protocol.h:98
ns3::Packet::GetByteTagIterator
ByteTagIterator GetByteTagIterator(void) const
Returns an iterator over the set of byte tags included in this packet.
Definition: packet.cc:933
ns3::Mac64Address
an EUI-64 address
Definition: mac64-address.h:44
ns3::ByteTagIterator::Item
Identifies a byte tag and a set of bytes within a packet to which the tag applies.
Definition: packet.h:62
ns3::PeekPointer
U * PeekPointer(const Ptr< U > &p)
Definition: ptr.h:415
ns3::AnimationInterface::m_routingNc
NodeContainer m_routingNc
routing node container
Definition: animation-interface.h:626
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:41
ns3::AnimationInterface::m_nodeIdIpv6Map
NodeIdIpv6Map m_nodeIdIpv6Map
node ID to IPv6 map
Definition: animation-interface.h:670
ns3::AnimationInterface::NodeSize::height
double height
height
Definition: animation-interface.h:545
ns3::AnimationInterface::AnimUidPacketInfoMap
std::map< uint64_t, AnimPacketInfo > AnimUidPacketInfoMap
AnimUidPacketInfoMap typedef.
Definition: animation-interface.h:550
ns3::AnimationInterface::WriteXmlP
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.
Definition: animation-interface.cc:2605
ns3::AnimationInterface::StopAnimation
void StopAnimation(bool onlyAnimation=false)
Stop animation function.
Definition: animation-interface.cc:1468
ns3::AnimationInterface::MobilityAutoCheck
void MobilityAutoCheck()
Mobility auto check function.
Definition: animation-interface.cc:445
ns3::AnimationInterface::WriteXmlUpdateNodeSize
void WriteXmlUpdateNodeSize(uint32_t nodeId, double width, double height)
Write XML update node size function.
Definition: animation-interface.cc:2653
ns3::LteEnbNetDevice::GetPhy
Ptr< LteEnbPhy > GetPhy(void) const
Definition: lte-enb-net-device.cc:194
ns3::AnimationInterface::LrWpanPhyTxBeginTrace
void LrWpanPhyTxBeginTrace(std::string context, Ptr< const Packet > p)
LR-WPAN Phy receive begin trace function.
Definition: animation-interface.cc:949
ns3::AnimationInterface::GetIpv4Addresses
std::vector< std::string > GetIpv4Addresses(Ptr< NetDevice > nd)
Get IPv4 addresses.
Definition: animation-interface.cc:1854
ns3::AnimationInterface::m_wifiPhyCountersStopTime
Time m_wifiPhyCountersStopTime
wifi Phy counters stop time
Definition: animation-interface.h:633
ns3::AnimationInterface::GetMovedNodes
std::vector< Ptr< Node > > GetMovedNodes()
Get moved nodes function.
Definition: animation-interface.cc:469
startTime
double startTime
Definition: tcp-nsc-comparison.cc:45
ns3::AnimationInterface::m_ipv4L3ProtocolDropCounterId
uint32_t m_ipv4L3ProtocolDropCounterId
IPv4 protocol drop counter ID.
Definition: animation-interface.h:643
ns3::AnimationInterface::WriteXmlUpdateNodeColor
void WriteXmlUpdateNodeColor(uint32_t nodeId, uint8_t r, uint8_t g, uint8_t b)
Write XML update node color function.
Definition: animation-interface.cc:2677
ns3::AnimationInterface::GetNetAnimVersion
std::string GetNetAnimVersion()
Get netanim version function.
Definition: animation-interface.cc:2153
ns3::WifiMacHeader
Implements the IEEE 802.11 MAC header.
Definition: wifi-mac-header.h:85
ns3::AnimationInterface::CounterType
CounterType
Counter Types.
Definition: animation-interface.h:89
ns3::Ipv4
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:77
ns3::AnimationInterface::m_writeCallback
AnimWriteCallback m_writeCallback
write callback
Definition: animation-interface.h:616
ns3::AnimationInterface::SetOutputFile
void SetOutputFile(const std::string &fn, bool routing=false)
Set output file function.
Definition: animation-interface.cc:2106
ns3::AnimByteTag::Get
uint64_t Get(void) const
Get Uid in tag.
Definition: animation-interface.cc:2906
ns3::AnimationInterface::GenericWirelessRxTrace
void GenericWirelessRxTrace(std::string context, Ptr< const Packet > p, ProtocolType protocolType)
Generic wireless receive trace function.
Definition: animation-interface.cc:837
ns3::AnimationInterface::AddPendingPacket
void AddPendingPacket(ProtocolType protocolType, uint64_t animUid, AnimPacketInfo pktInfo)
Add pending packet function.
Definition: animation-interface.cc:1293
ns3::Ptr< Node >
NS_FATAL_ERROR
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
ns3::AnimationInterface::CSMA
@ CSMA
Definition: animation-interface.h:536
ns3::AnimationInterface::m_ipv4L3ProtocolTxCounterId
uint32_t m_ipv4L3ProtocolTxCounterId
IPv4 L3 protocol transmit counter ID.
Definition: animation-interface.h:641
ns3::AnimationInterface::AnimPacketInfo::m_txnd
Ptr< const NetDevice > m_txnd
transmit device
Definition: animation-interface.h:450
ns3::Ipv6Address::IsLinkLocal
bool IsLinkLocal() const
If the IPv6 address is a link-local address (fe80::/64).
Definition: ipv6-address.cc:917
ns3::AnimationInterface::OutputWirelessPacketRxInfo
void OutputWirelessPacketRxInfo(Ptr< const Packet > p, AnimPacketInfo &pktInfo, uint64_t animUid)
Output wireless packet receive info.
Definition: animation-interface.cc:1267
ns3::AnimationInterface::m_wifiMacRxCounterId
uint32_t m_wifiMacRxCounterId
wifi MAC receive counter ID
Definition: animation-interface.h:651
ns3::AnimationInterface::RecursiveIpv4RoutePathSearch
void RecursiveIpv4RoutePathSearch(std::string from, std::string to, Ipv4RoutePathElements &rpElements)
Recursive IPv4 route path search function.
Definition: animation-interface.cc:2358
ns3::AnimationInterface::m_queueEnqueueCounterId
uint32_t m_queueEnqueueCounterId
queue enqueue counter ID
Definition: animation-interface.h:645
ns3::AnimByteTag::GetSerializedSize
virtual uint32_t GetSerializedSize(void) const
Get Serialized Size.
Definition: animation-interface.cc:2876
ns3::WifiPhyRxfailureReason
WifiPhyRxfailureReason
Enumeration of the possible reception failure reasons.
Definition: wifi-phy-common.h:258
ns3::AnimationInterface::UpdateLinkDescription
void UpdateLinkDescription(uint32_t fromNode, uint32_t toNode, std::string linkDescription)
Helper function to update the description for a link.
Definition: animation-interface.cc:368
ns3::AnimationInterface::m_nodeWifiPhyRxDrop
NodeCounterMap64 m_nodeWifiPhyRxDrop
node wifi Phy receive drop
Definition: animation-interface.h:694
ns3::AnimationInterface::WriteXmlUpdateLink
void WriteXmlUpdateLink(uint32_t fromId, uint32_t toId, std::string linkDescription)
Write XML update link counter function.
Definition: animation-interface.cc:2475
ns3::AnimationInterface::WifiPhyRxDropTrace
void WifiPhyRxDropTrace(std::string context, Ptr< const Packet > p, WifiPhyRxfailureReason reason)
wifi Phy receive drop trace function
Definition: animation-interface.cc:666
ns3::AnimationInterface::TrackIpv4L3ProtocolCounters
void TrackIpv4L3ProtocolCounters()
Track IPv4 L3 protocol counters function.
Definition: animation-interface.cc:2214
ns3::NodeList::Iterator
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
Definition: node-list.h:44
CHECK_STARTED_INTIMEWINDOW_TRACKPACKETS
#define CHECK_STARTED_INTIMEWINDOW_TRACKPACKETS
Definition: animation-interface.h:55
ns3::LrWpanMacHeader::GetSrcAddrMode
uint8_t GetSrcAddrMode(void) const
Get the Source Addressing Mode of Frame control field.
Definition: lr-wpan-mac-header.cc:149
ns3::AnimationInterface::WimaxRxTrace
void WimaxRxTrace(std::string context, Ptr< const Packet > p, const Mac48Address &m)
WIMax receive trace function.
Definition: animation-interface.cc:1083
ns3::AnimationInterface::AnimXmlElement
AnimXmlElement class.
Definition: animation-interface.h:565
ns3::AnimationInterface::EnablePacketMetadata
void EnablePacketMetadata(bool enable=true)
Enable Packet metadata.
Definition: animation-interface.cc:256
ns3::AnimationInterface::LteSpectrumPhyTxStart
void LteSpectrumPhyTxStart(std::string context, Ptr< const PacketBurst > pb)
LTE Spectrum Phy transmit start function.
Definition: animation-interface.cc:1104
ns3::AnimationInterface::SetAnimWriteCallback
void SetAnimWriteCallback(AnimWriteCallback cb)
Set a callback function to listen to AnimationInterface write events.
Definition: animation-interface.cc:278
ns3::AnimationInterface::m_ipv4L3ProtocolCountersStopTime
Time m_ipv4L3ProtocolCountersStopTime
IPv4 L3 protocol counters stop time.
Definition: animation-interface.h:627
ns3::Tag
tag a set of bytes in a packet
Definition: tag.h:37
ns3::Address
a polymophic address class
Definition: address.h:91
ns3::AnimationInterface::WAVE
@ WAVE
Definition: animation-interface.h:538
ns3::Ipv4InterfaceAddress
a class to store IPv4 address information on an interface
Definition: ipv4-interface-address.h:44
ns3::NodeContainer::Begin
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
Definition: node-container.cc:77
ns3::AnimationInterface::WriteXmlClose
void WriteXmlClose(std::string name, bool routing=false)
Write XML close function.
Definition: animation-interface.cc:2450
data
uint8_t data[writeSize]
Definition: socket-bound-tcp-static-routing.cc:53
ns3::AnimationInterface::m_nodeDescriptions
NodeDescriptionsMap m_nodeDescriptions
node description
Definition: animation-interface.h:673
ns3::AnimationInterface::TrackQueueCounters
void TrackQueueCounters()
Track queue counters function.
Definition: animation-interface.cc:2160
ns3::AnimationInterface::m_routingStopTime
Time m_routingStopTime
routing stop time
Definition: animation-interface.h:623
NS_LOG_INFO
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:281
ns3::AnimationInterface::GetNetDeviceFromContext
Ptr< NetDevice > GetNetDeviceFromContext(std::string context)
Get net device from context.
Definition: animation-interface.cc:591
ns3::AnimationInterface::IsStarted
bool IsStarted(void)
Is AnimationInterface started.
Definition: animation-interface.cc:272
ns3::AnimationInterface::AddResource
uint32_t AddResource(std::string resourcePath)
Add a resource such as the path to an image file.
Definition: animation-interface.cc:247
ns3::NetDevice::GetNode
virtual Ptr< Node > GetNode(void) const =0
ns3::AnimationInterface::m_maxPktsPerFile
uint64_t m_maxPktsPerFile
maximum pakets per file
Definition: animation-interface.h:621
ns3::AnimationInterface::m_routingFileName
std::string m_routingFileName
routing file name
Definition: animation-interface.h:624
ns3::WifiNetDevice::GetNode
Ptr< Node > GetNode(void) const override
Definition: wifi-net-device.cc:336
ns3::AnimationInterface::ConnectLte
void ConnectLte()
Connect LTE function.
Definition: animation-interface.cc:1597
ns3::LrWpanMacHeader
Represent the Mac Header with the Frame Control and Sequence Number fields.
Definition: lr-wpan-mac-header.h:54
ns3::AnimationInterface::WifiMacRxDropTrace
void WifiMacRxDropTrace(std::string context, Ptr< const Packet > p)
wifi MAC receive drop trace function
Definition: animation-interface.cc:694
NS_UNUSED
#define NS_UNUSED(x)
Mark a local variable as unused.
Definition: unused.h:36
ns3::EnergySource
Introspection did not find any typical Config paths.
Definition: energy-source.h:82
ns3::AnimationInterface::EnableIpv4RouteTracking
AnimationInterface & EnableIpv4RouteTracking(std::string fileName, Time startTime, Time stopTime, Time pollInterval=Seconds(5))
Enable tracking of the Ipv4 routing table for all Nodes.
Definition: animation-interface.cc:194
MAX_PKTS_PER_TRACE_FILE
#define MAX_PKTS_PER_TRACE_FILE
Definition: animation-interface.h:51
ns3::AnimationInterface::m_nodeLrWpanMacTx
NodeCounterMap64 m_nodeLrWpanMacTx
node LR-WPAN MAC transmit
Definition: animation-interface.h:695
ns3::AnimationInterface::GetAnimUidFromPacket
uint64_t GetAnimUidFromPacket(Ptr< const Packet >)
Get anim UID from packet function.
Definition: animation-interface.cc:604
ns3::AnimationInterface::AnimXmlElement::SetText
void SetText(std::string text)
Set text function.
Definition: animation-interface.cc:2800
ns3::AnimationInterface::StartAnimation
void StartAnimation(bool restart=false)
Start animation function.
Definition: animation-interface.cc:1493
ns3::Config::ConnectWithoutContextFailSafe
bool ConnectWithoutContextFailSafe(std::string path, const CallbackBase &cb)
This function will attempt to find all trace sources which match the input path and will then connect...
Definition: config.cc:909
ns3::AnimationInterface::CsmaPhyTxEndTrace
void CsmaPhyTxEndTrace(std::string context, Ptr< const Packet > p)
CSMA Phy transmit end trace function.
Definition: animation-interface.cc:1186
ns3::AnimationInterface::m_pendingWifiPackets
AnimUidPacketInfoMap m_pendingWifiPackets
pending wifi packets
Definition: animation-interface.h:657
ns3::AnimationInterface::WriteXmlRp
void WriteXmlRp(uint32_t nodeId, std::string destination, Ipv4RoutePathElements rpElements)
Write XMLRP function.
Definition: animation-interface.cc:2557
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::AnimationInterface::ProtocolTypeToPendingPackets
AnimUidPacketInfoMap * ProtocolTypeToPendingPackets(ProtocolType protocolType)
Protocol type to pending packets function.
Definition: animation-interface.cc:1339
ns3::Config::ConnectFailSafe
bool ConnectFailSafe(std::string path, const CallbackBase &cb)
This function will attempt to find all trace sources which match the input path and will then connect...
Definition: config.cc:929
ns3::AnimationInterface::Ipv4RoutePathElement
Ipv4RoutePathElement structure.
Definition: animation-interface.h:524
ns3::AnimationInterface::SkipPacketTracing
void SkipPacketTracing()
Do not trace packets.
Definition: animation-interface.cc:103
ns3::AnimationInterface::DOUBLE_COUNTER
@ DOUBLE_COUNTER
Definition: animation-interface.h:91
NS_ASSERT_MSG
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:88
ns3::AnimationInterface::WriteXmlRouting
void WriteXmlRouting(uint32_t id, std::string routingInfo)
Write XML routing function.
Definition: animation-interface.cc:2547
ns3::AnimationInterface::UpdateNodeSize
void UpdateNodeSize(uint32_t nodeId, double width, double height)
Helper function to update the size of a node.
Definition: animation-interface.cc:344
NS_LOG_UNCOND
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionally.
Definition: log-macros-enabled.h:269
ns3::AnimationInterface::m_f
FILE * m_f
File handle for output (0 if none)
Definition: animation-interface.h:611
ns3::AnimationInterface::m_queueDropCounterId
uint32_t m_queueDropCounterId
queue drop counter ID
Definition: animation-interface.h:647
list
#define list
Definition: openflow-interface.h:47
ns3::AnimationInterface::SetStopTime
void SetStopTime(Time t)
Specify the time at which capture should stop.
Definition: animation-interface.cc:226
ns3::AnimationInterface::CounterTypeToString
std::string CounterTypeToString(CounterType counterType)
Counter type to string function.
Definition: animation-interface.cc:1432
ns3::NetDevice::GetChannel
virtual Ptr< Channel > GetChannel(void) const =0
ns3::AnimationInterface::m_wifiPhyCountersPollInterval
Time m_wifiPhyCountersPollInterval
wifi Phy counters poll interval
Definition: animation-interface.h:634
ns3::AnimationInterface::WriteIpv4Addresses
void WriteIpv4Addresses()
Write IPv4 Addresses function.
Definition: animation-interface.cc:1907
ns3::AnimationInterface::TrackWifiMacCounters
void TrackWifiMacCounters()
Track wifi MAC counters function.
Definition: animation-interface.cc:2178
ns3::AnimationInterface::m_currentPktCount
uint64_t m_currentPktCount
current packet count
Definition: animation-interface.h:676
ns3::AnimByteTag::GetTypeId
static TypeId GetTypeId(void)
Get Type Id.
Definition: animation-interface.cc:2859
ns3::AnimationInterface::UAN
@ UAN
Definition: animation-interface.h:532
ns3::AnimationInterface::WriteLinkProperties
void WriteLinkProperties()
Write link properties function.
Definition: animation-interface.cc:1945
ns3::AnimationInterface::WriteXmlIpv4Addresses
void WriteXmlIpv4Addresses(uint32_t nodeId, std::vector< std::string > ipv4Addresses)
Write XML Ipv4 addresses function.
Definition: animation-interface.cc:2515
ns3::AnimationInterface::m_nodeColors
NodeColorsMap m_nodeColors
node colors
Definition: animation-interface.h:672
ns3::MakeCallback
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:1642
rgb::g
uint8_t g
green
Definition: colors-link-description.cc:36
ns3::AnimationInterface::m_ipv4L3ProtocolRxCounterId
uint32_t m_ipv4L3ProtocolRxCounterId
IPv4 L3 protocol receive counter ID.
Definition: animation-interface.h:642
ns3::AnimationInterface::GetNodeEnergyFraction
double GetNodeEnergyFraction(Ptr< const Node > node) const
Get node's energy fraction (This used only for testing)
Definition: animation-interface.cc:401
ns3::AnimationInterface::WifiMacTxDropTrace
void WifiMacTxDropTrace(std::string context, Ptr< const Packet > p)
wifi MAC transmit drop trace function
Definition: animation-interface.cc:680
ns3::AnimationInterface::m_wifiMacRxDropCounterId
uint32_t m_wifiMacRxDropCounterId
wifi MAC receive drop counter ID
Definition: animation-interface.h:652
ns3::AnimationInterface::GetNodeFromContext
Ptr< Node > GetNodeFromContext(const std::string &context) const
Get node from context.
Definition: animation-interface.cc:578
ns3::Ipv4::GetRoutingProtocol
virtual Ptr< Ipv4RoutingProtocol > GetRoutingProtocol(void) const =0
Get the routing protocol to be used by this Ipv4 stack.
ns3::AnimationInterface::m_nodeWifiMacRxDrop
NodeCounterMap64 m_nodeWifiMacRxDrop
node wifi MAC receive drop
Definition: animation-interface.h:692
ns3::AnimationInterface::Ipv4RxTrace
void Ipv4RxTrace(std::string context, Ptr< const Packet > p, Ptr< Ipv4 > ipv4, uint32_t interfaceIndex)
IPv4 receive trace function.
Definition: animation-interface.cc:736
ns3::NodeList::End
static Iterator End(void)
Definition: node-list.cc:235
ns3::AnimationInterface::m_wifiMacTxCounterId
uint32_t m_wifiMacTxCounterId
wifi MAC transmit counter ID
Definition: animation-interface.h:649
ns3::NodeContainer::Iterator
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
Definition: node-container.h:42
ns3::AnimationInterface::AnimPacketInfo::m_lbTx
double m_lbTx
lb transmit
Definition: animation-interface.h:453
ns3::TypeId::GetName
std::string GetName(void) const
Get the name.
Definition: type-id.cc:977
ns3::AnimationInterface::Ipv4TxTrace
void Ipv4TxTrace(std::string context, Ptr< const Packet > p, Ptr< Ipv4 > ipv4, uint32_t interfaceIndex)
IPv4 transmit trace function.
Definition: animation-interface.cc:729
ns3::AnimationInterface::m_pendingWimaxPackets
AnimUidPacketInfoMap m_pendingWimaxPackets
pending wimax packets
Definition: animation-interface.h:658
ns3::AnimationInterface::GetElementsFromContext
const std::vector< std::string > GetElementsFromContext(const std::string &context) const
Get elements from context.
Definition: animation-interface.cc:562
NS_LOG_DEBUG
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
ns3::AnimationInterface::m_enablePacketMetadata
bool m_enablePacketMetadata
enable packet metadata
Definition: animation-interface.h:618
ns3::AnimationInterface::Ipv4RouteTrackElement
Ipv4RouteTrackElement structure.
Definition: animation-interface.h:517
ns3::AnimationInterface::ResetAnimWriteCallback
void ResetAnimWriteCallback()
Reset the write callback function.
Definition: animation-interface.cc:284
ns3::AnimationInterface::WIFI
@ WIFI
Definition: animation-interface.h:534
ns3::AnimationInterface::AnimPacketInfo::m_lbRx
double m_lbRx
lb receive
Definition: animation-interface.h:455
rgb::r
uint8_t r
red
Definition: colors-link-description.cc:35
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1289
ns3::AnimationInterface::m_nodeIpv4Drop
NodeCounterMap64 m_nodeIpv4Drop
node IPv4 drop
Definition: animation-interface.h:683
ns3::AnimationInterface::UanPhyGenRxTrace
void UanPhyGenRxTrace(std::string context, Ptr< const Packet >)
UAN Phy gen receive trace function.
Definition: animation-interface.cc:864
ns3::AnimationInterface::AnimPacketInfo::m_fbRx
double m_fbRx
fb receive
Definition: animation-interface.h:454
ns3::AnimationInterface::NodeIdIpv4Pair
std::pair< uint32_t, std::string > NodeIdIpv4Pair
NodeIdIpv4Pair typedef.
Definition: animation-interface.h:555
ns3::AnimationInterface::ConnectLteEnb
void ConnectLteEnb(Ptr< Node > n, Ptr< LteEnbNetDevice > nd, uint32_t devIndex)
Connect LTE ENB function.
Definition: animation-interface.cc:1551
ns3::Object::GetInstanceTypeId
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
Definition: object.cc:79
f
double f(double x, void *params)
Definition: 80211b.c:70
ns3::AnimationInterface::AnimPacketInfo::AnimPacketInfo
AnimPacketInfo()
Definition: animation-interface.cc:2911
ns3::AnimationInterface::LrWpanMacRxTrace
void LrWpanMacRxTrace(std::string context, Ptr< const Packet > p)
LR-WPAN MAC receive trace function.
Definition: animation-interface.cc:715
ns3::AnimationInterface::m_resources
std::vector< std::string > m_resources
resources
Definition: animation-interface.h:679
ns3::AnimationInterface::m_ipv6ToNodeIdMap
std::map< std::string, uint32_t > m_ipv6ToNodeIdMap
IPv6 to node ID map.
Definition: animation-interface.h:668
sample-rng-plot.x
list x
Definition: sample-rng-plot.py:34
ns3::AnimationInterface::m_nodeLrWpanMacTxDrop
NodeCounterMap64 m_nodeLrWpanMacTxDrop
node LR-WPAN MAC transmit drop
Definition: animation-interface.h:696
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition: log-macros-enabled.h:244
ns3::AnimationInterface::m_pendingLrWpanPackets
AnimUidPacketInfoMap m_pendingLrWpanPackets
pending LR-WPAN packets
Definition: animation-interface.h:659
ns3::Simulator::IsFinished
static bool IsFinished(void)
Check if the simulation should finish.
Definition: simulator.cc:165
ns3::MobilityModel
Keep track of the current position and velocity of an object.
Definition: mobility-model.h:40
ns3::AnimationInterface::m_wifiPhyRxDropCounterId
uint32_t m_wifiPhyRxDropCounterId
wifi Phy receive drop counter ID
Definition: animation-interface.h:655
ns3::AnimationInterface::GetMacAddress
std::string GetMacAddress(Ptr< NetDevice > nd)
Get MAC address function.
Definition: animation-interface.cc:1786
ns3::NodeContainer
keep track of a set of node pointers.
Definition: node-container.h:39
ns3::AnimationInterface::WriteXmlUpdateNodeCounter
void WriteXmlUpdateNodeCounter(uint32_t counterId, uint32_t nodeId, double value)
Write XML update node counter function.
Definition: animation-interface.cc:2705
ns3::AnimationInterface::LTE
@ LTE
Definition: animation-interface.h:533
ns3::AnimationInterface::WifiPhyRxBeginTrace
void WifiPhyRxBeginTrace(std::string context, Ptr< const Packet > p, RxPowerWattPerChannelBand rxPowersW)
wifi Phy receive begin trace function
Definition: animation-interface.cc:912
ns3::AnimationInterface::m_nodeQueueDrop
NodeCounterMap64 m_nodeQueueDrop
node queue drop
Definition: animation-interface.h:688
ns3::ByteTagIterator::HasNext
bool HasNext(void) const
Definition: packet.cc:65
ns3::Ipv4InterfaceAddress::GetLocal
Ipv4Address GetLocal(void) const
Get the local address.
Definition: ipv4-interface-address.cc:74
ns3::AnimByteTag::Print
virtual void Print(std::ostream &os) const
Print tag info.
Definition: animation-interface.cc:2894
ns3::Ipv6
Access to the IPv6 forwarding table, interfaces, and configuration.
Definition: ipv6.h:82
ns3::AnimationInterface::WriteXmlUpdateNodeImage
void WriteXmlUpdateNodeImage(uint32_t nodeId, uint32_t resourceId)
Write XML update node image function.
Definition: animation-interface.cc:2642
ns3::AnimationInterface::GetTracePktCount
uint64_t GetTracePktCount()
Get trace file packet count (This used only for testing)
Definition: animation-interface.cc:1462
ns3::AnimationInterface::WifiMacRxTrace
void WifiMacRxTrace(std::string context, Ptr< const Packet > p)
wifi MAC receive trace function
Definition: animation-interface.cc:687
ns3::NodeContainer::End
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
Definition: node-container.cc:82
ns3::Packet::Print
void Print(std::ostream &os) const
Print the packet contents.
Definition: packet.cc:434
ns3::RxPowerWattPerChannelBand
std::map< WifiSpectrumBand, double > RxPowerWattPerChannelBand
A map of the received power (Watts) for each band.
Definition: phy-entity.h:75
ns3::AnimationInterface::m_queueDequeueCounterId
uint32_t m_queueDequeueCounterId
queue dequeue counter ID
Definition: animation-interface.h:646
ns3::AnimationInterface::AddToIpv4AddressNodeIdTable
void AddToIpv4AddressNodeIdTable(std::string ipv4Address, uint32_t nodeId)
Add to IPv4 address node ID table function.
Definition: animation-interface.cc:1514
ns3::AnimationInterface::AnimXmlElement::AnimXmlElement
AnimXmlElement(std::string tagName, bool emptyElement=true)
Constructor.
Definition: animation-interface.cc:2742
ns3::AnimationInterface::WifiPhyTxBeginTrace
void WifiPhyTxBeginTrace(std::string context, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW)
wifi Phy transmit PSDU begin trace function
Definition: animation-interface.cc:871
ns3::AnimationInterface::AnimPacketInfo
AnimPacketInfo class.
Definition: animation-interface.h:433
ns3::AnimationInterface::m_nodeEnergyFraction
EnergyFractionMap m_nodeEnergyFraction
node energy fraction
Definition: animation-interface.h:675
ns3::AnimationInterface::m_queueCountersStopTime
Time m_queueCountersStopTime
queue counters stop time
Definition: animation-interface.h:629
ns3::AnimationInterface::m_nodeWifiMacRx
NodeCounterMap64 m_nodeWifiMacRx
node wifi MAC receive
Definition: animation-interface.h:691
ns3::AnimationInterface::WavePhyTxBeginTrace
void WavePhyTxBeginTrace(std::string context, Ptr< const Packet > p)
WAVE Phy transmit begin trace function.
Definition: animation-interface.cc:1030
ns3::AnimationInterface::m_ipv4L3ProtocolCountersPollInterval
Time m_ipv4L3ProtocolCountersPollInterval
IPv4 L3 protocol counters poll interval.
Definition: animation-interface.h:628
ns3::AnimationInterface::m_nodeLocation
std::map< uint32_t, Vector > m_nodeLocation
node location
Definition: animation-interface.h:665
ns3::AnimationInterface::LrWpanMacTxDropTrace
void LrWpanMacTxDropTrace(std::string context, Ptr< const Packet > p)
LR-WPAN MAC transmit drop trace function.
Definition: animation-interface.cc:708
ns3::AnimationInterface::m_nodeQueueDequeue
NodeCounterMap64 m_nodeQueueDequeue
node queue dequeue
Definition: animation-interface.h:687
ns3::AnimationInterface::CsmaPhyTxBeginTrace
void CsmaPhyTxBeginTrace(std::string context, Ptr< const Packet > p)
CSMA Phy transmit begin trace function.
Definition: animation-interface.cc:1168
ns3::AnimationInterface::WriteXmlPRef
void WriteXmlPRef(uint64_t animUid, uint32_t fId, double fbTx, std::string metaInfo="")
Write XMLP Ref function.
Definition: animation-interface.cc:2580
ns3::AnimationInterface::OutputWirelessPacketTxInfo
void OutputWirelessPacketTxInfo(Ptr< const Packet > p, AnimPacketInfo &pktInfo, uint64_t animUid)
Output wireless packet transmit info.
Definition: animation-interface.cc:1251
ns3::AnimationInterface::AddToIpv6AddressNodeIdTable
void AddToIpv6AddressNodeIdTable(std::string ipv6Address, uint32_t nodeId)
Add to IPv6 address node ID table function.
Definition: animation-interface.cc:1532
ns3::AnimationInterface::GetIpv4Address
std::string GetIpv4Address(Ptr< NetDevice > nd)
Get IPv4 address.
Definition: animation-interface.cc:1795
ns3::AnimationInterface::WimaxTxTrace
void WimaxTxTrace(std::string context, Ptr< const Packet > p, const Mac48Address &m)
WIMax transmit trace function.
Definition: animation-interface.cc:1075
ns3::AnimationInterface::m_pendingUanPackets
AnimUidPacketInfoMap m_pendingUanPackets
pending UAN packets
Definition: animation-interface.h:662
ns3::AnimationInterface::MobilityCourseChangeTrace
void MobilityCourseChangeTrace(Ptr< const MobilityModel > mob)
Mobility course change trace function.
Definition: animation-interface.cc:409
ns3::AnimationInterface::NodeSize::width
double width
width
Definition: animation-interface.h:544
ns3::AnimationInterface::m_pendingLtePackets
AnimUidPacketInfoMap m_pendingLtePackets
pending LTE packets
Definition: animation-interface.h:660
ns3::AnimationInterface::IsInTimeWindow
bool IsInTimeWindow()
Is in time window function.
Definition: animation-interface.cc:2092
ns3::AnimationInterface::WriteXmlNonP2pLinkProperties
void WriteXmlNonP2pLinkProperties(uint32_t id, std::string ipAddress, std::string channelType)
Write XML non P2P link properties function.
Definition: animation-interface.cc:2729
ns3::AnimationInterface::CsmaPhyRxEndTrace
void CsmaPhyRxEndTrace(std::string context, Ptr< const Packet > p)
CSMA Phy receive end trace function.
Definition: animation-interface.cc:1209
ns3::ByteTagIterator
Iterator over the set of byte tags in a packet.
Definition: packet.h:55
ns3::AnimationInterface::GetPosition
Vector GetPosition(Ptr< Node > n)
Get position function.
Definition: animation-interface.cc:1775
ns3::Packet::FindFirstMatchingByteTag
bool FindFirstMatchingByteTag(Tag &tag) const
Finds the first tag matching the parameter Tag type.
Definition: packet.cc:939
ns3::AnimationInterface::OutputCsmaPacket
void OutputCsmaPacket(Ptr< const Packet > p, AnimPacketInfo &pktInfo)
Output CSMA packet function.
Definition: animation-interface.cc:1275
ns3::TagBuffer
read and write tag data
Definition: tag-buffer.h:52
ns3::AnimationInterface::AnimationInterface
AnimationInterface(const std::string filename)
Constructor.
Definition: animation-interface.cc:75
ns3::AnimationInterface::UpdateNodeImage
void UpdateNodeImage(uint32_t nodeId, uint32_t resourceId)
Helper function to update the image of a node.
Definition: animation-interface.cc:313
ns3::AnimationInterface::WriteXmlAnim
void WriteXmlAnim(bool routing=false)
Write XML anim function.
Definition: animation-interface.cc:2432
ns3::AnimationInterface::UpdateNodeDescription
void UpdateNodeDescription(Ptr< Node > n, std::string descr)
Helper function to update the description for a given node.
Definition: animation-interface.cc:384
ns3::AnimByteTag::Set
void Set(uint64_t AnimUid)
Set global Uid in tag.
Definition: animation-interface.cc:2900
ns3::AnimationInterface::SetMobilityPollInterval
void SetMobilityPollInterval(Time t)
Set mobility poll interval:WARNING: setting a low interval can cause slowness.
Definition: animation-interface.cc:290
ns3::Ipv4Header::SetDestination
void SetDestination(Ipv4Address destination)
Definition: ipv4-header.cc:298
ns3::AnimationInterface::AnimPacketInfo::m_txNodeId
uint32_t m_txNodeId
node ID
Definition: animation-interface.h:451
ns3::LrWpanNetDevice::GetMac
Ptr< LrWpanMac > GetMac(void) const
Get the MAC used by this NetDevice.
Definition: lr-wpan-net-device.cc:192
ns3::AnimationInterface::TrackWifiPhyCounters
void TrackWifiPhyCounters()
Track wifi phy counters function.
Definition: animation-interface.cc:2197
ns3::AnimationInterface::Ipv4DropTrace
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.
Definition: animation-interface.cc:743
ns3::WifiMacHeader::GetAddr2
Mac48Address GetAddr2(void) const
Return the address in the Address 2 field.
Definition: wifi-mac-header.cc:430
ns3::AnimationInterface::WriteXmlUpdateNodePosition
void WriteXmlUpdateNodePosition(uint32_t nodeId, double x, double y)
Write XML update node position function.
Definition: animation-interface.cc:2665
ns3::AnimationInterface::Rgb
RGB structure.
Definition: animation-interface.h:467
ns3::AnimationInterface::TrackIpv4RoutePaths
void TrackIpv4RoutePaths()
Track IPv4 route paths function.
Definition: animation-interface.cc:2238
NETANIM_VERSION
#define NETANIM_VERSION
Definition: animation-interface.h:53
ns3::AnimationInterface::SetStartTime
void SetStartTime(Time t)
Specify the time at which capture should start.
Definition: animation-interface.cc:220
ns3::AnimationInterface::WriteIpv6Addresses
void WriteIpv6Addresses()
Write IPv6 Addresses function.
Definition: animation-interface.cc:1926
ns3::AnimationInterface::AddNodeCounter
uint32_t AddNodeCounter(std::string counterName, CounterType counterType)
Setup a node counter.
Definition: animation-interface.cc:238
ns3::AnimationInterface::GenericWirelessTxTrace
void GenericWirelessTxTrace(std::string context, Ptr< const Packet > p, ProtocolType protocolType)
Generic wireless transmit trace function.
Definition: animation-interface.cc:807
ns3::AnimationInterface::m_startTime
Time m_startTime
start time
Definition: animation-interface.h:619
ns3::AnimationInterface::m_wifiMacCountersStopTime
Time m_wifiMacCountersStopTime
wifi MAC counters stop time
Definition: animation-interface.h:631
ns3::AnimationInterface::WriteNodeEnergies
void WriteNodeEnergies()
Write node energies function.
Definition: animation-interface.cc:2078
ns3::AnimationInterface::LRWPAN
@ LRWPAN
Definition: animation-interface.h:537
ns3::AnimationInterface::AnimXmlElement::AddAttribute
void AddAttribute(std::string attribute, T value, bool xmlEscape=false)
Add attribute function.
Definition: animation-interface.cc:2750
ns3::AnimationInterface::UanPhyGenTxTrace
void UanPhyGenTxTrace(std::string context, Ptr< const Packet >)
UAN Phy gen transmit trace function.
Definition: animation-interface.cc:857
ns3::MobilityModel::GetPosition
Vector GetPosition(void) const
Definition: mobility-model.cc:64
ns3::AnimationInterface::WifiMacTxTrace
void WifiMacTxTrace(std::string context, Ptr< const Packet > p)
wifi MAC transmit trace function
Definition: animation-interface.cc:673
ns3::Packet::AddByteTag
void AddByteTag(const Tag &tag) const
Tag each byte included in this packet with a new byte tag.
Definition: packet.cc:912
ns3::AnimationInterface::m_mobilityPollInterval
Time m_mobilityPollInterval
mobility poll interval
Definition: animation-interface.h:613
ns3::UniformRandomVariable::GetValue
double GetValue(double min, double max)
Get the next random value, as a double in the specified range .
Definition: random-variable-stream.cc:182
ns3::Socket::ERROR_NOROUTETOHOST
@ ERROR_NOROUTETOHOST
Definition: socket.h:93
ns3::AnimationInterface::LrWpanMacRxDropTrace
void LrWpanMacRxDropTrace(std::string context, Ptr< const Packet > p)
LR-WPAN MAC receive drop trace function.
Definition: animation-interface.cc:722
ns3::AnimationInterface::m_ipv4RouteTrackElements
std::vector< Ipv4RouteTrackElement > m_ipv4RouteTrackElements
IPv route track elements.
Definition: animation-interface.h:677
ns3::TagBuffer::ReadU64
uint64_t ReadU64(void)
Definition: tag-buffer.cc:134
ns3::AnimationInterface::~AnimationInterface
~AnimationInterface()
Destructor for the animator interface.
Definition: animation-interface.cc:97
ns3::AnimationInterface::DevTxTrace
void DevTxTrace(std::string context, Ptr< const Packet > p, Ptr< NetDevice > tx, Ptr< NetDevice > rx, Time txTime, Time rxTime)
Device transmit trace function.
Definition: animation-interface.cc:779
ns3::AnimationInterface::RemainingEnergyTrace
void RemainingEnergyTrace(std::string context, double previousEnergy, double currentEnergy)
Remaining energy trace function.
Definition: animation-interface.cc:638
ns3::AnimationInterface::NodeHasMoved
bool NodeHasMoved(Ptr< Node > n, Vector newLocation)
Node has moved function.
Definition: animation-interface.cc:428
ns3::NodeList::GetNode
static Ptr< Node > GetNode(uint32_t n)
Definition: node-list.cc:241
ns3::AnimationInterface::m_nodeCounters
std::vector< std::string > m_nodeCounters
node counters
Definition: animation-interface.h:680
CHECK_STARTED_INTIMEWINDOW
#define CHECK_STARTED_INTIMEWINDOW
Definition: animation-interface.h:54
ns3::Time::GetSeconds
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:380
sample-rng-plot.n
n
Definition: sample-rng-plot.py:37
ns3::AnimationInterface::Ipv4RouteTrackElement::destination
std::string destination
destination
Definition: animation-interface.h:518
ns3::AnimationInterface::LteSpectrumPhyRxStart
void LteSpectrumPhyRxStart(std::string context, Ptr< const PacketBurst > pb)
LTE Spectrum Phy receive start function.
Definition: animation-interface.cc:1134
third.mobility
mobility
Definition: third.py:108
ns3::TagBuffer::WriteU64
void WriteU64(uint64_t v)
Definition: tag-buffer.cc:102
ns3::AnimationInterface::AddByteTag
void AddByteTag(uint64_t animUid, Ptr< const Packet > p)
Add byte tag function.
Definition: animation-interface.cc:630
ns3::AnimationInterface::ProtocolTypeToString
std::string ProtocolTypeToString(ProtocolType protocolType)
Protocol type to string function.
Definition: animation-interface.cc:1385
ns3::AnimationInterface::WriteNodes
void WriteNodes()
Write nodes function.
Definition: animation-interface.cc:2038
ns3::WifiNetDevice::GetMac
Ptr< WifiMac > GetMac(void) const
Definition: wifi-net-device.cc:201
ns3::AnimationInterface::m_ipv4ToNodeIdMap
std::map< std::string, uint32_t > m_ipv4ToNodeIdMap
IPv4 to node ID map.
Definition: animation-interface.h:667
ns3::AnimationInterface::m_routingF
FILE * m_routingF
File handle for routing table output (0 if None);.
Definition: animation-interface.h:612
NS_ABORT_MSG
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition: abort.h:50
ns3::AnimByteTag::Serialize
virtual void Serialize(TagBuffer i) const
Serialize function.
Definition: animation-interface.cc:2882
ns3::AnimationInterface::LteTxTrace
void LteTxTrace(std::string context, Ptr< const Packet > p, const Mac48Address &m)
LTE transmit trace function.
Definition: animation-interface.cc:1090