This is my simple tcl script for our project research by using NS-2.34. In this project, we are going to combine 2 protocols, AODV+ and R-AODV, our proposed protocol called AODV-UI.
Here is the tcl script.
Code:
#============================================================================= # ABDUSY SYARIF # TCL AODV DESIGN #============================================================================= set opt(namfile) nam_aodv_out.nam set opt(tracefile) trace-new-aodv_m5_h2.tr set val(chan) Channel/WirelessChannel; #channel type set val(prop) Propagation/TwoRayGround; #radio-propagation model set val(netif) Phy/WirelessPhy; #network interface type set val(mac) Mac/802_11; #MAC type set val(ifq) Queue/DropTail/PriQueue; #interface queue type set val(ifqlen) 50; #max nbr of packets in ifq set val(ll) LL; #link layer type set val(ant) Antenna/OmniAntenna; #antenna type set val(adhocRP) AODV; #routing protocol set val(x) 1000; #x dimension of the topography set val(y) 800; #y dimension of the topography set val(stop) 600.0; #simulation time set val(mobility) "mobil5_4" set val(start-src) 1 set val(stop-src) 600 set nbrOfWirelessNodes 5 set nbrOfWiredNodes 4 set nbrOfGateways 2 #set val(gw_discovery) reactive; #gateway discovery method
Download the full tcl script here.
Tags: ad hoc, AODV+, Manet, network simulation, NS-2, NS2, routing protocol, tcl
February 2, 2011 at 15:50 |
I can see you’re an expert on TCL Script for My NS-2 Project | Abdusy Syarif! I am starting up a website in the near future, and your post can be very useful for me. Thanks for all your input. With very best wishes x
LikeLiked by 1 person
March 3, 2011 at 10:36 |
thanks a lot sir ,
but we have problem while executing progrmm
pls help me
ravi@ravi-desktop:~$ ns aodv3.tcl
num_nodes is set 7
INITIALIZE THE LIST xListHead
couldn’t read file “mobil5_4”: no such file or directory
while executing
“source.orig mobil5_4”
(“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 $val(mobility)”
(file “aodv3.tcl” line 130)
thank you
LikeLike
March 3, 2011 at 19:16 |
You need a file called mobile5_4. You can create it by using setdest function.
LikeLike
April 11, 2011 at 03:43
i ran the setdest function in ../cmu-scen-gen/setdest
./setdest -n 5 -p 2.0 -s 10.0 -t 100 -x 100 – y 150 > mobil5_4
i got the following error:
assertion “speed != 0.0” failed: file “setdest.cc”, line 595
Aborted ( core dumped)
plzz help
LikeLike
April 26, 2011 at 00:26
hi
can you tell me how to link files generated in setdest function with tcl script
as i am getting same error as ravi above
LikeLike
April 13, 2011 at 20:35 |
Please choose, which one you will use in your simulation.
usage:
./setdest -v -n -p -M
-t -x -y
OR
./setdest -v -n -s -m -M
-t -P -p -x -y
LikeLike
April 25, 2011 at 04:25 |
how to run setdest function, i installed ns2.34 in /user/local/
so when i tried running .sh file getting errors like
[root@localhost pr]# ./make-scenario.sh
‘movement’ is a directory
/user/local/ns-allinone-2.23/ns-2.23/indep-utils/cmu-scen-gen/setdest/setdest does not exist or is not executable
[root@localhost pr]#
whats the solution for this
LikeLike
April 26, 2011 at 04:13 |
please read the manual how to use ‘setdest’. After you create a mobility file using ‘setdest’ utility, you can copy / call the mobility file in your tcl script.
LikeLike
April 26, 2011 at 22:52 |
yes i got it…
now can you tell me how i can show local repair in aodv through tcl script???
LikeLike
April 26, 2011 at 04:42 |
hey i have been following your blog lately, you have done some great work in NS2. i am too working on it and i need some help. there is an energy model available in ns2, do u know the tcl script that i should run to get the results from it
LikeLike
April 27, 2011 at 02:53 |
You can use a simple tcl script in ns-allinone-2.xx/ns-2.xx/tcl/ex/wireless-newnode-energy.tcl
LikeLike
April 29, 2011 at 02:45 |
hi,
can you tell me how to write tcl script for aodv that includes node movement or mobility,and cbr/tcp traffic and should show data transfer between source and destination node…
LikeLike
May 5, 2011 at 09:36 |
#Create a simulator object
set ns [new Simulator]
#Open the nam trace file
set nf [open out.nam w]
$ns namtrace-all $nf
#Define a ‘finish’ procedure
proc finish {} {
global ns nf
$ns flush-trace
#Close the trace file
close $nf
#Execute nam on the trace file
exec nam out.nam &
exit 0
}
#Create nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]
set n6 [$ns node]
set n7 [$ns node]
#Create a duplex link between the nodes
$ns duplex-link $n0 $n1 1Mb 10ms DropTail
$ns duplex-link $n1 $n2 1Mb 10ms DropTail
$ns duplex-link $n2 $n3 1Mb 10ms DropTail
$ns duplex-link $n0 $n4 1Mb 10ms DropTail
$ns duplex-link $n0 $n5 1Mb 10ms DropTail
$ns duplex-link $n5 $n6 1Mb 10ms DropTail
$ns duplex-link $n6 $n7 1Mb 10ms DropTail
$ns duplex-link $n7 $n3 1Mb 10ms DropTail
$ns duplex-link $n4 $n5 1Mb 10ms DropTail
$ns duplex-link-op $n0 $n1 orient right-down
$ns duplex-link-op $n1 $n2 orient right
$ns duplex-link-op $n2 $n3 orient right-up
$ns duplex-link-op $n0 $n4 orient right
$ns duplex-link-op $n0 $n5 orient right-up
$ns duplex-link-op $n5 $n6 orient right-
$ns duplex-link-op $n6 $n7 orient right-down
$ns duplex-link-op $n7 $n3 orient right-down
$ns duplex-link-op $n4 $n5 orient up
#Create a UDP agent and attach it to node n0
set udp0 [new Agent/UDP]
$ns attach-agent $n0 $udp0
# Create a CBR traffic source and attach it to udp0
set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 500
$cbr0 set interval_ 0.005
$cbr0 attach-agent $udp0
#Create a UDP agent and attach it to node n1
set udp1 [new Agent/UDP]
$ns attach-agent $n1 $udp1
# Create a CBR traffic source and attach it to udp1
set cbr1 [new Application/Traffic/CBR]
$cbr1 set packetSize_ 500
$cbr1 set interval_ 0.005
$cbr1 attach-agent $udp1
set null0 [new Agent/Null]
$ns attach-agent $n3 $null0
$ns connect $udp0 $null0
$ns connect $udp1 $null0
$ns at 0.5 “$cbr0 start”
$ns at 1.0 “$cbr1 start”
$ns at 4.0 “$cbr1 stop”
$ns at 4.5 “$cbr0 stop”
$udp0 set class_ 1
$udp1 set class_ 2
$ns color 1 Blue
$ns color 2 Red
$ns color 2 Red
#Call the finish procedure after 5 seconds of simulation time
$ns at 50.0 “finish”
#Run the simulation
$ns run
…..
i have written this code…the route it follows is from 0 to 3 via node 1.
now i want it send packets using the route 0 to 3 via node 5
(i.e 0-5-6-7-3)..how do i do that..plzz help
LikeLike
April 24, 2012 at 18:08 |
i can’t see any option of R-AODV, is it done in AODV or in the .cc file?
And how the mechanism of switching between protocol?
LikeLike
April 25, 2012 at 00:13 |
It’s done in .cc. The mechanisme of R-AODV you can read from http://elmurod.net/sfiles/r-aodv.pdf
LikeLike
April 25, 2012 at 23:50
can you pass me the .cc code? is it two different file (aodv.cc and r_aodv.cc) and somehow you calling from one another.or it’s done in aodv.cc alone?
appreciate if you can email me the code…i’m doing something similiar in OLSR+DTN protocol..
LikeLike
April 26, 2012 at 02:36
can you send me the .cc file? do you:
1. calling each other from aodv.cc and r_aodv.cc file (two seperate file)?
2. Putting the mechanism in aodv.cc file?
I want to know the way combining two routing protocols together..
LikeLike
April 28, 2012 at 11:53 |
Hi everyone here!
I need your help in my graduation project, which is about “GNDA: Detecing good neighbor nodes in ad hoc routing protocol”. I need the implementaion code (TCL) in ns-2, which is based on AODV. Any help will be appreciated!
LikeLike
May 19, 2012 at 03:31 |
hi sir may i know how to implement mobile 5.4 package in ns2.34 please let me to know this detail .. reply me as soon as possible
LikeLike
May 19, 2012 at 23:08 |
You could learn from this tutorial (http://www.isi.edu/nsnam/ns/tutorial/nsscript7.html)
LikeLike
June 2, 2012 at 05:32 |
Hi! I need your urgent help. plz! help me to finish my GP. I need to implement the attached flowchart in AODV using ns2.34.
LikeLike
June 2, 2012 at 05:39 |
The flowchart (GNDA flowchart) is found here:
LikeLike
January 7, 2014 at 20:26 |
I have to create a Gateway Node which will act as a bridge between two ad-hoc nodes whereas both are running different protocols. I will appreciate if you guide i.e how to achieve/create this type of Gateway node. Can we do in tcl script or have to create in C++ ?. Is there any implementation of Gateway available which can be modified to solve the above problem.
Will really appreciate your help.
Thanks in advanvce
LikeLike
January 8, 2014 at 08:20 |
Hi Ali, you could refer to AODV+ or AODV-UU.
LikeLike
March 18, 2014 at 13:31
Hi Syarif,
In the above script:
1- mobile nodes are communicating with wired nodes via gateways and no communication between mobile nodes.
2- In script, there is only one routing protocol i.e. AODV and doesn’t show communication between different mobile routing protocols?
3- The functionality of basestation is not clear, does it transform the packets from source to destination type. Can you explain or any good material on its internal functionality.
Objective: I want to communicate between AODV and DSR via Gateway/Router/Basestation (whatever its called in ns-2).
Your help will be highly appreciated.
Thanks
LikeLike
January 23, 2014 at 11:38 |
hi,
can you tell me how to write tcl script for aodv that includes node movement or mobility,and cbr/tcp traffic and should show packet loss between source and destination node…
LikeLike
January 25, 2014 at 10:47 |
AODV+ .. salam dear brother . You are doing great job by sharing codes unlike others. Brother , can you mail me whole code for Aodv+ protocol . i need to enhance it , MAy be will enhance in terms of load .. If you having souce code in NS3 , that will be most useful else ns2 will also work..
LikeLike
January 27, 2014 at 12:16 |
Hi Saqib,
You can download & discuss with the inventor of AODV+ from this link http://www.eit.lth.se/index.php?uhpuid=sdkd.aha&hpuid=161&L=1
LikeLike
February 12, 2014 at 16:51 |
Hello sir,
I am currently working on a project of detection and prevention of blackhole in clustered manet. It would be of great help if you could guide me as to where to start with and where can i get code for clustering the manet and implementing a blackhole attack?
LikeLike
February 13, 2014 at 17:13 |
Sir i would be really grateful to you if you could help at the earliest…i have to submit the project by the 25th of this month. Kindly look into my query.
LikeLike
February 14, 2014 at 08:08
Hi Tom, Perhaps you can contact with the author of this blog http://harrismare.net/2011/06/18/performance-evaluation-of-aodv-variants-on-ddos-blackhole-and-malicious-attacks/
LikeLike
February 15, 2014 at 10:15 |
Sir but i wanted the code for formation of a clustered manet first. Thank you for the link but it seems that author has only evaluated the performance under a static topology. i wanted it for a cluster based manet. or can you provide me the code for introducing a blackhole in a manet atleast?
LikeLike
April 10, 2014 at 17:29 |
Sir, can i get any code inorder to form clusters based on aodv protocol?
LikeLike
December 7, 2014 at 11:35 |
sir,i am a post graduate student and I’m working in ns2 to design a 3-D network topology.I want to check parameters like area and energy,How is it possible in ns2?ALso is there any way to change routing algorithm in ns2 for wired networks?
LikeLike
January 21, 2015 at 09:03 |
Sir,I am a Mtech student and I’m doing a project on wireless mesh network.I need a running tcl script for designing wireless mesh network with mesh clients,routers and gateways. It would be of great help if you provide me the code because with this I will be able to proceed further with my project.
LikeLike
January 27, 2015 at 04:40 |
Hi sir, we(B.Tech final year) are doing project based on clustering using AODV protocol in MANETS. Initially we tried to execute your code in ns2, but it is not executed. It is showing some errors. Can you please provide us if they are any other codes related to clustering using gateways.
LikeLike
February 6, 2015 at 08:45 |
I run your program. I am getting error as num_nodes 7 and showing error in LL. what are the changes to be done to run the program without getting error
LikeLike
February 23, 2015 at 07:04 |
dear sir can u help me in blackhole attack prevention in MANETs. i need a tcl script in blackhole attack prevention using BHAPSC algorithm… can u plz help me out sir.
LikeLike
February 25, 2015 at 04:16 |
sir plz do help me out with my project.. i would be really grateful if u could reply me as early as possible…
LikeLike
March 16, 2015 at 04:23 |
Sir, I am doing my project on UnderWater Acoustic Communication.
We Successfully Installed AQUASIM… But How do we do Clustering among the Nodes?
LikeLike
May 20, 2015 at 15:14 |
hello sir, i have used your tcl script. but destination can’t receive message. i got DROP_RTR_QFULL. can you please help me.
LikeLike
January 14, 2016 at 06:53 |
Hai,
Can you provide the code for efficient neighbour discovery in AODV routing in ns2…
Regards,
Nithin K B
LikeLike
March 9, 2016 at 04:23 |
Hi sir,
It’s great to see you helping others with NS2. I’m a postgraduate student seeking for help in Energy model (optimization of energy) for linear topology. Do share if there are any relevant NS2 scripts which will benefit for linear topology.
Thank you.
Regards,
SK
LikeLike
April 8, 2016 at 09:01 |
HELLO SIR,I NEED NS2 SOURCE CODE FOR CLUSTERING OF NODES IN WSN.CAN YOU PLEASE SEND IT TO ME ON MY EMAIL ID-
yojanasingh91@gmail.com
LikeLike
December 13, 2016 at 15:30 |
hello sir i need ns2 coding for load balanced clustering in wireless sensor network using genetic algorithm.can u please send that coding to my mail-anisolaiammal@gmail.com
LikeLike
January 27, 2017 at 21:50 |
… [Trackback]
[…] Read More here: abdusyarif.net/2011/01/19/tcl_script_for_my_ns-2_project/ […]
LikeLike
January 30, 2017 at 17:22 |
Hello sir,i need code in ns2 tcl script for creating cluster and cluster head selection on the basis of node degree,can you pls mail me the code hpreet1405@gmail.com
LikeLike
March 1, 2017 at 14:43 |
Hello sir, i have run the above code but am not getting any output , the trace file contain nothing . help me to solve this problem.
LikeLike
March 4, 2017 at 10:43 |
hii sir
can u tell me tcl script for aodv-uu routing protocol based elliptic curve cryptograhpy algorithm
LikeLike
March 6, 2017 at 15:32 |
Hello
I got this error….PFA
LikeLike
April 28, 2017 at 12:17 |
Hi Sir or Ma. My name is Ajibesin Caleb Adejare doing my master program on manet routing protocols. I have problem in running my Tcl Script for mobile ad-hoc network. When i running your code above on my ns 2, it complains the following:
num_nodes is set 7
invalid command name “-llType”
while executing
“-llType $val(ll)
file “p.tcl” line 86
Pls, provide me with solution to the above. Thank you.
LikeLike
June 8, 2017 at 12:35 |
Check your tcl script on line 86. Maybe you missed a space.
LikeLike
June 3, 2017 at 12:03 |
Please help me out from this problem, i.e,
Segmentation fault (core dumped) while running nam file in ns2
how to resolve this
LikeLike
June 8, 2017 at 12:34 |
Have you tried re-install your NS-2?
LikeLike
June 9, 2017 at 19:33 |
When i use awk script for trace file, for throughput value i got -0.0. awk script for end to end delay, routing overhead, packet delivery ratio and average jitter complain of bug or give error message. Pls, what is solution?
LikeLike
June 9, 2017 at 19:48 |
When i used perl script for trace file, it gives me zero for send packet, receive packet, drop packet and soon. Pls, what is solution?
LikeLike
June 9, 2017 at 19:52 |
Another problem is that the tcl script i am using can only work for aodv and dsr but it can’t work for zrp. And i need a tcl script that can work for the three routing protocol. What is solution?
LikeLike
June 9, 2017 at 19:54 |
I mean it complain for zrp but it is not for aodv and dsr. Thank you for your respond.
LikeLiked by 1 person
June 9, 2017 at 23:28 |
You need to install ZRP in your NS-2.
LikeLike
June 10, 2017 at 02:23 |
Packet Sent:0
Packet Received:0awk: pd.awk:21: (FILENAME=simple-dsdv2.tr FNR=34919) fatal: division by zero attempted
pls, i need solution to this not the afformenttioned again. When i run my awk script for packet delivery ratio, i obtained zero and it complain division by zero attempted. Pls, provide with solution. Thank you very much.
LikeLike
June 10, 2017 at 02:27 |
Pls, can you give me detail or ideal of how to install zrp on my ns 2. Thank you u for previous reply. I am grateful
LikeLike
March 1, 2018 at 19:24 |
pls, how to simulate 10, 20, 30, 40 and 50 nodes simultaneously
in manet pls
LikeLike
June 20, 2019 at 13:35 |
hello
can you build an tcl file to encrypt AODV using diffie hellman and make hashing using md5
LikeLike