CSMA invisible

100 views
Skip to first unread message

David Hudec

unread,
Nov 14, 2015, 5:33:41 PM11/14/15
to ns-3-users
Here I am again :(
CSMA channel declared in my code is not showing up in NetAnim, nor it is successfully carrying data. Checked all the requirements, I can't say there is something missing. Every single thing matches with second.cc from examples/tutorials. Code attached, as well as NetAnim screenshot. To make it easier, here is the result of "grep csma" on the file:

#include "ns3/csma-module.h"
  NodeContainer csmaNodes (n2, n3, n4);
  CsmaHelper csma;
  csma.SetChannelAttribute ("DataRate", StringValue ("100Mbps"));
  csma.SetChannelAttribute ("Delay", TimeValue (NanoSeconds (6560)));
  NetDeviceContainer csmaDevices;
  csmaDevices = csma.Install (csmaNodes);
  Ipv4InterfaceContainer csmaInterfaces;
  csmaInterfaces = address.Assign (csmaDevices);
  ApplicationContainer clientApps = echoClient.Install (csmaNodes);
  csma.EnablePcapAll ("dos:csma");

Any help appreciated.
David.
dos.cc
na.png

Tommaso Pecorella

unread,
Nov 15, 2015, 4:07:57 AM11/15/15
to ns-3-users
Hi,

no idea, without the proper headers (the ones you defined) it's impossible to run the script. And without the XML it's hard to say what's going on.

T.

David Hudec

unread,
Nov 15, 2015, 5:45:09 AM11/15/15
to ns-3-users
You're right, I post-attached them. Tried to examine those one by one, but I don't see anything there that could be causing the trouble. Nevertheless if the main file is OK, there has to be something in them, though.
_callback - calculates time from packet's departure to answer's arrival and puts these in datasets to be plotted
_plot - plots these datasets
_anim - sets animation's attributes and creates it.
Thanks for that answer.
_anim.cc
_anim.h
_callback.cc
_callback.h
_plot.cc
_plot.h
anim_dos.xml

Tommaso Pecorella

unread,
Nov 15, 2015, 7:40:34 AM11/15/15
to ns-3-users, john.ab...@gmail.com
Hi,

it seems a funny bug. Better to let John know about it.
Also, it seems that you're using an outdated ns-3 version. In the latest one AnimationInterface::SetConstantPosition must be used before instancing the AnimationInterface and using the class function, otherwise it doesn't have any effect (another bug ?)

Cheers,

T.

David Hudec

unread,
Nov 15, 2015, 8:13:15 AM11/15/15
to ns-3-users, john.ab...@gmail.com
Hi.
Cool. I found a bug :(. Which John do you mean? Is it a bug in the animation, or a bug in the simulation? The channel seems not to be working to me, so I guess it's simulation. 
The ns-3 I'm using is 3.24.1 - up to date.

Tommaso Pecorella

unread,
Nov 15, 2015, 8:24:09 AM11/15/15
to ns-3-users, john.ab...@gmail.com
John is already reading us, and I think it's a bug in the animator.
The simulation... I didn't check it, but I have seen packets flowing on it. Try using Wireshark and pcaps.

T.

John Abraham

unread,
Nov 15, 2015, 1:05:46 PM11/15/15
to Tommaso Pecorella, ns-3-users
This problem can be traced to the fact, that we cannot determine the Rx time of the last bit at any receiver in the case of CSMA. LastBit Rx is used for quite a few computations in netanim, and this got missed.

I pushed a workaround. You should get something like the picture attached.
Please clone netanim again



Further, 
I would change your function like so. (i.e return a pointer to AnimationInterface rather than return a local variable. Not sure if the default copy constructor copies all pointers correctly)


ns3::AnimationInterface * setAnimation(ns3::NodeContainer nodes)

{

        ns3::AnimationInterface::SetConstantPosition(nodes.Get(0), 0.0, 3.0);

        ns3::AnimationInterface::SetConstantPosition(nodes.Get(1), 3.0, 0.0);

        ns3::AnimationInterface::SetConstantPosition(nodes.Get(2), 3.0, 3.0);

        ns3::AnimationInterface::SetConstantPosition(nodes.Get(3), 6.1, 6.0);

        ns3::AnimationInterface::SetConstantPosition(nodes.Get(4), 3.0, 9.0);

        ns3::AnimationInterface * anim = new ns3::AnimationInterface ("anim_dos.xml");


        anim->UpdateNodeDescription (nodes.Get(0)->GetId(), "Atacker n0");

        anim->UpdateNodeDescription (nodes.Get(1)->GetId(), "Server");

        anim->UpdateNodeDescription (nodes.Get(2)->GetId(), "Client n2");

        anim->UpdateNodeDescription (nodes.Get(3)->GetId(), "Client n3");

        anim->UpdateNodeDescription (nodes.Get(4)->GetId(), "Client n4");


        anim->UpdateNodeSize(nodes.Get(0)->GetId(), 0.5, 0.5);

        anim->UpdateNodeSize(nodes.Get(1)->GetId(), 1.0, 1.0);

        anim->UpdateNodeSize(nodes.Get(2)->GetId(), 0.5, 0.5);

        anim->UpdateNodeSize(nodes.Get(3)->GetId(), 0.5, 0.5);

        anim->UpdateNodeSize(nodes.Get(4)->GetId(), 0.5, 0.5);


        anim->EnablePacketMetadata (true);

        //anim.SetMobilityPollInterval (ns3::Seconds (1));

        anim->SetStartTime (ns3::Seconds (0));

        anim->SetStopTime (ns3::Seconds (20));


        return anim;

}






Screen Shot 2015-11-15 at 9.59.40 AM.png
Reply all
Reply to author
Forward
0 new messages