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
64namespace ns3 {
65
66NS_LOG_COMPONENT_DEFINE ("AnimationInterface");
67
68// Globals
69
70static 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;
95}
96
98{
100}
101
102void
104{
105 m_trackPackets = false;
106}
107
108void
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
127void
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;
147 }
149}
150
151void
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;
168 }
170}
171
172void
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
194AnimationInterface::EnableIpv4RouteTracking (std::string fileName, Time startTime, Time stopTime, Time pollInterval)
195{
196 SetOutputFile (fileName, true);
198 m_routingPollInterval = pollInterval;
199 WriteXmlAnim (true);
201 return *this;
202}
203
205AnimationInterface::EnableIpv4RouteTracking (std::string fileName, Time startTime, Time stopTime, NodeContainer nc, Time pollInterval)
206{
207 m_routingNc = nc;
208 return EnableIpv4RouteTracking (fileName, startTime, stopTime, pollInterval);
209}
210
212AnimationInterface::AddSourceDestination (uint32_t fromNodeId, std::string ipv4Address)
213{
214 Ipv4RouteTrackElement element = { ipv4Address, fromNodeId };
215 m_ipv4RouteTrackElements.push_back (element);
216 return *this;
217}
218
219void
221{
222 m_startTime = t;
223}
224
225void
227{
228 m_stopTime = t;
229}
230
231void
233{
234 m_maxPktsPerFile = maxPacketsPerFile;
235}
236
238AnimationInterface::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
247AnimationInterface::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
255void
257{
258 m_enablePacketMetadata = enable;
259 if (enable)
260 {
262 }
263}
264
265bool
267{
268 return initialized;
269}
270
271bool
273{
274 return m_started;
275}
276
277void
279{
280 m_writeCallback = cb;
281}
282
283void
285{
286 m_writeCallback = 0;
287}
288
289void
291{
293}
294
295
296void
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
312void
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
323void
324AnimationInterface::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
333void
334AnimationInterface::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
343void
344AnimationInterface::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
351void
352AnimationInterface::UpdateNodeColor (Ptr <Node> n, uint8_t r, uint8_t g, uint8_t b)
353{
354 UpdateNodeColor (n->GetId (), r, g, b);
355}
356
357void
358AnimationInterface::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
367void
369 std::string linkDescription)
370{
371 WriteXmlUpdateLink (fromNode, toNode, linkDescription);
372}
373
374void
376 std::string linkDescription)
377{
378 NS_ASSERT (fromNode);
379 NS_ASSERT (toNode);
380 WriteXmlUpdateLink (fromNode->GetId (), toNode->GetId (), linkDescription);
381}
382
383void
385{
386 UpdateNodeDescription (n->GetId (), descr);
387}
388
389void
391{
392 NS_ASSERT (NodeList::GetNode (nodeId));
393 m_nodeDescriptions[nodeId] = descr;
395}
396
397// Private methods
398
399
400double
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
408void
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
427bool
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
444void
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
468std::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);
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
499int
500AnimationInterface::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
513int
514AnimationInterface::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
538void
539AnimationInterface::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
555void
556AnimationInterface::WriteNonP2pLinkProperties (uint32_t id, std::string ipv4Address, std::string channelType)
557{
558 WriteXmlNonP2pLinkProperties (id, ipv4Address, channelType);
559}
560
561const std::vector<std::string>
562AnimationInterface::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
578AnimationInterface::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
603uint64_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
629void
631{
632 AnimByteTag tag;
633 tag.Set (animUid);
634 p->AddByteTag (tag);
635}
636
637void
638AnimationInterface::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
658void
660{
661 const Ptr <const Node> node = GetNodeFromContext (context);
662 ++m_nodeWifiPhyTxDrop[node->GetId ()];
663}
664
665void
667{
668 const Ptr <const Node> node = GetNodeFromContext (context);
669 ++m_nodeWifiPhyRxDrop[node->GetId ()];
670}
671
672void
674{
675 const Ptr <const Node> node = GetNodeFromContext (context);
676 ++m_nodeWifiMacTx[node->GetId ()];
677}
678
679void
681{
682 const Ptr <const Node> node = GetNodeFromContext (context);
683 ++m_nodeWifiMacTxDrop[node->GetId ()];
684}
685
686void
688{
689 const Ptr <const Node> node = GetNodeFromContext (context);
690 ++m_nodeWifiMacRx[node->GetId ()];
691}
692
693void
695{
696 const Ptr <const Node> node = GetNodeFromContext (context);
697 ++m_nodeWifiMacRxDrop[node->GetId ()];
698}
699
700void
702{
703 const Ptr <const Node> node = GetNodeFromContext (context);
704 ++m_nodeLrWpanMacTx[node->GetId ()];
705}
706
707void
709{
710 const Ptr <const Node> node = GetNodeFromContext (context);
711 ++m_nodeLrWpanMacTxDrop[node->GetId ()];
712}
713
714void
716{
717 const Ptr <const Node> node = GetNodeFromContext (context);
718 ++m_nodeLrWpanMacRx[node->GetId ()];
719}
720
721void
723{
724 const Ptr <const Node> node = GetNodeFromContext (context);
725 ++m_nodeLrWpanMacRxDrop[node->GetId ()];
726}
727
728void
729AnimationInterface::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
735void
736AnimationInterface::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
742void
744 const Ipv4Header & ipv4Header,
747 Ptr<Ipv4> ipv4,
748 uint32_t)
749{
750 const Ptr <const Node> node = GetNodeFromContext (context);
751 ++m_nodeIpv4Drop[node->GetId ()];
752}
753
754void
757{
758 const Ptr <const Node> node = GetNodeFromContext (context);
759 ++m_nodeQueueEnqueue[node->GetId ()];
760}
761
762void
765{
766 const Ptr <const Node> node = GetNodeFromContext (context);
767 ++m_nodeQueueDequeue[node->GetId ()];
768}
769
770void
773{
774 const Ptr <const Node> node = GetNodeFromContext (context);
775 ++m_nodeQueueDrop[node->GetId ()];
776}
777
778void
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
806void
808{
809 NS_LOG_FUNCTION (this);
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
836void
838{
839 NS_LOG_FUNCTION (this);
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
856void
858{
859 NS_LOG_FUNCTION (this);
861}
862
863void
865{
866 NS_LOG_FUNCTION (this);
868}
869
870void
871AnimationInterface::WifiPhyTxBeginTrace (std::string context, WifiConstPsduMap psduMap, [[maybe_unused]] WifiTxVector txVector, double txPowerW)
872{
873 NS_LOG_FUNCTION (this);
876 NS_ASSERT (ndev);
877 UpdatePosition (ndev);
878
879 AnimPacketInfo pktInfo (ndev, Simulator::Now ());
881 for (auto& psdu : psduMap)
882 {
883 for (auto& mpdu : *PeekPointer (psdu.second))
884 {
885 ++gAnimUid;
886 NS_LOG_INFO ("WifiPhyTxTrace for MPDU:" << gAnimUid);
887 AddByteTag (gAnimUid, mpdu->GetPacket ()); //the underlying MSDU/A-MSDU should be handed off
888 AddPendingPacket (WIFI, gAnimUid, pktInfo);
889 OutputWirelessPacketTxInfo (mpdu->GetProtocolDataUnit (), pendingPackets->at (gAnimUid), gAnimUid); //PDU should be considered in order to have header
890 }
891 }
892
893 Ptr<WifiNetDevice> netDevice = DynamicCast<WifiNetDevice> (ndev);
894 if (netDevice)
895 {
896 Mac48Address nodeAddr = netDevice->GetMac ()->GetAddress ();
897 std::ostringstream oss;
898 oss << nodeAddr;
899 Ptr<Node> n = netDevice->GetNode ();
900 NS_ASSERT (n);
901 m_macToNodeIdMap[oss.str ()] = n->GetId ();
902 NS_LOG_INFO ("Added Mac" << oss.str () << " node:" << m_macToNodeIdMap[oss.str ()]);
903 }
904 else
905 {
906 NS_ABORT_MSG ("This NetDevice should be a Wi-Fi network device");
907 }
908}
909
910void
912{
913 NS_LOG_FUNCTION (this);
916 NS_ASSERT (ndev);
917 UpdatePosition (ndev);
918 uint64_t animUid = GetAnimUidFromPacket (p);
919 NS_LOG_INFO ("Wifi RxBeginTrace for packet: " << animUid);
921 {
922 NS_ASSERT_MSG (false, "WifiPhyRxBeginTrace: unknown Uid");
923 std::ostringstream oss;
924 WifiMacHeader hdr;
925 if (!p->PeekHeader (hdr))
926 {
927 NS_LOG_WARN ("WifiMacHeader not present");
928 return;
929 }
930 oss << hdr.GetAddr2 ();
931 if (m_macToNodeIdMap.find (oss.str ()) == m_macToNodeIdMap.end ())
932 {
933 NS_LOG_WARN ("Transmitter Mac address " << oss.str () << " never seen before. Skipping");
934 return;
935 }
936 Ptr <Node> txNode = NodeList::GetNode (m_macToNodeIdMap[oss.str ()]);
937 UpdatePosition (txNode);
938 AnimPacketInfo pktInfo (0, Simulator::Now (), m_macToNodeIdMap[oss.str ()]);
939 AddPendingPacket (AnimationInterface::WIFI, animUid, pktInfo);
940 NS_LOG_WARN ("WifiPhyRxBegin: unknown Uid, but we are adding a wifi packet");
941 }
943 m_pendingWifiPackets[animUid].ProcessRxBegin (ndev, Simulator::Now ().GetSeconds ());
945}
946
947void
950{
951 NS_LOG_FUNCTION (this);
953
955 NS_ASSERT (ndev);
956 Ptr<LrWpanNetDevice> netDevice = DynamicCast<LrWpanNetDevice> (ndev);
957
958 Ptr <Node> n = ndev->GetNode ();
959 NS_ASSERT (n);
960
961 UpdatePosition (n);
962
963 LrWpanMacHeader hdr;
964 if (!p->PeekHeader (hdr))
965 {
966 NS_LOG_WARN ("LrWpanMacHeader not present");
967 return;
968 }
969
970 std::ostringstream oss;
971 if (hdr.GetSrcAddrMode () == 2)
972 {
973 Mac16Address nodeAddr = netDevice->GetMac ()->GetShortAddress ();
974 oss << nodeAddr;
975 }
976 else if (hdr.GetSrcAddrMode () == 3)
977 {
978 Mac64Address nodeAddr = netDevice->GetMac ()->GetExtendedAddress ();
979 oss << nodeAddr;
980 }
981 else
982 {
983 NS_LOG_WARN ("LrWpanMacHeader without source address");
984 return;
985 }
986 m_macToNodeIdMap[oss.str ()] = n->GetId ();
987 NS_LOG_INFO ("Added Mac" << oss.str () << " node:" << m_macToNodeIdMap[oss.str ()]);
988
989 ++gAnimUid;
990 NS_LOG_INFO ("LrWpan TxBeginTrace for packet:" << gAnimUid);
991 AddByteTag (gAnimUid, p);
992
993 AnimPacketInfo pktInfo (ndev, Simulator::Now ());
995
997}
998
999void
1002{
1003 NS_LOG_FUNCTION (this);
1006 NS_ASSERT (ndev);
1007 Ptr <Node> n = ndev->GetNode ();
1008 NS_ASSERT (n);
1009
1010 AnimByteTag tag;
1011 if (!p->FindFirstMatchingByteTag (tag))
1012 {
1013 return;
1014 }
1015
1016 uint64_t animUid = GetAnimUidFromPacket (p);
1017 NS_LOG_INFO ("LrWpan RxBeginTrace for packet:" << animUid);
1019 {
1020 NS_LOG_WARN ("LrWpanPhyRxBeginTrace: unknown Uid - most probably it's an ACK.");
1021 }
1022
1023 UpdatePosition (n);
1024 m_pendingLrWpanPackets[animUid].ProcessRxBegin (ndev, Simulator::Now ().GetSeconds ());
1026}
1027
1028void
1030{
1031 NS_LOG_FUNCTION (this);
1033}
1034
1035void
1037{
1038 NS_LOG_FUNCTION (this);
1041 NS_ASSERT (ndev);
1042 UpdatePosition (ndev);
1043 uint64_t animUid = GetAnimUidFromPacket (p);
1044 NS_LOG_INFO ("Wave RxBeginTrace for packet:" << animUid);
1046 {
1047 NS_ASSERT_MSG (false, "WavePhyRxBeginTrace: unknown Uid");
1048 std::ostringstream oss;
1049 WifiMacHeader hdr;
1050 if (!p->PeekHeader (hdr))
1051 {
1052 NS_LOG_WARN ("WaveMacHeader not present");
1053 return;
1054 }
1055 oss << hdr.GetAddr2 ();
1056 if (m_macToNodeIdMap.find (oss.str ()) == m_macToNodeIdMap.end ())
1057 {
1058 NS_LOG_WARN ("Transmitter Mac address " << oss.str () << " never seen before. Skipping");
1059 return;
1060 }
1061 Ptr <Node> txNode = NodeList::GetNode (m_macToNodeIdMap[oss.str ()]);
1062 UpdatePosition (txNode);
1063 AnimPacketInfo pktInfo (0, Simulator::Now (), m_macToNodeIdMap[oss.str ()]);
1064 AddPendingPacket (AnimationInterface::WAVE, animUid, pktInfo);
1065 NS_LOG_WARN ("WavePhyRxBegin: unknown Uid, but we are adding a wave packet");
1066 }
1068 m_pendingWavePackets[animUid].ProcessRxBegin (ndev, Simulator::Now ().GetSeconds ());
1069 OutputWirelessPacketRxInfo (p, m_pendingWavePackets[animUid], animUid);
1070}
1071
1072
1073void
1075{
1076 NS_LOG_FUNCTION (this);
1078}
1079
1080
1081void
1083{
1084 NS_LOG_FUNCTION (this);
1086}
1087
1088void
1090{
1091 NS_LOG_FUNCTION (this);
1093}
1094
1095void
1097{
1098 NS_LOG_FUNCTION (this);
1100}
1101
1102void
1104{
1105 NS_LOG_FUNCTION (this);
1107 if (!pb)
1108 {
1109 NS_LOG_WARN ("pb == 0. Not yet supported");
1110 return;
1111 }
1112 context = "/" + context;
1114 NS_ASSERT (ndev);
1115 UpdatePosition (ndev);
1116
1117 std::list <Ptr <Packet> > pbList = pb->GetPackets ();
1118 for (std::list <Ptr <Packet> >::iterator i = pbList.begin ();
1119 i != pbList.end ();
1120 ++i)
1121 {
1122 Ptr <Packet> p = *i;
1123 ++gAnimUid;
1124 NS_LOG_INFO ("LteSpectrumPhyTxTrace for packet:" << gAnimUid);
1125 AnimPacketInfo pktInfo (ndev, Simulator::Now ());
1126 AddByteTag (gAnimUid, p);
1129 }
1130}
1131
1132void
1134{
1135 NS_LOG_FUNCTION (this);
1137 if (!pb)
1138 {
1139 NS_LOG_WARN ("pb == 0. Not yet supported");
1140 return;
1141 }
1142 context = "/" + context;
1144 NS_ASSERT (ndev);
1145 UpdatePosition (ndev);
1146
1147 std::list <Ptr <Packet> > pbList = pb->GetPackets ();
1148 for (std::list <Ptr <Packet> >::iterator i = pbList.begin ();
1149 i != pbList.end ();
1150 ++i)
1151 {
1152 Ptr <Packet> p = *i;
1153 uint64_t animUid = GetAnimUidFromPacket (p);
1154 NS_LOG_INFO ("LteSpectrumPhyRxTrace for packet:" << gAnimUid);
1156 {
1157 NS_LOG_WARN ("LteSpectrumPhyRxTrace: unknown Uid");
1158 return;
1159 }
1160 AnimPacketInfo& pktInfo = m_pendingLtePackets[animUid];
1161 pktInfo.ProcessRxBegin (ndev, Simulator::Now ().GetSeconds ());
1162 OutputWirelessPacketRxInfo (p, pktInfo, animUid);
1163 }
1164}
1165
1166void
1168{
1169 NS_LOG_FUNCTION (this);
1172 NS_ASSERT (ndev);
1173 UpdatePosition (ndev);
1174 ++gAnimUid;
1175 NS_LOG_INFO ("CsmaPhyTxBeginTrace for packet:" << gAnimUid);
1176 AddByteTag (gAnimUid, p);
1177 UpdatePosition (ndev);
1178 AnimPacketInfo pktInfo (ndev, Simulator::Now ());
1180
1181
1182}
1183
1184void
1186{
1187 NS_LOG_FUNCTION (this);
1190 NS_ASSERT (ndev);
1191 UpdatePosition (ndev);
1192 uint64_t animUid = GetAnimUidFromPacket (p);
1193 NS_LOG_INFO ("CsmaPhyTxEndTrace for packet:" << animUid);
1195 {
1196 NS_LOG_WARN ("CsmaPhyTxEndTrace: unknown Uid");
1197 NS_FATAL_ERROR ("CsmaPhyTxEndTrace: unknown Uid");
1198 AnimPacketInfo pktInfo (ndev, Simulator::Now ());
1199 AddPendingPacket (AnimationInterface::CSMA, animUid, pktInfo);
1200 NS_LOG_WARN ("Unknown Uid, but adding Csma Packet anyway");
1201 }
1203 AnimPacketInfo& pktInfo = m_pendingCsmaPackets[animUid];
1204 pktInfo.m_lbTx = Simulator::Now ().GetSeconds ();
1205}
1206
1207void
1209{
1210 NS_LOG_FUNCTION (this);
1213 NS_ASSERT (ndev);
1214 UpdatePosition (ndev);
1215 uint64_t animUid = GetAnimUidFromPacket (p);
1217 {
1218 NS_LOG_WARN ("CsmaPhyRxEndTrace: unknown Uid");
1219 return;
1220 }
1222 AnimPacketInfo& pktInfo = m_pendingCsmaPackets[animUid];
1223 pktInfo.ProcessRxBegin (ndev, Simulator::Now ().GetSeconds ());
1224 NS_LOG_INFO ("CsmaPhyRxEndTrace for packet:" << animUid);
1225 NS_LOG_INFO ("CsmaPhyRxEndTrace for packet:" << animUid << " complete");
1226 OutputCsmaPacket (p, pktInfo);
1227}
1228
1229void
1232{
1233 NS_LOG_FUNCTION (this);
1236 NS_ASSERT (ndev);
1237 uint64_t animUid = GetAnimUidFromPacket (p);
1239 {
1240 NS_LOG_WARN ("CsmaMacRxTrace: unknown Uid");
1241 return;
1242 }
1244 AnimPacketInfo& pktInfo = m_pendingCsmaPackets[animUid];
1245 NS_LOG_INFO ("MacRxTrace for packet:" << animUid << " complete");
1246 OutputCsmaPacket (p, pktInfo);
1247}
1248
1249void
1251{
1253 uint32_t nodeId = 0;
1254 if (pktInfo.m_txnd)
1255 {
1256 nodeId = pktInfo.m_txnd->GetNode ()->GetId ();
1257 }
1258 else
1259 {
1260 nodeId = pktInfo.m_txNodeId;
1261 }
1262 WriteXmlPRef (animUid, nodeId, pktInfo.m_fbTx, m_enablePacketMetadata ? GetPacketMetadata (p) : "");
1263}
1264
1265void
1267{
1269 uint32_t rxId = pktInfo.m_rxnd->GetNode ()->GetId ();
1270 WriteXmlP (animUid, "wpr", rxId, pktInfo.m_fbRx, pktInfo.m_lbRx);
1271}
1272
1273void
1275{
1277 NS_ASSERT (pktInfo.m_txnd);
1278 uint32_t nodeId = pktInfo.m_txnd->GetNode ()->GetId ();
1279 uint32_t rxId = pktInfo.m_rxnd->GetNode ()->GetId ();
1280
1281 WriteXmlP ("p",
1282 nodeId,
1283 pktInfo.m_fbTx,
1284 pktInfo.m_lbTx,
1285 rxId,
1286 pktInfo.m_fbRx,
1287 pktInfo.m_lbRx,
1289}
1290
1291void
1293{
1294 AnimUidPacketInfoMap * pendingPackets = ProtocolTypeToPendingPackets (protocolType);
1295 NS_ASSERT (pendingPackets);
1296 pendingPackets->insert (AnimUidPacketInfoMap::value_type (animUid, pktInfo));
1297}
1298
1299bool
1301{
1302 AnimUidPacketInfoMap * pendingPackets = ProtocolTypeToPendingPackets (protocolType);
1303 NS_ASSERT (pendingPackets);
1304 return (pendingPackets->find (animUid) != pendingPackets->end ());
1305}
1306
1307void
1309{
1310 AnimUidPacketInfoMap * pendingPackets = ProtocolTypeToPendingPackets (protocolType);
1311 NS_ASSERT (pendingPackets);
1312 if (pendingPackets->empty ())
1313 {
1314 return;
1315 }
1316 std::vector <uint64_t> purgeList;
1317 for (AnimUidPacketInfoMap::iterator i = pendingPackets->begin ();
1318 i != pendingPackets->end ();
1319 ++i)
1320 {
1321
1322 AnimPacketInfo pktInfo = i->second;
1323 double delta = (Simulator::Now ().GetSeconds () - pktInfo.m_fbTx);
1324 if (delta > PURGE_INTERVAL)
1325 {
1326 purgeList.push_back (i->first);
1327 }
1328 }
1329 for (std::vector <uint64_t>::iterator i = purgeList.begin ();
1330 i != purgeList.end ();
1331 ++i)
1332 {
1333 pendingPackets->erase (*i);
1334 }
1335}
1336
1339{
1340 AnimUidPacketInfoMap * pendingPackets = 0;
1341 switch (protocolType)
1342 {
1344 {
1345 pendingPackets = &m_pendingWifiPackets;
1346 break;
1347 }
1349 {
1350 pendingPackets = &m_pendingUanPackets;
1351 break;
1352 }
1354 {
1355 pendingPackets = &m_pendingCsmaPackets;
1356 break;
1357 }
1359 {
1360 pendingPackets = &m_pendingWimaxPackets;
1361 break;
1362 }
1364 {
1365 pendingPackets = &m_pendingLtePackets;
1366 break;
1367 }
1369 {
1370 pendingPackets = &m_pendingLrWpanPackets;
1371 break;
1372 }
1374 {
1375 pendingPackets = &m_pendingWavePackets;
1376 break;
1377 }
1378 }
1379 return pendingPackets;
1380
1381}
1382
1383std::string
1385{
1386 std::string result = "Unknown";
1387 switch (protocolType)
1388 {
1390 {
1391 result = "WIFI";
1392 break;
1393 }
1395 {
1396 result = "UAN";
1397 break;
1398 }
1400 {
1401 result = "CSMA";
1402 break;
1403 }
1405 {
1406 result = "WIMAX";
1407 break;
1408 }
1410 {
1411 result = "LTE";
1412 break;
1413 }
1415 {
1416 result = "LRWPAN";
1417 break;
1418 }
1420 {
1421 result = "WAVE";
1422 break;
1423 }
1424 }
1425 return result;
1426}
1427
1428// Counters
1429
1430std::string
1432{
1433 std::string typeString = "unknown";
1434 switch (counterType)
1435 {
1436 case UINT32_COUNTER:
1437 {
1438 typeString = "UINT32";
1439 break;
1440 }
1441 case DOUBLE_COUNTER:
1442 {
1443 typeString = "DOUBLE";
1444 break;
1445 }
1446 }
1447 return typeString;
1448}
1449
1450// General
1451
1452std::string
1454{
1455 std::ostringstream oss;
1456 p->Print (oss);
1457 return oss.str ();
1458}
1459
1460uint64_t
1462{
1463 return m_currentPktCount;
1464}
1465
1466void
1468{
1469 m_started = false;
1470 NS_LOG_INFO ("Stopping Animation");
1472 if (m_f)
1473 {
1474 // Terminate the anim element
1475 WriteXmlClose ("anim");
1476 std::fclose (m_f);
1477 m_f = 0;
1478 }
1479 if (onlyAnimation)
1480 {
1481 return;
1482 }
1483 if (m_routingF)
1484 {
1485 WriteXmlClose ("anim", true);
1486 std::fclose (m_routingF);
1487 m_routingF = 0;
1488 }
1489}
1490
1491void
1493{
1495 m_started = true;
1497 WriteXmlAnim ();
1498 WriteNodes ();
1499 WriteNodeColors ();
1503 WriteNodeSizes ();
1505 if (!restart)
1506 {
1509 }
1510}
1511
1512void
1514{
1515 m_ipv4ToNodeIdMap[ipv4Address] = nodeId;
1516 m_nodeIdIpv4Map.insert (NodeIdIpv4Pair (nodeId, ipv4Address));
1517}
1518
1519void
1520AnimationInterface::AddToIpv4AddressNodeIdTable (std::vector<std::string> ipv4Addresses, uint32_t nodeId)
1521{
1522 for (std::vector<std::string>::const_iterator i = ipv4Addresses.begin ();
1523 i != ipv4Addresses.end ();
1524 ++i)
1525 {
1526 AddToIpv4AddressNodeIdTable (*i, nodeId);
1527 }
1528}
1529
1530void
1532{
1533 m_ipv6ToNodeIdMap[ipv6Address] = nodeId;
1534 m_nodeIdIpv6Map.insert (NodeIdIpv6Pair (nodeId, ipv6Address));
1535}
1536
1537void
1538AnimationInterface::AddToIpv6AddressNodeIdTable (std::vector<std::string> ipv6Addresses, uint32_t nodeId)
1539{
1540 for (std::vector<std::string>::const_iterator i = ipv6Addresses.begin ();
1541 i != ipv6Addresses.end ();
1542 ++i)
1543 {
1544 AddToIpv6AddressNodeIdTable (*i, nodeId);
1545 }
1546}
1547
1548// Callbacks
1549void
1551{
1552
1553 Ptr<LteEnbPhy> lteEnbPhy = nd->GetPhy ();
1554 Ptr<LteSpectrumPhy> dlPhy = lteEnbPhy->GetDownlinkSpectrumPhy ();
1555 Ptr<LteSpectrumPhy> ulPhy = lteEnbPhy->GetUplinkSpectrumPhy ();
1556 std::ostringstream oss;
1557 //NodeList/*/DeviceList/*/
1558 oss << "NodeList/" << n->GetId () << "/DeviceList/" << devIndex << "/";
1559 if (dlPhy)
1560 {
1561 dlPhy->TraceConnect ("TxStart", oss.str (), MakeCallback (&AnimationInterface::LteSpectrumPhyTxStart, this));
1562 dlPhy->TraceConnect ("RxStart", oss.str (), MakeCallback (&AnimationInterface::LteSpectrumPhyRxStart, this));
1563 }
1564 if (ulPhy)
1565 {
1566 ulPhy->TraceConnect ("TxStart", oss.str (), MakeCallback (&AnimationInterface::LteSpectrumPhyTxStart, this));
1567 ulPhy->TraceConnect ("RxStart", oss.str (), MakeCallback (&AnimationInterface::LteSpectrumPhyRxStart, this));
1568 }
1569}
1570
1571
1572
1573void
1575{
1576
1577 Ptr<LteUePhy> lteUePhy = nd->GetPhy ();
1578 Ptr<LteSpectrumPhy> dlPhy = lteUePhy->GetDownlinkSpectrumPhy ();
1579 Ptr<LteSpectrumPhy> ulPhy = lteUePhy->GetUplinkSpectrumPhy ();
1580 std::ostringstream oss;
1581 //NodeList/*/DeviceList/*/
1582 oss << "NodeList/" << n->GetId () << "/DeviceList/" << devIndex << "/";
1583 if (dlPhy)
1584 {
1585 dlPhy->TraceConnect ("TxStart", oss.str (), MakeCallback (&AnimationInterface::LteSpectrumPhyTxStart, this));
1586 dlPhy->TraceConnect ("RxStart", oss.str (), MakeCallback (&AnimationInterface::LteSpectrumPhyRxStart, this));
1587 }
1588 if (ulPhy)
1589 {
1590 ulPhy->TraceConnect ("TxStart", oss.str (), MakeCallback (&AnimationInterface::LteSpectrumPhyTxStart, this));
1591 ulPhy->TraceConnect ("RxStart", oss.str (), MakeCallback (&AnimationInterface::LteSpectrumPhyRxStart, this));
1592 }
1593}
1594
1595void
1597{
1598
1599 for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
1600 {
1601 Ptr<Node> n = *i;
1602 NS_ASSERT (n);
1603 uint32_t nDevices = n->GetNDevices ();
1604 for (uint32_t devIndex = 0; devIndex < nDevices; ++devIndex)
1605 {
1606 Ptr <NetDevice> nd = n->GetDevice (devIndex);
1607 if (!nd)
1608 {
1609 continue;
1610 }
1611 Ptr<LteUeNetDevice> lteUeNetDevice = DynamicCast<LteUeNetDevice> (nd);
1612 if (lteUeNetDevice)
1613 {
1614 ConnectLteUe (n, lteUeNetDevice, devIndex);
1615 continue;
1616 }
1617 Ptr<LteEnbNetDevice> lteEnbNetDevice = DynamicCast<LteEnbNetDevice> (nd);
1618 if (lteEnbNetDevice)
1619 {
1620 ConnectLteEnb (n, lteEnbNetDevice, devIndex);
1621 }
1622 }
1623
1624 }
1625}
1626
1627void
1629{
1630 // Connect the callbacks
1631 Config::ConnectFailSafe ("/ChannelList/*/TxRxPointToPoint",
1633 Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxPsduBegin",
1635 Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxBegin",
1637 Config::ConnectWithoutContextFailSafe ("/NodeList/*/$ns3::MobilityModel/CourseChange",
1639 Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::WimaxNetDevice/Tx",
1641 Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::WimaxNetDevice/Rx",
1643 Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::LteNetDevice/Tx",
1645 Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::LteNetDevice/Rx",
1647 Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::CsmaNetDevice/PhyTxBegin",
1649 Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::CsmaNetDevice/PhyTxEnd",
1651 Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::CsmaNetDevice/PhyRxEnd",
1653 Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::CsmaNetDevice/MacRx",
1655 Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::UanNetDevice/Phy/PhyTxBegin",
1657 Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::UanNetDevice/Phy/PhyRxBegin",
1659 Config::ConnectFailSafe ("/NodeList/*/$ns3::BasicEnergySource/RemainingEnergy",
1661
1662 ConnectLte ();
1663
1664 Config::ConnectFailSafe ("/NodeList/*/$ns3::Ipv4L3Protocol/Tx",
1666 Config::ConnectFailSafe ("/NodeList/*/$ns3::Ipv4L3Protocol/Rx",
1668 Config::ConnectFailSafe ("/NodeList/*/$ns3::Ipv4L3Protocol/Drop",
1670
1671 // Queue Enqueues
1672
1673 Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::AlohaNoackNetDevice/Queue/Enqueue",
1675 Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::CsmaNetDevice/TxQueue/Enqueue",
1677 Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::PointToPointNetDevice/TxQueue/Enqueue",
1679
1680 // Queue Dequeues
1681
1682 Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::AlohaNoackNetDevice/Queue/Dequeue",
1684 Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::CsmaNetDevice/TxQueue/Dequeue",
1686 Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::PointToPointNetDevice/TxQueue/Dequeue",
1688
1689 // Queue Drops
1690
1691 Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::AlohaNoackNetDevice/Queue/Drop",
1693 Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::CsmaNetDevice/TxQueue/Drop",
1695 Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::PointToPointNetDevice/TxQueue/Drop",
1697
1698
1699 // Wifi Mac
1700 Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/MacTx",
1702 Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/MacTxDrop",
1704 Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/MacRx",
1706 Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/MacRxDrop",
1708
1709 // Wifi Phy
1710 Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxDrop",
1712 Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxDrop",
1714
1715 // LrWpan
1716 Config::ConnectFailSafe ("NodeList/*/DeviceList/*/$ns3::LrWpanNetDevice/Phy/PhyTxBegin",
1718 Config::ConnectFailSafe ("NodeList/*/DeviceList/*/$ns3::LrWpanNetDevice/Phy/PhyRxBegin",
1720 Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::LrWpanNetDevice/Mac/MacTx",
1722 Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::LrWpanNetDevice/Mac/MacTxDrop",
1724 Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::LrWpanNetDevice/Mac/MacRx",
1726 Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::LrWpanNetDevice/Mac/MacRxDrop",
1728
1729 // Wave
1730 Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::WaveNetDevice/PhyEntities/*/$ns3::WifiPhy/PhyTxBegin",
1732 Config::ConnectFailSafe ("/NodeList/*/DeviceList/*/$ns3::WaveNetDevice/PhyEntities/*/$ns3::WifiPhy/PhyRxBegin",
1734}
1735
1736Vector
1738{
1740 if (loc)
1741 {
1742 m_nodeLocation[n->GetId ()] = loc->GetPosition ();
1743 }
1744 else
1745 {
1746 NS_LOG_UNCOND ( "AnimationInterface WARNING:Node:" << n->GetId () << " Does not have a mobility model. Use SetConstantPosition if it is stationary");
1747 Ptr<UniformRandomVariable> x = CreateObject<UniformRandomVariable> ();
1748 x->SetAttribute ("Min", DoubleValue (0));
1749 x->SetAttribute ("Max", DoubleValue (100));
1750 Ptr<UniformRandomVariable> y = CreateObject<UniformRandomVariable> ();
1751 y->SetAttribute ("Min", DoubleValue (0));
1752 y->SetAttribute ("Max", DoubleValue (100));
1753 m_nodeLocation[n->GetId ()] = Vector (int (x->GetValue ()), int (y->GetValue ()), 0);
1754 }
1755 return m_nodeLocation[n->GetId ()];
1756}
1757
1758Vector
1760{
1761 m_nodeLocation[n->GetId ()] = v;
1762 return v;
1763}
1764
1765Vector
1767{
1768 Ptr <Node> n = ndev->GetNode ();
1769 NS_ASSERT (n);
1770 return UpdatePosition (n);
1771}
1772
1773Vector
1775{
1776 if (m_nodeLocation.find (n->GetId ()) == m_nodeLocation.end ())
1777 {
1778 NS_FATAL_ERROR ("Node:" << n->GetId () << " not found in Location table");
1779 }
1780 return m_nodeLocation[n->GetId ()];
1781}
1782
1783
1784std::string
1786{
1787 Address nodeAddr = nd->GetAddress ();
1788 std::ostringstream oss;
1789 oss << nodeAddr;
1790 return oss.str ().substr (6); // Skip the first 6 chars to get the Mac
1791}
1792
1793std::string
1795{
1796 Ptr<Ipv4> ipv4 = NodeList::GetNode (nd->GetNode ()->GetId ())->GetObject <Ipv4> ();
1797 if (!ipv4)
1798 {
1799 NS_LOG_WARN ("Node: " << nd->GetNode ()->GetId () << " No ipv4 object found");
1800 return "0.0.0.0";
1801 }
1802 int32_t ifIndex = ipv4->GetInterfaceForDevice (nd);
1803 if (ifIndex == -1)
1804 {
1805 NS_LOG_WARN ("Node :" << nd->GetNode ()->GetId () << " Could not find index of NetDevice");
1806 return "0.0.0.0";
1807 }
1808 Ipv4InterfaceAddress addr = ipv4->GetAddress (ifIndex, 0);
1809 std::ostringstream oss;
1810 oss << addr.GetLocal ();
1811 return oss.str ();
1812}
1813
1814std::string
1816{
1817 Ptr<Ipv6> ipv6 = NodeList::GetNode (nd->GetNode ()->GetId ())->GetObject <Ipv6> ();
1818 if (!ipv6)
1819 {
1820 NS_LOG_WARN ("Node: " << nd->GetNode ()->GetId () << " No ipv4 object found");
1821 return "::";
1822 }
1823 int32_t ifIndex = ipv6->GetInterfaceForDevice (nd);
1824 if (ifIndex == -1)
1825 {
1826 NS_LOG_WARN ("Node :" << nd->GetNode ()->GetId () << " Could not find index of NetDevice");
1827 return "::";
1828 }
1829 bool nonLinkLocalFound = false;
1830 uint32_t nAddresses = ipv6->GetNAddresses (ifIndex);
1832 for (uint32_t addressIndex = 0; addressIndex < nAddresses; ++addressIndex)
1833 {
1834 addr = ipv6->GetAddress (ifIndex, addressIndex);
1835 if (!addr.GetAddress ().IsLinkLocal ())
1836 {
1837 nonLinkLocalFound = true;
1838 break;
1839 }
1840 }
1841 if (!nonLinkLocalFound)
1842 {
1843 addr = ipv6->GetAddress (ifIndex, 0);
1844 }
1845 std::ostringstream oss;
1846 oss << addr.GetAddress ();
1847 return oss.str ();
1848}
1849
1850
1851
1852std::vector<std::string>
1854{
1855 std::vector<std::string> ipv4Addresses;
1856 Ptr<Ipv4> ipv4 = NodeList::GetNode (nd->GetNode ()->GetId ())->GetObject <Ipv4> ();
1857 if (!ipv4)
1858 {
1859 NS_LOG_WARN ("Node: " << nd->GetNode ()->GetId () << " No ipv4 object found");
1860 return ipv4Addresses;
1861 }
1862 int32_t ifIndex = ipv4->GetInterfaceForDevice (nd);
1863 if (ifIndex == -1)
1864 {
1865 NS_LOG_WARN ("Node :" << nd->GetNode ()->GetId () << " Could not find index of NetDevice");
1866 return ipv4Addresses;
1867 }
1868 for (uint32_t index = 0; index < ipv4->GetNAddresses (ifIndex); ++index)
1869 {
1870 Ipv4InterfaceAddress addr = ipv4->GetAddress (ifIndex, index);
1871 std::ostringstream oss;
1872 oss << addr.GetLocal ();
1873 ipv4Addresses.push_back (oss.str ());
1874 }
1875 return ipv4Addresses;
1876}
1877
1878std::vector<std::string>
1880{
1881 std::vector<std::string> ipv6Addresses;
1882 Ptr<Ipv6> ipv6 = NodeList::GetNode (nd->GetNode ()->GetId ())->GetObject <Ipv6> ();
1883 if (!ipv6)
1884 {
1885 NS_LOG_WARN ("Node: " << nd->GetNode ()->GetId () << " No ipv6 object found");
1886 return ipv6Addresses;
1887 }
1888 int32_t ifIndex = ipv6->GetInterfaceForDevice (nd);
1889 if (ifIndex == -1)
1890 {
1891 NS_LOG_WARN ("Node :" << nd->GetNode ()->GetId () << " Could not find index of NetDevice");
1892 return ipv6Addresses;
1893 }
1894 for (uint32_t index = 0; index < ipv6->GetNAddresses (ifIndex); ++index)
1895 {
1896 Ipv6InterfaceAddress addr = ipv6->GetAddress (ifIndex, index);
1897 std::ostringstream oss;
1898 oss << addr.GetAddress ();
1899 ipv6Addresses.push_back (oss.str ());
1900 }
1901 return ipv6Addresses;
1902}
1903
1904
1905void
1907{
1908 for (NodeIdIpv4Map::const_iterator i = m_nodeIdIpv4Map.begin ();
1909 i != m_nodeIdIpv4Map.end ();
1910 ++i)
1911 {
1912 std::vector <std::string> ipv4Addresses;
1913 std::pair<NodeIdIpv4Map::const_iterator, NodeIdIpv4Map::const_iterator> iterPair = m_nodeIdIpv4Map.equal_range (i->first);
1914 for (NodeIdIpv4Map::const_iterator it = iterPair.first;
1915 it != iterPair.second;
1916 ++it)
1917 {
1918 ipv4Addresses.push_back (it->second);
1919 }
1920 WriteXmlIpv4Addresses (i->first, ipv4Addresses);
1921 }
1922}
1923
1924void
1926{
1927 for (NodeIdIpv6Map::const_iterator i = m_nodeIdIpv6Map.begin ();
1928 i != m_nodeIdIpv6Map.end ();
1929 i = m_nodeIdIpv6Map.upper_bound (i->first))
1930 {
1931 std::vector <std::string> ipv6Addresses;
1932 std::pair<NodeIdIpv6Map::const_iterator, NodeIdIpv6Map::const_iterator> iterPair = m_nodeIdIpv6Map.equal_range (i->first);
1933 for (NodeIdIpv6Map::const_iterator it = iterPair.first;
1934 it != iterPair.second;
1935 ++it)
1936 {
1937 ipv6Addresses.push_back (it->second);
1938 }
1939 WriteXmlIpv6Addresses (i->first, ipv6Addresses);
1940 }
1941}
1942
1943void
1945{
1946 for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
1947 {
1948 Ptr<Node> n = *i;
1949 UpdatePosition (n);
1950 uint32_t n1Id = n->GetId ();
1951 uint32_t nDev = n->GetNDevices (); // Number of devices
1952 for (uint32_t i = 0; i < nDev; ++i)
1953 {
1954 Ptr<NetDevice> dev = n->GetDevice (i);
1955 NS_ASSERT (dev);
1956 Ptr<Channel> ch = dev->GetChannel ();
1957 std::string channelType = "Unknown channel";
1958 if (ch)
1959 {
1960 channelType = ch->GetInstanceTypeId ().GetName ();
1961 }
1962 NS_LOG_DEBUG ("Got ChannelType" << channelType);
1963
1964 if (!ch || (channelType != std::string ("ns3::PointToPointChannel")))
1965 {
1966 NS_LOG_DEBUG ("No channel can't be a p2p device");
1967 /*
1968 // Try to see if it is an LTE NetDevice, which does not return a channel
1969 if ((dev->GetInstanceTypeId ().GetName () == "ns3::LteUeNetDevice") ||
1970 (dev->GetInstanceTypeId ().GetName () == "ns3::LteEnbNetDevice")||
1971 (dev->GetInstanceTypeId ().GetName () == "ns3::VirtualNetDevice"))
1972 {
1973 WriteNonP2pLinkProperties (n->GetId (), GetIpv4Address (dev) + "~" + GetMacAddress (dev), channelType);
1974 AddToIpv4AddressNodeIdTable (GetIpv4Address (dev), n->GetId ());
1975 }
1976 */
1977 std::vector<std::string> ipv4Addresses = GetIpv4Addresses (dev);
1978 AddToIpv4AddressNodeIdTable (ipv4Addresses, n->GetId ());
1979 std::vector<std::string> ipv6Addresses = GetIpv6Addresses (dev);
1980 AddToIpv6AddressNodeIdTable (ipv6Addresses, n->GetId ());
1981 if (!ipv4Addresses.empty ())
1982 {
1983 NS_LOG_INFO ("Writing Ipv4 link");
1984 WriteNonP2pLinkProperties (n->GetId (), GetIpv4Address (dev) + "~" + GetMacAddress (dev), channelType);
1985 }
1986 else if (!ipv6Addresses.empty ())
1987 {
1988 NS_LOG_INFO ("Writing Ipv6 link");
1989 WriteNonP2pLinkProperties (n->GetId (), GetIpv6Address (dev) + "~" + GetMacAddress (dev), channelType);
1990 }
1991 continue;
1992 }
1993
1994 else if (channelType == std::string ("ns3::PointToPointChannel"))
1995 { // Since these are duplex links, we only need to dump
1996 // if srcid < dstid
1997 std::size_t nChDev = ch->GetNDevices ();
1998 for (std::size_t j = 0; j < nChDev; ++j)
1999 {
2000 Ptr<NetDevice> chDev = ch->GetDevice (j);
2001 uint32_t n2Id = chDev->GetNode ()->GetId ();
2002 if (n1Id < n2Id)
2003 {
2004
2005 std::vector<std::string> ipv4Addresses = GetIpv4Addresses (dev);
2006 AddToIpv4AddressNodeIdTable (ipv4Addresses, n1Id);
2007 ipv4Addresses = GetIpv4Addresses (chDev);
2008 AddToIpv4AddressNodeIdTable (ipv4Addresses, n2Id);
2009 std::vector<std::string> ipv6Addresses = GetIpv6Addresses (dev);
2010 AddToIpv6AddressNodeIdTable (ipv6Addresses, n1Id);
2011 ipv6Addresses = GetIpv6Addresses (chDev);
2012 AddToIpv6AddressNodeIdTable (ipv6Addresses, n2Id);
2013
2014 P2pLinkNodeIdPair p2pPair;
2015 p2pPair.fromNode = n1Id;
2016 p2pPair.toNode = n2Id;
2017 if (!ipv4Addresses.empty ())
2018 {
2019 LinkProperties lp = { GetIpv4Address (dev) + "~" + GetMacAddress (dev), GetIpv4Address (chDev) + "~" + GetMacAddress (chDev), "" };
2020 m_linkProperties[p2pPair] = lp;
2021 }
2022 else if (!ipv6Addresses.empty ())
2023 {
2024 LinkProperties lp = { GetIpv6Address (dev) + "~" + GetMacAddress (dev), GetIpv6Address (chDev) + "~" + GetMacAddress (chDev), "" };
2025 m_linkProperties[p2pPair] = lp;
2026 }
2027 WriteXmlLink (n1Id, 0, n2Id);
2028 }
2029 }
2030 }
2031 }
2032 }
2033 m_linkProperties.clear ();
2034}
2035
2036void
2038{
2039 for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
2040 {
2041 Ptr<Node> n = *i;
2042 NS_LOG_INFO ("Update Position for Node: " << n->GetId ());
2043 Vector v = UpdatePosition (n);
2044 WriteXmlNode (n->GetId (), n->GetSystemId (), v.x, v.y);
2045 }
2046}
2047
2048void
2050{
2051 for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
2052 {
2053 Ptr<Node> n = *i;
2054 Rgb rgb = {255, 0, 0};
2055 if (m_nodeColors.find (n->GetId ()) == m_nodeColors.end ())
2056 {
2057 m_nodeColors[n->GetId ()] = rgb;
2058 }
2059 UpdateNodeColor (n, rgb.r, rgb.g, rgb.b);
2060 }
2061}
2062
2063void
2065{
2066 for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
2067 {
2068 Ptr<Node> n = *i;
2069 NS_LOG_INFO ("Update Size for Node: " << n->GetId ());
2070 AnimationInterface::NodeSize s = { 1, 1 };
2071 m_nodeSizes[n->GetId ()] = s;
2072 UpdateNodeSize (n->GetId (), s.width, s.height);
2073 }
2074}
2075
2076void
2078{
2080 for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
2081 {
2082 Ptr<Node> n = *i;
2084 {
2086 }
2087 }
2088}
2089
2090bool
2092{
2093 if ((Simulator::Now () >= m_startTime)
2094 && (Simulator::Now () <= m_stopTime))
2095 {
2096 return true;
2097 }
2098 else
2099 {
2100 return false;
2101 }
2102}
2103
2104void
2105AnimationInterface::SetOutputFile (const std::string& fn, bool routing)
2106{
2107 if (!routing && m_f)
2108 {
2109 return;
2110 }
2111 if (routing && m_routingF)
2112 {
2113 NS_FATAL_ERROR ("SetRoutingOutputFile already used once");
2114 return;
2115 }
2116
2117 NS_LOG_INFO ("Creating new trace file:" << fn.c_str ());
2118 FILE * f = 0;
2119 f = std::fopen (fn.c_str (), "w");
2120 if (!f)
2121 {
2122 NS_FATAL_ERROR ("Unable to open output file:" << fn.c_str ());
2123 return; // Can't open output file
2124 }
2125 if (routing)
2126 {
2127 m_routingF = f;
2128 m_routingFileName = fn;
2129 }
2130 else
2131 {
2132 m_f = f;
2133 m_outputFileName = fn;
2134 }
2135 return;
2136}
2137
2138void
2140{
2141 // Start a new trace file if the current packet count exceeded nax packets per file
2144 {
2145 return;
2146 }
2147 NS_LOG_UNCOND ("Max Packets per trace file exceeded");
2148 StopAnimation (true);
2149}
2150
2151std::string
2153{
2154 return NETANIM_VERSION;
2155}
2156
2157
2158void
2160{
2162 {
2163 NS_LOG_INFO ("TrackQueueCounters Completed");
2164 return;
2165 }
2166 for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
2167 {
2168 uint32_t nodeId = Ptr <Node> (*i)->GetId ();
2172 }
2174}
2175
2176void
2178{
2180 {
2181 NS_LOG_INFO ("TrackWifiMacCounters Completed");
2182 return;
2183 }
2184 for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
2185 {
2186 uint32_t nodeId = Ptr <Node> (*i)->GetId ();
2191 }
2193}
2194
2195void
2197{
2199 {
2200 NS_LOG_INFO ("TrackWifiPhyCounters Completed");
2201 return;
2202 }
2203 for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
2204 {
2205 uint32_t nodeId = Ptr <Node> (*i)->GetId ();
2208 }
2210}
2211
2212void
2214{
2216 {
2217 NS_LOG_INFO ("TrackIpv4L3ProtocolCounters Completed");
2218 return;
2219 }
2220 for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
2221 {
2222 uint32_t nodeId = Ptr <Node> (*i)->GetId ();
2226 }
2228}
2229
2230
2231
2232
2233
2234/***** Routing-related *****/
2235
2236void
2238{
2239 if (m_ipv4RouteTrackElements.empty ())
2240 {
2241 return;
2242 }
2243 for (std::vector <Ipv4RouteTrackElement>::const_iterator i = m_ipv4RouteTrackElements.begin ();
2244 i != m_ipv4RouteTrackElements.end ();
2245 ++i)
2246 {
2247 Ipv4RouteTrackElement trackElement = *i;
2248 Ptr <Node> fromNode = NodeList::GetNode (trackElement.fromNodeId);
2249 if (!fromNode)
2250 {
2251 NS_FATAL_ERROR ("Node: " << trackElement.fromNodeId << " Not found");
2252 continue;
2253 }
2254 Ptr <ns3::Ipv4> ipv4 = fromNode->GetObject <ns3::Ipv4> ();
2255 if (!ipv4)
2256 {
2257 NS_LOG_WARN ("ipv4 object not found");
2258 continue;
2259 }
2261 if (!rp)
2262 {
2263 NS_LOG_WARN ("Routing protocol object not found");
2264 continue;
2265 }
2266 NS_LOG_INFO ("Begin Track Route for: " << trackElement.destination.c_str () << " From:" << trackElement.fromNodeId);
2267 Ptr<Packet> pkt = Create<Packet> ();
2268 Ipv4Header header;
2269 header.SetDestination (Ipv4Address (trackElement.destination.c_str ()));
2270 Socket::SocketErrno sockerr;
2271 Ptr <Ipv4Route> rt = rp->RouteOutput (pkt, header, 0, sockerr);
2272 Ipv4RoutePathElements rpElements;
2273 if (!rt)
2274 {
2275 NS_LOG_INFO ("No route to :" << trackElement.destination.c_str ());
2276 Ipv4RoutePathElement elem = { trackElement.fromNodeId, "-1" };
2277 rpElements.push_back (elem);
2278 WriteRoutePath (trackElement.fromNodeId, trackElement.destination, rpElements);
2279 continue;
2280 }
2281 std::ostringstream oss;
2282 oss << rt->GetGateway ();
2283 NS_LOG_INFO ("Node:" << trackElement.fromNodeId << "-->" << rt->GetGateway ());
2284 if (rt->GetGateway () == "0.0.0.0")
2285 {
2286 Ipv4RoutePathElement elem = { trackElement.fromNodeId, "C" };
2287 rpElements.push_back (elem);
2288 if ( m_ipv4ToNodeIdMap.find (trackElement.destination) != m_ipv4ToNodeIdMap.end ())
2289 {
2290 Ipv4RoutePathElement elem2 = { m_ipv4ToNodeIdMap[trackElement.destination], "L" };
2291 rpElements.push_back (elem2);
2292 }
2293 }
2294 else if (rt->GetGateway () == "127.0.0.1")
2295 {
2296 Ipv4RoutePathElement elem = { trackElement.fromNodeId, "-1" };
2297 rpElements.push_back (elem);
2298 }
2299 else
2300 {
2301 Ipv4RoutePathElement elem = { trackElement.fromNodeId, oss.str () };
2302 rpElements.push_back (elem);
2303 }
2304 RecursiveIpv4RoutePathSearch (oss.str (), trackElement.destination, rpElements);
2305 WriteRoutePath (trackElement.fromNodeId, trackElement.destination, rpElements);
2306 }
2307
2308}
2309
2310void
2312{
2314 {
2315 NS_LOG_INFO ("TrackIpv4Route completed");
2316 return;
2317 }
2318 if (m_routingNc.GetN ())
2319 {
2320 for (NodeContainer::Iterator i = m_routingNc.Begin (); i != m_routingNc.End (); ++i)
2321 {
2322 Ptr <Node> n = *i;
2324 }
2325 }
2326 else
2327 {
2328 for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
2329 {
2330 Ptr <Node> n = *i;
2332 }
2333 }
2336}
2337
2338std::string
2340{
2341
2342 NS_ASSERT (n);
2343 Ptr <ns3::Ipv4> ipv4 = n->GetObject <ns3::Ipv4> ();
2344 if (!ipv4)
2345 {
2346 NS_LOG_WARN ("Node " << n->GetId () << " Does not have an Ipv4 object");
2347 return "";
2348 }
2349 std::stringstream stream;
2350 Ptr<OutputStreamWrapper> routingstream = Create<OutputStreamWrapper> (&stream);
2351 ipv4->GetRoutingProtocol ()->PrintRoutingTable (routingstream);
2352 return stream.str ();
2353
2354}
2355
2356void
2357AnimationInterface::RecursiveIpv4RoutePathSearch (std::string from, std::string to, Ipv4RoutePathElements & rpElements)
2358{
2359 NS_LOG_INFO ("RecursiveIpv4RoutePathSearch from:" << from.c_str () << " to:" << to.c_str ());
2360 if ((from == "0.0.0.0") || (from == "127.0.0.1"))
2361 {
2362 NS_LOG_INFO ("Got " << from.c_str () << " End recursion");
2363 return;
2364 }
2367 if (fromNode->GetId () == toNode->GetId ())
2368 {
2369 Ipv4RoutePathElement elem = { fromNode->GetId (), "L" };
2370 rpElements.push_back (elem);
2371 return;
2372 }
2373 if (!fromNode)
2374 {
2375 NS_FATAL_ERROR ("Node: " << m_ipv4ToNodeIdMap[from] << " Not found");
2376 return;
2377 }
2378 if (!toNode)
2379 {
2380 NS_FATAL_ERROR ("Node: " << m_ipv4ToNodeIdMap[to] << " Not found");
2381 return;
2382 }
2383 Ptr <ns3::Ipv4> ipv4 = fromNode->GetObject <ns3::Ipv4> ();
2384 if (!ipv4)
2385 {
2386 NS_LOG_WARN ("ipv4 object not found");
2387 return;
2388 }
2390 if (!rp)
2391 {
2392 NS_LOG_WARN ("Routing protocol object not found");
2393 return;
2394 }
2395 Ptr<Packet> pkt = Create<Packet> ();
2396 Ipv4Header header;
2397 header.SetDestination (Ipv4Address (to.c_str ()));
2398 Socket::SocketErrno sockerr;
2399 Ptr <Ipv4Route> rt = rp->RouteOutput (pkt, header, 0, sockerr);
2400 if (!rt)
2401 {
2402 return;
2403 }
2404 NS_LOG_DEBUG ("Node: " << fromNode->GetId () << " G:" << rt->GetGateway ());
2405 std::ostringstream oss;
2406 oss << rt->GetGateway ();
2407 if (oss.str () == "0.0.0.0" && (sockerr != Socket::ERROR_NOROUTETOHOST))
2408 {
2409 NS_LOG_INFO ("Null gw");
2410 Ipv4RoutePathElement elem = { fromNode->GetId (), "C" };
2411 rpElements.push_back (elem);
2412 if ( m_ipv4ToNodeIdMap.find (to) != m_ipv4ToNodeIdMap.end ())
2413 {
2414 Ipv4RoutePathElement elem2 = { m_ipv4ToNodeIdMap[to], "L" };
2415 rpElements.push_back (elem2);
2416 }
2417 return;
2418 }
2419 NS_LOG_INFO ("Node:" << fromNode->GetId () << "-->" << rt->GetGateway ());
2420 Ipv4RoutePathElement elem = { fromNode->GetId (), oss.str () };
2421 rpElements.push_back (elem);
2422 RecursiveIpv4RoutePathSearch (oss.str (), to, rpElements);
2423
2424}
2425
2426
2427
2428/***** WriteXml *****/
2429
2430void
2432{
2433 AnimXmlElement element ("anim");
2434 element.AddAttribute ("ver", GetNetAnimVersion ());
2435 FILE * f = m_f;
2436 if (!routing)
2437 {
2438 element.AddAttribute ("filetype", "animation");
2439 }
2440 else
2441 {
2442 element.AddAttribute ("filetype", "routing");
2443 f = m_routingF;
2444 }
2445 WriteN (element.ToString (false) + ">\n", f);
2446}
2447
2448void
2449AnimationInterface::WriteXmlClose (std::string name, bool routing)
2450{
2451 std::string closeString = "</" + name + ">\n";
2452 if (!routing)
2453 {
2454 WriteN (closeString, m_f);
2455 }
2456 else
2457 {
2458 WriteN (closeString, m_routingF);
2459 }
2460}
2461
2462void
2463AnimationInterface::WriteXmlNode (uint32_t id, uint32_t sysId, double locX, double locY)
2464{
2465 AnimXmlElement element ("node");
2466 element.AddAttribute ("id", id);
2467 element.AddAttribute ("sysId", sysId);
2468 element.AddAttribute ("locX", locX);
2469 element.AddAttribute ("locY", locY);
2470 WriteN (element.ToString (), m_f);
2471}
2472
2473void
2474AnimationInterface::WriteXmlUpdateLink (uint32_t fromId, uint32_t toId, std::string linkDescription)
2475{
2476 AnimXmlElement element ("linkupdate");
2477 element.AddAttribute ("t", Simulator::Now ().GetSeconds ());
2478 element.AddAttribute ("fromId", fromId);
2479 element.AddAttribute ("toId", toId);
2480 element.AddAttribute ("ld", linkDescription, true);
2481 WriteN (element.ToString (), m_f);
2482}
2483
2484void
2486{
2487 AnimXmlElement element ("link");
2488 element.AddAttribute ("fromId", fromId);
2489 element.AddAttribute ("toId", toId);
2490
2491 LinkProperties lprop;
2492 lprop.fromNodeDescription = "";
2493 lprop.toNodeDescription = "";
2494 lprop.linkDescription = "";
2495
2496 P2pLinkNodeIdPair p1 = { fromId, toId };
2497 P2pLinkNodeIdPair p2 = { toId, fromId };
2498 if (m_linkProperties.find (p1) != m_linkProperties.end ())
2499 {
2500 lprop = m_linkProperties[p1];
2501 }
2502 else if (m_linkProperties.find (p2) != m_linkProperties.end ())
2503 {
2504 lprop = m_linkProperties[p2];
2505 }
2506
2507 element.AddAttribute ("fd", lprop.fromNodeDescription, true);
2508 element.AddAttribute ("td", lprop.toNodeDescription, true);
2509 element.AddAttribute ("ld", lprop.linkDescription, true);
2510 WriteN (element.ToString (), m_f);
2511}
2512
2513void
2514AnimationInterface::WriteXmlIpv4Addresses (uint32_t nodeId, std::vector<std::string> ipv4Addresses)
2515{
2516 AnimXmlElement element ("ip");
2517 element.AddAttribute ("n", nodeId);
2518 for (std::vector<std::string>::const_iterator i = ipv4Addresses.begin ();
2519 i != ipv4Addresses.end ();
2520 ++i)
2521 {
2522 AnimXmlElement valueElement ("address");
2523 valueElement.SetText (*i);
2524 element.AppendChild (valueElement);
2525 }
2526 WriteN (element.ToString (), m_f);
2527}
2528
2529void
2530AnimationInterface::WriteXmlIpv6Addresses (uint32_t nodeId, std::vector<std::string> ipv6Addresses)
2531{
2532 AnimXmlElement element ("ipv6");
2533 element.AddAttribute ("n", nodeId);
2534 for (std::vector<std::string>::const_iterator i = ipv6Addresses.begin ();
2535 i != ipv6Addresses.end ();
2536 ++i)
2537 {
2538 AnimXmlElement valueElement ("address");
2539 valueElement.SetText (*i);
2540 element.AppendChild (valueElement);
2541 }
2542 WriteN (element.ToString (), m_f);
2543}
2544
2545void
2546AnimationInterface::WriteXmlRouting (uint32_t nodeId, std::string routingInfo)
2547{
2548 AnimXmlElement element ("rt");
2549 element.AddAttribute ("t", Simulator::Now ().GetSeconds ());
2550 element.AddAttribute ("id", nodeId);
2551 element.AddAttribute ("info", routingInfo.c_str (), true);
2552 WriteN (element.ToString (), m_routingF);
2553}
2554
2555void
2556AnimationInterface::WriteXmlRp (uint32_t nodeId, std::string destination, Ipv4RoutePathElements rpElements)
2557{
2558 std::string tagName = "rp";
2559 AnimXmlElement element (tagName, false);
2560 element.AddAttribute ("t", Simulator::Now ().GetSeconds ());
2561 element.AddAttribute ("id", nodeId);
2562 element.AddAttribute ("d", destination.c_str ());
2563 element.AddAttribute ("c", rpElements.size ());
2564 for (Ipv4RoutePathElements::const_iterator i = rpElements.begin ();
2565 i != rpElements.end ();
2566 ++i)
2567 {
2568 Ipv4RoutePathElement rpElement = *i;
2569 AnimXmlElement rpeElement ("rpe");
2570 rpeElement.AddAttribute ("n", rpElement.nodeId);
2571 rpeElement.AddAttribute ("nH", rpElement.nextHop.c_str ());
2572 element.AppendChild (rpeElement);
2573 }
2574 WriteN (element.ToString (), m_routingF);
2575}
2576
2577
2578void
2579AnimationInterface::WriteXmlPRef (uint64_t animUid, uint32_t fId, double fbTx, std::string metaInfo)
2580{
2581 AnimXmlElement element ("pr");
2582 element.AddAttribute ("uId", animUid);
2583 element.AddAttribute ("fId", fId);
2584 element.AddAttribute ("fbTx", fbTx);
2585 if (!metaInfo.empty ())
2586 {
2587 element.AddAttribute ("meta-info", metaInfo.c_str (), true);
2588 }
2589 WriteN (element.ToString (), m_f);
2590}
2591
2592void
2593AnimationInterface::WriteXmlP (uint64_t animUid, std::string pktType, uint32_t tId, double fbRx, double lbRx)
2594{
2595 AnimXmlElement element (pktType);
2596 element.AddAttribute ("uId", animUid);
2597 element.AddAttribute ("tId", tId);
2598 element.AddAttribute ("fbRx", fbRx);
2599 element.AddAttribute ("lbRx", lbRx);
2600 WriteN (element.ToString (), m_f);
2601}
2602
2603void
2604AnimationInterface::WriteXmlP (std::string pktType, uint32_t fId, double fbTx, double lbTx,
2605 uint32_t tId, double fbRx, double lbRx, std::string metaInfo)
2606{
2607 AnimXmlElement element (pktType);
2608 element.AddAttribute ("fId", fId);
2609 element.AddAttribute ("fbTx", fbTx);
2610 element.AddAttribute ("lbTx", lbTx);
2611 if (!metaInfo.empty ())
2612 {
2613 element.AddAttribute ("meta-info", metaInfo.c_str (), true);
2614 }
2615 element.AddAttribute ("tId", tId);
2616 element.AddAttribute ("fbRx", fbRx);
2617 element.AddAttribute ("lbRx", lbRx);
2618 WriteN (element.ToString (), m_f);
2619}
2620
2621void
2622AnimationInterface::WriteXmlAddNodeCounter (uint32_t nodeCounterId, std::string counterName, CounterType counterType)
2623{
2624 AnimXmlElement element ("ncs");
2625 element.AddAttribute ("ncId", nodeCounterId);
2626 element.AddAttribute ("n", counterName);
2627 element.AddAttribute ("t", CounterTypeToString (counterType));
2628 WriteN (element.ToString (), m_f);
2629}
2630
2631void
2632AnimationInterface::WriteXmlAddResource (uint32_t resourceId, std::string resourcePath)
2633{
2634 AnimXmlElement element ("res");
2635 element.AddAttribute ("rid", resourceId);
2636 element.AddAttribute ("p", resourcePath);
2637 WriteN (element.ToString (), m_f);
2638}
2639
2640void
2642{
2643 AnimXmlElement element ("nu");
2644 element.AddAttribute ("p", "i");
2645 element.AddAttribute ("t", Simulator::Now ().GetSeconds ());
2646 element.AddAttribute ("id", nodeId);
2647 element.AddAttribute ("rid", resourceId);
2648 WriteN (element.ToString (), m_f);
2649}
2650
2651void
2652AnimationInterface::WriteXmlUpdateNodeSize (uint32_t nodeId, double width, double height)
2653{
2654 AnimXmlElement element ("nu");
2655 element.AddAttribute ("p", "s");
2656 element.AddAttribute ("t", Simulator::Now ().GetSeconds ());
2657 element.AddAttribute ("id", nodeId);
2658 element.AddAttribute ("w", width);
2659 element.AddAttribute ("h", height);
2660 WriteN (element.ToString (), m_f);
2661}
2662
2663void
2665{
2666 AnimXmlElement element ("nu");
2667 element.AddAttribute ("p", "p");
2668 element.AddAttribute ("t", Simulator::Now ().GetSeconds ());
2669 element.AddAttribute ("id", nodeId);
2670 element.AddAttribute ("x", x);
2671 element.AddAttribute ("y", y);
2672 WriteN (element.ToString (), m_f);
2673}
2674
2675void
2676AnimationInterface::WriteXmlUpdateNodeColor (uint32_t nodeId, uint8_t r, uint8_t g, uint8_t b)
2677{
2678 AnimXmlElement element ("nu");
2679 element.AddAttribute ("p", "c");
2680 element.AddAttribute ("t", Simulator::Now ().GetSeconds ());
2681 element.AddAttribute ("id", nodeId);
2682 element.AddAttribute ("r", (uint32_t) r);
2683 element.AddAttribute ("g", (uint32_t) g);
2684 element.AddAttribute ("b", (uint32_t) b);
2685 WriteN (element.ToString (), m_f);
2686}
2687
2688void
2690{
2691 AnimXmlElement element ("nu");
2692 element.AddAttribute ("p", "d");
2693 element.AddAttribute ("t", Simulator::Now ().GetSeconds ());
2694 element.AddAttribute ("id", nodeId);
2695 if (m_nodeDescriptions.find (nodeId) != m_nodeDescriptions.end ())
2696 {
2697 element.AddAttribute ("descr", m_nodeDescriptions[nodeId], true);
2698 }
2699 WriteN (element.ToString (), m_f);
2700}
2701
2702
2703void
2704AnimationInterface::WriteXmlUpdateNodeCounter (uint32_t nodeCounterId, uint32_t nodeId, double counterValue)
2705{
2706 AnimXmlElement element ("nc");
2707 element.AddAttribute ("c", nodeCounterId);
2708 element.AddAttribute ("i", nodeId);
2709 element.AddAttribute ("t", Simulator::Now ().GetSeconds ());
2710 element.AddAttribute ("v", counterValue);
2711 WriteN (element.ToString (), m_f);
2712}
2713
2714void
2715AnimationInterface::WriteXmlUpdateBackground (std::string fileName, double x, double y, double scaleX, double scaleY, double opacity)
2716{
2717 AnimXmlElement element ("bg");
2718 element.AddAttribute ("f", fileName);
2719 element.AddAttribute ("x", x);
2720 element.AddAttribute ("y", y);
2721 element.AddAttribute ("sx", scaleX);
2722 element.AddAttribute ("sy", scaleY);
2723 element.AddAttribute ("o", opacity);
2724 WriteN (element.ToString (), m_f);
2725}
2726
2727void
2728AnimationInterface::WriteXmlNonP2pLinkProperties (uint32_t id, std::string ipAddress, std::string channelType)
2729{
2730 AnimXmlElement element ("nonp2plinkproperties");
2731 element.AddAttribute ("id", id);
2732 element.AddAttribute ("ipAddress", ipAddress);
2733 element.AddAttribute ("channelType", channelType);
2734 WriteN (element.ToString (), m_f);
2735}
2736
2737
2738
2739/***** AnimXmlElement *****/
2740
2741AnimationInterface::AnimXmlElement::AnimXmlElement (std::string tagName, bool emptyElement)
2742 : m_tagName (tagName),
2743 m_text ("")
2744{
2745}
2746
2747template <typename T>
2748void
2749AnimationInterface::AnimXmlElement::AddAttribute (std::string attribute, T value, bool xmlEscape)
2750{
2751 std::ostringstream oss;
2752 oss << std::setprecision (10);
2753 oss << value;
2754 std::string attributeString = attribute.c_str ();
2755 if (xmlEscape)
2756 {
2757 attributeString += "=\"";
2758 std::string valueStr = oss.str ();
2759 for (std::string::iterator it = valueStr.begin (); it != valueStr.end (); ++it)
2760 {
2761 switch (*it)
2762 {
2763 case '&':
2764 attributeString += "&amp;";
2765 break;
2766 case '\"':
2767 attributeString += "&quot;";
2768 break;
2769 case '\'':
2770 attributeString += "&apos;";
2771 break;
2772 case '<':
2773 attributeString += "&lt;";
2774 break;
2775 case '>':
2776 attributeString += "&gt;";
2777 break;
2778 default:
2779 attributeString += *it;
2780 break;
2781 }
2782 }
2783 attributeString += "\" ";
2784 }
2785 else
2786 {
2787 attributeString += "=\"" + oss.str () + "\" ";
2788 }
2789 m_attributes.push_back (attributeString);
2790}
2791
2792void
2794{
2795 m_children.push_back (e.ToString ());
2796}
2797
2798void
2800{
2801 m_text = text;
2802}
2803
2804std::string
2806{
2807 std::string elementString = "<" + m_tagName + " ";
2808
2809
2810 for (std::vector<std::string>::const_iterator i = m_attributes.begin ();
2811 i != m_attributes.end ();
2812 ++i)
2813 {
2814 elementString += *i;
2815 }
2816 if (m_children.empty () && m_text.empty ())
2817 {
2818 if (autoClose)
2819 {
2820 elementString += "/>";
2821 }
2822 }
2823 else
2824 {
2825 elementString += ">";
2826 if (!m_text.empty ())
2827 {
2828 elementString += m_text;
2829 }
2830 if (!m_children.empty ())
2831 {
2832 elementString += "\n";
2833 for (std::vector<std::string>::const_iterator i = m_children.begin ();
2834 i != m_children.end ();
2835 ++i)
2836 {
2837 elementString += *i + "\n";
2838 }
2839
2840 }
2841 if (autoClose)
2842 {
2843 elementString += "</" + m_tagName + ">";
2844 }
2845 }
2846
2847
2848 return elementString + ((autoClose) ? "\n" : "");
2849}
2850
2851
2852
2853
2854
2855/***** AnimByteTag *****/
2856
2857TypeId
2859{
2860 static TypeId tid = TypeId ("ns3::AnimByteTag")
2861 .SetParent<Tag> ()
2862 .SetGroupName ("NetAnim")
2863 .AddConstructor<AnimByteTag> ()
2864 ;
2865 return tid;
2866}
2867
2868TypeId
2870{
2871 return GetTypeId ();
2872}
2873
2876{
2877 return sizeof (uint64_t);
2878}
2879
2880void
2882{
2883 i.WriteU64 (m_AnimUid);
2884}
2885
2886void
2888{
2889 m_AnimUid = i.ReadU64 ();
2890}
2891
2892void
2893AnimByteTag::Print (std::ostream &os) const
2894{
2895 os << "AnimUid=" << m_AnimUid;
2896}
2897
2898void
2899AnimByteTag::Set (uint64_t AnimUid)
2900{
2901 m_AnimUid = AnimUid;
2902}
2903
2904uint64_t
2906{
2907 return m_AnimUid;
2908}
2909
2911 : m_txnd (0),
2912 m_txNodeId (0),
2913 m_fbTx (0),
2914 m_lbTx (0),
2915 m_lbRx (0)
2916{
2917}
2918
2920{
2921 m_txnd = pInfo.m_txnd;
2922 m_txNodeId = pInfo.m_txNodeId;
2923 m_fbTx = pInfo.m_fbTx;
2924 m_lbTx = pInfo.m_lbTx;
2925 m_lbRx = pInfo.m_lbRx;
2926}
2927
2929 const Time fbTx,
2930 uint32_t txNodeId)
2931 : m_txnd (txnd),
2932 m_txNodeId (0),
2933 m_fbTx (fbTx.GetSeconds ()),
2934 m_lbTx (0),
2935 m_lbRx (0)
2936{
2937 if (!m_txnd)
2938 {
2939 m_txNodeId = txNodeId;
2940 }
2941}
2942
2943void
2945{
2946 Ptr <Node> n = nd->GetNode ();
2947 m_fbRx = fbRx;
2948 m_rxnd = nd;
2949}
2950
2951} // namespace ns3
double f(double x, void *params)
Definition: 80211b.c:70
#define NETANIM_VERSION
#define MAX_PKTS_PER_TRACE_FILE
#define CHECK_STARTED_INTIMEWINDOW_TRACKPACKETS
#define CHECK_STARTED_INTIMEWINDOW
#define PURGE_INTERVAL
a polymophic address class
Definition: address.h:91
Byte tag using by Anim to uniquely identify packets.
virtual void Serialize(TagBuffer i) const
Serialize function.
virtual void Deserialize(TagBuffer i)
Deserialize function.
virtual void Print(std::ostream &os) const
Print tag info.
virtual TypeId GetInstanceTypeId(void) const
Get Instance Type Id.
virtual uint32_t GetSerializedSize(void) const
Get Serialized Size.
static TypeId GetTypeId(void)
Get Type Id.
uint64_t Get(void) const
Get Uid in tag.
void Set(uint64_t AnimUid)
Set global Uid in tag.
Ptr< const NetDevice > m_txnd
transmit device
void ProcessRxBegin(Ptr< const NetDevice > nd, const double fbRx)
Process receive begin.
Ptr< const NetDevice > m_rxnd
receive device
void AppendChild(AnimXmlElement e)
Append child function.
void SetText(std::string text)
Set text function.
std::string ToString(bool autoClose=true)
Get text for the element function.
AnimXmlElement(std::string tagName, bool emptyElement=true)
Constructor.
void AddAttribute(std::string attribute, T value, bool xmlEscape=false)
Add attribute function.
Interface to network animator.
FILE * m_f
File handle for output (0 if none)
Time m_wifiMacCountersPollInterval
wifi MAC counters poll interval
void CsmaPhyRxEndTrace(std::string context, Ptr< const Packet > p)
CSMA Phy receive end trace function.
void WriteNodeSizes()
Write node sizes function.
uint32_t AddNodeCounter(std::string counterName, CounterType counterType)
Setup a node counter.
void TrackQueueCounters()
Track queue counters function.
void SetMobilityPollInterval(Time t)
Set mobility poll interval:WARNING: setting a low interval can cause slowness.
uint32_t m_wifiMacRxCounterId
wifi MAC receive counter ID
bool IsPacketPending(uint64_t animUid, ProtocolType protocolType)
Is packet pending function.
bool NodeHasMoved(Ptr< Node > n, Vector newLocation)
Node has moved function.
void LrWpanPhyTxBeginTrace(std::string context, Ptr< const Packet > p)
LR-WPAN Phy receive begin trace function.
uint32_t m_queueDropCounterId
queue drop counter ID
void WimaxTxTrace(std::string context, Ptr< const Packet > p, const Mac48Address &m)
WIMax transmit trace function.
void LrWpanPhyRxBeginTrace(std::string context, Ptr< const Packet > p)
LR-WPAN Phy receive begin trace function.
Time m_routingPollInterval
routing poll interval
void OutputCsmaPacket(Ptr< const Packet > p, AnimPacketInfo &pktInfo)
Output CSMA packet function.
uint64_t GetAnimUidFromPacket(Ptr< const Packet >)
Get anim UID from packet function.
EnergyFractionMap m_nodeEnergyFraction
node energy fraction
AnimUidPacketInfoMap m_pendingWavePackets
pending WAVE packets
void GenericWirelessTxTrace(std::string context, Ptr< const Packet > p, ProtocolType protocolType)
Generic wireless transmit trace function.
void LteRxTrace(std::string context, Ptr< const Packet > p, const Mac48Address &m)
LTE receive trace function.
std::string ProtocolTypeToString(ProtocolType protocolType)
Protocol type to string function.
NodeCounterMap64 m_nodeLrWpanMacRx
node LR-WPAN MAC receive
std::string m_routingFileName
routing file name
NodeCounterMap64 m_nodeIpv4Tx
node IPv4 transmit
std::map< std::string, uint32_t > m_ipv6ToNodeIdMap
IPv6 to node ID map.
void MobilityAutoCheck()
Mobility auto check function.
void WriteXmlRouting(uint32_t id, std::string routingInfo)
Write XML routing function.
void WifiPhyRxDropTrace(std::string context, Ptr< const Packet > p, WifiPhyRxfailureReason reason)
wifi Phy receive drop trace function
void WifiMacRxDropTrace(std::string context, Ptr< const Packet > p)
wifi MAC receive drop trace function
bool IsStarted(void)
Is AnimationInterface started.
NodeCounterMap64 m_nodeQueueDrop
node queue drop
void ConnectLteUe(Ptr< Node > n, Ptr< LteUeNetDevice > nd, uint32_t devIndex)
Connect LTE ue function.
void DequeueTrace(std::string context, Ptr< const Packet >)
Dequeue trace function.
void ConnectCallbacks()
Connect callbacks function.
void WriteRoutePath(uint32_t nodeId, std::string destination, Ipv4RoutePathElements rpElements)
Write route path function.
AnimUidPacketInfoMap * ProtocolTypeToPendingPackets(ProtocolType protocolType)
Protocol type to pending packets function.
void RemainingEnergyTrace(std::string context, double previousEnergy, double currentEnergy)
Remaining energy trace function.
void Ipv4DropTrace(std::string context, const Ipv4Header &ipv4Header, Ptr< const Packet > p, Ipv4L3Protocol::DropReason dropReason, Ptr< Ipv4 > ipv4, uint32_t interfaceIndex)
IPv4 drop trace function.
NodeColorsMap m_nodeColors
node colors
void UpdateNodeCounter(uint32_t nodeCounterId, uint32_t nodeId, double counter)
Helper function to update a node's counter referenced by the nodeCounterId.
void WifiPhyRxBeginTrace(std::string context, Ptr< const Packet > p, RxPowerWattPerChannelBand rxPowersW)
wifi Phy receive begin trace function
void LrWpanMacRxDropTrace(std::string context, Ptr< const Packet > p)
LR-WPAN MAC receive drop trace function.
void LteSpectrumPhyTxStart(std::string context, Ptr< const PacketBurst > pb)
LTE Spectrum Phy transmit start function.
NodeCounterMap64 m_nodeLrWpanMacTx
node LR-WPAN MAC transmit
void WriteXmlAddNodeCounter(uint32_t counterId, std::string counterName, CounterType counterType)
Write XML add node counter function.
void WriteXmlPRef(uint64_t animUid, uint32_t fId, double fbTx, std::string metaInfo="")
Write XMLP Ref function.
NodeCounterMap64 m_nodeWifiPhyTxDrop
node wifi Phy transmit drop
void WriteLinkProperties()
Write link properties function.
void WriteIpv4Addresses()
Write IPv4 Addresses function.
const std::vector< std::string > GetElementsFromContext(const std::string &context) const
Get elements from context.
void WriteXmlAddResource(uint32_t resourceId, std::string resourcePath)
Write XML add resource function.
void OutputWirelessPacketTxInfo(Ptr< const Packet > p, AnimPacketInfo &pktInfo, uint64_t animUid)
Output wireless packet transmit info.
void LteSpectrumPhyRxStart(std::string context, Ptr< const PacketBurst > pb)
LTE Spectrum Phy receive start function.
void SetOutputFile(const std::string &fn, bool routing=false)
Set output file function.
NodeCounterMap64 m_nodeWifiMacTx
node wifi MAC transmit
AnimUidPacketInfoMap m_pendingWimaxPackets
pending wimax packets
void LteTxTrace(std::string context, Ptr< const Packet > p, const Mac48Address &m)
LTE transmit trace function.
void EnableIpv4L3ProtocolCounters(Time startTime, Time stopTime, Time pollInterval=Seconds(1))
Enable tracking of Ipv4 L3 Protocol Counters such as Tx, Rx, Drop.
int WriteN(const char *data, uint32_t count, FILE *f)
WriteN function.
std::map< std::string, uint32_t > m_macToNodeIdMap
MAC to node ID map.
Ptr< Node > GetNodeFromContext(const std::string &context) const
Get node from context.
std::map< uint32_t, Vector > m_nodeLocation
node location
Ptr< NetDevice > GetNetDeviceFromContext(std::string context)
Get net device from context.
FILE * m_routingF
File handle for routing table output (0 if None);.
void UpdateNodeImage(uint32_t nodeId, uint32_t resourceId)
Helper function to update the image of a node.
void TrackWifiPhyCounters()
Track wifi phy counters function.
void WavePhyTxBeginTrace(std::string context, Ptr< const Packet > p)
WAVE Phy transmit begin trace function.
AnimUidPacketInfoMap m_pendingUanPackets
pending UAN packets
void TrackIpv4RoutePaths()
Track IPv4 route paths function.
double GetNodeEnergyFraction(Ptr< const Node > node) const
Get node's energy fraction (This used only for testing)
bool IsInTimeWindow()
Is in time window function.
void CsmaPhyTxBeginTrace(std::string context, Ptr< const Packet > p)
CSMA Phy transmit begin trace function.
bool m_enablePacketMetadata
enable packet metadata
void PurgePendingPackets(ProtocolType protocolType)
Purge pending packets function.
void SetMaxPktsPerTraceFile(uint64_t maxPktsPerFile)
Set Max packets per trace file.
uint64_t m_maxPktsPerFile
maximum pakets per file
uint32_t m_ipv4L3ProtocolRxCounterId
IPv4 L3 protocol receive counter ID.
NodeCounterMap64 m_nodeIpv4Rx
node IPv4 receive
~AnimationInterface()
Destructor for the animator interface.
void AddToIpv4AddressNodeIdTable(std::string ipv4Address, uint32_t nodeId)
Add to IPv4 address node ID table function.
NodeIdIpv4Map m_nodeIdIpv4Map
node ID to IPv4 map
Time m_queueCountersPollInterval
queue counters poll interval
std::vector< std::string > GetIpv6Addresses(Ptr< NetDevice > nd)
Get IPv6 addresses.
void UpdateLinkDescription(uint32_t fromNode, uint32_t toNode, std::string linkDescription)
Helper function to update the description for a link.
void Ipv4RxTrace(std::string context, Ptr< const Packet > p, Ptr< Ipv4 > ipv4, uint32_t interfaceIndex)
IPv4 receive trace function.
NodeCounterMap64 m_nodeQueueEnqueue
node queue enqueue
void WriteXmlUpdateNodeCounter(uint32_t counterId, uint32_t nodeId, double value)
Write XML update node counter function.
std::vector< std::string > GetIpv4Addresses(Ptr< NetDevice > nd)
Get IPv4 addresses.
Time m_wifiPhyCountersPollInterval
wifi Phy counters poll interval
uint32_t m_queueDequeueCounterId
queue dequeue counter ID
NodeCounterMap64 m_nodeWifiMacRx
node wifi MAC receive
void AddToIpv6AddressNodeIdTable(std::string ipv6Address, uint32_t nodeId)
Add to IPv6 address node ID table function.
AnimationInterface & AddSourceDestination(uint32_t fromNodeId, std::string destinationIpv4Address)
Helper function to print the routing path from a source node to destination IP.
NodeCounterMap64 m_nodeIpv4Drop
node IPv4 drop
Time m_ipv4L3ProtocolCountersStopTime
IPv4 L3 protocol counters stop time.
uint32_t m_queueEnqueueCounterId
queue enqueue counter ID
void AddByteTag(uint64_t animUid, Ptr< const Packet > p)
Add byte tag function.
Time m_ipv4L3ProtocolCountersPollInterval
IPv4 L3 protocol counters poll interval.
void WriteNonP2pLinkProperties(uint32_t id, std::string ipv4Address, std::string channelType)
Write non P2P link properties function.
void StopAnimation(bool onlyAnimation=false)
Stop animation function.
std::vector< Ipv4RoutePathElement > Ipv4RoutePathElements
Ipv4RoutePathElements typedef.
void UanPhyGenTxTrace(std::string context, Ptr< const Packet >)
UAN Phy gen transmit trace function.
void WifiMacTxDropTrace(std::string context, Ptr< const Packet > p)
wifi MAC transmit drop trace function
uint32_t m_ipv4L3ProtocolTxCounterId
IPv4 L3 protocol transmit counter ID.
Time m_queueCountersStopTime
queue counters stop time
std::string CounterTypeToString(CounterType counterType)
Counter type to string function.
ProtocolType
ProtocolType enumeration.
std::string GetMacAddress(Ptr< NetDevice > nd)
Get MAC address function.
std::vector< Ptr< Node > > GetMovedNodes()
Get moved nodes function.
uint32_t m_wifiMacTxCounterId
wifi MAC transmit counter ID
void SkipPacketTracing()
Do not trace packets.
NodeCounterMap64 m_nodeWifiMacRxDrop
node wifi MAC receive drop
NodeDescriptionsMap m_nodeDescriptions
node description
void WriteXmlAnim(bool routing=false)
Write XML anim function.
void SetStartTime(Time t)
Specify the time at which capture should start.
uint32_t AddResource(std::string resourcePath)
Add a resource such as the path to an image file.
AnimationInterface(const std::string filename)
Constructor.
std::string GetIpv6Address(Ptr< NetDevice > nd)
Get IPv6 address.
void WriteNodeEnergies()
Write node energies function.
void CsmaMacRxTrace(std::string context, Ptr< const Packet > p)
CSMA MAC receive trace function.
void WifiPhyTxBeginTrace(std::string context, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW)
wifi Phy transmit PSDU begin trace function
void UanPhyGenRxTrace(std::string context, Ptr< const Packet >)
UAN Phy gen receive trace function.
LinkPropertiesMap m_linkProperties
link properties
void WriteXmlUpdateNodeDescription(uint32_t nodeId)
Write XML update node description function.
std::map< uint32_t, NodeSize > m_nodeSizes
node sizes
std::pair< uint32_t, std::string > NodeIdIpv6Pair
NodeIdIpv6Pair typedef.
void ConnectLte()
Connect LTE function.
bool m_trackPackets
track packets
std::string GetNetAnimVersion()
Get netanim version function.
void WriteXmlNonP2pLinkProperties(uint32_t id, std::string ipAddress, std::string channelType)
Write XML non P2P link properties function.
void UpdateNodeSize(uint32_t nodeId, double width, double height)
Helper function to update the size of a node.
AnimationInterface & EnableIpv4RouteTracking(std::string fileName, Time startTime, Time stopTime, Time pollInterval=Seconds(5))
Enable tracking of the Ipv4 routing table for all Nodes.
void WriteXmlClose(std::string name, bool routing=false)
Write XML close function.
uint64_t gAnimUid
Packet unique identifier used by AnimationInterface.
void CheckMaxPktsPerTraceFile()
Check maximum packets per trace file function.
NodeCounterMap64 m_nodeLrWpanMacTxDrop
node LR-WPAN MAC transmit drop
NodeIdIpv6Map m_nodeIdIpv6Map
node ID to IPv6 map
void TrackIpv4Route()
Track IPv4 router function.
void EnableWifiPhyCounters(Time startTime, Time stopTime, Time pollInterval=Seconds(1))
Enable tracking of Wifi Phy Counters such as TxDrop, RxDrop.
AnimUidPacketInfoMap m_pendingWifiPackets
pending wifi packets
void EnablePacketMetadata(bool enable=true)
Enable Packet metadata.
Time m_routingStopTime
routing stop time
void SetStopTime(Time t)
Specify the time at which capture should stop.
void MobilityCourseChangeTrace(Ptr< const MobilityModel > mob)
Mobility course change trace function.
void EnableWifiMacCounters(Time startTime, Time stopTime, Time pollInterval=Seconds(1))
Enable tracking of Wifi Mac Counters such as Tx, TxDrop, Rx, RxDrop.
void WriteXmlP(std::string pktType, uint32_t fId, double fbTx, double lbTx, uint32_t tId, double fbRx, double lbRx, std::string metaInfo="")
Write XMLP function.
uint32_t m_wifiMacTxDropCounterId
wifi MAC transmit drop counter ID
void WriteXmlRp(uint32_t nodeId, std::string destination, Ipv4RoutePathElements rpElements)
Write XMLRP function.
AnimUidPacketInfoMap m_pendingLrWpanPackets
pending LR-WPAN packets
void WifiMacTxTrace(std::string context, Ptr< const Packet > p)
wifi MAC transmit trace function
void ResetAnimWriteCallback()
Reset the write callback function.
void WimaxRxTrace(std::string context, Ptr< const Packet > p, const Mac48Address &m)
WIMax receive trace function.
void LrWpanMacTxDropTrace(std::string context, Ptr< const Packet > p)
LR-WPAN MAC transmit drop trace function.
void LrWpanMacRxTrace(std::string context, Ptr< const Packet > p)
LR-WPAN MAC receive trace function.
uint64_t GetTracePktCount()
Get trace file packet count (This used only for testing)
std::vector< std::string > m_nodeCounters
node counters
void WriteXmlNode(uint32_t id, uint32_t sysId, double locX, double locY)
Write XML node function.
AnimWriteCallback m_writeCallback
write callback
NodeCounterMap64 m_nodeWifiMacTxDrop
node wifi MAC transmit drop
uint64_t m_currentPktCount
current packet count
std::string GetIpv4RoutingTable(Ptr< Node > n)
Get IPv4 routing table function.
void Ipv4TxTrace(std::string context, Ptr< const Packet > p, Ptr< Ipv4 > ipv4, uint32_t interfaceIndex)
IPv4 transmit trace function.
std::pair< uint32_t, std::string > NodeIdIpv4Pair
NodeIdIpv4Pair typedef.
void EnqueueTrace(std::string context, Ptr< const Packet >)
Enqueue trace function.
void WriteXmlUpdateNodeColor(uint32_t nodeId, uint8_t r, uint8_t g, uint8_t b)
Write XML update node color function.
Vector UpdatePosition(Ptr< Node > n)
Update position function.
std::string m_outputFileName
output file name
void WriteIpv6Addresses()
Write IPv6 Addresses function.
void AddPendingPacket(ProtocolType protocolType, uint64_t animUid, AnimPacketInfo pktInfo)
Add pending packet function.
NodeCounterMap64 m_nodeWifiPhyRxDrop
node wifi Phy receive drop
void WriteXmlIpv4Addresses(uint32_t nodeId, std::vector< std::string > ipv4Addresses)
Write XML Ipv4 addresses function.
Vector GetPosition(Ptr< Node > n)
Get position function.
AnimUidPacketInfoMap m_pendingLtePackets
pending LTE packets
void SetBackgroundImage(std::string fileName, double x, double y, double scaleX, double scaleY, double opacity)
Helper function to set the background image.
void WriteNodes()
Write nodes function.
NodeCounterMap64 m_nodeLrWpanMacRxDrop
node LR-WPAN MAC receive drop
Time m_wifiMacCountersStopTime
wifi MAC counters stop time
void WriteNodeColors()
Write node colors function.
static bool IsInitialized(void)
Check if AnimationInterface is initialized.
void RecursiveIpv4RoutePathSearch(std::string from, std::string to, Ipv4RoutePathElements &rpElements)
Recursive IPv4 route path search function.
void LrWpanMacTxTrace(std::string context, Ptr< const Packet > p)
LR-WPAN MAC transmit trace function.
void WriteXmlUpdateBackground(std::string fileName, double x, double y, double scaleX, double scaleY, double opacity)
Write XML update background function.
void CsmaPhyTxEndTrace(std::string context, Ptr< const Packet > p)
CSMA Phy transmit end trace function.
void WriteXmlUpdateNodeSize(uint32_t nodeId, double width, double height)
Write XML update node size function.
uint32_t m_remainingEnergyCounterId
remaining energy counter ID
void WriteXmlUpdateNodeImage(uint32_t nodeId, uint32_t resourceId)
Write XML update node image function.
uint32_t m_wifiMacRxDropCounterId
wifi MAC receive drop counter ID
void TrackWifiMacCounters()
Track wifi MAC counters function.
void UpdateNodeDescription(Ptr< Node > n, std::string descr)
Helper function to update the description for a given node.
void UpdateNodeColor(Ptr< Node > n, uint8_t r, uint8_t g, uint8_t b)
Helper function to update the node color.
static void SetConstantPosition(Ptr< Node > n, double x, double y, double z=0)
Helper function to set Constant Position for a given node.
NodeCounterMap64 m_nodeQueueDequeue
node queue dequeue
void WifiPhyTxDropTrace(std::string context, Ptr< const Packet > p)
wifi Phy transmit drop trace function
uint32_t m_wifiPhyRxDropCounterId
wifi Phy receive drop counter ID
void WriteXmlUpdateLink(uint32_t fromId, uint32_t toId, std::string linkDescription)
Write XML update link counter function.
void ConnectLteEnb(Ptr< Node > n, Ptr< LteEnbNetDevice > nd, uint32_t devIndex)
Connect LTE ENB function.
void GenericWirelessRxTrace(std::string context, Ptr< const Packet > p, ProtocolType protocolType)
Generic wireless receive trace function.
std::string GetPacketMetadata(Ptr< const Packet > p)
Get packet metadata function.
uint32_t m_wifiPhyTxDropCounterId
wifi Phy transmit drop counter ID
std::vector< Ipv4RouteTrackElement > m_ipv4RouteTrackElements
IPv route track elements.
void EnableQueueCounters(Time startTime, Time stopTime, Time pollInterval=Seconds(1))
Enable tracking of Queue Counters such as Enqueue, Dequeue, Queue Drops.
uint32_t m_ipv4L3ProtocolDropCounterId
IPv4 protocol drop counter ID.
Time m_wifiPhyCountersStopTime
wifi Phy counters stop time
Time m_mobilityPollInterval
mobility poll interval
void OutputWirelessPacketRxInfo(Ptr< const Packet > p, AnimPacketInfo &pktInfo, uint64_t animUid)
Output wireless packet receive info.
std::map< std::string, uint32_t > m_ipv4ToNodeIdMap
IPv4 to node ID map.
AnimUidPacketInfoMap m_pendingCsmaPackets
pending CSMA packets
std::vector< std::string > m_resources
resources
void TrackIpv4L3ProtocolCounters()
Track IPv4 L3 protocol counters function.
void WriteXmlUpdateNodePosition(uint32_t nodeId, double x, double y)
Write XML update node position function.
void StartAnimation(bool restart=false)
Start animation function.
void DevTxTrace(std::string context, Ptr< const Packet > p, Ptr< NetDevice > tx, Ptr< NetDevice > rx, Time txTime, Time rxTime)
Device transmit trace function.
std::string GetIpv4Address(Ptr< NetDevice > nd)
Get IPv4 address.
void WavePhyRxBeginTrace(std::string context, Ptr< const Packet > p)
WAVE Phy receive begin trace function.
void WifiMacRxTrace(std::string context, Ptr< const Packet > p)
wifi MAC receive trace function
void WriteXmlIpv6Addresses(uint32_t nodeId, std::vector< std::string > ipv6Addresses)
Write XML Ipv6 addresses function.
NodeContainer m_routingNc
routing node container
void SetAnimWriteCallback(AnimWriteCallback cb)
Set a callback function to listen to AnimationInterface write events.
void QueueDropTrace(std::string context, Ptr< const Packet >)
Queue trace function.
void WriteXmlLink(uint32_t fromId, uint32_t toLp, uint32_t toId)
Write XML link counter function.
std::map< uint64_t, AnimPacketInfo > AnimUidPacketInfoMap
AnimUidPacketInfoMap typedef.
Identifies a byte tag and a set of bytes within a packet to which the tag applies.
Definition: packet.h:62
TypeId GetTypeId(void) const
Definition: packet.cc:34
void GetTag(Tag &tag) const
Read the requested tag and store it in the user-provided tag instance.
Definition: packet.cc:49
Iterator over the set of byte tags in a packet.
Definition: packet.h:55
bool HasNext(void) const
Definition: packet.cc:65
Item Next(void)
Definition: packet.cc:70
virtual Ptr< NetDevice > GetDevice(std::size_t i) const =0
virtual std::size_t GetNDevices(void) const =0
Mobility model for which the current position does not change once it has been set and until it is se...
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:41
Introspection did not find any typical Config paths.
Definition: energy-source.h:87
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
Packet header for IPv4.
Definition: ipv4-header.h:34
void SetDestination(Ipv4Address destination)
Definition: ipv4-header.cc:298
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:77
virtual Ptr< Ipv4RoutingProtocol > GetRoutingProtocol(void) const =0
Get the routing protocol to be used by this Ipv4 stack.
a class to store IPv4 address information on an interface
Ipv4Address GetLocal(void) const
Get the local address.
DropReason
Reason why a packet has been dropped.
bool IsLinkLocal() const
If the IPv6 address is a link-local address (fe80::/64).
Access to the IPv6 forwarding table, interfaces, and configuration.
Definition: ipv6.h:82
IPv6 address associated with an interface.
Ipv6Address GetAddress() const
Get the IPv6 address.
Represent the Mac Header with the Frame Control and Sequence Number fields.
uint8_t GetSrcAddrMode(void) const
Get the Source Addressing Mode of Frame control field.
Ptr< LrWpanMac > GetMac(void) const
Get the MAC used by this NetDevice.
Ptr< LteEnbPhy > GetPhy(void) const
This class can contain 16 bit addresses.
Definition: mac16-address.h:42
an EUI-48 address
Definition: mac48-address.h:44
an EUI-64 address
Definition: mac64-address.h:44
Keep track of the current position and velocity of an object.
Vector GetPosition(void) const
virtual Address GetAddress(void) const =0
virtual Ptr< Node > GetNode(void) const =0
virtual Ptr< Channel > GetChannel(void) const =0
keep track of a set of node pointers.
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
uint32_t GetN(void) const
Get the number of Ptr<Node> stored in this container.
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
A network Node.
Definition: node.h:57
uint32_t GetId(void) const
Definition: node.cc:109
uint32_t GetNDevices(void) const
Definition: node.cc:152
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
Definition: node.cc:144
uint32_t GetSystemId(void) const
Definition: node.cc:123
static Iterator End(void)
Definition: node-list.cc:235
static Ptr< Node > GetNode(uint32_t n)
Definition: node-list.cc:241
static Iterator Begin(void)
Definition: node-list.cc:229
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
Definition: node-list.h:44
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:256
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
Definition: object.cc:79
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:470
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
Definition: object.cc:252
bool FindFirstMatchingByteTag(Tag &tag) const
Finds the first tag matching the parameter Tag type.
Definition: packet.cc:939
ByteTagIterator GetByteTagIterator(void) const
Returns an iterator over the set of byte tags included in this packet.
Definition: packet.cc:933
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Definition: packet.cc:290
void Print(std::ostream &os) const
Print the packet contents.
Definition: packet.cc:434
void AddByteTag(const Tag &tag) const
Tag each byte included in this packet with a new byte tag.
Definition: packet.cc:912
static void EnablePrinting(void)
Enable printing packets metadata.
Definition: packet.cc:572
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:556
static bool IsFinished(void)
Check if the simulation should finish.
Definition: simulator.cc:165
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:195
SocketErrno
Enumeration of the possible errors returned by a socket.
Definition: socket.h:82
@ ERROR_NOROUTETOHOST
Definition: socket.h:93
read and write tag data
Definition: tag-buffer.h:52
void WriteU64(uint64_t v)
Definition: tag-buffer.cc:102
uint64_t ReadU64(void)
Definition: tag-buffer.cc:134
tag a set of bytes in a packet
Definition: tag.h:37
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:379
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
std::string GetName(void) const
Get the name.
Definition: type-id.cc:976
double GetValue(double min, double max)
Get the next random value, as a double in the specified range .
Implements the IEEE 802.11 MAC header.
Mac48Address GetAddr2(void) const
Return the address in the Address 2 field.
Ptr< WifiMac > GetMac(void) const
Ptr< Node > GetNode(void) const override
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
Time stopTime
#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
#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
bool ConnectFailSafe(std::string path, const CallbackBase &cb)
Definition: config.cc:929
bool ConnectWithoutContextFailSafe(std::string path, const CallbackBase &cb)
Definition: config.cc:909
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition: abort.h:50
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionally.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:265
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:281
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1244
WifiPhyRxfailureReason
Enumeration of the possible reception failure reasons.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
U * PeekPointer(const Ptr< U > &p)
Definition: ptr.h:415
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
static bool initialized
Initialization flag.
std::map< WifiSpectrumBand, double > RxPowerWattPerChannelBand
A map of the received power (Watts) for each band.
Definition: phy-entity.h:75
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:1648
list x
Random number samples.
mobility
Definition: third.py:107
#define list
uint8_t data[writeSize]
RGB structure.
uint8_t b
blue
uint8_t g
green
uint8_t r
red