,

BonnMotion - A mobile scenario Generator Tool

BonnMotion is a tool that generates scenario for ns2, ns3, qualnet, etc. This will comfortably work with Linux. And in windows, there could be some bugs.

Please refer the documentation here: http://sys.cs.uos.de/bonnmotion/doc/BonnMotion_Docu.pdf

To use this tool for ns2, here are the steps.
Step1 : Download the BonnMotion tool from this website
Step 2: Unzip it to home folder (/home/pradeepkumar in my case)
step 3: Here are the commands to install
$] unzip -d bonnmotion-2.1.3.zip
$] cd bonnmotion-2.1.3/
$] ./install 
The above command will install, if any packages are missing for dependencies, please install it.

$] Once installed, copy the bonnmotion-2.1.3/bin/bm file to /usr/bin/ for running it anywhere. if not go to bin folder using the command given below

$] cd bonnmotion-2.1.3/bin/

To run BonnMotion
$bonnmotion-2.1.3/bin] ./bm -hm 
(this will list all the models)

$bonnmotion-2.1.3/bin] ./bm -hm RandomWaypoint
Will display all the parameters for RandomWaypoint like number of nodes, x, y, random seed, etc.

Assuming RandomWaypoint is the model

$bonnmotion-2.1.3/bin] ./bm -f scenario RandomWaypoint -n 10 -x 500 -y 500
The above command will create a file called scenario with 10 number of nodes with x and y as 500x500)

$bonnmotion-2.1.3/bin]  ./bm NSFile -f scenario
This will create two files called scenario.ns_movements, scenario.ns_params


The above two files can be used inside tcl script for ns2 using the source command

source scenario.ns_params
source scenario.ns_movements



(NB: Please note that the above two files represents nodes like $node_(0), etc and $ns_ as simulator object, either you change these variables within your tcl file or edit the above two files.  Also scenario.ns_params file shows the stop script as set val(duration) 600.0, but most of the tcl scripts may have val(stop), so change it to val(duration) in all cases) 


The same will be applied to other simulators also, refer the documentation given in the beginning of the slide.

Some screenshots for you.:

Bonnmotion
Installing Bonnmotion

Bonnmotion
bm command with options

Bonnmotion
A Sample Tcl file using the script generated by BonnMotion

Download the sample files here: put all the files in a single folder and run the tcl file using
$] ns ex.tcl

Provide your comments below, if you need any queries.

Credits to:  http://sys.cs.uos.de/bonnmotion/index.shtml


 T S Pradeep Kumar
,

Link State Routing in NS3 - Wired Network

Link state routing in ns3

There are two varieties of protocols that deals with wired networks namely distance vector routing and link state routing, 

As per the wikipedia, Distance-vector routing protocols, which work by having each node share its routing table with its neighbours, in a link-state protocol the only information passed between nodes is connectivity related. Link-state algorithms are sometimes characterized informally as each router, "telling the world about its neighbors.

This exercise can be one of the lab exercises of many universities in India. There are many more exercises to follow. If one understand this video, they can able to simulate any network design and run it successfully in ns3.

In this blog post, I am not going to explain the concepts of link state routing, but will explain how to configure the nodes to use link state routing in ns3. 

Please find the video for the source code explanation and compilation in ns3 on link state routing protocol



Here is the step to run the LSR and compile it to get the details.

Scenario is
LinkStateRouting
Link State Routing (LSR)



Here is the source code from GITHUB https://github.com/tspradeepkumar/ns3

else you can copy from here:

//Link state routing for Wired Networks, OLSR 
#include <iostream>
#include <fstream>
#include <string>
#include <cassert>

#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/internet-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/applications-module.h"
#include "ns3/olsr-helper.h"
#include "ns3/ipv4-static-routing-helper.h"
#include "ns3/ipv4-list-routing-helper.h"

#include "ns3/netanim-module.h"

using namespace ns3;

NS_LOG_COMPONENT_DEFINE ("SimplePointToPointOlsrExample");

int
main (int argc, char *argv[])
{
  Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (210));
  Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("448kb/s"));

  CommandLine cmd;
  cmd.Parse (argc, argv);

  NS_LOG_INFO ("Create nodes.");
  NodeContainer c;
  c.Create (5);
  NodeContainer n01 = NodeContainer (c.Get (0), c.Get (1));
  NodeContainer n14 = NodeContainer (c.Get (1), c.Get (4));
  NodeContainer n43 = NodeContainer (c.Get (4), c.Get (3));
  NodeContainer n30 = NodeContainer (c.Get (3), c.Get (0));
  NodeContainer n02 = NodeContainer (c.Get (0), c.Get (2));
  NodeContainer n23 = NodeContainer (c.Get (2), c.Get (3));
    
  // Enable OLSR
  NS_LOG_INFO ("Enabling OLSR Routing.");
  OlsrHelper olsr;

  Ipv4StaticRoutingHelper staticRouting;

  Ipv4ListRoutingHelper list;
  list.Add (staticRouting, 0);
  list.Add (olsr, 10);

  InternetStackHelper internet;
  internet.SetRoutingHelper (list); // has effect on the next Install ()
  internet.Install (c);

  // We create the channels first without any IP addressing information
  NS_LOG_INFO ("Create channels.");
  PointToPointHelper p2p;
  
  p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps"));
  p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
  NetDeviceContainer nd01 = p2p.Install (n01);
  
  p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
  p2p.SetChannelAttribute ("Delay", StringValue ("10ms"));
  NetDeviceContainer nd14 = p2p.Install (n14);
  
  p2p.SetDeviceAttribute ("DataRate", StringValue ("50Mbps"));
  p2p.SetChannelAttribute ("Delay", StringValue ("50ms"));
  NetDeviceContainer nd43 = p2p.Install (n43);
  
  p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
  p2p.SetChannelAttribute ("Delay", StringValue ("5ms"));
  NetDeviceContainer nd30 = p2p.Install (n30);
  
  p2p.SetDeviceAttribute ("DataRate", StringValue ("1Mbps"));
  p2p.SetChannelAttribute ("Delay", StringValue ("1ms"));
  NetDeviceContainer nd02 = p2p.Install (n02);
  
  p2p.SetDeviceAttribute ("DataRate", StringValue ("2Mbps"));
  p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
  NetDeviceContainer nd23 = p2p.Install (n23);

  // Later, we add IP addresses.
  NS_LOG_INFO ("Assign IP Addresses.");
  Ipv4AddressHelper ipv4;
  ipv4.SetBase ("10.1.1.0", "255.255.255.0");
  Ipv4InterfaceContainer i01 = ipv4.Assign (nd01);

  ipv4.SetBase ("10.1.2.0", "255.255.255.0");
  Ipv4InterfaceContainer i14 = ipv4.Assign (nd14);

  ipv4.SetBase ("10.1.3.0", "255.255.255.0");
  Ipv4InterfaceContainer i43 = ipv4.Assign (nd43);

  ipv4.SetBase ("10.1.4.0", "255.255.255.0");
  Ipv4InterfaceContainer i30 = ipv4.Assign (nd30);

  ipv4.SetBase ("10.1.5.0", "255.255.255.0");
  Ipv4InterfaceContainer i02 = ipv4.Assign (nd02);
    
  ipv4.SetBase ("10.1.6.0", "255.255.255.0");
  Ipv4InterfaceContainer i23 = ipv4.Assign (nd23);
  
  // Create the OnOff application to send UDP datagrams of size
  // 210 bytes at a rate of 448 Kb/s
  
  NS_LOG_INFO ("Create Applications.");
  uint16_t port = 8000;   // Discard port (RFC 863)

  OnOffHelper onoff1 ("ns3::UdpSocketFactory",
                     InetSocketAddress (i02.GetAddress (1), port));
  onoff1.SetConstantRate (DataRate ("448kb/s"));

  ApplicationContainer onOffApp1 = onoff1.Install (c.Get (1));
  onOffApp1.Start (Seconds (10.0));
  onOffApp1.Stop (Seconds (20.0));

  // Create packet sinks to receive these packets
  PacketSinkHelper sink ("ns3::UdpSocketFactory",
                         InetSocketAddress (Ipv4Address::GetAny (), port));
  NodeContainer sinks = NodeContainer (c.Get (2), c.Get (1));
  ApplicationContainer sinkApps = sink.Install (sinks);
  sinkApps.Start (Seconds (0.0));
  sinkApps.Stop (Seconds (21.0));

  AsciiTraceHelper ascii;
  p2p.EnableAsciiAll (ascii.CreateFileStream ("lsr.tr"));
  p2p.EnablePcapAll ("lsr");

AnimationInterface anim("lsr.xml");
anim.SetConstantPosition(c.Get(0),0.0,50.0);
anim.SetConstantPosition(c.Get(1),50.0,100.0);
anim.SetConstantPosition(c.Get(2),50.0,50.0);
anim.SetConstantPosition(c.Get(3),50.0,0.0);
anim.SetConstantPosition(c.Get(4),100.0,50.0);

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

  return 0;
}

How to Run this file in ns3
This file LinkStateRouting.cc have to be stored in ns-3.29/scratch folder
open a terminal 

$ cd ns-allinone-3.29/ns-3.29/
$ ./waf --run scratch/LinkStaterouting

To run network animation

Open a new terminal 

$] cd ns-allinone-3.29/netanim-3.108/
$] ./NetAnim

The output is shown like this
LinkStateRouting
Link State Routing


Tracemetrics 
Open a new Terminal

$] cd tracemetrics-1.4.0/
$] java -jar tracemetrics.jar