Archive for April, 2012|Monthly archive page

How to install leach on ubuntu 10. +

I suppose that ns-2.34 is installed with the compiler gcc-4.3.

The home directory of ns-2.34 is “/buddharaj/ns-allinone-2.34”
1- download the package “ns-234-leach.tar.gz” into the directory “/buddharaj/ns-allinone-2.34/ns-2.34”. and Unzip the ns-234-leach.tar.gz…CNWG1NQK&hl=en
2- download the bash file “” into the directory “/buddharaj/ns-allinone-2.34/ns-2.34”.…CJSU5ZYG&hl=en
3- Go to the terminal and go into that directory as:
wsn@ubuntu:~$ cd /opt/ns-allinone-2.34/ns-2.34/ and Open the file “” and replace the all occurences
of “/opt/ns-allinone-2.34” with “/home/buddharaj/ns-allinone-2.34” and run  the file as:

4- Open two files
– “Makefile” : found in the directory “yourpath/ns-allinone-2.34/ns-2.34”.
– “” : found in the directory “yourpath/ns-allinone-2.34/ns-2.34”.

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”.
– “” : found in the directory “yourpath/ns-allinone-2.34/ns-2.34”.
6. Edit both “Makefile” as
CC    = gcc-4.3
CPP    = g++

& “” as following:
CC    = gcc-4.3
CPP    = @CXX@

7- Insert following code into “yourpath/ns-allinone-2.34/ns-2.34/trace/cmu-trace.h” after the line 59.

#ifdef MIT_uAMPS
#define ADV_CHAR ‘A’
#define REQ_CHAR ‘R’
#define DATA_CHAR ‘D’

and go to the line number 167 and insert following function there

void     format_rca(Packet *p, int offset);

8- Again delete the code in file “yourpath/ns-allinone-2.34/ns-2.34/mit/uAMPS/sims/uamps.tcl” from line number 8 to 20
and insert the following code there

source mit/rca/ns-ranode.tcl
source mit/uAMPS/ns-bsapp.tcl
source mit/uAMPS/extras.tcl
source mit/uAMPS/stats.tcl
source mit/rca/resources/ns-resource-manager.tcl
source mit/rca/resources/ns-energy-resource.tcl
source mit/rca/resources/ns-neighbor-resource.tcl

9- run the following commands
wsn@ubuntu:/opt/ns-allinone-2.34/ns-2.34$make clean

10- If the previous commands passed successfully then you are ready to test your “Leach” by running ./test:

11- check the file “leach.err”, if no error reported then go to “leach.out” and enjoy your results!