how to integrate the "Resource/Energy" leach class into NS-2.34?
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hellow everyody
me too i had the same error melokuhle had when i tried to setup the leach on ns2.34 using above steps:
trace/cmu-trace.cc:1327: error: ‘format_rca’ was not declared in this scope
trace/cmu-trace.cc: At global scope:
trace/cmu-trace.cc:1523: error: no ‘void CMUTrace::format_rca(Packet*, int)’ member function declared in class ‘CMUTrace’
make: *** [trace/cmu-trace.
Dears,
I had the same problem mealokuhle had when i tried to install leach on ns2.34 using above steps, the errors are:
trace/cmu-trace.cc:1327: error: ‘format_rca’ was not declared in this scope
trace/cmu-trace.cc: At global scope:
trace/cmu-trace.cc:1523: error: no ‘void CMUTrace::format_rca(Packet*, int)’ member function declared in class ‘CMUTrace’
make: *** [trace/cmu-trace.
can anyone help plz asap as i need it badly
thanks in advance
Thanks exidus, it's working now, the make file executed without errors but when i type ./test and try to run the .nam file i found there are only 3 nodes and there is no connection between them, so i need to know how can i see the simulation of the leach i mean i need to see the clusters and cluster heads formed and sending we receiving the packets after the clusters formed
also if i want to add something to the packets sent and received in leach , where should i add my code?
Dears,
I got this error in leach.err file when i run the test file:
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)
Answer for your problem is in post #58
You must change path to sources in file /mit/uAMPS/sims/umaps.tcl
For example you must change all 7 sources from this: source $env(RCA_LIBRARY)/ns-ranode.tcl
to this source /your_path_to_ns2/ns-2.34/mit/rca/ns-ranode.tcl
@exidus: thank you exidus for your support to me. thanks GOD the leach now is running without errors but i have 2 questions:
The first question is:
there are some files in mit/leach_sims i don't know their structure and can't understand their content and i tried to search for them in leach files to know when and where they are filled but i can't find anything:
Leach.Data
leach.alive
Leach.save1
Leach.save2
the second question that i want to add a security to all leach packets/messages. i mean i want to encrypt all sent messages in leach protocol before they are sent and decrypt them on receiving, could you tell me where exactly(in which files) i can add my code for encryption & decryption at each sent and receive function in leach protocol
Dears,
i want to know the name of the trace file i should analyze it when running the leach using ./test as i found alto of .tr (like out.tr, 694demo.tr and leach.tr ) files and i don't know which one i should analyze it for leach performance
also the name file names 694demo.nam when i run it , it simulated 2 nodes with no connection , while in leach_test file the used topology is :topology_file="mit/uAMPS/sims/100nodes.txt". which contains 100 nodes not only 3 and i can't see the clusters formation in the nam simulation, how can i see it?
I am trying to add LEACH to NS2.35 on Cygwin by following these steps but I am getting this error when I make:
Code:
queue/priqueue.cc: In member function `virtual void PriQueue::recv(Packet*, Hand
ler*)':
queue/priqueue.cc:94: error: `PT_MDART' was not declared in this scope
make: *** [queue/priqueue.o] Error 1
Any ideas why?
Thanks
Quote:
Originally Posted by MayTamer
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!
1. Main output file is leach.out. There are information about which file is a cluster head, which node send a message etc. You can see total spend energz at the end of file. Can you check a number of total energy at the end of simulation when you simulate 100 nodes?
2. If you want to add security to leach packets, I think that a good place for it will be a files mit/rca/rcagent.cc and mit/uAMPS/bsagent.cc. There are function for sending and receiving packets. But I am not sure if my idea is correct.
3. Trace file is for leach_test file is leach.tr in ns-2.34 directory. I think that nam file is not created for leach_test.
Thank you. I have managed to implement LEACH on ns2.34. However, I don't know how to use the test output files such as leach.energy and leach.data, etc. Is there any recommended resource that explains them?
Regards
Quote:
Originally Posted by exidus
@monazEssam
1. Main output file is leach.out. There are information about which file is a cluster head, which node send a message etc. You can see total spend energz at the end of file. Can you check a number of total energy at the end of simulation when you simulate 100 nodes?
2. If you want to add security to leach packets, I think that a good place for it will be a files mit/rca/rcagent.cc and mit/uAMPS/bsagent.cc. There are function for sending and receiving packets. But I am not sure if my idea is correct.
3. Trace file is for leach_test file is leach.tr in ns-2.34 directory. I think that nam file is not created for leach_test.
---------- Post added 08-25-11 at 08:49 PM ----------
Thanks a lot all mates. I have created a simple how to, called: "Installing NS and LEACH on ubuntu" in PDF format and I want to share my experinces collected from this usefull site:
Code:
I suppose that you have:
1. Ubuntu installed on your machine and I suggest ubuntu 10.10.
2. ns-2.34 is installed in "/opt/ns-allinone-2.34" this is path is optional but it could be easier if this path changed because the default directory of LEACH is "/opt/ns-allinone-2.34/ns-2.34".
3. The gcc-4.3 compiler. If not, First you MUST install gcc-4.3 and g++-4.3. It seems gcc-4.2 and g++-4.2 will work but I suggest 4.3:
Add following lines to end of the /etc/apt/sources.list by:
sudo gedit /etc/apt/sources.list
deb http://76.73.4.58/ubuntu/ maverick-updates main
deb http://76.73.4.58/ubuntu/ maverick universe
deb http://security.ubuntu.com/ubuntu maverick-security main
deb http://security.ubuntu.com/ubuntu maverick-security universe
Now save the file and close, then refresh your catalog by:
sudo apt-get update
Now gcc-4.3 and g++-4.3 will be available. install them:
sudo apt-get install gcc-4.3 and g++-4.3
If you prefer 4.2, simlpy add 'hardy' instead of 'maverick'. And:
sudo apt-get install gcc-4.2 and g++-4.2
Download and install LEACH
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"
farab@ubuntu:~$ cd /opt/ns-allinone-2.34/ns-2.34/
farab@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. You need to add a declaration of format_rca in cmu-trace.h found in the directory "yourpath/ns-allinone-2.34/ns-2.34/”.
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
// This holds all the tracers added at run-time
static PacketTracer *pktTrc_;
};
And the flowing lins to end of that:
#ifdef MIT_uAMPS
#define ADV_CHAR 'A'
#define REQ_CHAR 'R'
#define DATA_CHAR 'D'
#endif
8. Then, modify the uamps.tcl in the /opt/ns-allinone-2.34/ns-2.34/mit/uAMPS/sims/ folder and replace:
$env(uAMPS_LIBRARY) with yourpath/ns-allinone-2.34/ns-2.34/mit/rca
and
$env(uAMPS_LIBRARY) with yourpath/ns-allinone-2.34/ns-2.34/mit/uAMPS
9. You need to set the variables in \tcl\lib\ns-default.tcl
# ------------------------------------------------------
Phy/WirelessPhy set alive_ 1
Phy/WirelessPhy set Efriss_amp_ 100e-12
Phy/WirelessPhy set Etwo_ray_amp_ 0.013e-12
Phy/WirelessPhy set EXcvr_ 50e-9
Phy/WirelessPhy set sleep_ 0
Phy/WirelessPhy set ss_ 1
Phy/WirelessPhy set dist_ 0
# ------------------------------------------------------
once u modify the .tcl, make sure you do a 'make clean' and a 'make depend'
10. run the following commands:
farab@ubuntu:/opt/ns-allinone-2.34/ns-2.34$./configure
farab@ubuntu:/opt/ns-allinone-2.34/ns-2.34$make clean
farab@ubuntu:/opt/ns-allinone-2.34/ns-2.34$make
farab@ubuntu:/opt/ns-allinone-2.34/ns-2.34$sudo chmod 777 -R ns-allinone-2.34
If the previous commands passed successfully then you are ready to test your "Leach" by running ./test:
farab@ubuntu:/opt/ns-allinone-2.34/ns-2.34$./test
check the file "leach.err", if no error reported then go to "leach.out" and enjoy your results!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.