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!
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
deeptipadhy@gmail.com
thank u.
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
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?
can u pls tell d steps for installing leach in ns2.34 on ubuntu 10.04..?
thanks in advance!
This link should help.
was that working for you?
I will be thankful to you.
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?
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
#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 ....
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...
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
:)
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
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
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.
thank u Deepali Deshpande
Tnkx for advance.
snehal.kole27@gmail.com..
thanx in advance
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?
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?
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
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?
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
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.
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
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 ..
make: *** No rule to make target `tcp/linux/tcp_naivereno.cc', needed by `depend'. Stop.
help me?