How to install leach protocol on ns2.34 in ubuntu 9.10

I suppose that ns-2.34 is installed with the compiler gcc-4.3.
The home directory of ns-2.34 is "/opt/ns-allinone-2.34"
1- download the package "ns-234-leach.tar.gz" into the directory "/opt/ns-allinone-2.34/ns-2.34".
https://docs.google.com/uc?id=0BzLWx...CNWG1NQK&hl=en
2- download the bash file "leach-setup.sh" into the directory "/opt/ns-allinone-2.34/ns-2.34".
https://docs.google.com/uc?id=0BzLWx...CJSU5ZYG&hl=en
3- If the home directory of your "ns-2.34" is other than "/opt/...", then you need to find "/opt/ns-allinone-2.34" and replace with "yourpath/ns-allinone-2.34" for the file "leach-setup.sh".
4- move to the directory "/opt/ns-allinone-2.34/ns-2.34" and patch the file "leach-setup.sh"
wsn@ubuntu:~$ cd /opt/ns-allinone-2.34/ns-2.34/
wsn@ubuntu:/opt/ns-allinone-2.34/ns-2.34$ bash leach-setup.sh
5- If the home directory of your "ns-2.34" is other than "/opt/...", then you need to find "/opt/ns-allinone-2.34" and replace with "yourpath/ns-allinone-2.34" for the follwoing two files:
- "Makefile" : found in the directory "yourpath/ns-allinone-2.34/ns-2.34".
- "Makefile.in" : found in the directory "yourpath/ns-allinone-2.34/ns-2.34".
6. Edit both “Makefile” & “Makefile.in” as following:
CC = gcc-4.3
CPP = g++-4.3(NOt always necessary. I did not need to )
7- run the following commands
wsn@ubuntu:/opt/ns-allinone-2.34/ns-2.34$./configure
wsn@ubuntu:/opt/ns-allinone-2.34/ns-2.34$make clean

wsn@ubuntu:/opt/ns-allinone-2.34/ns-2.34$make clean
wsn@ubuntu:/opt/ns-allinone-2.34/ns-2.34$make
7- If the previous commands passed successfully then you are ready to test your "Leach" by running bash ./test:
wsn@ubuntu:/opt/ns-allinone-2.34/ns-2.34$bash ./test

8. If you get errors in the terminal as 
[trace/cmu-trace.cc: In member function ‘void CMUTrace::format(Packet*, const char*)’:
trace/cmu-trace.cc:1327: error: ‘format_rca’ was not declared in this scope..................................] then you need to
void format_imep(Packet *p, int offset);
void format_aodv(Packet *p, int offset);
void format_aomdv(Packet *p, int offset);
#ifdef MIT_uAMPS
void format_rca(Packet *p, int offset);
#endif
#ifdef MIT_uAMPS
#define ADV_CHAR 'A'
#define REQ_CHAR 'R'
#define DATA_CHAR 'D'
#endif
add these lines to CMUTrace.h to class CMUTrace
9. check the file "leach.err", if no error reported then go to "leach.out" and enjoy your results!

Comments

narendra said…
i have done all the steps .I got som warnings while executing ./test command. I got errors in leach.out. I dont know why I got these errors.Can anyone help me.
Pushpita said…
I had installed leach protocol a few months back, but unfortunately the leach.out file showed wrong results. The energy values were not correct. I did not get any concrete help from Linux forums also. But you can always check up with linux forums.
Deepti said…
hii pushpita, this is deepti, will you please help me out, i need to implement LEACH for my project purpose, but all the files those i got frm google search r in ns2.27 i m doing on ns2.34 , so kindly mail me the link of ns2.34 leach implementation,.my email id
deeptipadhy@gmail.com

thank u.
honey said…
hi there!!!!
i have installed leach on my ns-2.34 & its working fine without error.
but in the leach.out file it is mentioned that ns doesnt support DST_add n port_add
can u kindly tell me for this error which patch i need to b installed on ns2.
kindly reply me as soon as possible

Regards
jignya said…
thanks Pushpita for the guidlines u have provided...

I have followed the steps.
In /home/jignya/ns-allinone-2.34/ns-2.34/ns-234-leach/mit/leach_sims , I found in leach.out following warnings:

Warning dst_ is no longer being supported in NS. dst_ 0xffffffff
Use dst_addr_ and dst_port_ instead
Warning dst_ is no longer being supported in NS. dst_ 0xffffffff
Use dst_addr_ and dst_port_ instead
Warning dst_ is no longer being supported in NS. dst_ 0xffffffff
Use dst_addr_ and dst_port_ instead

At 494.80000000004401:
Total Energy = 327.82507706058254
Total Data = 44146
Total Alive = 4

Simulation complete.

What do i need to do? Are these simulation results correct?
Unknown said…
Hi pushpita,
can u pls tell d steps for installing leach in ns2.34 on ubuntu 10.04..?
thanks in advance!
Pushpita said…
Hii Deepti!! Sorry for the late reply. I also implemented LEACH for project purpose so I might not know much in details. http://sourceforge.net/projects/nsnam/files/allinone/ns-allinone-2.34/

This link should help.
Pushpita said…
@honey I really did not go deeper after I found that leach.out gave wrong results for energy and power concerns. i finally implemented LEACH in C as my main point was to calculate the energy. SO it was possible to implement in C. Moreover i got similar values for direct transmission and LEACH as given in the original paper.
Pushpita said…
@jignya as I said earlier, the simulation results are wrong. There are 100 nodes starting with 2J per node. So it is impossible for such a value to pop up. Though I have a doubt what this energy actually meant.
Pushpita said…
@gowdham I think these steps might work. i too have shifted to ubuntu 10.04 as 9.10 does not have apt-get update working. I will try myself and see.
Muni said…
This comment has been removed by the author.
Muni said…
This comment has been removed by the author.
Sagar Shimpi said…
Hi Pushpita...did you tried NAM output for LEACH??

was that working for you?
Sagar Shimpi said…
Can you pass me your email id..i need to discuss abt leach implementation..

I will be thankful to you.
Muni said…
While implementing the LEACH I got the following error. If any one who has implemented LEACH provide us the correct steps.

can't read "env(RCA_LIBRARY)": no such variable
while executing
"source $env(RCA_LIBRARY)/ns-ranode.tcl"
(file "mit/uAMPS/sims/uamps.tcl" line 9)
invoked from within
"source.orig mit/uAMPS/sims/uamps.tcl"
("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 mit/uAMPS/sims/uamps.tcl"
(file "tcl/mobility/leach.tcl" line 18)
invoked from within
"source.orig tcl/mobility/leach.tcl"
("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 tcl/mobility/$opt(rp).tcl"
(file "tcl/ex/wireless.tcl" line 187)


And I have another doubt that the output should be verified in this location (/home/user-name/ns-allinone-2.34/ns-2.34/mit/leach.err) right?
Shridhar Sanshi said…
hey i'm getting this errors can any1 help me.. plzz

trace/cmu-trace.cc: In member function ‘void CMUTrace::format_rca(Packet*, int)’:
trace/cmu-trace.cc:1531: error: ‘A’ was not declared in this scope
trace/cmu-trace.cc:1535: error: ‘R’ was not declared in this scope
trace/cmu-trace.cc:1539: error: ‘D’ was not declared in this scope
make: *** [trace/cmu-trace.o] Error 1
Muni said…
@Shree.....
#ifdef MIT_uAMPS
void format_rca(Packet *p, int offset);
#endif
#ifdef MIT_uAMPS
#define ADV_CHAR 'A'
#define REQ_CHAR 'R'
#define DATA_CHAR 'D'
#endif

Add the above lines to /home/username/ns-allinone-2.34/ns-2.34/trace/cmu-trace.h file. U r problem will be solved.

Dear ns2 users, while installing leach many will be getting errors only due to mismatch of gcc and/or g++. So my suggestion is do install everything from the scratch to avoid errors.
yours Muni ....
Pushpita said…
@shree I had got the same error and I had done what Muni said, and it worked perfectly fine. I really don't remember much to help perfectly.
viral thakar said…
hey when i m trying to implement LEACH in NS 2.27 i got this error in leach.err file.

invalid command name "Resource/Energy"
while executing
"Resource/Energy instproc setParams {args} {
$self instvar energyLevel_ alarmLevel_
set energyLevel_ [lindex $args 0]
set alarmLevel_ [lind..."
(file "/root/ns-allinone-2.27/ns-2.27/mit/rca/resources/ns-energy-resource.tcl" line 11)
invoked from within
"source.orig /root/ns-allinone-2.27/ns-2.27/mit/rca/resources/ns-energy-resource.tcl"
("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 $env(RCA_LIBRARY)/resources/ns-energy-resource.tcl"
(file "mit/uAMPS/sims/uamps.tcl" line 18)
invoked from within
"source.orig mit/uAMPS/sims/uamps.tcl"
("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 mit/uAMPS/sims/uamps.tcl"
(file "tcl/mobility/leach.tcl" line 18)
invoked from within
"source.orig tcl/mobility/leach.tcl"
("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 tcl/mobility/$opt(rp).tcl"
(file "tcl/ex/wireless.tcl" line 187)


it l be a grt hlp frm ur side if u can post ny sollution for this....i m using fedora 8...
sumanth said…
THANK U SO MUCH ,NOW I AM ALSO JOIN WITH U FOR SEARCHING PROBLEMS AND SOLUTIONS OF LEACH PROTOCOL IN NS2
Nice tutorial for the Leach users on NS2. Kudos to Pushpita for the documentation.

I gave a try and it worked like magic for me (on Linux variants and Cygwin too).

For Muni and Viral's questions :
The errors you are getting are because of the improper environment variables. Make sure you have following environment set for LEACH in ~/.bashrc file:

export RCA_LIBRARY=/path-to-ns-allinone/ns-allinone-2.34/ns-2.34/mit/rca

export uAMPS_LIBRARY=/path-to-ns-allinone/ns-allinone-2.34/ns-2.34/mit/uAMPS



Regards,
Deepak Panwar
Pushpita said…
ThANKS, but I am really ignorant about it now, so the good work doesnt seem to be going on by me. You people are free to discuss your LEACH problems, as nowadays I hardly check my blog
:)
psd_prasad said…
I installed the leach protocol
while running the bash ./test
i got
um_nodes is set 3
warning: Please use -channel as shown in tcl/ex/wireless-mitf.tcl
warning: no class variable Phy/WirelessPhy::alive_

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

warning: no class variable Phy/WirelessPhy::Efriss_amp_

warning: no class variable Phy/WirelessPhy::Etwo_ray_amp_

warning: no class variable Phy/WirelessPhy::EXcvr_

warning: no class variable Phy/WirelessPhy::sleep_

warning: no class variable Phy/WirelessPhy::ss_

warning: no class variable Phy/WirelessPhy::dist_

INITIALIZE THE LIST xListHead
warning: no class variable Phy/WirelessPhy::alive_

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

warning: no class variable Phy/WirelessPhy::Efriss_amp_

warning: no class variable Phy/WirelessPhy::Etwo_ray_amp_

warning: no class variable Phy/WirelessPhy::EXcvr_

warning: no class variable Phy/WirelessPhy::sleep_

warning: no class variable Phy/WirelessPhy::ss_

warning: no class variable Phy/WirelessPhy::dist_

warning: no class variable Phy/WirelessPhy::alive_

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

warning: no class variable Phy/WirelessPhy::Efriss_amp_

warning: no class variable Phy/WirelessPhy::Etwo_ray_amp_

warning: no class variable Phy/WirelessPhy::EXcvr_

warning: no class variable Phy/WirelessPhy::sleep_

warning: no class variable Phy/WirelessPhy::ss_

warning: no class variable Phy/WirelessPhy::dist_

Loading connection pattern...
Loading scenario file...
Starting Simulation...
channel.cc:sendUp - Calc highestAntennaZ_ and distCST_
highestAntennaZ_ = 1.5, distCST_ = 89.8
SORTING LISTS ...DONE!
NS EXITING...

i look into the leach.err nothing there

while running the example file
[Prasad@localhost ex]$ ns wireless.tcl
couldn't read file "tcl/lib/ns-mobilenode.tcl": no such file or directory
while executing
"source.orig tcl/lib/ns-mobilenode.tcl"
("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 tcl/lib/ns-mobilenode.tcl"
(file "wireless.tcl" line 184)
[Prasad@localhost ex]$

how to run the exaple file
Unknown said…
I have the same problem while executing the test file:
num_nodes is set 3
warning: Please use -channel as shown in tcl/ex/wireless-mitf.tcl
warning: no class variable Phy/WirelessPhy::alive_

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

warning: no class variable Phy/WirelessPhy::Efriss_amp_
...
Loading connection pattern...
Loading scenario file...
Starting Simulation...
channel.cc:sendUp - Calc highestAntennaZ_ and distCST_
highestAntennaZ_ = 1.5, distCST_ = 89.8
SORTING LISTS ...DONE!
NS EXITING...

so I cant have any result about energy, I have this problem in ubuntu 11.04 with gcc 4.5 and also fedora 15 with gcc 4.4
honey said…
hi pushpita..
i have installed ns2.34 it is successfully installed and running examples.
but when i installed ns-2.34-leach on it
after configuring when i write
ns or ./test
it gives
segmentation fault
y is it so.. plz help me asap.
Unknown said…
Hi pushpita, I implemented leach successfully but i am not getting meaning of some files such as leach.data,leach.energy, leach.alive, TDMAschedule.txt. Please help me ,
thank u Deepali Deshpande
Unknown said…
Tanks sir for this great tutorial, but how can i use the leach.out ?

Tnkx for advance.
snehal said…
hii pushpita, this is snehal, will you please help me, i need to implement LEACH for my project purpose,i m doing on ns2.34 , so kindly mail me the link of ns2.34 leach implementation,.my email id
snehal.kole27@gmail.com..

thanx in advance
kamlendu said…
Hi
I have installed ns-2.35 with manassim and it is running very well. The problem is when I use leach with RCAgent and RCALinkLayer. first there was problem of insufficient size of char meta_[1000] I changed it to 4000. problem was solved. But when I see my trace file the values in -Hd, -Is are highly abnormal when the packet is send to base station from cluster head. for other packets the trace seems to be fine. I can send u the tcl and trace file if u say. what can be the problem?
kamlendu said…
Hi
I have installed ns-2.35 with manassim and it is running very well. The problem is when I use leach with RCAgent and RCALinkLayer. first there was problem of insufficient size of char meta_[1000] I changed it to 4000. problem was solved. But when I see my trace file the values in -Hd, -Is are highly abnormal when the packet is send to base station from cluster head. for other packets the trace seems to be fine. I can send u the tcl and trace file if u say. what can be the problem?
Unknown said…
This comment has been removed by the author.
Unknown said…
Hi,
I am facing problem in generating nam. I tried changing the nodes to ns_ node and got the nodes deployed but cant show the data sending. Also where can I get the cc file of the ResourceAwareNodes. Help
anupamasikchi@gmail.com
Dr. Manjula R said…
@ Deepak panwar

Can we use ubuntu 12.04 and gcc-4.3 compiler? If yes then can you please mail me the link to download gcc-4.3 and how to install on ubuntu 12.04?

Unknown said…
Hi, I simulate the wireless.tcl using LEACH protocol but I got this error:
couldn't read file "tcl/lib/ns-mobilenode.tcl": no such file or directory
while executing
"source.orig tcl/lib/ns-mobilenode.tcl"
("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 tcl/lib/ns-mobilenode.tcl"
(file "tcl/ex/wireless.tcl" line 184)

Please help me
anusha said…
while running configure command facing the below proble..please help me out with the solution...

configure: error: Installation of tcl seems incomplete or can't be found automatically.
Please correct the problem by telling configure where tcl is
using the argument --with-tcl=/path/to/package
(perhaps after installing it),
or the package is not required, disable it with --with-tcl=no.
Unknown said…
ehiiiiiii.......im trying to add a new protocol with ns2.34.....but im getting some erros while compiling makefile pls help me to fix it...


root@ubuntu:~/ns-allinone-2.34/ns-2.34# make
g++ -c -Wall -Wno-write-strings -DTCP_DELAY_BIND_ALL -DNO_TK -DTCLCL_CLASSINSTVAR -DNDEBUG -DLINUX_TCP_HEADER -DUSE_SHM -DHAVE_LIBTCLCL -DHAVE_TCLCL_H -DHAVE_LIBOTCL1_13 -DHAVE_OTCL_H -DHAVE_LIBTK8_4 -DHAVE_TK_H -DHAVE_LIBTCL8_4 -DHAVE_TCLINT_H -DHAVE_TCL_H -DHAVE_CONFIG_H -DNS_DIFFUSION -DSMAC_NO_SYNC -DCPP_NAMESPACE=std -DUSE_SINGLE_ADDRESS_SPACE -Drng_test -I. -I. -I/root/ns-allinone-2.34/tclcl-1.19 -I/root/ns-allinone-2.34/otcl -I/root/ns-allinone-2.34/include -I/root/ns-allinone-2.34/include -I/root/ns-allinone-2.34/include -I/usr/include/pcap -I./tcp -I./sctp -I./common -I./link -I./queue -I./adc -I./apps -I./mac -I./mobile -I./trace -I./routing -I./tools -I./classifier -I./mcast -I./diffusion3/lib/main -I./diffusion3/lib -I./diffusion3/lib/nr -I./diffusion3/ns -I./diffusion3/filter_core -I./asim/ -I./qs -I./diffserv -I./satellite -I./wpan -o mobileExOR/mobileExOR.o mobileExOR/mobileExOR.cc
In file included from ./mobile/propagation.h:49:0,
from ./mac/wireless-phyExt.h:62,
from ./mac/mac-802_11Ext.h:64,
from ./mobileExOR/mobileExOR.h:8,
from mobileExOR/mobileExOR.cc:1:
./mac/wireless-phy.h:131:37: error: expected identifier before 'r'
./mac/wireless-phy.h:131:37: error: expected ‘}’ before 'r'
./mac/wireless-phy.h:131:37: error: expected unqualified-id before 'r'
./mac/wireless-phy.h: In member function ‘bool& WirelessPhy::Is_node_on()’:
./mac/wireless-phy.h:98:37: error: ‘node_on_’ was not declared in this scope
./mac/wireless-phy.h: In member function ‘bool WirelessPhy::Is_sleeping()’:
./mac/wireless-phy.h:99:34: error: ‘status_’ was not declared in this scope
./mac/wireless-phy.h: At global scope:
./mac/wireless-phy.h:133:14: error: no matching function for call to ‘Sleep_Timer::Sleep_Timer()’
./mac/wireless-phy.h:133:14: note: candidates are:
./mac/wireless-phy.h:59:2: note: Sleep_Timer::Sleep_Timer(WirelessPhy*)
./mac/wireless-phy.h:59:2: note: candidate expects 1 argument, 0 provided
./mac/wireless-phy.h:57:7: note: Sleep_Timer::Sleep_Timer(const Sleep_Timer&)
./mac/wireless-phy.h:57:7: note: candidate expects 1 argument, 0 provided
./mac/wireless-phy.h:136:1: error: expected unqualified-id before ‘private’
./mac/wireless-phy.h: In function ‘EnergyModel* em()’:
./mac/wireless-phy.h:144:34: error: ‘node’ was not declared in this scope
./mac/wireless-phy.h: At global scope:
./mac/wireless-phy.h:146:2: error: ‘friend’ used outside of class
./mac/wireless-phy.h:148:1: error: expected declaration before ‘}’ token
./mac/wireless-phy.h: In function ‘EnergyModel* em()’:
./mac/wireless-phy.h:144:53: warning: control reaches end of non-void function [-Wreturn-type]
make: *** [mobileExOR/mobileExOR.o] Error 1
Unknown said…
hi ..
I'm thesis on energy efficiency at the nodal sensor with ns2.34 LEACH algorithm in WSN

do i have to install LEACH algorithm on ns2.34 I ...?

please give an explanation to me ..
Unknown said…
ha@ubuntu:~/ns-allinone-2.34/ns-2.34$ make depend
make: *** No rule to make target `tcp/linux/tcp_naivereno.cc', needed by `depend'. Stop.




help me?

Popular posts from this blog

How to install NS2 2.34 on ubuntu 10.04

UGLY NUMBERS