Skip to main content

Installing ns-3.37 and ns-3.35 in Ubuntu | Ubuntu 22.04 | NS3

Multiple Versions of ns3 in Ubuntu 22.04 In this post, we are going to install two versions of ns3 namely ns-3.35 and ns-3.37  My OS is : Ubuntu 22.04 LTS (Long Term Support) ns-3.35 uses waf and (./waf --run scratch/first)  ns-3.37 uses cmake  (./ns3 run scratch/first.cc) So we will install both the packages  Go through the video for complete instructions To start with  $ sudo apt update  $ sudo apt install build-essential autoconf automake libxmu-dev g++ python3 python3-dev pkg-config sqlite3 cmake python3-setuptools git qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools gir1.2-goocanvas-2.0 python3-gi python3-gi-cairo python3-pygraphviz gir1.2-gtk-3.0 ipython3 openmpi-bin openmpi-common openmpi-doc libopenmpi-dev autoconf cvs bzr unrar gsl-bin libgsl-dev libgslcblas0 wireshark tcpdump sqlite sqlite3 libsqlite3-dev  libxml2 libxml2-dev libc6-dev libc6-dev-i386 libclang-dev llvm-dev automake python3-pip libxml2 libxml2-dev libboost-all-dev  I have downloaded both the versions of ns3 fr

OLSR protocol in NS-2.35 (ns2)

OLSR protocol is called as Optimized link State routing protocol and is defined by http://tools.ietf.org/html/draft-ietf-manet-olsr-03
The OLSR is available as a patch for ns2 for various versions. There is a new version UM-OLSR patch in the given link below.

OS Used: Linux Mint 14 and Ubuntu 12.10

The following files are modified in ns-2.35 for OLSR
~ns-2.35/Makefile.in
~ns-2.35/common/packet.h
~ns-2.35/queue/priqueue.cc
~ns-2.35/tcl/lib/ns-agent.tcl
~ns-2.35/tcl/lib/ns-default.tcl
~ns-2.35/tcl/lib/ns-lib.tcl
~ns-2.35/tcl/lib/ns-packet.tcl
~ns-2.35/trace/cmu-trace.cc
~ns-2.35/trace/cmu-trace.h

Download the OLSR File here (the original OLSR may contain some bug, so download from this location for bug free OLSR Code)
Copy the file from ns-modified files/ to the corresponding location

Ensure that you have a fresh installation of ns-2.35 (else pasting these files will overwrite the information what you have earlier)

The zip file also has a patch file that can be patched for various ns2 versions. if you encounter any errors, go for manual patching.

You can also see: SUMO and MOVE Installation for VANETs

OLSR Installation

Once all the files were copied to their location. Open the terminal and go to the ~ns-2.35/ folder and execute the commands one by one.

./configure
make

Thats it, the code gets recompiled and download this source code to test the OLSR protocol
here is the code
# ======================================================================
# Define options
# ======================================================================
set opt(chan) Channel/WirelessChannel ;# channel type
set opt(prop) Propagation/TwoRayGround ;# radio-propagation model
set opt(netif) Phy/WirelessPhy ;# network interface type
set opt(mac) Mac/802_11 ;# MAC type
set opt(ifq) Queue/DropTail/PriQueue ;# interface queue type
set opt(ll) LL ;# link layer type
set opt(ant) Antenna/OmniAntenna ;# antenna model
set opt(ifqlen) 50 ;# max packet in ifq
set opt(nn) 5 ;# number of mobilenodes
set opt(adhocRouting) OLSR ;# routing protocol
set opt(cp) "" ;# connection pattern file
set opt(sc) "" ;# node movement file.
set opt(x) 400 ;#
set opt(y) 600 ;#
set opt(seed) 0.0 ;#
set opt(stop) 45 ;#
set opt(cbr-start) 30.0
# ============================================================================
#
# check for random seed
#
if {$opt(seed) > 0} {
puts "Seeding Random number generator with $opt(seed)\n"
ns-random $opt(seed)
}
#
# create simulator instance
#
set ns_ [new Simulator]
#
# control OLSR behaviour from this script -
# commented lines are not needed because
# those are default values
#
Agent/OLSR set use_mac_ true
#Agent/OLSR set debug_ false
#Agent/OLSR set willingness 3
#Agent/OLSR set hello_ival_ 2
#Agent/OLSR set tc_ival_ 5
#
# open traces
#
set tracefd [open olsr_example.tr w]
set namtrace [open olsr_example.nam w]
$ns_ trace-all $tracefd
$ns_ namtrace-all-wireless $namtrace $opt(x) $opt(y)
#
# create topography object
set topo [new Topography]
#
# define topology
#
$topo load_flatgrid $opt(x) $opt(y)
#
# create God
#
create-god $opt(nn)

set chan_1_ [new $opt(chan)]

#
# configure mobile nodes
#
$ns_ node-config -adhocRouting $opt(adhocRouting) \
-llType $opt(ll) \
-macType $opt(mac) \
-ifqType $opt(ifq) \
-ifqLen $opt(ifqlen) \
-antType $opt(ant) \
-propType $opt(prop) \
-phyType $opt(netif) \
-channel $chan_1_ \
-topoInstance $topo \
-wiredRouting OFF \
-agentTrace ON \
-routerTrace ON \
-macTrace OFF
for {set i 0} {$i < $opt(nn)} {incr i} {
set node_($i) [$ns_ node]
}

#
# define initial node position in nam
#
for {set i 0} {$i < $opt(nn)} {incr i} {
$ns_ initial_node_pos $node_($i) 20
}

#
# positions
#
$node_(0) set X_ 350.0
$node_(0) set Y_ 200.0
$node_(1) set Z_ 0.0
$node_(0) set Z_ 0.0
$node_(1) set X_ 200.0
$node_(1) set Y_ 350.0
$node_(2) set X_ 200.0
$node_(2) set Y_ 550.0
$node_(2) set Z_ 0.0
$node_(3) set X_ 50.0
$node_(3) set Y_ 200.0
$node_(3) set Z_ 0.0
$node_(4) set X_ 200.0
$node_(4) set Y_ 50.0
$node_(4) set Z_ 0.0
#
# setup UDP connection
set udp [new Agent/UDP]
set null [new Agent/Null]
$ns_ attach-agent $node_(0) $udp
$ns_ attach-agent $node_(2) $null
$ns_ connect $udp $null
set cbr [new Application/Traffic/CBR]
$cbr set packetSize_ 512
$cbr set rate_ 20Kb
$cbr attach-agent $udp
$ns_ at $opt(cbr-start) "$cbr start"
#
# print (in the trace file) routing table and other
# internal data structures on a per-node basis
#

$ns_ at 10.0 "[$node_(0) agent 255] print_rtable"
$ns_ at 15.0 "[$node_(0) agent 255] print_linkset"
$ns_ at 20.0 "[$node_(0) agent 255] print_nbset"
$ns_ at 25.0 "[$node_(0) agent 255] print_nb2hopset"
$ns_ at 30.0 "[$node_(0) agent 255] print_mprset"
$ns_ at 35.0 "[$node_(0) agent 255] print_mprselset"
$ns_ at 40.0 "[$node_(0) agent 255] print_topologyset"
#
# source connection-pattern and node-movement scripts
#
if { $opt(cp) == "" } {
puts "*** NOTE: no connection pattern specified."
set opt(cp) "none"
} else {
puts "Loading connection pattern..."
source $opt(cp)
}
if { $opt(sc) == "" } {
puts "*** NOTE: no scenario file specified."
set opt(sc) "none"
} else {
puts "Loading scenario file..."
source $opt(sc)
puts "Load complete..."
}
#
# tell all nodes when the simulation ends
#
for {set i 0} {$i < $opt(nn) } {incr i} {
$ns_ at $opt(stop) "$node_($i) reset";
}
$ns_ at $opt(stop) "puts \"NS EXITING...\" ; $ns_ halt"
$ns_ at $opt(stop) "stop"

proc stop {} {
global ns_ tracefd namtrace
$ns_ flush-trace
close $tracefd
close $namtrace
}
puts "Starting Simulation..."
$ns_ run

The above code tells the protocol to print the routing table, neighbour list, etc to the trace file. So open the trace file and see the routing table printing as various times 10.0, 15.0, 20.0, etc
Here is the sample output for the node 1 with various printing.
Screenshot
OLSR
OLSR Trace

P 10.000000 _1_ Routing Table
P dest next iface dist
P 0 0 1 1
P 2 2 1 1
P 3 3 1 1
P 4 3 1 2


P 15.000000 _1_ Link Set
P local nb sym asym lost time
P 1 0 20.563653 20.563653 0.000000 26.563653
P 1 2 20.457948 20.457948 0.000000 26.457948
P 1 3 20.511131 20.511131 0.000000 26.511131

P 20.000000 _1_ Neighbor Set
P nb status willingness
P 0 1 3
P 2 1 3
P 3 1 3

P 25.000000 _1_ Neighbor2hop Set
P nb nb2hop time
P 0 4 29.878606
P 3 4 30.756880

P 30.000000 _1_ MPR Set
P nb
P 0

P 35.000000 _1_ MPR Selector Set
P nb time
P 0 40.819322
P 2 39.935872
P 3 39.741881

P 40.000000 _1_ Topology Set
P dest last seq time
P 1 0 1 54.025467
P 4 0 1 54.025467

This shows the successful installation of OLSR in ns-2.35.  Comment on if you have any other queries.

Comments

  1. sir please help me in installing OSLR in ns-2.35 even though i tried what u said it doesn't work to me please kindly mail me more details sir my email is bharath.aor@gmail.com

    ReplyDelete
    Replies
    1. PLEASE HELP ME THE SAME PROBLEM IS HAPPEN TO ME

      Delete
    2. https://drive.google.com/file/d/1W4Q5_H04CHcEBKOw8l18iZmQ9fUa1c8b/view?usp=sharing

      Delete
  2. Sir I tired you method but it showing me problem on ns 2.34 and ns 2.35.
    some for loop problem

    can't read "node_(0)": no such variable
    while executing
    "$ns_ initial_node_pos $node_($i) 20"
    ("for" body line 2)
    invoked from within
    "for {set i 0} {$i < $opt(nn)} {incr i} {
    $ns_ initial_node_pos $node_($i) 20
    }"
    (file "2.tcl" line 88)

    ReplyDelete
  3. hello sir
    I'm not able to download the olsr code and the program written here has some errors could you please share the program

    ReplyDelete
  4. Sir I tired you method but it showing me problem on ns 2.34
    i cant installing olsr so please help me

    ReplyDelete
  5. Replies
    1. Download here.
      https://drive.google.com/file/d/1W4Q5_H04CHcEBKOw8l18iZmQ9fUa1c8b/view?usp=sharing

      Delete
  6. Hello Sir,
    I'm getting a Segmentation fault (core dumped) while running the .tcl file.
    Where could have I gone wrong?
    Please Help! Thank You.
    num_nodes is set 5
    INITIALIZE THE LIST xListHead
    *** NOTE: no connection pattern specified.
    *** NOTE: no scenario file specified.
    Starting Simulation...
    Segmentation fault (core dumped)

    ReplyDelete
  7. can you Make video explain the installation of OLSR Protocol IN ns2.35

    ReplyDelete

Post a Comment

Popular posts from this blog

Installation of NS2 (ns-2.35) in Ubuntu 20.04

Installation of NS2 (ns-2.35) in Ubuntu 20.04 LTS Step 1: Install the basic libraries like      $] sudo apt install build-essential autoconf automake libxmu-dev Step 2: install gcc-4.8 and g++-4.8 open the file using sudo mode $] sudo nano /etc/apt/sources.list Include the following line deb http://in.archive.ubuntu.com/ubuntu bionic main universe $] sudo apt update $] sudo apt install gcc-4.8 g++-4.8 Step 3:  Unzip the ns2 packages to home folder $] tar zxvf ns-allinone-2.35.tar.gz $] cd ns-allinone-2.35/ns-2.35 Modify the following make files. ~ns-2.35/Makefile.in Change @CC@ to gcc-4.8 change @CXX@ to g++-4.8 ~nam-1.15/Makefile.in ~xgraph-12.2/Makefile.in ~otcl-1.14/Makefile.in Change in all places  @CC@ to gcc-4.8 @CPP@ or @CXX@ to g++-4.8 open the file: ~ns-2.35/linkstate/ls.h Change at the Line no 137  void eraseAll() { erase(baseMap::begin(), baseMap::end()); } to This void eraseAll() { this->erase(baseMap::begin(), baseMap::end()); } All changes made Step 4: Open a new termi

Installing ns3 in Ubuntu 22.04 | Complete Instructions

In this post, we are going to see how to install ns-3.36.1 in Ubuntu 22.04. You can follow the video for complete details Tools used in this simulation: NS3 version ns-3.36.1  OS Used: Ubuntu 22.04 LTS Installation of NS3 (ns-3.36.1) There are some changes in the ns3 installation procedure and the dependencies. So open a terminal and issue the following commands Step 1:  Prerequisites $ sudo apt update In the following packages, all the required dependencies are taken care and you can install all these packages for the complete use of ns3. $ sudo apt install g++ python3 python3-dev pkg-config sqlite3 cmake python3-setuptools git qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools gir1.2-goocanvas-2.0 python3-gi python3-gi-cairo python3-pygraphviz gir1.2-gtk-3.0 ipython3 openmpi-bin openmpi-common openmpi-doc libopenmpi-dev autoconf cvs bzr unrar gsl-bin libgsl-dev libgslcblas0 wireshark tcpdump sqlite sqlite3 libsqlite3-dev  libxml2 libxml2-dev libc6-dev libc6-dev-i386 libclang-dev llvm-

VPL Jail Server Installation | Virtual Programming Laboratory with Moodle

Virtual Programming Laboratory (VPL)  This post tells you how to install VPL Jail Server Installation in Ubuntu 20.04 and how to configure it using Moodle Learning Management System. VPL - Virtual Programming Laboratory  For full installation with complete description, follow the video What is VPL? VPL is Virtual Programming Laboratory which is a tool for programming assignments, evaluation and running of programs. The programming languages supported by VPL is C, C++, Java, Python, Perl, PHP, NodeJS, Verilog, etc. Step 1 - Install  VPN Jail Server Installation  My Server configuration  16GB RAM and 16 Core PRocessor (Intel Xeon)  Virtual Machine  Ubuntu 20.04 (64 bit OS). To download the softwares  https://vpl.dis.ulpgc.es/index.php/home/download  Unzip or untar the above file in the home folder (in my case it is /home/tspradeepkumar/ ) $ cd vpl-jail-system-2.7.2/ $ sudo ./install-vpl-sh VPL Jail Server Installation This will take some time based on your internet connection: To Star