Issues in Blackhole attack and installation in ns2 simulator

199 views
Skip to first unread message

Harshit Bishnoi

unread,
Mar 18, 2018, 4:49:06 PM3/18/18
to Network Simulator 2 (NS2)
Hello,

I am trying to implement blackhole attack in ns2 simulator. I am facing several issues.

I have installed ns2 from this tutorial :  https://www.youtube.com/watch?v=4Dh7MubQ_5Q

When I am trying to run the code for blackhole attack I am facing this issue. Code for blackhole is attached in the file.

-------------------------------------------------------------------------------------------------------------------------------
harshit@harshit
-HP-Pavilion-Notebook:~/Downloads$ ns blackhole.tcl
num_nodes
is set 25
INITIALIZE THE LIST xListHead
ns
: _o171 blackhole:
   
(_o171 cmd line 1)
    invoked
from within
"_o171 cmd blackhole"
    invoked
from within
"catch "$self cmd $args" ret"
    invoked
from within
"if [catch "$self cmd $args" ret] {
set cls [$self info class]
global errorInfo
set savedInfo $errorInfo
error "
error when calling class $cls: $args" $..."
   
(procedure "_o171" line 2)
   
(SplitObject unknown line 2)
    invoked
from within
"_o171 blackhole"
harshit@harshit
-HP-Pavilion-Notebook:~/Downloads$
-------------------------------------------------------------------------------------------------------------------------------------


When I tried it installing the tar file setup for ns2, it gave me this error in installation
------------------------------------------------------------------------------------------------------------------------------------
checking
for libtk8.5... -L../lib -ltk8.5
checking
for tk.tcl... ../lib/tk8.5
checking
for X11 header files
can
't find X includes
otcl-1.14 configuration failed! Exiting ...
Please check http://www.isi.edu/nsnam/ns/ns-problems.html
for common problems and bug fixes.
--------------------------------------------------------------------------------------------------------------------------------------


Can anyone help me with out with this, it's urgent.
blackhole.tcl

knudfl

unread,
Mar 18, 2018, 5:46:21 PM3/18/18
to Network Simulator 2 (NS2)
Hi.

The usual ....
Fedora, CentOS:
# yum install gcc-c++ autoconf automake libtool libXmu-devel
Xgraph https://drive.google.com/file/d/0B7S255p3kFXNZXdGclBSZXcxS0k/view?usp=sharing
Download, and install:
# cd Downloads/ && yum install ./xgraph-12.1-1.pclos2013.x86_64.rpm

Debian, Ubuntu:
$ sudo apt install g
++ autoconf libtool libxmu-dev xgraph

Build ns-2.35 + blackholeAODV:
tar xvf ns-allinone-2.35_gcc5.tar.gz   // 2014 - 2017 update
https
://drive.google.com/file/d/0B7S255p3kFXNVVlxR0ZNRGVORjQ/view?usp=sharing
cd ns
-allinone-2.35/
patch
-p0 < blackholeaodv2013-ns235_1.patch
https
://drive.google.com/file/d/0B7S255p3kFXNWWVDZzd2ZC14akE/view?usp=sharing
./install          // gcc, g++ must be g++-5.x or earlier
cd ns
-2.35/
cp ns ns
-blackhole
sudo cp ns
-blackhole /usr/local/bin/
cd
../nam-1.15/
sudo make install

--------------------- Simulation -------------
ns-blackhole blackhole20-1.tcl
Etc. etc. examples from "blackholeaodv2005~2013-examples-05.17.tar.gz"
https://drive.google.com/file/d/0B7S255p3kFXNTUlreWIzVGxUXzQ/view?usp=sharing

All ~2500 ns2 examples
https://drive.google.com/drive/folders/0B7S255p3kFXNSmRYb2lGcDRUdWs?usp=sharing

All ~300 patches
https://drive.google.com/drive/folders/0B7S255p3kFXNZ2lWZDBRSW40Q00?usp=sharing

knudfl

unread,
Mar 18, 2018, 6:17:35 PM3/18/18
to Network Simulator 2 (NS2)
P.S. :    Your "blackhole.tcl" doesn't work with the well known versions of  "blackholeAODV".

The video :  No blackholeAODV is added, or mentioned at all.


knudfl

unread,
Mar 18, 2018, 6:37:50 PM3/18/18
to Network Simulator 2 (NS2)
PPS :   Found the origin of your file "blackhole.tcl -- jgyan.com" :
http://www.jgyan.com/ns2/blackhole%20attack%20simulation%20in%20ns2.php
( For ns-2.34 ).

Harshit Bishnoi

unread,
Mar 20, 2018, 1:07:30 PM3/20/18
to Network Simulator 2 (NS2)
Sir , we are trying to install ns2 in ubuntu 17.10 in which gcc ,g++ version is higher then 5.x and it shows following error while installing older version after removing the new one
E: Unable to locate package g++-4.4.7
E: Couldn't find any package by glob 'g++-4.4.7'
E: Couldn't find any package by regex 'g++-4.4.7'
 Kindly help us with the above problem.
Message has been deleted

knudfl

unread,
Mar 20, 2018, 3:00:11 PM3/20/18
to Network Simulator 2 (NS2)
@Harshit Bishnoi ,  Hi.

»» Unable to locate package g++-4.4.7 «« :  g++-4.4.7 never existed as a package.
And : g++-5 or earlier means { g++-5, g++-4.9, g++-4.8 }, whichever is available.
  •     Please do never remove the system compiler.
  •     You can have as many versions of gcc/g++ as you want, installed at the same time.
And please search for a package before installing ...
apt-cache search g++
.... The reply is g++-5, g++-4.8 .... and some you may not want.

sudo apt install g++ g++-5 g++-4.8

Instead of ./install the ns2 build command for Ubuntu 17.10 is :
export CC=gcc-4.8 CXX=g++-4.8 && ./install
( 17.10 : We have seen some rare issues with g++-5, I think.)

Package search / overview :  On-line search pages can also be used →
https://packages.ubuntu.com/search?suite=artful&searchon=names&keywords=g%2B%2B

Harshit Bishnoi

unread,
Mar 20, 2018, 4:11:41 PM3/20/18
to ns-u...@googlegroups.com
Thank you for your help
We have successfully installed ns2 but we are facing minor issues in running blackhole20-1.tcl script
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
harshit@harshit-HP-Pavilion-Notebook:~/ns-allinone-2.35/nam-1.15$ ns-blackhole blackhole20-1.tcl
num_nodes is set 21
INITIALIZE THE LIST xListHead
loading random connection pattern...
couldn't read file "./scen-20": no such file or directory
    while executing
"source.orig ./scen-20"
    ("uplevel" body line 1)
    invoked from within
"uplevel source.orig [list $fileName]"
    invoked from within
"if [$instance_ is_http_url $fileName] {
set buffer [$instance_ read_url $fileName]
uplevel eval $buffer
} else {
uplevel source.orig [list $fileName]
..."
    (procedure "source" line 8)
    invoked from within
"source ./scen-20"
    (file "blackhole20-1.tcl" line 69)
harshit@harshit-HP-Pavilion-Notebook:~/ns-allinone-2.35/nam-1.15$
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Harshit Bishnoi
B.Tech , Second Year
Computer Science and Engineering
The LNM Institute of Information Technology , Jaipur
Contact : +91 9414791205

--
You received this message because you are subscribed to the Google Groups "Network Simulator 2 (NS2)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-users+unsubscribe@googlegroups.com.
To post to this group, send email to ns-u...@googlegroups.com.
Visit this group at https://groups.google.com/group/ns-users.
For more options, visit https://groups.google.com/d/optout.

knudfl

unread,
Mar 20, 2018, 6:14:15 PM3/20/18
to Network Simulator 2 (NS2)
@Harshit Bishnoi.

»» ~/ns-allinone-2.35/nam-1.15$ ns-blackhole blackhole20-1.tcl «« :
.... Looks like your location is "nam-1.15/" ?

The first command is always $ pwd
.... if any doubt about location.
.... The location is supposed to be "ex-2005-2013__05.17/ , where also './scen-20' is :
$ cd ex-2005-2013__05.17/ && ns-blackhole blackhole20-1.tcl
To unsubscribe from this group and stop receiving emails from it, send an email to ns-users+u...@googlegroups.com.

Sreelakshmi T R

unread,
Mar 21, 2018, 2:08:40 PM3/21/18
to Network Simulator 2 (NS2)
sir,

i want to know that whether this patch file is to be placed in ns-2.35 folder or not?. Also i got the error as follows

user@user-X541UJ:~/Documents/test/ns-allinone-2.35/ns-2.35$ patch -p0 < blackholeaodv2013-ns235_1.patch
patching file ns-2.35/blackholeaodv/blackholeaodv.cc
patching file ns-2.35/blackholeaodv/blackholeaodv.h
patching file ns-2.35/blackholeaodv/blackholeaodv_logs.cc
patching file ns-2.35/blackholeaodv/blackholeaodv_rqueue.cc
patching file ns-2.35/blackholeaodv/blackholeaodv_rqueue.h
patching file ns-2.35/blackholeaodv/blackholeaodv_rtable.cc
patching file ns-2.35/blackholeaodv/blackholeaodv_rtable.h
can't find file to patch at input line 2604
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -Naur ns-2.35-orig/common/packet.h ns-2.35/common/packet.h
|--- ns-2.35-orig/common/packet.h    2010-05-10 00:28:41.000000000 +0200
|+++ ns-2.35/common/packet.h    2014-05-13 12:37:11.000000000 +0200
--------------------------
File to patch:
On Monday, March 19, 2018 at 3:16:21 AM UTC+5:30, knudfl wrote:

knudfl

unread,
Mar 21, 2018, 2:45:09 PM3/21/18
to Network Simulator 2 (NS2)
@Sreelakshmi T R.

------

cd ns-allinone-2.35/
patch -p0 < blackholeaodv2013-ns235_1.patch
------
... means that a copy of blackholeaodv2013-ns235_1.patch must be present in cd ns-allinone-2.35/.
... Or that you do : patch -p0 < [path-to-folder-with-patch]/blackholeaodv2013-ns235_1.patch
... cd ns-allinone-2.35/ means that is here you are applying the patch, not in "ns-2.35/".

Arief Hidayat

unread,
Aug 15, 2018, 5:04:14 AM8/15/18
to Network Simulator 2 (NS2)
hi mr Knudlf
when  i running atk3.tcl, I got the problem as below

arief-pc@ubuntu:~/Documents/blackhole/ex-2005-2013__05.17$ ns atk3.tclnum_nodes is set 3
warning: Please use -channel as shown in tcl/ex/wireless-mitf.tcl
warning: no class variable Agent/AODV::gw_discovery

    see tcl-object.tcl in tclcl for info about this warning.

INITIALIZE THE LIST xListHead
warning: no class variable Agent/AODV::gw_discovery

    see tcl-object.tcl in tclcl for info about this warning.


    (_o58 cmd line 1)
    invoked from within
"_o58 cmd addr"

    invoked from within
"catch "$self cmd $args" ret"
    invoked from within
"if [catch "$self cmd $args" ret] {
set cls [$self info class]
global errorInfo
set savedInfo $errorInfo
error "error when calling class $cls: $args" $..."
    (procedure "_o58" line 2)

    (SplitObject unknown line 2)
    invoked from within
"_o58 addr"
    ("eval" body line 1)
    invoked from within
"eval $node addr $args"
    ("default" arm line 2)
    invoked from within
"switch -exact $routingAgent_ {
DSDV {
set ragent [$self create-dsdv-agent $node]
}
DSR {
$self at 0.0 "$node start-dsr"
}
AODV {
set ragent [$self cre..."
    (procedure "_o3" line 14)
    (Simulator create-wireless-node line 14)
    invoked from within
"_o3 create-wireless-node"
    ("eval" body line 1)
    invoked from within
"eval $self create-wireless-node $args"
    (procedure "_o3" line 23)
    (Simulator node line 23)
    invoked from within
"$ns node"
    invoked from within
"set node_(2) [$ns node]"
    (file "atk3.tcl" line 56)
arief-pc@ubuntu:~/Documents/blackhole/ex-2005-2013__05.17$ ns atk3.tcl
num_nodes is set 3
warning: Please use -channel as shown in tcl/ex/wireless-mitf.tcl
warning: no class variable Agent/AODV::gw_discovery

    see tcl-object.tcl in tclcl for info about this warning.

INITIALIZE THE LIST xListHead
warning: no class variable Agent/AODV::gw_discovery

    see tcl-object.tcl in tclcl for info about this warning.


    (_o58 cmd line 1)
    invoked from within
"_o58 cmd addr"

    invoked from within
"catch "$self cmd $args" ret"
    invoked from within
"if [catch "$self cmd $args" ret] {
set cls [$self info class]
global errorInfo
set savedInfo $errorInfo
error "error when calling class $cls: $args" $..."
    (procedure "_o58" line 2)

    (SplitObject unknown line 2)
    invoked from within
"_o58 addr"
    ("eval" body line 1)
    invoked from within
"eval $node addr $args"
    ("default" arm line 2)
    invoked from within
"switch -exact $routingAgent_ {
DSDV {
set ragent [$self create-dsdv-agent $node]
}
DSR {
$self at 0.0 "$node start-dsr"
}
AODV {
set ragent [$self cre..."
    (procedure "_o3" line 14)
    (Simulator create-wireless-node line 14)
    invoked from within
"_o3 create-wireless-node"
    ("eval" body line 1)
    invoked from within
"eval $self create-wireless-node $args"
    (procedure "_o3" line 23)
    (Simulator node line 23)
    invoked from within
"$ns node"
    invoked from within
"set node_(2) [$ns node]"
    (file "atk3.tcl" line 56)

knudfl

unread,
Aug 15, 2018, 6:49:10 AM8/15/18
to Network Simulator 2 (NS2)
@Arief Hidayat , hi.

The conditions are : ns-2.35 patched with blackholeaodv2013-ns235_1.patch
https://drive.google.com/file/d/0B7S255p3kFXNWWVDZzd2ZC14akE/view?usp=sharing
... and and executable "ns_new-name" in /usr/local/bin/

My test :
$ ns235-black-64 atk3.tcl
num_nodes
is set 3

warning
: Please use -channel as shown in tcl/ex/wireless-mitf.
tcl
INITIALIZE THE LIST xListHead
channel
.cc:sendUp - Calc highestAntennaZ_ and distCST_
highestAntennaZ_
= 1.5,  distCST_ = 550.0
SORTING LISTS
...DONE!
... The files bhatk.tr 4.3MB, wrlsaodv.nam 3.0MB are created.



--------------------------

Arief Hidayat

unread,
Aug 15, 2018, 9:40:28 AM8/15/18
to Network Simulator 2 (NS2)
hi Knudlf
i has installed patch -p0 < blackholeaodv2013-ns235_1.patch and follow your instruction but it not working, the message as below

arief-pc@ubuntu:~/Documents/blackhole/ex-2005-2013__05.17$ ns235-black-64 atk3.tcl
ns235-black-64: command not found

knudfl

unread,
Aug 15, 2018, 10:42:51 AM8/15/18
to Network Simulator 2 (NS2)
@Arief Hidayat

tar xvf ns-allinone-2.35_gcc5.tar.gz
https
://drive.google.com/file/d/0B7S255p3kFXNVVlxR0ZNRGVORjQ/view?usp=sharing
cd ns
-allinone-2.35/patch -p0 < blackholeaodv2013-ns235_2.patch
https
://drive.google.com/file/d/0B7S255p3kFXNMk1uX2N5VmtXeTA/view?usp=sharing
./install
cd ns
-2.35/
cp ns ns
-black
sudo cp ns
-black

-------------- Simulation -------------
ns-black Aska123-f__Blacktcl2.tcl

Ahmad Rifki

unread,
Oct 12, 2018, 1:11:22 AM10/12/18
to Network Simulator 2 (NS2)
blackhole aodv, can i use in aomdv blackhole?

thanks sir

yusran syuja

unread,
Oct 12, 2018, 1:30:54 AM10/12/18
to Network Simulator 2 (NS2)
I have same problem, please help for aomdv black hole
Reply all
Reply to author
Forward
0 new messages