Routing Protocols in MANET

780 views
Skip to first unread message

Pavel Mašek

unread,
Nov 6, 2012, 4:05:40 PM11/6/12
to ns-3-...@googlegroups.com
Hello,

I am working on my project, in which I would like to edit some parameters of OLSR and AODV routing protocols. I created simple (10 mobile nodes) MANET network. When I am using AODV routing protocol (simply AodvHelper aodv and then stack.SetRoutingHelper(aodv) - see in code) for routing, then I get (in my opinion) correct output in console. Data in pcap file are also fine. (Link: http://www.2i.cz/f7876b4192)

But, when I am implementing OLSR routing protocol, then the output from console look like this http://www.2i.cz/c4b45872a1 . I don't know, why is in console output only one record (regarding ping).

My source code is here:

/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */

#include "ns3/core-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/network-module.h"
#include "ns3/applications-module.h"
#include "ns3/wifi-module.h"
#include "ns3/mobility-module.h"
#include "ns3/csma-module.h"
#include "ns3/internet-module.h"
#include "ns3/netanim-module.h"
#include "ns3/ipv4-global-routing-helper.h"
#include "ns3/olsr-helper.h"
#include "ns3/aodv-helper.h"
#include "ns3/dsdv-helper.h"
#include "ns3/dsr-helper.h"
#include <fstream>
#include <string>


using namespace ns3;


NS_LOG_COMPONENT_DEFINE ("ThirdScriptExample");

void CourseChange (std::string context, Ptr<const MobilityModel> model)
{
Vector position = model->GetPosition ();
NS_LOG_UNCOND (context <<
" x = " << position.x << ", y = " << position.y);
}

int 
main (int argc, char *argv[])
{
  bool verbose = true; 
  std::string animFile = "mymanet.xml"; 

  CommandLine cmd;
  cmd.AddValue ("verbose", "Jestli běží aplikace, tak povol logování.", verbose);
  cmd.Parse (argc,argv); 

 
  if (verbose)
    {
      LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
      LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);
    }

  NodeContainer wifiStaNodes;
  wifiStaNodes.Create (20);
  
  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
  phy.SetChannel (channel.Create ());

  WifiHelper wifi = WifiHelper::Default ();
  wifi.SetRemoteStationManager ("ns3::AarfWifiManager");


  QosWifiMacHelper mac = QosWifiMacHelper::Default();
  //NqosWifiMacHelper mac = NqosWifiMacHelper::Default();

  mac.SetType("ns3::AdhocWifiMac");


  NetDeviceContainer staDevices;
  staDevices = wifi.Install (phy, mac, wifiStaNodes); //zařízení je přiřazeno uzlu, s patřičnými phy a mac vlastnostmi.



  OlsrHelper olsr;
  //AodvHelper aodv;
  //DsdvHelper dsdv;


  MobilityHelper mobility;


  mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
                                 "MinX", DoubleValue (10.0),
                                 "MinY", DoubleValue (10.0),
                                 "DeltaX", DoubleValue (5.0),
                                 "DeltaY", DoubleValue (2.0),
                                 "GridWidth", UintegerValue (3),
                                 "LayoutType", StringValue ("RowFirst"));
  
  mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",
                             "Bounds", RectangleValue (Rectangle (-50, 50, -50, 50)));
  mobility.Install (wifiStaNodes);

  InternetStackHelper stack;
  stack.SetRoutingHelper(olsr);
  //stack.SetRoutingHelper(aodv);
  //stack.SetRoutingHelper(dsdv);
  stack.Install (wifiStaNodes);

  Ipv4AddressHelper address;
  address.SetBase ("10.1.3.0", "255.255.255.0");
  address.Assign (staDevices);

  Ipv4InterfaceContainer interface = address.Assign(staDevices);

  UdpEchoServerHelper echoServer (9);

  ApplicationContainer serverApps = echoServer.Install (wifiStaNodes.Get(0));
  serverApps.Start (Seconds (1.0));
  serverApps.Stop (Seconds (10.0));

  UdpEchoClientHelper echoClient (interface.GetAddress(0), 9); 
  //Můžu využít díky Ipv4InterfaceContainer.
  echoClient.SetAttribute ("MaxPackets", UintegerValue (2)); 
  echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.))); 
  echoClient.SetAttribute ("PacketSize", UintegerValue (1024)); //Velikost paketu

  ApplicationContainer clientApps = echoClient.Install (wifiStaNodes.Get (19));
  clientApps.Start (Seconds (4.0));
  clientApps.Stop (Seconds (10.0));

  AnimationInterface::SetNodeDescription (wifiStaNodes, "STA");
  AnimationInterface anim (animFile);
  anim.EnablePacketMetadata (true); //Povolí popis zasílaných zpráv

  Ipv4GlobalRoutingHelper::PopulateRoutingTables ();

  Simulator::Stop (Seconds (10.0));

  std::ostringstream oss;
  oss <<  "/NodeList/" << wifiStaNodes.Get (1)->GetId () <<
    "/$ns3::MobilityModel/CourseChange";
  Config::Connect (oss.str (), MakeCallback (&CourseChange));

  phy.EnablePcap("manet",staDevices.Get(19),true);

  Simulator::Run ();
  Simulator::Destroy ();
  return 0;
}



Konstantinos

unread,
Nov 6, 2012, 5:34:05 PM11/6/12
to ns-3-...@googlegroups.com
For OLSR you have to give some time to calculate the routing tables.
That depends on the size of the network and the frequency of HELLO.
AODV does not have such issues since it is re-active protocol.

So, try the ping after some time (e.g. 20-30sec)

Pavel Mašek

unread,
Nov 7, 2012, 1:14:45 AM11/7/12
to ns-3-...@googlegroups.com
Hi,

I change the simulation time on 180s. The client application start in 150s, but the console output still show only message: At time 150s client sent 1024 bytes to 10.1.3.1 port 9.

Dne úterý, 6. listopadu 2012 23:34:05 UTC+1 Konstantinos napsal(a):

Konstantinos

unread,
Nov 7, 2012, 7:48:31 AM11/7/12
to ns-3-...@googlegroups.com
I guess that the problem you have is related to the HELLO packets of OLSR.
If you try to print the routing table of OLSR

  Ptr<OutputStreamWrapper> routingStream = Create<OutputStreamWrapper> ("test", std::ios::out);
  olsr.PrintRoutingTableAllEvery (Seconds (2), routingStream);

you will see that they are empty. That suggests that NO hello is received. Try to change the prop. model you have or trace it down to that.

Pavel Mašek

unread,
Nov 7, 2012, 8:28:03 AM11/7/12
to ns-3-...@googlegroups.com
Thank you for your answer,

I switched olsr to aodv routing protocol and then I use your proposed command to verify the routing table. For AODV it is correct - that is OK.

Because I'm a beginner in NS3, could you tell me, what do you mean with: change the prop. model?




Dne středa, 7. listopadu 2012 13:48:31 UTC+1 Konstantinos napsal(a):

Konstantinos

unread,
Nov 7, 2012, 9:18:48 AM11/7/12
to ns-3-...@googlegroups.com
could be that the propagation loss model that you use (the default in your case) with other model.
One possible answer to your problem is that the HELLO messages collide, therefore the nodes don't "see" each other.

You don't have such problems with AODV because it is re-active and does not broadcast HELLOs (almost) simultaneously. There should be some randomization in the broadcast of HELLO, but it seems that you don't have that. Try to log the OLSR routing protocol and see the timings of these broadcasts.
Message has been deleted

Pavel Mašek

unread,
Nov 7, 2012, 12:29:02 PM11/7/12
to ns-3-...@googlegroups.com
Hi,

you have right. I used the command NS_LOG=OlsrRoutingProtocol ./waf --run my-code and in log file it is see TcTimerExpire and HnaTimerExpire. The log file is here: https://skydrive.live.com/redir?resid=1942BA723D63F882!19060&authkey=!APg4FfFlnP9bfn8

Unfortunately I don't know, how fix it. 

Dne středa, 7. listopadu 2012 15:18:48 UTC+1 Konstantinos napsal(a):

Pavel Mašek

unread,
Nov 11, 2012, 8:25:09 AM11/11/12
to ns-3-...@googlegroups.com
Here is one interesting thing. When I use DSDV routing protocol, which is pro-active (as well as OLSR), then the simulation is running. The routing tables are filled corect.

Dne středa, 7. listopadu 2012 18:29:02 UTC+1 Pavel Mašek napsal(a):

Faiza Firdousi

unread,
Aug 10, 2017, 2:51:14 AM8/10/17
to ns-3-users
I can't seem to bulid your code. Any idea why im getting an error?? Help is much appreciated. Thanks.

Konstantinos

unread,
Aug 10, 2017, 10:55:14 AM8/10/17
to ns-3-users
Simply because it is 5 years old and the scenario is not compatible (without some modifications) with the current ns-3 release you are using.

Faiza Firdousi

unread,
Oct 5, 2017, 3:25:47 AM10/5/17
to ns-3-...@googlegroups.com
Hey I did figure out how to run the code about which I posted the question earlier. And thanks for your response. I couldn't read your answer before because it got sent to my spam box somehow. Anyways can you please help me with the question that I posted. This is the link to my question:
Actually I really need some help in understanding some concepts. I don't have any guidance for ns3 except this group, and no one is bothered to answer my question in this group. I don't know what I'm doing wrong. Hope that this mail won't go unanswered. 
Regards...

--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/m0Ywxx5GGcc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+unsubscribe@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at https://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.

Faiza Firdousi

unread,
Oct 8, 2017, 11:31:49 AM10/8/17
to ns-3-users
Hey can anyone help me to figure out where am I going wrong?? The code is posted below:

#include "ns3/aodv-module.h"
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/internet-module.h"
#include "ns3/mobility-module.h"
#include "ns3/wifi-module.h" 
#include "ns3/v4ping-helper.h"
#include "ns3/netanim-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/applications-module.h"
#include "ns3/csma-module.h"
#include <iostream>
#include <cmath>

using namespace ns3;

NS_LOG_COMPONENT_DEFINE ("ModifiedAodv");

int
main (int argc, char *argv[])
{
  CommandLine cmd;
  cmd.Parse (argc, argv);
  
  Time::SetResolution (Time::NS);
  LogComponentEnable ("ModifiedAodv", LOG_LEVEL_INFO);

  SeedManager::SetSeed (12345);

  Config::SetDefault("ns3::RangePropagationLossModel::MaxRange",StringValue("15"));

  NodeContainer nodes;
  nodes.Create(4);

  // Name nodes
  for (uint32_t i = 0; i < 4; ++i)
    {
      std::ostringstream os;
      os << "node-" << i;
      Names::Add (os.str (), nodes.Get (i));
    }

  //mobility model

  WifiMacHelper wifiMac;
  wifiMac.SetType ("ns3::AdhocWifiMac");
  YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
 
  YansWifiChannelHelper wifiChannel;
  wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
  wifiChannel.AddPropagationLoss ("ns3::RangePropagationLossModel");
  
  wifiPhy.SetChannel (wifiChannel.Create ());

  WifiHelper wifi;
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue ("OfdmRate6Mbps"), "RtsCtsThreshold", UintegerValue (0));
  NetDeviceContainer devices;
  devices = wifi.Install (wifiPhy, wifiMac, nodes); 
  
  AodvHelper aodv;
  InternetStackHelper stack;
  stack.SetRoutingHelper (aodv); // has effect on the next Install ()
  stack.Install (nodes);
  Ipv4AddressHelper address;
  address.SetBase ("10.0.0.0", "255.0.0.0");
  Ipv4InterfaceContainer interfaces;
  interfaces = address.Assign (devices);

  Ptr<OutputStreamWrapper> routingStream = Create<OutputStreamWrapper> ("mod-aodv.routes", std::ios::out);
  aodv.PrintRoutingTableAllAt (Seconds (10), routingStream);

  //applications
  UdpEchoServerHelper echoServer (9);

  ApplicationContainer serverApps = echoServer.Install (nodes.Get (0));
  serverApps.Start (Seconds (1.0));
  serverApps.Stop (Seconds (10.0));

  UdpEchoClientHelper echoClient (interfaces.GetAddress (0), 9);
  echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
  echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
  echoClient.SetAttribute ("PacketSize", UintegerValue (1024));

  ApplicationContainer clientApps = echoClient.Install (nodes.Get (3));
  clientApps.Start (Seconds (2.0));
  clientApps.Stop (Seconds (10.0));


  Simulator::Stop (Seconds (30));
  Simulator::Run ();
  Simulator::Destroy ();
  return 0;
}

Please please someone help me. I literally done have a single person to help me. Please experts read and run my code once please!!

Konstantinos

unread,
Oct 8, 2017, 4:50:00 PM10/8/17
to ns-3-users
Hi, 

Please follow the posting guidelines. You should do your 'homework' first, and then ask for specific question.

You haven't specified what the issue with it?
Is it a compilation error? A run time error?
Do you get an error message? 

Regards
K

Faiza Firdousi

unread,
Oct 9, 2017, 2:49:19 AM10/9/17
to ns-3-...@googlegroups.com
Hey. This is not my homework. I wrote the whole code myself. And according to me there should not be any errors in it. that's why I am surprised as to why its not working. waf says build finished successfully but after that it just gives error in red "Terminated with signal SIGSEGV", and that's it. I understand I haven't used the logging functionality, probably that's why its not showing what is causing the program to terminate. But I wanna know what's wrong with it before going into learning how to put logging in it. If you could just go through the code once and see if you could spot any errors or maybe run it, it would mean so much to me. I literally don't have a single person around me who knows ns-3, that's why I look so desperately for help in this group. I don't know where I'm going wrong and I've literally done ALL the homework I can. 

--

Konstantinos

unread,
Oct 9, 2017, 4:10:31 AM10/9/17
to ns-3-users
Hi,

When I refer to homework, do not take it literary. 
It is what is pointed out in the posting guidelines here https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting#Do_your_homework
Before the SIGSEGV, there is possibly another error message. If not, you should use a debugger to identify the point of failure. 

Regards
K
Reply all
Reply to author
Forward
0 new messages