Routing table access at the MAC layer on NS-3

119 views
Skip to first unread message

Mallesh Yadhav

unread,
Dec 22, 2014, 4:34:48 AM12/22/14
to ns-3-...@googlegroups.com
Hi,

   I wan to find the next hop MAC address at the relay nodes in a multi hop network for a cross layer design. So, I was wondering if I could access the routing table maintained at the routing layer in MAC layer.

Thanks & regards,
   Mallesham

Mallesh Yadhav

unread,
Dec 22, 2014, 8:19:47 AM12/22/14
to ns-3-...@googlegroups.com
I have tried with this code,

       std::cout<<"node id: "<<ns3::Simulator::GetContext( )<<"\n";
       //ns3::Ipv4StaticRoutingHelper helper;
       ns3::Ptr<ns3::Node> myself = ns3::NodeList::GetNode( ns3::Simulator::GetContext( ) );
       ns3::Ptr<ns3::Ipv4> stack = myself->GetObject<ns3::Ipv4>( );
      //ns3::Ptr<ns3::Ipv4StaticRouting> globalrouting = helper.GetStaticRouting(stack);
       ns3::Ptr<ns3::GlobalRouter> router = myself->GetObject<ns3::GlobalRouter> ( );
       ns3::Ptr<ns3::Ipv4GlobalRouting> globalrouting = router->GetRoutingProtocol( );
       ns3::Ipv4RoutingTableEntry entry;
       uint32_t numroutes = globalrouting->GetNRoutes( );
       for( uint32_t i =0; i<numroutes; i++ )
       {
            entry = globalrouting->GetRoute(i);
            if( dst == entry.GetDest( ) )
            {
                break;
            }
       }
       return entry.GetGateway( );

I am getting the following segmentation fault and back trace with gdb.



Program received signal SIGSEGV, Segmentation fault.
0x01a02c94 in ns3::PeekPointer<ns3::Ipv4GlobalRouting> (p=...) at ./ns3/ptr.h:281
281      return p.m_ptr;
(gdb) bt
#0  0x01a02c94 in ns3::PeekPointer<ns3::Ipv4GlobalRouting> (p=...) at ./ns3/ptr.h:281
#1  0x01a018c1 in Ptr (this=0xbfffcee0, o=...) at ./ns3/ptr.h:439
#2  0x019f05bb in ns3::GlobalRouter::GetRoutingProtocol (this=0x0) at ../src/internet/model/global-router-interface.cc:540
#3  0x01c449a9 in stdma::StdmaMac::uu_tdma_get_next_hop_bwr (this=0x80a14a8, dst=...) at ../src/stdma/model/stdma-mac.cc:592

Please help me..

Thanks & regards,
   Mallesham
Reply all
Reply to author
Forward
0 new messages