Unable to send the packets to the destination. No errors.

426 views
Skip to first unread message

karthik karra

unread,
Mar 25, 2016, 3:01:40 PM3/25/16
to ns-3-users
Hi, Below is my topology

//            csma          csma               csma        csma
// node1-----------node2--------OFSwitch--------node3------------node4
//                                       controller

 Below is my code. could anyone please point out the error.
 I am unable to send the packets to destination(from node1 to node4). I have tried even with "BridgeHelper" in place of OF Controller but the result was same.
 just I am able to see the one side transmission from node 1 to node2.

===========code==================

using namespace ns3 ;

NS_LOG_COMPONENT_DEFINE("Project");

ns3::Time timeout = ns3::Seconds (0);

int main(int argc, char *argv[])
{

    NS_LOG_INFO("Create Nodes");
    NodeContainer csmanode;
    csmanode.Create(4);

    NodeContainer OFSwitch;
    OFSwitch.Create(1);

    NS_LOG_INFO("Build Topology");
    CsmaHelper csma;
    csma.SetChannelAttribute ("DataRate", DataRateValue (5000000));
    csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));

    NetDeviceContainer csmaNetDevices, link;
    NetDeviceContainer switchDevice;

    //connect node0 to node1
    link = csma.Install(NodeContainer(csmanode.Get(0),csmanode.Get(1)));
    csmaNetDevices.Add(link.Get(0));
    csmaNetDevices.Add(link.Get(1));

    //connect node1 to OFSwitch
    link = csma.Install(NodeContainer(csmanode.Get(1),OFSwitch.Get(0)));
    switchDevice.Add(link.Get(1));

    //connect OFSwitch to node2
    link = csma.Install(NodeContainer(OFSwitch.Get(0),csmanode.Get(2)));
    switchDevice.Add(link.Get(0));
    csmaNetDevices.Add(link.Get(1));

    //connect node2 to node3
    link = csma.Install(NodeContainer(csmanode.Get(2),csmanode.Get(3)));
    csmaNetDevices.Add(link.Get(0));
    csmaNetDevices.Add(link.Get(1));

    Ipv4GlobalRoutingHelper::PopulateRoutingTables ();

    //Create Switch net device, which will do packet switching
    Ptr<Node> OFNode0 = OFSwitch.Get(0);
    OpenFlowSwitchHelper OFSwHelper;

    //Install controller on switch
     Ptr<ns3::ofi::LearningController> controller = CreateObject<ns3::ofi::LearningController> ();
     if (!timeout.IsZero ()) controller->SetAttribute ("ExpirationTime",TimeValue (timeout));
     OFSwHelper.Install (OFNode0, switchDevice, controller);

    //Add Internet stack to terminals
     InternetStackHelper internet;
     internet.Install(csmanode);

     Ipv4AddressHelper address;
     address.SetBase ("10.1.1.0", "255.255.255.0");
     address.Assign (csmaNetDevices);

     //Print IP address of Nodes
     for (int i=0; i<4; i++)
       {
          Ptr<Node> n = csmanode.Get (i);
          Ptr<Ipv4> ipv4 = n->GetObject<Ipv4> ();
          Ipv4InterfaceAddress ipv4_int_addr = ipv4->GetAddress (1, 0);
          Ipv4Address ip_addr = ipv4_int_addr.GetLocal ();
          NS_LOG_INFO ("Node: " << i << " IP Address: "<< ip_addr);
       }

     Ptr<Node> n = csmanode.Get (3);
               Ptr<Ipv4> ipv4 = n->GetObject<Ipv4> ();
               Ipv4InterfaceAddress ipv4_int_addr = ipv4->GetAddress (1, 0);
               Ipv4Address ip_addr = ipv4_int_addr.GetLocal ();

                  Ptr<OutputStreamWrapper> routintable = Create<OutputStreamWrapper>("routingtable",std::ios::out);
                  Ipv4GlobalRoutingHelper ipv4global;
                  ipv4global.PrintRoutingTableAllAt(Seconds(2.0), routintable);



     OnOffHelper onoff("ns3::UdpSocketFactory",Address(InetSocketAddress(ip_addr,1024)));
     onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
     onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
     onoff.SetAttribute ("DataRate", DataRateValue (DataRate (6000)));

     ApplicationContainer apps = onoff.Install(csmanode.Get(0));
       apps.Start(Seconds(1.0));
       apps.Stop(Seconds(10.0));


       PacketSinkHelper sink ("ns3::UdpSocketFactory", Address (InetSocketAddress (Ipv4Address::GetAny(), 1024)));
         apps = sink.Install(csmanode.Get(3));
         apps.Start(Seconds(1.0));
         apps.Stop(Seconds(10.0));


       AsciiTraceHelper ascii;
       Ptr<OutputStreamWrapper> stream = ascii.CreateFileStream ("MobilityWlans.tr");
       csma.EnableAsciiAll (stream);
       csma.EnablePcapAll ("MobilityWlans", false);



                               NS_LOG_INFO ("Run Simulation.");
                                 Simulator::Run ();
                                 Simulator::Destroy ();
                                 NS_LOG_INFO ("Done.");

}

Tommaso Pecorella

unread,
Mar 25, 2016, 5:44:42 PM3/25/16
to ns-3-users
Hi,

please don't copy-paste the code, attach the source file. Or, at least, format the code (it's all explained in the posting guidelines).

About the error, node2 and node3 are routers, not switches. As a consequence, having the very same subnet on all the coma links is a bad idea.

T.

karthik karra

unread,
Mar 26, 2016, 5:47:05 AM3/26/16
to ns-3-users
Hi, 
I would never paste the code again. Sorry for that. I have made the changes as mentioned by you(Address are different). But, previously I was able to get transmission but now even that's not there. I am attaching the whole code with the changed part in Bold and highlighted parts and I am also attaching the router table I have got.

Actually I am confused on how the switching is happening for packets between node 2 and node3. Could you please look into it.

Thanks.
code.cc.odt
routingtable

Tommaso Pecorella

unread,
Mar 26, 2016, 6:35:44 AM3/26/16
to ns-3-users
What about using PopulateRoutingtable after you actually install IP and assign IP addresses to the nodes ?
You know, it might help.

T.

karthik karra

unread,
Mar 26, 2016, 7:12:07 AM3/26/16
to ns-3-users
Until assigning the IP addresses to nodes its working perfectly(I have checked with the LOG messages.).
but the moment it encounters the command "Ipv4GlobalRoutingHelper::PopulateRoutingTables ();" after assigning IPs its showing the below error

"aborted. cond="!(bnd)", msg="GlobalRouter::DiscoverLSAs (): GetObject for <BridgeNetDevice> failed", file=../src/internet/model/global-router-interface.cc, line=1685
terminate called without an active exception"
Message has been deleted

karthik karra

unread,
Mar 26, 2016, 7:55:36 AM3/26/16
to ns-3-users
I have checked the line it has shown in the error so I replaced the Openflow controller with "BridgeHelper". Now I am not getting any error but packets are not getting transmitted at all.

Node 0 and Node 1 are having only two subnets(10.1.3.0 is not present) in their destination lists but Node 2 and node 3 are having all subnets in their destination lists

so node0 doesn't know where to send if it receives "10.1.3.0"(Right ?) which is the subnet and node in it I am trying to send to.

How to populate 10.1.3.0 as destination in node0 and node 1 ? And why the error with the Open Flow Controller ?

Attaching the new routing table file.
routingtable

Tommaso Pecorella

unread,
Mar 26, 2016, 8:52:21 AM3/26/16
to ns-3-users
Hi,

no idea about the OpenFlow one, but you could have found a bug (unlikely, but possible).
Please attach the latest source code **as a .cc file**.

Thanks,

T.

karthik karra

unread,
Mar 26, 2016, 9:18:53 AM3/26/16
to ns-3-users
Hi,

I have attached the source code.

As packets are unable to route from node 0 to node 3 with "Ipv4GlobalRoutingHelper::PopulateRoutingTables ();", the Ipv4 static routing should be the solution for sending packets from every node to every other node (Am I Right ?). Or can you suggest any other better solution ? (for my above mentioned topology).

Thanks,
KK.
a.cc

Tommaso Pecorella

unread,
Mar 26, 2016, 2:12:34 PM3/26/16
to ns-3-users
Hi,

beside the fact that you forgot the includes... the problem seems to be real.
The immediate solution is to use RIP. The pros is that it will work, also with OpenFlow. The cons is that it needs time to build the routes. Just start your apps after 1 minute, so to give time to RIP to build the routing tables.
Attached is the modified code, but I didn't fully modify it (i.e., apps have to be adjusted).


Cheers,

T.
a.cc

karthik karra

unread,
Mar 27, 2016, 4:51:39 AM3/27/16
to ns-3-users
Hi,

Thanks for your time.

I deliberately removed the includes as there are many in number. So, you say that bug is present(Right ?).

I am using NS3.24 and it looks like RipHelper is not being supported because when its included the eclipse says "Unresolved Inclusion" and I am using Eclipse Luna 4.4.2  with Mercurial (I am not sure if these have any dependencies.)

So, right now I have changed it to "ripng-helper.h",RipNgHelper and its working fine. No Errors.

Just for being on safe side, I have printed the routing table after 80 seconds and have started app and sink at 100 and 90 seconds respectively and stopped at 120 and 140 seconds respectively and simulator stops at 200 seconds. But every thing happens to be in less than few seconds.(Irrespective of whether time is relative or absolute I think this should not be a problem for the above simulation).

Even this time no transmission is taking place(empty .tr file) and all destination links are not populated in any of the nodes. I don't know if am going wrong anywhere.

Can I use static routing and will it work for both Normal and Open flow switches ?. Actually my requirement is with Open Flow Switch.

Attaching the routing table for reference.
routingtable

Tommaso Pecorella

unread,
Mar 27, 2016, 5:24:31 AM3/27/16
to ns-3-users
'When I use a word,’ Humpty Dumpty said in rather a scornful tone, ‘it means just what I choose it to mean — neither more nor less.’
― Lewis Carroll, Through the Looking Glass

RipNg is for IPv6, and you're using IPv4.
Rip has been added in ns-3.25, which has been released some days ago.

T.

karthik karra

unread,
Mar 27, 2016, 7:50:31 AM3/27/16
to ns-3-users
I forgot that RipNG is for Ipv6 and I thought that as RipNG is being supported, Rip should also be supported and I am not aware of the fact that Rip has been added to 3.25 version.

I have installed and tried with both normal switch and Open Flow controller it worked fine. Routing table is perfect. .tr file is getting populated and I need to check the transmission of the packets.

Thanks for your Help.
KK.

7705...@qq.com

unread,
Nov 20, 2018, 3:38:39 AM11/20/18
to ns-3-users
Hello, I have encountered the same problem with you. I tried it many times to solve it, but it didn't work. I don't know if your code file is still there. Can you send me a copy? Thank you very much.

在 2016年3月27日星期日 UTC+8下午7:50:31,karthik karra写道:

7705...@qq.com

unread,
Nov 21, 2018, 9:56:45 PM11/21/18
to ns-3-users

11.JPG

Hi,My model is n0, n1 is connected to the switch, the switch is connected to n2, n2 is connected to another switch, and the second switch is connected to n3 and n4. I want n0 to send data to n3, n1 transfer to n4, but now The data is interrupted when it reaches n2. Which friend can help me check it out, thank you very much. Attachment is my code.

在 2016年3月27日星期日 UTC+8下午5:24:31,Tommaso Pecorella写道:
test2.cc
Reply all
Reply to author
Forward
0 new messages