Static routing in wifi adhoc???

348 views
Skip to first unread message

Wei Wang

unread,
Aug 27, 2014, 4:38:59 PM8/27/14
to ns-3-users
Dear all:
I am recently simulating a algorithm, it requires the fixed roouting in wifi ad-hoc. However, OLSR, AODV routing protocols will select a new route if I change the txpower during simulation. So I want the routes to be fixed. If I use the chain topology, the packet should send on by one.

I am tring to use static routing in wifi, but it has a run-time error, after I dubug it, it showed:

Program received signal SIGSEGV, Segmentation fault.
0x00000000004249c7 in ns3::PeekPointer<ns3::NetDevice> (p=...) at ./ns3/ptr.h:281
281  return p.m_ptr;

I previously used the OLSR, it run correctly.  I am looking for help!

It is my topology: n0------n1------n2------n3------n4------n5
I want to creat the routes of two flows:, tcp n0->n3, n2->n5, following is the key part of routing:
......
......
NetDeviceContainer staDevices;
staDevices = wifi.Install (phy, mac, c);
..........
.........
  Ipv4StaticRoutingHelper staticRoutingHelper;
  Ipv4ListRoutingHelper listRouting;
  listRouting.Add (staticRoutingHelper, 0);
  
  InternetStackHelper stack;
  stack.SetRoutingHelper (listRouting);
  stack.Install (c);
  
  NS_LOG_INFO ("Assign IP Addresses.");
  Ipv4AddressHelper address;
  address.SetBase ("10.1.1.0", "255.255.255.0");
  Ipv4InterfaceContainer interfaces = address.Assign (staDevices);

  Ptr<Ipv4> ipv4A = c.Get(0)->GetObject<Ipv4> ();
  Ptr<Ipv4> ipv4B = c.Get(1)->GetObject<Ipv4> ();
  Ptr<Ipv4> ipv4C = c.Get(2)->GetObject<Ipv4> ();
  Ptr<Ipv4> ipv4D = c.Get(3)->GetObject<Ipv4> ();
  Ptr<Ipv4> ipv4E = c.Get(4)->GetObject<Ipv4> ();
  Ptr<Ipv4> ipv4F = c.Get(5)->GetObject<Ipv4> ();

  //A<--1-->B<--2-->C<--1-->D<--2-->E<--1-->F
  //n0------n1------n2------n3------n4------n5
Ptr<Ipv4StaticRouting> staticRoutingA = staticRoutingHelper.GetStaticRouting (ipv4A);
  Ptr<Ipv4StaticRouting> staticRoutingB = staticRoutingHelper.GetStaticRouting (ipv4B);
  Ptr<Ipv4StaticRouting> staticRoutingC = staticRoutingHelper.GetStaticRouting (ipv4C);
  Ptr<Ipv4StaticRouting> staticRoutingD = staticRoutingHelper.GetStaticRouting (ipv4D);
  Ptr<Ipv4StaticRouting> staticRoutingE = staticRoutingHelper.GetStaticRouting (ipv4E);
  Ptr<Ipv4StaticRouting> staticRoutingF = staticRoutingHelper.GetStaticRouting (ipv4F);
  //N0->N3
  staticRoutingA->AddHostRouteTo (Ipv4Address ("10.1.1.4"), Ipv4Address ("10.1.1.2"), 1);//The ifIndex for this outbound route is 1;loopback is 0
  staticRoutingB->AddHostRouteTo (Ipv4Address ("10.1.1.4"), Ipv4Address ("10.1.1.3"), 2);
  staticRoutingC->AddHostRouteTo (Ipv4Address ("10.1.1.4"), Ipv4Address ("10.1.1.4"), 1);
  staticRoutingD->AddHostRouteTo (Ipv4Address ("10.1.1.4"), Ipv4Address ("10.1.1.4"), 0);
  //N3->N0
  staticRoutingD->AddHostRouteTo (Ipv4Address ("10.1.1.1"), Ipv4Address ("10.1.1.3"), 1);
  staticRoutingC->AddHostRouteTo (Ipv4Address ("10.1.1.1"), Ipv4Address ("10.1.1.2"), 2);
  staticRoutingB->AddHostRouteTo (Ipv4Address ("10.1.1.1"), Ipv4Address ("10.1.1.1"), 1);
  staticRoutingA->AddHostRouteTo (Ipv4Address ("10.1.1.1"), Ipv4Address ("10.1.1.1"), 0);
  //N2->N5
  staticRoutingC->AddHostRouteTo (Ipv4Address ("10.1.1.6"), Ipv4Address ("10.1.1.4"), 1);
  staticRoutingD->AddHostRouteTo (Ipv4Address ("10.1.1.6"), Ipv4Address ("10.1.1.5"), 2);
  staticRoutingE->AddHostRouteTo (Ipv4Address ("10.1.1.6"), Ipv4Address ("10.1.1.6"), 1);
  staticRoutingD->AddHostRouteTo (Ipv4Address ("10.1.1.6"), Ipv4Address ("10.1.1.6"), 0);
   //N5->N2
  staticRoutingF->AddHostRouteTo (Ipv4Address ("10.1.1.3"), Ipv4Address ("10.1.1.5"), 1);
  staticRoutingE->AddHostRouteTo (Ipv4Address ("10.1.1.3"), Ipv4Address ("10.1.1.4"), 2);
  staticRoutingD->AddHostRouteTo (Ipv4Address ("10.1.1.3"), Ipv4Address ("10.1.1.3"), 1);
  staticRoutingC->AddHostRouteTo (Ipv4Address ("10.1.1.3"), Ipv4Address ("10.1.1.3"), 0);

......
wifi-my-0.cc

Tommaso Pecorella

unread,
Aug 27, 2014, 5:03:46 PM8/27/14
to ns-3-...@googlegroups.com, ww1324...@my.bristol.ac.uk
Hi,

  staticRoutingB->AddHostRouteTo (Ipv4Address ("10.1.1.4"), Ipv4Address ("10.1.1.3"), 2);

I don't see two interfaces in that node... I just see one. Am I missing something ?

T.

yuechengww

unread,
Aug 27, 2014, 6:07:58 PM8/27/14
to ns-3-...@googlegroups.com
Hi:
Thank you very much~It should be 1, not 2. 
However, since there are two tcp flows, when I run the codec, there is only one flow can tramsmit at a time.In other words, each flow transmit individually well, but two flows can not send together. By the way, I let their app start time to be different. Who knows why? Is it due to static routing?  

Wei Wang

unread,
Aug 27, 2014, 6:55:40 PM8/27/14
to Tommaso Pecorella, ns-3-...@googlegroups.com
Hi:
You are right, there is only one interface, so it should be 1, not 2, thank you very much!
However, when I run my code, there is always a tcp flow 1 (n0->n5) has throughput, another does not transmit, or vice versa. Most impoertant thing is that I traced the tcp congestion window and rtt, found that the tcp seems did not work!
Is due to the static routing? It is very strange~ 
Does anyone know why?

Many thanks~
ww
wifi-my-0.cc
Reply all
Reply to author
Forward
0 new messages