Friday, January 18, 2008

NS2 for Wireless Sensor Network

NS2 has been widely used for network simulation for wired and wireless.
Me and friends get some fund from e-science fund to do the performance evaluation on available wireless sensor network routing protocol and suggests new improvement if any.

For simulation NS2 is suggested to be used in this project it is mainly because we know a little bit of NS2. It is open source and extensible. Researcher or user can add their own module as an extension for NS2.

So I think there are 2 main thing our group member should know:
  1. The WSN technology itself including the architecture , routing , performance evaluation and so on.
  2. How to create new module on NS2
Of course there must be someone else who are conducting the same project. That's why it is important to do some literature survey and Internet search on what has been done by others. The top Google search result with keyword "NS2 for WSN" show this website URL:
Mannasim ( )

Maybe we should start from here?


Anonymous said...

can u help me with my ns2? i need to create wsn topology said...

first of all, where are u from?
If you refer to my post, it shows that we are also start to learn to use NS2 for WSN simulation.
As suggested in this entry, we are going to use Mannasim as one of our option for WSN simulation. Why don't you have a try too? Good Luck ^_^

akhilgm said...


i am also starting to work on WSN on NS-2. I am also a newbie. SO wouls appreciate all the help i ca get... Mannasims a great start but i intend to simulate only particular protocols. Direct Distributed Algorith is one of them. Can some help me??? said...

hi ^_^.. welcome to my blog
I'm also newbie in WSN n wireless networking in NS2 ..
However I have some little experiences in using NS2 for wired networking.
I'm not sure whether the Direct Distributed Algorithm is implemented in NS2. If it is implemented then it will be no problem, else, users need to add their own module.

akhilgm said...


seems we complement each other... even though i am a newbie to NS-s. i have tried my hand at implementing ieee 802.11 in NS2... n the direct distributed algo module is what i need the most. unfortunately i cant find anything to help me create the module. any suggestions??? said...

hey .. ^_^,
frankly speaking , I dont know about the direct distributed algo..
but if it is not implemented yet.. then it is up to user to create their own module. To create own module.. user need to know on how to extend ns2. Of course understanding C++ and OTcl are essential. I found a simple tutorial to do that :

hady said...

hi..i supposed to simulate WSN using ns2 and i have already installed ns2.29 under windows environment in my pc

the question is how can i simulate wsn for a given radio frequency 2.45GHZ..i need some guidance and hope u and the other might help..please..

hady said...

for any information please contact me at said...

Hi hady,

Since mannasim is an extension of wireless support of NS2, you can change the frequency in the simulation script.

Phy/WirelessPhy set freq_ 2.45e+9

good luck!

hady said...

thanx about the information. and how about the bandwidth? how much does it need for that frequency? said...

sorry hady,

It is up to you, based on your literature survey to determine the bandwidth value, maybe you can have a look on any standards , technical paper , or anything related to your project.

Good Luck

ahmad said...

please tell me how to find some implemented code in sensor network said...

dear ahmad,

The sample code can be retrieved from the download section of mannasim..

scroll down and there will be 2 examples there.

malar said...

Hi..malar here.i need help regarding this ns2.29 which is new to taking final year project regarding Improvement of QoS in Wireless Sensor Network and we need to use this ns2.29 to find out how this QoS can be improved by simulating routing algorithm..can u guide on how to do it.thank you

Karan said...

hey there....
i came across your blog and my dimming hopes suddenly rose high when i saw a few "newbies" on NS2 post stufff here....!! (hehe)
Frankly speaking i am totally new to NS2 and WSN both...and want to evetually implement an Adhoc WSN...For that i was suggested by a few people to first to first try my hands on NS2 for simulating the algorithms i wanna implement (sounds practical !!)...
Now i REALLY hope i have come to the right place here where i can find some basic help and guidance from all the bloggers here...
I dont want any kinda code from anyone...but I just want people to show a path of execution to me...
I hope i get an URGENT REPLY from the blog owner as well as other bloggers here...!!.
Karan... said...

dear malar, sorry.. the blog owner is very busy. I cannot help but saying sorry since I cannot provide much time to help you.. Maybe other visitors can help u? YOu can read trough NS2 related article in this blog if it can assists

dear KARAN, sorry also for late reply.. Since I've taken quite a long time in replying this message.. I belive that you are already using NS2 and able to do simulation using it..

Anonymous said...

Hi! I am new to ns2. I want to simulate routing protocols for WSN. Could some one help me to estblish communication between wsn nodes. waiting for reply

Karan said...

hey everyone...i need an urgent assistance from whoever can provide...i am simulating WSN and i want to knw how can i let a node in the n/w find it's neighbours, using the "energy of the received signal" (i.e. the signal carrying a response to the "hello" message)...

i want to decrement a signal strength value "per unit time" or "per unit distance", so that i can get the value for the receieved signal ...but having probs implementing it...


Félix Jesús said...

Under /tcl/ex directory in ns-2.XX you can find a lot of examples.

They have the answer to a lot of questions made here. said...

thanks felix

sudhi25 said...

hello everyone.... it seems that i am at the right place...guyz i need to simulate WSN using genetic algorithm as an optimization technique..... i dont know as to where i should start.... please help me on this....and what language am i supposed to use tcl or c++ or both and how do i run a c++ program in ns2??????

Abhilash said...

How to impleent WSN protocols like SPIN,GAF and LEECH in ns2 simulator.Previouslyi had simulated MANET protocls(DSR,AODV,DSDV) for various scenarios.But i don know how to start for WSN.I cant find any thing realted to it in NS2.What should i do for already installed ns2 to simulate WSN protocls.Plz help me..

Mohd.Taufiq said...

Dear Abhilash, you can simulate WSN for Leach algorithm using mannasim TcL generator, ok

DD said...

How to get energy of a node in ns2.29. Please help me.

Rishabh said...

There have been some unanswered questions regarding energy issues in previous posts. I am interested in implementing an energy harvesting protocol for which I need to know the energy of current node's neighbors and take the routing decisions. I would really appreciate any help in this matter.

Thank You.

manel said...

Hi all,
I'm trying to implement new routing protocol for sensor networks. The LEACH example provided with mannasim was very useful to me but i wasn't able to read the leach script generate by script-generator-tools. Is there any format or source of unformation that can help me to know the meaning of each columns.
Any help woulb great.

Anonymous said...

Salam and hi to all

i am a new user of ns2. currently my final thesis are in progress and i am working on wireless sensor networks. i want to implement an energy efficient protocol for wsn, for this i want to first make a simple wireless senario of wsn.

if any one have the code and want to help me please i will wait.

razaullah khan

maryam said...

i want to simulate a algorithm based on genetic algorithm in wsn using ns2 . how can i do it? I need a implementation the same as it . could anyone help me????

dinesh said...

i have patched mannasim in ns2 and run the examples but only data is output
can u tell me how to generate nam file for wsn.

komal said...

I am working on ns2.I want to know how to create WSN topology and how to examine node power over a period of time. Plz help me out.

Vivek said...

I m newbie to Ns-2

Now I need to simulate wsn routoing algos in ns2.

I Was installing mannasim bt found errors

Can you please tell me the way to correct it.

Thanking You in Advance

sahilpasrija said...


i'm working on ns2

i want codes of the project

so plz mail me ies coding

Anonymous said...

How do you set up a basic AP node in NS2 and attach 5 wireless static nodes to it? I want to use FTP over TCP and CBR over UDP for traffic/agents.

Any help on this matter would be great! Thanks :)


renukaprasad said...

my self renukaprasad, i am currently doing my M.TECh project in Wireless sensor networks which is implemented in NS2.
could u plz provide me any sample code of wireless sensor network simulation in NS2 to my mail.

s said...

hi friends,im doing my project in wireless sensor doing topology management schemes like span..first i plan to implement to implement span..i dono much abu pls send me the ns2 code of any topology scheme of wsn..

R said...

Hi guys i read all your comments..i had successfully developed heterogenous WSN topolgy..But i am using cygwin..if anyone wants help then say!!

s said...

sir,i working on wireless sensor networking project..i want the ns2 code for STEM(topology management scheme) and also SPAN..pls send it so that it ll be helpful in my project..

Samia Siddiqui said...


can any one plz help me to get implemented code of LEACH, SPIN and GEAR either in ns2 or jsim.

if so e-mail me at

Subha said...

Hi all, am doing my ME project in sensor network. Am using NS2. Just now i come across with "mannasim". If i want 2 implement new routing agent in mannasim, what should i do? Can anyone please help me....

Anonymous said...

hi all,

im sangeetha... im doing my proj on "qos n selective encryption on wsn" in ns2.. im new to this field... can anybody help me plz.. im very much in need of help... suggest me some codings if u kno...

Axe Your Ex said...

i am searching code for grid based coverage strategy for wireless sensor network for ns2.from where i can get the code.

Anonymous said...

i need a code for generating two-tier heterogenous topology for wireless sensor network in ns2(ns2+mannasim). plz any one can help

Louk_88 said...


Can anyone tell me how we can implemeent a routing protocol for WSN? Plz help me!

Bharati said...

i'm doing project in ns2.29 , i need a code for multiconstrained Qos multipath routing in wireless sensor networks.plz any one help me


E.Solano said...

I'm completely new at NS-2 and I'm just downloading mannasim extension. Is it compatible with ns 2.35? or do I specifically need ns 2.29?

Kind Regards

Najma said...

hi, i m using ns2.29 with mannasim on ubuntu 10.04. i tried to ran leach protocol using script generated by mannasim script generator tool but it fails gives an error metasize 4064 too large (maxsize=1000). i found that this size is set to 1000in packet.h file. when i changed this value to 4000 it gives segmentation fault error.
please help me in resolving this issue. my email id is: logicator94@gmailcom

Sharuammu said...

Hai everyone,
Kindly give me an idea for creating a new algorithm and how to implement in ns2. is it possible in ns2 for wireless sensor networks routing protocols. suggest some websites and books to create an algorithm .

Anonymous said...

let me know the sensor network related algorithm implementation code

sharu said...

hai everyone,
how to find nignest energy of the node while executing . how to implement an algorithm in ns2 for wireless sensor networks

vinoth said...

hello half sem project is dynamic data aggregation in doing in ns2..i have no idea about it..can u help me plz...
mail id

asha said...


I'm doing project in WSN using ns2..
can anyone tell me how retrieve energy of particular sensor node using ns2 ?????
plz help me...

delali said...

I am new to ns2 for WSN. I am currently working on resource congestion control in WSN using idea of multiplexing for path selection depending on energy level of nodes. Can any one help me with a script or sample tutorial. Thank u in advance.

email me :

poohbha said...

I want to make a new routing protocol,
I follwed the basic steps from some tutorial nd compile it properly but
If we run the TCL file it results in error….what should we do….

The error is

num_nodes is set 100

(_o14 cmd line 1)
invoked from within
“_o14 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 “_o14″ line 2)
(SplitObject unknown line 2)
invoked from within
“_o14 addr”
(“eval” body line 1)
invoked from within
“eval $node addr $args”
(“default” arm line 2)
invoked from within
“switch -exact $routingAgent_ {
set ragent [$self create-dsdv-agent $node]
$self at 0.0 “$node start-dsr”
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"
("for" body line 2)
invoked from within
"for {set i 0} {$i < $val(nn) } { incr i } {
set mnode_($i) [$ns node]
(file "wfrp_802_15_4.tcl" line 74)