STDMA mac implementation NS-3 animation not working

134 views
Skip to first unread message

Mallesh Yadhav

unread,
Sep 19, 2014, 5:38:06 AM9/19/14
to ns-3-...@googlegroups.com
Hi,

I am running the STDMA code in NS-3, but I am not getting any animation of flow of packets from one node to another node. Below is my configuration file.


                ns3::SeedManager::SetSeed (1);

                stdma::StdmaHelper stdma;
                stdma.SetStandard(ns3::WIFI_PHY_STANDARD_80211p_CCH);
                stdma::StdmaMacHelper stdmaMac = stdma::StdmaMacHelper::Default();

                ns3::Config::SetDefault ("stdma::StdmaMac::FrameDuration", ns3::TimeValue(ns3::MilliSeconds(200.0)));
                ns3::Config::SetDefault ("stdma::StdmaMac::MaximumPacketSize", ns3::UintegerValue(700));
                ns3::Config::SetDefault ("stdma::StdmaMac::ReportRate", ns3::UintegerValue(1));
                ns3::Config::SetDefault ("stdma::StdmaMac::Timeout", ns3::RandomVariableValue (ns3::UniformVariable(8, 8)));

                // Create network nodes
                ns3::NodeContainer m_nodes;
                m_nodes.Create(2);

              
                ns3::YansWifiChannelHelper wifiChannel;
              
                wifiChannel.AddPropagationLoss("ns3::RangePropagationLossModel");
                ns3::Config::SetDefault ("ns3::RangePropagationLossModel::MaxRange", ns3::DoubleValue(10));
                wifiChannel.SetPropagationDelay("ns3::ConstantSpeedPropagationDelayModel");

                ns3::YansWifiPhyHelper wifiPhy = ns3::YansWifiPhyHelper::Default();
                wifiPhy.SetChannel(wifiChannel.Create());

                // Install wifiPhy and link it with STDMA medium access control layer implementation
                NetDeviceContainer devices = stdma.Install(wifiPhy, stdmaMac, m_nodes);

                // Define positions of the two nodes
                ns3::MobilityHelper mobility;
                ns3::Ptr<ns3::ListPositionAllocator> positionAlloc = ns3::CreateObject<ns3::ListPositionAllocator>();
                for (uint32_t i = 0; i < 2; i++)
                {
                        positionAlloc->Add(ns3::Vector(8.0 * i, 0.0, 0.0));
                }
                mobility.SetPositionAllocator(positionAlloc);
                mobility.Install(m_nodes);

                AnimationInterface anim("multi.xml");
                anim.EnablePacketMetadata(true);
                anim.EnableIpv4RouteTracking("routing-table.txt",Seconds(50.0),Seconds(80.0),Seconds(5.0));

                AodvHelper aodv;

                //install internet stack on all nodes
                InternetStackHelper internet;
                internet.SetRoutingHelper (aodv);
                internet.Install (m_nodes);
                //assign ip address to each node               
                Ipv4AddressHelper ipv4;
                ipv4.SetBase ("10.1.1.0", "255.255.255.0");
                Ipv4InterfaceContainer inter = ipv4.Assign (devices);

                InetSocketAddress remote = InetSocketAddress (Ipv4Address("10.1.1.2"), 9);

                 OnOffHelper onoff ("ns3::UdpSocketFactory", Address (remote));
                 onoff.SetConstantRate (DataRate ("10kbps"));
                 onoff.SetAttribute ("PacketSize", UintegerValue (500));


                 ApplicationContainer apps = onoff.Install(m_nodes.Get(0)) ;
                 apps.Start (Seconds (65.0));
                 apps.Stop (Seconds (70.0));

                 FlowMonitorHelper help;
                Ptr<FlowMonitor> monitor;
                monitor = help.InstallAll();
                stdma.EnablePcap("multi-hop",devices,false);

                ns3::Simulator::Stop(ns3::Seconds(100.0));
 
                ns3::Simulator::Run ();
                monitor -> SerializeToXmlFile("multi.flowmon",true,true);
                ns3::Simulator::Destroy ();

Konstantinos

unread,
Sep 19, 2014, 6:05:07 AM9/19/14
to ns-3-...@googlegroups.com
Dear Mallesh,

Please do not spam the list with the same question in different threads.

Your scenario is not correct. You have created a traffic generator (OnOff app) but you do not have any sink application.
So no traffic is actually transmitted, or to be correct, there might be some packets broadcasted but not actually received, so they can't be visualised!

Mallesh Yadhav

unread,
Sep 19, 2014, 7:35:11 AM9/19/14
to ns-3-...@googlegroups.com
Thank you for your response Konstantinos.
  
         First of all I am sorry for multiple copies. Can you help me how can I write sink application instead of OnOff application, so that I can visualize in Netanim.

Thanks & regards,
  Mallesh


Konstantinos

unread,
Sep 19, 2014, 7:46:53 AM9/19/14
to ns-3-...@googlegroups.com
The sink applications is needed not instead of the OnOff, but along side with it.
The OnOff application is the traffic generator, i.e creates and sends packets.
You need one application to consume those packets, a sink.

Read the tutorial. The first example gives you an idea what is needed. 

Mallesh Yadhav

unread,
Sep 19, 2014, 8:26:09 AM9/19/14
to ns-3-...@googlegroups.com
Thanks,

          I have added the following sink application, still I am not able to visualize the packets, please help me.

InetSocketAddress local = InetSocketAddress (Ipv4Address::GetAny (),9);

   PacketSinkHelper sink ("ns3::UdpSocketFactory",
                         Address (local));
  apps = sink.Install (m_nodes.Get (1));
  apps.Start (Seconds (0.0));
  apps.Stop (Seconds (100.0));
Reply all
Reply to author
Forward
0 new messages