netanim stats counter tables not showing specific trace

112 views
Skip to first unread message

Francisco Eduardo Balart Sanchez

unread,
Sep 7, 2017, 7:28:02 PM9/7/17
to ns-3-users
Good day John:

I have a very basic question, i manage to fire the WifiPhyTxBegin trace, and i would like to know if there is something i need to do
in order to see it in the netanim app, in the stats tab in the "counter tables" section i can only see there are available:
  • RemainingEnergy
  • WifiMac Tx
  • WifiMac TxDrop
  • WifiMac Rx
  • WifiMac Rx Drop
  • WifiPhy TxDrop
  • WifiPhy Rx Drop
So i would like to be able to select the WifiPhyTxBegin as well

Thanks in advance and best regards

John Abraham

unread,
Sep 9, 2017, 10:26:47 AM9/9/17
to ns-3-...@googlegroups.com
I haven't tried it
but adding it will be similar to other Wifi counters

You will have to add the counter related code in  


EnableWifiPhyCounters


WifiPhyTxBeginTrace


TrackWifiPhyCounters





--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+unsubscribe@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at https://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted

Francisco Eduardo Balart Sanchez

unread,
Oct 1, 2017, 9:31:12 PM10/1/17
to ns-3-users
Good day John:
Sorry for my delayed response
So It worked, as you said, i leave my documentation in case someone want to see a specific trace in the net anim
This Tutorial is for enabling WifiPhyTxBegin trace on the netanim
  • Files of concern 
    • animation-interface.cc
    • animation-interface.h
  1. On the animation-interface.h source code declare the following variables
    1. On the // Counter ID section
      • uint32_t m_wifiPhyTxBeginCounterId;
    2. On the /* Value-added custom counters */ Section
      • NodeCounterMap64 m_nodeWifiPhyTxBegin;
  2. On the animation-interface.cc source code add/modify the following
    • As John well put the following instructions follow its advice (thanks)
    1. On the AnimationInterface::EnableWifiPhyCounters (Time startTime, Time stopTime, Time pollInterval) function add the following code lines
      • void 
        AnimationInterface::EnableWifiPhyCounters (Time startTime, Time stopTime, Time pollInterval)
        {
          m_wifiPhyCountersStopTime = stopTime;
          m_wifiPhyCountersPollInterval = pollInterval;
          m_wifiPhyTxDropCounterId = AddNodeCounter ("WifiPhy TxDrop", AnimationInterface::DOUBLE_COUNTER);
          m_wifiPhyRxDropCounterId = AddNodeCounter ("WifiPhy RxDrop", AnimationInterface::DOUBLE_COUNTER);
          // added by febalart
          m_wifiPhyTxBeginCounterId = AddNodeCounter ("WifiPhy TxBegin", AnimationInterface::DOUBLE_COUNTER);
          for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
            {
              Ptr<Node> n = *i;
              m_nodeWifiPhyTxDrop[n->GetId ()] = 0;
              m_nodeWifiPhyRxDrop[n->GetId ()] = 0;
              // added by febalart
              m_nodeWifiPhyTxBegin[n->GetId ()] = 0;

              UpdateNodeCounter (m_wifiPhyTxDropCounterId, n->GetId (), 0);
              UpdateNodeCounter (m_wifiPhyRxDropCounterId, n->GetId (), 0);
              UpdateNodeCounter (m_wifiPhyTxBeginCounterId, n->GetId (), 0);
            }
          Simulator::Schedule (startTime, &AnimationInterface::TrackWifiPhyCounters, this);
         
        }
    2. Now go to the WifiPhyTxBeginTrace function and modify accordingly (same as WifiPhyTxDropTrace function)
      • I highlighted in yellow the code lines added
      • void
        AnimationInterface::WifiPhyTxBeginTrace (std::string context, Ptr<const Packet> p)
        {
          NS_LOG_FUNCTION (this);
          const Ptr <const Node> node = GetNodeFromContext (context);
          ++m_nodeWifiPhyTxBegin[node->GetId ()];
          return GenericWirelessTxTrace (context, p, AnimationInterface::WIFI);
        }
    3. Then goto the AnimationInterface::TrackWifiPhyCounters () function and add the following lines
      • void
        AnimationInterface::TrackWifiPhyCounters ()
        {
          if (Simulator::Now () > m_wifiPhyCountersStopTime)
            {
              NS_LOG_INFO ("TrackWifiPhyCounters Completed");
              return;
            }
          for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
            {
              uint32_t nodeId = Ptr <Node> (*i)->GetId ();
              UpdateNodeCounter (m_wifiPhyTxDropCounterId, nodeId, m_nodeWifiPhyTxDrop[nodeId]);
              UpdateNodeCounter (m_wifiPhyRxDropCounterId, nodeId, m_nodeWifiPhyRxDrop[nodeId]);
              // by febalart
              UpdateNodeCounter (m_wifiPhyTxBeginCounterId, nodeId, m_nodeWifiPhyTxBegin[nodeId]);
            }
          Simulator::Schedule (m_wifiPhyCountersPollInterval, &AnimationInterface::TrackWifiPhyCounters, this);
        }
    4. Finally On the AnimationInterface::ConnectCallbacks () function connect the trace with its callback on the //Wifi Phy section
      •  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxBegin",
                           MakeCallback (&AnimationInterface::WifiPhyTxBeginTrace, this));
    5. And that's it, then after running the test when opening net anim you can see the counter table and trace

Reply all
Reply to author
Forward
0 new messages