how to integrate the "Resource/Energy" leach class into NS-2.34?
Hello ...
I recently started installing leach protocol on NS-2.34 and Ubuntu 11.04. I'm sure that I did all the necessary steps that were mentioned in this thread and other threads related Leach. However, when running the ./test I got this error : 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 "/opt/ns-allinone-2.34/ns-2.34/mit/rca/resources/ns-energy-resource.tcl" line 11) ........ I've read that I need to use either g++3.3 or g++4.1, but seems as there's a problem in installing these versions of compiler. Can any one help me to integrate the "Resource/Energy" class into NS-2.34? Please!!!!! |
Welcome to LQ.
Add 'hardy' to /etc/apt/sources.list : g++-3.3....gcc-4.2((g++-4.2)) will be available. sudo gedit /etc/apt/sources.list ; sudo apt-get update Code:
deb http://76.73.4.58/ubuntu/ hardy-updates main All new objects must be added to 'Makefile' ( Makefile.in ). Patch ns234-leach.tar.bz2 https://docs.google.com/uc?id=0B7S25...CJzYt5QP&hl=en May be compare the Makefile with the original ns-2.27 LEACH Makefile : https://docs.google.com/uc?id=0B7S25...CNPCuaYP&hl=en EDIT : See post # 22 .. |
solved!!
Thank you very much, Leach is working now on ns-2.34 :) I've started from scratch and installed g++4.3.
|
Several members have asked how to add "ns234-leach files" to ns-2.34.
It will be very much appreciated, if you can write a short HOWTO. Either here in the thread, or a in a blog entry : http://www.linuxquestions.org/questi...yTamer-578702/ Or LQ 'Linux Wiki' http://wiki.linuxquestions.org/wiki/Main_Page .. |
Install Leach on ns-2.34
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 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 7- If the previous commands passed successfully then you are ready to test your "Leach" by running ./test: wsn@ubuntu:/opt/ns-allinone-2.34/ns-2.34$./test 8. check the file "leach.err", if no error reported then go to "leach.out" and enjoy your results! |
Thank you for the excellent description and the repacked files.
Regards. .. |
Hello All
I tried to install LEACH on ns2.34 but IO got thi error when I was trying to Install it.keepwalking@ubuntu:~/ns-allinone-2.34/ns-2.34$ bash leach-setup.sh ns-234-leach/trace/cmu-trace.cc ns-234-leach/trace/ ns-234-leach/test ns-234-leach/tcl/mobility/stat-clus.tcl ns-234-leach/tcl/mobility/mte.tcl ns-234-leach/tcl/mobility/leach.tcl ns-234-leach/tcl/mobility/leach-c.tcl ns-234-leach/tcl/mobility/ ns-234-leach/tcl/ex/wireless.tcl ns-234-leach/tcl/ex/ ns-234-leach/tcl/ ns-234-leach/package_up ns-234-leach/mit/uAMPS/stats.tcl ns-234-leach/mit/uAMPS/sims/uamps.tcl ns-234-leach/mit/uAMPS/sims/stat-clus.tcl ns-234-leach/mit/uAMPS/sims/nodescen ns-234-leach/mit/uAMPS/sims/mte.tcl ns-234-leach/mit/uAMPS/sims/leach.tcl ns-234-leach/mit/uAMPS/sims/leach-c.tcl ns-234-leach/mit/uAMPS/sims/genscen ns-234-leach/mit/uAMPS/sims/100nodes.txt ns-234-leach/mit/uAMPS/sims/ ns-234-leach/mit/uAMPS/ns-stat-cluster.tcl ns-234-leach/mit/uAMPS/ns-mte.tcl ns-234-leach/mit/uAMPS/ns-leach.tcl ns-234-leach/mit/uAMPS/ns-leach-c.tcl ns-234-leach/mit/uAMPS/ns-bsapp.tcl ns-234-leach/mit/uAMPS/extras.tcl ns-234-leach/mit/uAMPS/bsagent.o ns-234-leach/mit/uAMPS/bsagent.h ns-234-leach/mit/uAMPS/bsagent.cc ns-234-leach/mit/uAMPS/ ns-234-leach/mit/rca/resources/ns-resource.tcl ns-234-leach/mit/rca/resources/ns-resource-manager.tcl ns-234-leach/mit/rca/resources/ns-neighbor-resource.tcl ns-234-leach/mit/rca/resources/ns-energy-resource.tcl ns-234-leach/mit/rca/resources/ ns-234-leach/mit/rca/resource.o ns-234-leach/mit/rca/resource.h ns-234-leach/mit/rca/resource.cc ns-234-leach/mit/rca/rcagent.o ns-234-leach/mit/rca/rcagent.h ns-234-leach/mit/rca/rcagent.cc ns-234-leach/mit/rca/rca-ll.o ns-234-leach/mit/rca/rca-ll.h ns-234-leach/mit/rca/rca-ll.cc ns-234-leach/mit/rca/ns-ranode.tcl ns-234-leach/mit/rca/energy.o ns-234-leach/mit/rca/energy.h ns-234-leach/mit/rca/energy.cc ns-234-leach/mit/rca/ ns-234-leach/mit/leach_sims/startup.energy ns-234-leach/mit/leach_sims/leach.save2 ns-234-leach/mit/leach_sims/leach.save1 ns-234-leach/mit/leach_sims/leach.out ns-234-leach/mit/leach_sims/leach.err ns-234-leach/mit/leach_sims/leach.energy ns-234-leach/mit/leach_sims/leach.data ns-234-leach/mit/leach_sims/leach.alive ns-234-leach/mit/leach_sims/conditions.txt ns-234-leach/mit/leach_sims/TDMAschedule.80.txt ns-234-leach/mit/leach_sims/TDMAschedule.60.txt ns-234-leach/mit/leach_sims/TDMAschedule.480.txt ns-234-leach/mit/leach_sims/TDMAschedule.460.txt ns-234-leach/mit/leach_sims/TDMAschedule.440.txt ns-234-leach/mit/leach_sims/TDMAschedule.420.txt ns-234-leach/mit/leach_sims/TDMAschedule.400.txt ns-234-leach/mit/leach_sims/TDMAschedule.40.txt ns-234-leach/mit/leach_sims/TDMAschedule.380.txt ns-234-leach/mit/leach_sims/TDMAschedule.360.txt ns-234-leach/mit/leach_sims/TDMAschedule.340.txt ns-234-leach/mit/leach_sims/TDMAschedule.320.txt ns-234-leach/mit/leach_sims/TDMAschedule.300.txt ns-234-leach/mit/leach_sims/TDMAschedule.280.txt ns-234-leach/mit/leach_sims/TDMAschedule.260.txt ns-234-leach/mit/leach_sims/TDMAschedule.240.txt ns-234-leach/mit/leach_sims/TDMAschedule.220.txt ns-234-leach/mit/leach_sims/TDMAschedule.200.txt ns-234-leach/mit/leach_sims/TDMAschedule.20.txt ns-234-leach/mit/leach_sims/TDMAschedule.180.txt ns-234-leach/mit/leach_sims/TDMAschedule.160.txt ns-234-leach/mit/leach_sims/TDMAschedule.140.txt ns-234-leach/mit/leach_sims/TDMAschedule.120.txt ns-234-leach/mit/leach_sims/TDMAschedule.100.txt ns-234-leach/mit/leach_sims/TDMAschedule.0.txt ns-234-leach/mit/leach_sims/ ns-234-leach/mit/ ns-234-leach/mac/wireless-phy.h ns-234-leach/mac/wireless-phy.cc ns-234-leach/mac/phy.h ns-234-leach/mac/phy.cc ns-234-leach/mac/mac.cc ns-234-leach/mac/mac-sensor.h ns-234-leach/mac/mac-sensor.cc ns-234-leach/mac/mac-sensor-timers.h ns-234-leach/mac/mac-sensor-timers.cc ns-234-leach/mac/ll.h ns-234-leach/mac/channel.cc ns-234-leach/mac/ ns-234-leach/leach_test ns-234-leach/common/packet.h ns-234-leach/common/packet.cc ns-234-leach/common/mobilenode.cc ns-234-leach/common/ ns-234-leach/apps/app.h ns-234-leach/apps/app.cc ns-234-leach/apps/ ns-234-leach/Makefile.in ns-234-leach/Makefile ns-234-leach/ cp: cannot create directory `/keepwalking/ns-allinone-2.34/ns-2.34': No such file or directory cp: target `/keepwalking/ns-allinone-2.34/ns-2.34/apps' is not a directory cp: cannot create regular file `/keepwalking/ns-allinone-2.34/ns-2.34/mac': No such file or directory cp: cannot create regular file `/keepwalking/ns-allinone-2.34/ns-2.34/mac': No such file or directory cp: target `/keepwalking/ns-allinone-2.34/ns-2.34/mac' is not a directory cp: target `/keepwalking/ns-allinone-2.34/ns-2.34/mac' is not a directory cp: cannot create regular file `/keepwalking/ns-allinone-2.34/ns-2.34/mac': No such file or directory cp: target `/keepwalking/ns-allinone-2.34/ns-2.34/mac' is not a directory cp: cannot create regular file `/keepwalking/ns-allinone-2.34/ns-2.34/trace': No such file or directory cp: target `/keepwalking/ns-allinone-2.34/ns-2.34/common' is not a directory cp: cannot create regular file `/keepwalking/ns-allinone-2.34/ns-2.34/common': No such file or directory cp: cannot create regular file `/keepwalking/ns-allinone-2.34/ns-2.34/tcl/mobility': No such file or directory cp: cannot create regular file `/keepwalking/ns-allinone-2.34/ns-2.34/tcl/mobility': No such file or directory cp: cannot create regular file `/keepwalking/ns-allinone-2.34/ns-2.34/tcl/mobility': No such file or directory cp: cannot create regular file `/keepwalking/ns-allinone-2.34/ns-2.34/tcl/mobility': No such file or directory cp: cannot create regular file `/keepwalking/ns-allinone-2.34/ns-2.34/tcl/ex': No such file or directory cp: cannot create regular file `/keepwalking/ns-allinone-2.34/ns-2.34': No such file or directory cp: cannot create regular file `/keepwalking/ns-allinone-2.34/ns-2.34': No such file or directory cp: cannot create regular file `/keepwalking/ns-allinone-2.34/ns-2.34': No such file or directory cp: cannot create regular file `/keepwalking/ns-allinone-2.34/ns-2.34': No such file or directory keepwalking@ubuntu:~/ns-allinone-2.34/ns-2.34$ cd keepwalking@ubuntu:~$ ns may you please help me to solve this problem |
did you try to change the path in bash file to '/home/keepwalking/..' ?
|
Moved: This thread is more suitable in Linux-Software and has been moved accordingly to help your question get the exposure it deserves.
|
@Maytamer
Yes I did so but It still show me the same error can any one help me to solve this problem |
Post # 7, @ melokuhle.
Please edit post #7 to use code tags : Write [/code] after the text, and [code] at error text start. Or use the ( # ) button in the 'Advanced Editor' : > Edit > Go Advanced. http://www.linuxquestions.org/questi....php?do=bbcode About the errors : The first command to be used is : pwd .. which will reply with your location. I.e. you are either doing the command from a wrong location, or you have no "/keepwalking/ns-allinone-2.34/ns-2.34/tcl/mobility" .. |
How did you install gcc-4.3 on Ubuntu 11.04?
Thanks |
@magicbullet, post # 12 : Welcome to LQ.
No gcc-4.3 for Ubuntu 11.04, but you can then use gcc-4.2. *** EDIT *** EDIT: see post #22. Add hardy to etc/apt/sources.list, as described in post # 2. ( sudo gedit etc/apt/sources.list ). And next .. sudo apt-get update && sudo apt-get install g++-4.2 gcc-4.2 .. |
thanks for help me to solve the above problem now I came across another one may you please help me to solve it.
|
Hello every body
when I'm using the make command I get the following error: Code:
trace/cmu-trace.cc: In member function ‘void CMUTrace::format(Packet*, const char*)’: |
Quote:
============================================================ * Build tcl8.4.18 ============================================================ configure: WARNING: unrecognized options: --enable-gcc checking whether to use symlinks for manpages... no checking whether to compress the manpages... no checking whether to add a package name suffix for the manpages... no checking for gcc... gcc-4.2 checking whether the C compiler works... no configure: error: in `/home/wilson/Documents/ns-allinone-2.34/tcl8.4.18/unix': configure: error: C compiler cannot create executables See `config.log' for more details tcl8.4.18 configuration failed! Exiting ... Tcl is not part of the ns project. Please see www.Scriptics.com to see if they have a fix for your platform. I did this: export CC=gcc-4.2 CXX=g++-4.2 && ./install Before this, I have installed other gcc versions like 4.3, 3.3 but they all failed as well It seems all the gcc versions cannot compile, i.e. "checking whether the C compiler works... no" |
@magicbullet, post # 16.
'sudo apt-get install g++ g++-4.2' , etc. etc. GCC cannot be used for very much alone. You will have to install the g++** for all versions : g++ insures that the files required by gcc also will get installed. EDIT : See post # 22 .. |
Quote:
Anything else? Anyhow, by doing: sudo apt-get install g++-4.2 gcc-4.2, I still get the same error. I also did the following: sudo rm /usr/bin/gcc sudo ln -s /usr/bin/gcc-4.2 /usr/bin/gcc export CC=gcc-4.2 CXX=g++-4.2 && ./install Same error |
#18
Quote:
for dependency, when you type g++*. But there are problems with the older compilers in Ubuntu 11.04. Versions 3.3 , 3.4 , 4.2 don't work here either : Ubuntu 11.04, 64bits. I will look for a solution. And please tell, if you have a 64bits OS. The command : 'uname -a' will show. |
Quote:
|
Quote:
/usr/bin/ld: cannot find -lgcc_s collect2: ld returned 1 exit status make: *** [tcl2c++] Error 1 tclcl-1.19 make failed! Exiting ... |
# 20-21.
Quote:
There seems to be a workaround for the 32bits Ubuntu 11.04 (Not 64bits) : cd /usr/local/lib/ && sudo ln -s /lib/i386-linux-gnu/libgcc_s.so.1 libgcc_s.so cd /usr/local/include/ && sudo ln -s /usr/include/i386-linux-gnu/asm/ Works with : export CC=gcc-4.2 CXX=g++-4.2 && ./install ( 4.3 should be OK too. Where did you get the "4.3" ? ) .. |
Quote:
Btw, how do I remove all the linkages, i.e. sudo ln -s /lib/i386-linux-gnu/libgcc_s.so.1 libgcc_s.so and sudo ln -s /usr/include/i386-linux-gnu/asm/? |
# 23
cd /usr/local/lib/ && sudo rm libgcc_s* cd /usr/local/include/ && sudo rm -r asm/ |
Hello every body
may any one help me to change this pseudo code to and real protocol I m not familiar with C++ Code:
Initialization |
same question~
Quote:
|
Hi MayTamer,
Could you please advise me how to download "leach-setup.sh" file from your link provided? When i clicked that link, it doesn't work at all. Thank in advance. |
# 27, @leminh1009.
The link works OK here. However, I have uploaded the files too some time ago, to provide a "second source". leach-setup234.sh = leach-setup.sh https://docs.google.com/uc?id=0B7S25...download&hl=en ns234-leach-042011.tar.bz2 = ns-234-leach.tar.gz https://docs.google.com/uc?id=0B7S25...download&hl=en .. |
You need to add a declaration of format_rca in cmu-trace.h
Code:
void format_imep(Packet *p, int offset); Quote:
---------- Post added 05-10-11 at 08:11 PM ---------- |
Please see my reply on Post #29
Quote:
|
Please see my reply in Post #29
|
Hi there,
I am really a beginner and for a school project I have to make a simulation for LEACH protocol in ns. I have installed ns-allinone-2.34 on Ubuntu 11.04 and now i think i have to add the LEACH patch to ns. As i read here there are some steps to do but the problem is that i have installed "gcc version 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4) ". Can someone please help me with the exact steps for this version of gcc complier. Thank you in advance. Awaiting for your early reply. |
Hi MayTamer,
I set up successfully ns2 and leach but I've run ./test and I can't find leach.out. Could you please advise me this problem ? Quote: oot@bt:~/ns-allinone-2.34/ns-2.34# ./test num_nodes is set 3 warning: Please use -channel as shown in tcl/ex/wireless-mitf.tcl INITIALIZE THE LIST xListHead Loading connection pattern... Loading scenario file... Starting Simulation... channel.cc:sendUp - Calc highestAntennaZ_ and distCST_ highestAntennaZ_ = 1.5, distCST_ = 550.0 SORTING LISTS ...DONE! NS EXITING... root@bt:~/ns-allinone-2.34/ns-2.34# |
leminh1009, can you help me with my issue? please
|
Quote:
|
@ helyos, post # 32 : Welcome to LQ.
You can have as many compilers as you want, installed at the same time. Installing g++-4.2 : Read post # 2. And g++-4.3 : Must be manually installed. It's an Ubuntu Lucid package : http://packages.ubuntu.com/lucid/g++-4.3 Use with e.g.: export CC=gcc-4.3 CXX=g++-4.3 && ./install .. |
Thank you knudfl,
I have installed g++-4.2 and i have followed post #7 and at step 6: 6. Edit both “Makefile” & “Makefile.in” as following: CC = gcc-4.2 CPP = g++-4.2 Then when i gave ./configure it gave me : Code:
checking for tclsh8.4.18... no rares@ubuntu:/opt/ns-allinone-2.34/ns-2.34$ ./configure --with-tcl=/usr/share/tcltk/ : Code:
checking if STL works with namespace std... yes |
Hi everyone,
As previous, when I've been running ./test and I reached leach.out as following path: /root/ns-allinone-2.34/ns-2.34/ns-234-leach/mit/leach_sims but no result in it. Could you please help me solve this problem? Thanks in advance, |
#37, @ helyos : "" ... have followed post #7 and at step 6: ""
You mean post # 5 ? Post #5 assumes a working ns-allinone-2.34/. cd ns-allinone-2.34/ && export CC=gcc4.2 CXX=g++-4.2 && ./install ( If you have built ns-allinone-2.34/ to another location, it cannot be reused. You will have to start from scratch.) Another thing : Ubuntu 11.04 is 'worst choice' for ns-allinone-2.34/. Suggest : Use the 'Long Term Supported' Ubuntu 10.04. .. |
Quote:
|
Pfff.. now I am more closer to the end. So i installed the 'Long Term Supported' Ubuntu 10.04. In staled ns2 into the opt directory.
And now i passed from ./configure I am stucked when i enter $ make: Code:
rares@ubuntu:/opt/ns-allinone-2.34/ns-2.34$ make |
Hi,
Ok .. try running leach_test alone. See if the output is created. ( You have to manually create the folder leach_sims ) Once you run leach_test, in \mit\leach_sims\ folder, open leach.err. Do you have any error messages in it ? Quote:
|
#41, @helyos : No g++-4.3 unless you install it : Like all other prerequisites.
sudo apt-get install g++ g++-4.3 autoconf automake libtool \ libx11-dev libxmu-dev libxmu-headers libxt-dev cd ns-allinone-2.34/ && export CC=gcc-4.3 CXX=g++-4.3 && ./install .. |
@ knudfl When i have installed ns2 i have followed this http://www.anand-iyer.com/blog/?p=22 .
sudo apt-get install build-essential autoconf automake libxmu-dev gcc-4.3 was issued. ./install was issued too. --------------------------- Ok so i have tried your way but failed at /install it gave me : Code:
* Build tcl8.4.18 |
#44, @helyos.
Please do : sudo apt-get install g++ g++-3.4 I.e. the g++ components are required to have a working gcc(-any-version) Quote:
A good idea before compiling is to do these checks : 1) ls /usr/bin/gcc* 2) ls /usr/bin/g++* .. to verify the compiler spelling. ("gcc34" is commonly used too.) |
Ok then i had the error from post #29:
I have corrected that error conform to deepa but when i hit again "make": Code:
./common/packet.h:398: warning: deprecated conversion from string constant to ‘char*’ Thank you |
These are in cmu-trace.h
Code:
#ifdef MIT_uAMPS Quote:
|
Are there any files in leach_sims ? for example, leach.err ?
What do you mean by "and I reached leach.out" ??? And did you made a folder called "ns-234-leach". If so, have u modified the leach_test file (line that says dirname="mit/leach_sims") accordingly? Quote:
|
deepa_2111 i added what you told me. So, my cmu-trace.h file is :
Code:
/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- I ask this because when i run .test something it's working but I have some warning: Code:
/test Code:
INITIALIZE THE LIST xListHead |
@ Heylos, post #49
Congrats ! You have got it working. Whats you see in leach.err is not a warning/error. It is a status message that appears if your simulation is running. The warnings you see are ok. But if you want to remove them, in uamps.tcl, added the last paragraph i.e. Code:
Phy/WirelessPhy set bandwidth_ $opt(bw) Code:
# ===== Get rid of the warnings in bind ================================ Quote:
|
All times are GMT -5. The time now is 07:46 PM. |