NetAnim problem: AnimationInterface is not tracing wifi packets

676 views
Skip to first unread message

Enrico Zamagni

unread,
Jul 31, 2013, 6:06:34 AM7/31/13
to ns-3-...@googlegroups.com
Hi everybody,

i'm working on a VANET simulation with ns-3.17 and i recently decided to use NetAnim to better debug my code and get some visual feedback. I went for the simplest approach and i just call AnimationInterface anim ("test.xml") right before Simulator::Run().

My script is an adaptation of the example "wifi-simple-adhoc" under examples/wireless folder. If i add the aforementioned instruction on that script i can get a correct netanim animation while i can't on my simulation. Looking at my output .xml it seems that no packet has been traced by Animationinterface despite having sent and received plenty of broadcast udp packets, as my log testifies.

I'm trying to investigate and solve this problem and probably i'm just missing something silly, but i went and looked at AnimationInterface.cc code and discovered some strange behaviour: the component registers itself for a lot of trace sources like "NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxBegin" and "NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxBegin". 
I placed a breakpoint in both callbacks (WifiPhyTxBeginTrace and WifiPhyRxBeginTrace) and run my script. It came out that while the first one is being called as expected (still, i get no packet trace), the second one (WifiPhyRxBeginTrace) is not. I even placed a breakpoint in wifi-phy.cc (line 324) NotifyRxBegin method and the funny thing is that the trace source correctly notifies its subscribers, but the callback is AnimationInterface is not called and i get 0 packets in my xml.

If i execute the example script, everything works normally. I just can't understand what is wrong with my code.

I'm attaching the two scripts: the working one is a simple zztest.cc file that can be put on the scratch folder, the other one is a package containing a folder that's also meant to be put in scratch dir, it's a stripped-down version of my much more sophisticated script.
Any help would be really appreciated, thanks in advance!

Enrico
itstest.zip
zztest.cc

John Abraham

unread,
Jul 31, 2013, 11:21:46 AM7/31/13
to ns-3-...@googlegroups.com
I see , for some reason, there are no callbacks installed when NotifyRxBegin happens. Will have to look into it




Enrico

--
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+...@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at http://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Screen Shot 2013-07-31 at 8.20.30 AM.png

John Abraham

unread,
Jul 31, 2013, 2:22:14 PM7/31/13
to ns-3-...@googlegroups.com
My guess is that you should not get any NotifyRxBegin callbacks even without AnimationInterface in the picture.
ie. Config::Connect ("NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxBegin",
                   MakeCallback (&<Yourclass::YourMethod>, this));

should not work for your setup.
can you check?

Enrico Zamagni

unread,
Jul 31, 2013, 6:44:33 PM7/31/13
to ns-3-...@googlegroups.com
Confermed.
With or without AnimationInterface the effect is the same: with this black-magical configuration WifiPhy::NotifyRxBegin always notifies an empty callback list.
So the problem seems unrelated to NetAnim, should i report it somewhere else?

John Abraham

unread,
Jul 31, 2013, 6:53:09 PM7/31/13
to ns-3-...@googlegroups.com
I was able to narrow it down to a part where
NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxBegin

the * , resolves only for one node and not the other. It is likely because one of your nodes is not a standard ns-3 node or the order of wifi installation is overwriting something.

John Abraham

unread,
Aug 1, 2013, 1:01:36 AM8/1/13
to ns-3-...@googlegroups.com
i looked at this some more.
The tracing system uses the type-id to resolve attribute information.
Since MobileNode has its own type-id, at the time of connecting traces for NodeList/*/ the Ptr<MobileNode> is retrieved instead of Ptr<Node>. So far so good. Unfortunately MobileNode does not have attributes such as the following in Node.

    .AddAttribute ("DeviceList", "The list of devices associated to this Node.",
    .AddAttribute ("ApplicationList", "The list of applications associated to

The "Config" cannot/does not check if the base class has attributes such as "DeviceList".

Therefore NodeList/*/DeviceList/*/ and NodeList/*/ApplicationList/*/ will not resolve to anything for MobileNode.

If I were to do it, I would not subclass/inherit "Node", I would aggregate a new Object of type "MobileNodeProperties" to "Node".

See an example of aggregation here.


Screen Shot 2013-07-31 at 9.28.27 PM.png
Screen Shot 2013-07-31 at 9.27.27 PM.png

John Abraham

unread,
Aug 1, 2013, 1:53:18 AM8/1/13
to ns-3-...@googlegroups.com
also here is another brute force approach to connect callbacks without config::connect in AnimationInterface

  ConnectLte ();
// Add the for loop below
  for(uint32_t i = 0; i < NodeList::GetNNodes (); ++i)
  {
 Ptr <Node> n = NodeList::GetNode(i);
 for(uint32_t j = 0; j < n->GetNDevices (); j++)
 {
 Ptr <WifiNetDevice> wifiNd = DynamicCast <WifiNetDevice> (n->GetDevice(j));
 if (wifiNd)
 {
std::ostringstream oss;
                        //NodeList/*/DeviceList/*/
                        oss << "NodeList/" << n->GetId () << "/DeviceList/" << j << "/";
                        wifiNd->GetPhy()->TraceConnect("PhyRxBegin", oss.str (),MakeCallback (&AnimationInterface::WifiPhyRxBeginTrace, this));
                        wifiNd->GetPhy()->TraceConnect("PhyTxBegin", oss.str (),MakeCallback (&AnimationInterface::WifiPhyTxBeginTrace, this));

 }
 }

Also note NetAnim, rejects packets sent by a node to itself from animation.

Enrico Zamagni

unread,
Aug 1, 2013, 4:58:50 AM8/1/13
to ns-3-...@googlegroups.com
Thanks John, i really appreciate all your help and effort!

Unfortunately, this is the second time i run into problems because of the lack of inheritance of ns3 attributes. Aggregating MobileNodeProperties is not a comfortable option for me, since it would require lots of refactoring (my script has become quite complex in the meantime); i guess i must go with the brute-force solution.
But what if i re-implement "DeviceList" attribute in my MobileNode and i link it to the parent class? Any chance it might work?

Also, from what i understood so far, NetAnim also rejects packets that were sent but not received (ie: a broadcast wireless packet with no receivers), doesn't it? Is there any quick workaround to this?

Again, thanks for your help!

John Abraham

unread,
Aug 1, 2013, 9:11:58 AM8/1/13
to ns-3-...@googlegroups.com
yes , it is a non trivial fix to get NetAnim to accept frames which do not go up the stack of any receiver. you can possibly call the PhyRxBegin callback forcibly when PhyTxBegin callback is triggered and the frame is bcast.

that being said wifi mgmt beacons which are bcast do have receivers , and they do show up if the frame went up wifi mac low of any node.
also please ensure you use the latest NetAnim via hg clone http://code.nsnam.org/netanim

finally even if you do the brute force approach, it is important to note that you are losing not just devicelist , but also applicationlist , and possibly other places where config::connect or tracing are used
Reply all
Reply to author
Forward
0 new messages