Home Forums HCL Reviews Tutorials Articles Register Search Today's Posts Mark Forums Read
 LinuxQuestions.org how to integrate the "Resource/Energy" leach class into NS-2.34?
 User Name Remember Me? Password
 Linux - Software This 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

03-05-2013, 07:29 AM   #406
deepa_2111
Member

Registered: Apr 2011
Distribution: -
Posts: 182

Rep:

@lavender:

1) k=5 signifies the average no. of cluster heads during the entire simulation. Hence, in some rounds, it can be high, and in some low. If you read the PhD thesis by Heinzelman, you'll see that they have a plot which shows that the no. of cluster heads during simulation can vary between 0 and 10

2) Initially, the dist is set as max distance for every node. Once the nodes receive CH advertisements, they calculate the distance between themselves and the CH. Again, not that the distance is not the physical distance, but the communication distance.

For the CH, the dist is set as Max dist as it should be capable of transmitting over the entire network, and 139 is the physical distance between the 2 farthest nodes in the network

Quote:
 Originally Posted by @lavender please does any person face this? 1- when i implemented Leach i count the number of cluster heads in leach.out but the number was more than 5 nodes although i put k=5. 2- " 78: current cluster-head is 79, code is 2, dist is 29 " " 79: current cluster-head is 79, code is 2, dist is 139.0" " 80: current cluster-head is 84, code is 1, dist is 62 " Max distance for this simulation is 139.0 i miss this please help me? i think that dist is the distance between the sensor node and the cluster head. but in case of cluster head node how is dist=139 ??

Last edited by deepa_2111; 03-05-2013 at 07:30 AM.

1 members found this post helpful.
03-06-2013, 04:07 AM   #407
@lavender
LQ Newbie

Registered: Feb 2013
Posts: 15

Rep:
@ Deepa Thank you ^_^

but could you tell me if my simulation result is true or false?
Attached Files
 leach.pdf (193.1 KB, 141 views)

 03-06-2013, 03:19 PM #408 sonatasin LQ Newbie   Registered: Mar 2013 Posts: 11 Rep: hellow deepa 2111 , i integrate leach in ns-allinone 2.34 in ubuntu 10.04 i did all the steps one by one at the end when i checked leach.out i found it empty and leach.err has 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 "/home/rain/ns-allinone-2.34/ns-2.34/mit/rca/resources/ns-energy-resource.tcl" line 11) invoked from within "source.orig /home/rain/ns-allinone-2.34/ns-2.34/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) pleaaaaaaaaaaaaaaaaaaaaaaaaaaase help me , despite i didn't make any changes to the files that showed in the error
 03-08-2013, 02:26 AM #409 rakeshpanchiwala LQ Newbie   Registered: Dec 2012 Posts: 12 Rep: thank you all for helping me to install leach, Now i have installed leach and leach-c protocol but how to plot graph from leach.alive, leach.energy and leach.data file...... And how to calculate network lifetime and remaining energy for both leach and leach-c protocol.
03-10-2013, 09:08 PM   #410
doussa
LQ Newbie

Registered: Feb 2013
Posts: 29

Rep:
Quote:
 @deepa_2111 and @helyos, #75 i had removed all the warnings. 1. Make sure the bind code is there in wireless-phy.cc 2. Add the commands in uamps.tcl i think there was something else i did ... check the tcl-object.tcl file. I remember i followed instructions from there. Got it ! You need to set the variables in \tcl\lib\ns-default.tcl also :: Code: ```# ------------------------------------------------------ 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 # ------------------------------------------------------```
hi,
can you more explain this step because I don't understand where exactly I will insert this code on the file /ns-allinone-2.34/ns-2.34/mac/wireless-phy.cc.I try many time but it generate this error
error:expected initializer before ‘alive_’

 03-11-2013, 06:59 PM #411 emma166 LQ Newbie   Registered: Mar 2013 Posts: 14 Rep: i installed leach finally in my ns2.27 according to one of the threads in this site but when i do ./test and verify my energy in leach .out my nergy is > 200 j which is not correct because i have 100 nodes with 2 J each one i did all the modifications i even change my CC=gcc-4.4 and cpp=g++-4.4 in makefile.in i don't know what to do everything seems normal and i got no error when i do ./configure make clean make but my leach.out is false !! please help this is urgent for my project and i have no more time
 03-11-2013, 08:48 PM #412 emma166 LQ Newbie   Registered: Mar 2013 Posts: 14 Rep: [QUOTE=engr;4869599]alos my leach.out file is empty. while leach.err file has these errors invalid command name "Resource/Energy" while executing "Resource/Energy instproc setParams {args} { hi please could u tell me if u found a solution for that because i have the same problem ??? thx
 03-11-2013, 08:59 PM #413 emma166 LQ Newbie   Registered: Mar 2013 Posts: 14 Rep: [QUOTE=rakeshpanchiwala;4878908]Hello Everyone i have insalled ns2.34 in ubuntu12.04 with gcc-4.4. i also want to simulate leach in ns2.34 but i got error in leach.err file. add these changes: Edi the file in ns-allione-2.27/ns-2.27/mit/uAMPS/sims/uamps.tcl Replace lines #12 to 15 with these lines: source mit/rca/ns-ranode.tcl source mit/uAMPS/ns-bsapp.tcl source mit/uAMPS/extras.tcl source mit/uAMPS/stats.tcl Replace lines #20 to 22 with these lines: source mit/rca/resources/ns-resource-manager.tcl source mit/rca/resources/ns-energy-resource.tcl source mit/rca/resources/ns-neighbor-resource.tcl Follow the same logic of replacing \$env(RCA_LIBRARY) and \$env(uAMPS_LIBRARY) with mit/rca and mit/uAMPS correspondingly in the following files: ns-allione-2.27/ns-2.27/mit/uAMPS/sims/leach.tcl ns-allione-2.27/ns-2.27/mit/uAMPS/sims/leach-c.tcl Step 3: cd ns-allione-2.27/ns-2.27/ ./configure make clean make ./validate ./leach-test Check in ns-allione-2.27/ns-2.27/mit/leach_sims/leach.err if the file reports any errors Check the simulation outputs in ns-allione-2.27/ns-2.27/mit/leach_sims/leach.out
 03-11-2013, 09:02 PM #414 emma166 LQ Newbie   Registered: Mar 2013 Posts: 14 Rep: [QUOTE=monajh;4899843]hello all i am installing leach protocol in ns 2.34 try to do this : Edi the file in ns-allione-2.27/ns-2.27/mit/uAMPS/sims/uamps.tcl Replace lines #12 to 15 with these lines: source mit/rca/ns-ranode.tcl source mit/uAMPS/ns-bsapp.tcl source mit/uAMPS/extras.tcl source mit/uAMPS/stats.tcl Replace lines #20 to 22 with these lines: source mit/rca/resources/ns-resource-manager.tcl source mit/rca/resources/ns-energy-resource.tcl source mit/rca/resources/ns-neighbor-resource.tcl Follow the same logic of replacing \$env(RCA_LIBRARY) and \$env(uAMPS_LIBRARY) with mit/rca and mit/uAMPS correspondingly in the following files: ns-allione-2.27/ns-2.27/mit/uAMPS/sims/leach.tcl ns-allione-2.27/ns-2.27/mit/uAMPS/sims/leach-c.tcl Step 3: cd ns-allione-2.27/ns-2.27/ ./configure make clean make ./validate ./leach-test Check in ns-allione-2.27/ns-2.27/mit/leach_sims/leach.err if the file reports any errors Check the simulation outputs in ns-allione-2.27/ns-2.27/mit/leach_sims/leach.out 1 members found this post helpful.
 03-12-2013, 10:32 AM #415 rakeshpanchiwala LQ Newbie   Registered: Dec 2012 Posts: 12 Rep: thank you all for helping me to install leach, @ deepa 2111 I have installed leach and leach-c protocol but how to plot graph from leach.alive, leach.energy and leach.data file...... And how to calculate network lifetime and remaining energy for both leach and leach-c protocol. 1 members found this post helpful.
03-13-2013, 08:35 AM   #416
deepa_2111
Member

Registered: Apr 2011
Distribution: -
Posts: 182

Rep:
@lavender ...

I did not go through the 88 pages of your result .. I looked at the last page, and find that though the total data sent and the energy consumption seem to be fine,the nodes alive seem strange. Why does your simulation stop despite there being 33 nodes ? Generally, simulation stops when the no. of alive nodes = k-1

Quote:
 Originally Posted by @lavender @ Deepa Thank you ^_^ but could you tell me if my simulation result is true or false?

03-13-2013, 08:38 AM   #417
deepa_2111
Member

Registered: Apr 2011
Distribution: -
Posts: 182

Rep:
@rakesh (#415)
You can have 3 plots:
no.of nodes alive on Y axis and time on X axis
energy consumption on Y axis and time on X axis
total data received at BS on Y axis and time on X axis

from leach.alive, leach.energy and leach.data files respectively.

Try to see if your plots match those plots in the PhD thesis by Heinzelman. If they do, your simulation results are fine.

Quote:
 Originally Posted by rakeshpanchiwala thank you all for helping me to install leach, @ deepa 2111 I have installed leach and leach-c protocol but how to plot graph from leach.alive, leach.energy and leach.data file...... And how to calculate network lifetime and remaining energy for both leach and leach-c protocol.

03-13-2013, 08:42 AM   #418
deepa_2111
Member

Registered: Apr 2011
Distribution: -
Posts: 182

Rep:
@ emma166
Please go through the earlier posts on this link ... There has already been a discussion on this issue.
I had updated my fixes for this problem.
Hope it helps you.
I used ns2.35 though.

Quote:
 Originally Posted by emma166 i installed leach finally in my ns2.27 according to one of the threads in this site but when i do ./test and verify my energy in leach .out my nergy is > 200 j which is not correct because i have 100 nodes with 2 J each one i did all the modifications i even change my CC=gcc-4.4 and cpp=g++-4.4 in makefile.in i don't know what to do everything seems normal and i got no error when i do ./configure make clean make but my leach.out is false !! please help this is urgent for my project and i have no more time

 03-13-2013, 10:42 AM #419 nmmn134 LQ Newbie   Registered: Feb 2013 Posts: 3 Rep: Result of Leach & Leach-c @ deepa 2111 I already run Leach and Leach-c. But my result of leach is better than result of leach-c. why this for result ? Please help me ! Leach.out Code: ```....... At 400: Total Energy = 198.2718899939282 Total Data = 32287 Total Alive = 5 Cluster Head 60 broadcasting ADV at time 400.00005465351148 Cluster Head 71 broadcasting ADV at time 400.00012004899071 Cluster Head 88 broadcasting ADV at time 400.00013453761619 Cluster Head 65 broadcasting ADV at time 400.00020262053306 Cluster Head 64 broadcasting ADV at time 400.00022274211489 83 rcvd ADV_CH from 60 at 400.00028069347451 19 rcvd ADV_CH from 60 at 400.00028069638847 66 rcvd ADV_CH from 60 at 400.00028087165214 83 rcvd ADV_CH from 71 at 400.00052207979502 19 rcvd ADV_CH from 71 at 400.00052210070487 66 rcvd ADV_CH from 71 at 400.00052227427147 19 rcvd ADV_CH from 88 at 400.00071262933767 66 rcvd ADV_CH from 88 at 400.00071263804108 83 rcvd ADV_CH from 88 at 400.00071266675309 66 rcvd ADV_CH from 65 at 400.0009567402717 19 rcvd ADV_CH from 65 at 400.00095675996732 83 rcvd ADV_CH from 65 at 400.00095677573063 66 rcvd ADV_CH from 64 at 400.00115280768415 19 rcvd ADV_CH from 64 at 400.00115289704598 83 rcvd ADV_CH from 64 at 400.00115293189424 60: Current cluster-head is 60, code is 1, dist is 139.0 64: Current cluster-head is 64, code is 5, dist is 139.0 65: Current cluster-head is 65, code is 4, dist is 139.0 71: Current cluster-head is 71, code is 2, dist is 139.0 88: Current cluster-head is 88, code is 3, dist is 139.0 Warning! There are no nodes in this cluster (60)! Node 60 sending {{60 , 401.00487199999998}} to BS at time 401.01378397215711 Warning! There are no nodes in this cluster (64)! Node 64 sending {{64 , 401.00487199999998}} to BS at time 401.00956952399935 Warning! There are no nodes in this cluster (65)! Node 65 sending {{65 , 401.00487199999998}} to BS at time 401.00552772314461 Warning! There are no nodes in this cluster (71)! Node 71 sending {{71 , 401.00487199999998}} to BS at time 401.01068834159469 Warning! There are no nodes in this cluster (88)! Node 88 sending {{88 , 401.00487199999998}} to BS at time 401.01184276302342 BS Received data 65 , 401.00487199999998 from 65 at time 401.03786598556053 This represents data from nodes: 64 65 BS Received data 64 , 401.00487199999998 from 64 at time 401.07419583237009 This represents data from nodes: BS Received data 71 , 401.00487199999998 from 71 at time 401.10760269308474 This represents data from nodes: BS Received data 88 , 401.00487199999998 from 88 at time 401.14104507844246 This represents data from nodes: BS Received data 60 , 401.00487199999998 from 60 at time 401.17527433052982 This represents data from nodes: Node 60 sending {{60 , 404.36487199999999}} to BS at time 404.37002783861857 Node 64 sending {{64 , 404.36487199999999}} to BS at time 404.36640139361589 Node 65 sending {{65 , 404.36487199999999}} to BS at time 404.37143595620506 Node 71 sending {{71 , 404.36487199999999}} to BS at time 404.37135039974913 Node 88 sending {{88 , 404.36487199999999}} to BS at time 404.36548136582303 BS Received data 88 , 404.36487199999999 from 88 at time 404.39781968124208 This represents data from nodes: BS Received data 64 , 404.36487199999999 from 64 at time 404.43102770198664 This represents data from nodes: BS Received data 60 , 404.36487199999999 from 60 at time 404.46694219699128 This represents data from nodes: BS Received data 71 , 404.36487199999999 from 71 at time 404.50055275123918 This represents data from nodes: BS Received data 65 , 404.36487199999999 from 65 at time 404.53292621862096 This represents data from nodes: 64 65 Node 71 is DEAD!!!! At 404.6000000000235: Total Energy = 198.38865199430379 Total Data = 32291 Total Alive = 4 Simulation complete.``` Leach-c.out Code: ```H 47 must now perform comp and xmit to BS. compute_energy = 4.0000000000000003e-05 Node 47 sending {{47 , 307.84411645897018}} to BS at time 307.85325084629716 BS Received data 47 , 307.84411645897018 from 47 at time 307.87755722422162 This represents data from nodes: 75 75 sending data {75 , 307.99621037444587} to 47 at 307.99621037444587 (dist = 25.357299175391802) Node 75 removing sensing energy = 0 J. CH 47 received data (75 , 307.99621037444587) from 75 at 308.02051645897018 CH 47 must now perform comp and xmit to BS. compute_energy = 4.0000000000000003e-05 Node 47 sending {{47 , 308.02051645897018}} to BS at time 308.02622177452736 BS Received data 47 , 308.02051645897018 from 47 at time 308.05052815245182 This represents data from nodes: 75 75 sending data {75 , 308.17261037444587} to 47 at 308.17261037444587 (dist = 25.357299175391802) Node 75 removing sensing energy = 0 J. CH 47 received data (75 , 308.17261037444587) from 75 at 308.19691645897018 CH 47 must now perform comp and xmit to BS. compute_energy = 4.0000000000000003e-05 Node 47 sending {{47 , 308.19691645897018}} to BS at time 308.20383700000002 Node 62 is DEAD!!!! At 308.20000000000158: Total Energy = 199.14768268729432 Total Data = 31012 Total Alive = 4 Simulation complete.```
 03-14-2013, 01:37 AM #420 rakeshpanchiwala LQ Newbie   Registered: Dec 2012 Posts: 12 Rep: @deepa 2111 Thanks for your reply........... I have plotted my graph as you described but i want to plot graph of network lifetime and remaining energy. so please give me quick reply its urgent. I also want to compare that results in xgraph but it only plots one graph. If possible to compare in xgraph then Please give me quick reply.

 Tags leach, leach-warning50, ns2, ns2 ns234, pegasis

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is Off HTML code is Off Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post shojaru Linux - Newbie 0 03-05-2009 04:23 AM baosheng Linux - Software 2 09-28-2007 11:02 AM hauneboo Linux - Laptop and Netbook 1 11-29-2005 09:08 AM kornerr Linux - General 1 03-10-2005 12:07 PM KeithSpook Linux - Hardware 4 03-03-2004 12:21 PM

LinuxQuestions.org

All times are GMT -5. The time now is 07:29 AM.

 Contact Us - Advertising Info - Rules - LQ Merchandise - Donations - Contributing Member - LQ Sitemap -