LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   running leach on ns2.34 (https://www.linuxquestions.org/questions/linux-software-2/running-leach-on-ns2-34-a-860250/)

Stanley33 02-02-2011 11:15 AM

running leach on ns2.34
 
I am trying to run leach ns2.27 on ns2.34, can any one give me a clue of how to do it am currently using ubuntu 10.4
thank you

Snark1994 02-02-2011 11:24 AM

What do you mean "how to run"? I was under the impression LEACH was a wireless protocol... Can you explain exactly what you're trying to do, where you've looked for information and at what point in the process you've got stuck? Thankyou :)

knudfl 02-02-2011 11:33 AM

Welcome to LQ. .. .. :) ..

You can have as many versions of ns-allinone-2.x installed, as you want.

Installing ns-allinone-2.27 on Ubuntu, post #3 here
http://www.linuxquestions.org/questi...10-a-782356/#3

More info : LQ Search , Tag = leach
Or LQ Search , keyword = leach

..

Stanley33 02-03-2011 11:11 AM

leach simulation
 
I want to run a simulation on leach (protocol )so I downloaded an ns2.27 package of it, currently I have ns2.34 installed
I am having problem compiling it

is there any modification that needs to be made
or
I would not mind if I can get a link where I can download a package that can run on ns2.34

knudfl 02-03-2011 11:32 AM

NS-allinone-2.27 :
Quote:

I am having problem compiling it
Did you follow all the mentioned 27 steps ?
You will have to read everything , post #3 here
http://www.linuxquestions.org/questi...10-a-782356/#3

EDIT : New package ns-234-leach.tar.gz + instructions here
http://www.linuxquestions.org/questi...34-a-870368/#5
( LEACH for ns-2.34 : posts 68 - 78 - 88 , etc., here
http://www.linuxquestions.org/questi...379/page5.html )

..

deepa_2111 04-05-2011 11:26 AM

hey !

I have just added LEACH to Ns 2.35. HAd to make a couple of changes, but it has passed all the validation tests.
Now, while trying to run LEACH, am stuck at ::

couldn't read file "/usr/local/ns-allinone-2.35-RC4
/ns-2.35/mit/rca
/ns-ranode.tcl": no such file or directory
while executing
"source.orig {/usr/local/ns-allinone-2.35-RC4
/ns-2.35/mit/rca
/ns-ranode.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)/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_leach.tcl" line 187)

I know this is from uamps.tcl. I know the file is there, and the env variables are set. Have seen this question on a couple of forums, but not able to figure out how to fiz this. Please help !

knudfl 04-05-2011 01:36 PM

Post #6 @deepa_2111 : Welcome to LQ. .. .. :) ..

Please edit post #6 to use code tags:
[/code] at code end, and [code] at code text start.
http://www.linuxquestions.org/questi....php?do=bbcode

Why ns-allinone-2.35-RC4, when RC7 is available ?
http://www.isi.edu/nsnam/dist/release/

And /usr/local/ is not a very convenient location for ns-allinone-2.xx.
Default is /home/<user-name>/ns2/ns-allinone-2.xx/.

It is not quite clear, what you are doing. "run LEACH" : What do you mean ?
Please specify the used command.
(Most things are probably described here, posts # 68...# 140 .... ..
http://www.linuxquestions.org/questi...79/page10.html )

LEACH for ns-2.34 : The latest files and install instructions are here
http://www.linuxquestions.org/questi...34-a-870368/#5
..

deepa_2111 04-05-2011 02:57 PM

Hey ..

Thanks a lot ...

I've got it running. Regarding ns-allinone-2.35-RC4, it is coz I'm running it on cygwin, and I think this is the most stable version.
I was trying to run the leach_test file, and i had the issues i mentioned above. I fixed it by manually typing the path to remove any extra spaces.

I am going to analyse my results now.

Thanks for the "code" suggestions.

deepa_2111 04-07-2011 10:00 AM

Hello,

I was analysing the results, and I come across this discrepancy (which I see mentioned on a couple of forum posts as well).

If I start with 2J energy per node, with 100 nodes, the maximum energy that can be expended in the network is 200J.
But, leach.out shows me::

Code:

At 548.60000000005618:
                Total Energy = 373.70924811232476
                Total Data = 56353
                Total Alive = 4

Simulation complete

This is impossible. How can the network expend 373.7J of energy.

Further, the document "Porting and Verifying AROS to NS in Linux/UNIX" (by Francisco José Mosqueira Sáez) (http://www.idt.mdh.se/utbildning/exj...les/TR0509.pdf) mentions this issue on page 33, with an explanation::

Quote:

The problem was in the medium, implemented by a class that is not modified by the MIT code.
That is the reason why it was so difficult to find the problem. In ns2.1b5,
there is already
implemented a wireless channel. But this channel behaves like a normal cable connected to every
node. This channel also simulated a more accurate wireless propagation delay than a normal cable.
When a packet arrives to a node, the network interface of the receiving node decides if the power of
transmission was enough to allow the reception of the packet.
In ns2.31,
the channel propagates the signal to every node listening to the channel within a
radius of propagation. To calculate this radius, propagation equations are used based on the
transmitted power of the wireless interface.
How do I go about fixing this ?? Help !!

MayTamer 04-24-2011 02:08 AM

Quote:

Originally Posted by deepa_2111 (Post 4317071)
Hello,

I was analysing the results, and I come across this discrepancy (which I see mentioned on a couple of forum posts as well).

If I start with 2J energy per node, with 100 nodes, the maximum energy that can be expended in the network is 200J.
But, leach.out shows me::

Code:

At 548.60000000005618:
                Total Energy = 373.70924811232476
                Total Data = 56353
                Total Alive = 4

Simulation complete

This is impossible. How can the network expend 373.7J of energy.

Further, the document "Porting and Verifying AROS to NS in Linux/UNIX" (by Francisco José Mosqueira Sáez) (http://www.idt.mdh.se/utbildning/exj...les/TR0509.pdf) mentions this issue on page 33, with an explanation::



How do I go about fixing this ?? Help !!

The total energy and other statistics are calculated through the tcl file "/mit/uAMPS/stats.tcl". the reason for this unreasonable value is that the expended energy of the node is added to the total energy even when the node is dead, while it should be zero. you can check the individual expended energies by reviewing the output file "leach.energy", so you need to check the status of the current node if it's still alive. otherwise the expended value should be zero.

MayTamer 04-25-2011 12:06 AM

Quote:

Originally Posted by MayTamer (Post 4334166)
The total energy and other statistics are calculated through the tcl file "/mit/uAMPS/stats.tcl". the reason for this unreasonable value is that the expended energy of the node is added to the total energy even when the node is dead, while it should be zero. you can check the individual expended energies by reviewing the output file "leach.energy", so you need to check the status of the current node if it's still alive. otherwise the expended value should be zero.

I've wrote this simple awk file https://docs.google.com/uc?id=0BzLWx...download&hl=en to calculate the actual cumulative expanded energy by all nodes over time, it's for Leach-C. to be executed for Leach just comment or delete the first 'if condition'. download it into "/mit/leach_sims" and run the command:
wsn@ubuntu:/opt/ns-allinone-2.34/ns-2.34/mit/leach_sims$ awk -f TotEn.awk leach-c.energy // for Leach-C
wsn@ubuntu:/opt/ns-allinone-2.34/ns-2.34/mit/leach_sims$ awk -f TotEn.awk leach.energy // for Leach

knudfl 04-25-2011 02:33 AM

Post # 11 : Thank you.

But the link isn't working. Shared settings in 'Google Docs':

<awk file> → Actions > Share > Sharing Settings > Change >
> Anyone with a link >>> Save ( > Close ).

deepa_2111 04-25-2011 11:18 PM

Hello ,

Thanks for ur replies. I modified the code as well ::

In \mac\Wireless-Phy.cc:
Code:

if (energy_)
          {
                if(alive_ != 0) // Deepa
                {
                        if (energy_->remove(pktEnergy(Pt_, PXcvr_, ch->size())) != 0)
                        {
                                  printf("alive = 0\n");
                                  alive_ = 0;
                        }
                } // Deepa
          }

i.e., add the <code> if(alive_ != 0) </code> wherever the remove energy function is called,

and in mit\rca\energy.cc :
Code:

int EnergyResource::remove(double amount)
{
  double new_level = energy_level_ - amount;

  if(new_level >= 0 )
  {
          energy_level_ = new_level;
          expended_ += amount;
  } // Deepa

check if the new_level is greater or equal to 0. if it is not, energy cant be removed

deepa_2111 04-25-2011 11:20 PM

Have you noticed that LEACH-C performs worse than LEACH though actually it is supposed to give better performance ? In a previous post, I see someone has mentioned this same observation ... not sure if it has been rectified though.

MayTamer 04-26-2011 12:18 AM

Quote:

Originally Posted by deepa_2111 (Post 4336330)
Have you noticed that LEACH-C performs worse than LEACH though actually it is supposed to give better performance ? In a previous post, I see someone has mentioned this same observation ... not sure if it has been rectified though.

I'm sorry to miss the shared settings. Well, for Homogeneous wireless network (i.e. eq_energy=1), Leach-C performance should be worse because it's a centralised protocol and will consume more energy during the set-up phase than Leach. but for Heterogeneous network (eq_energy=0) Leach-C should came up with a better performance than Leach. However, I've run both protocols for Heterogeneous network and to my surprise, Leach still outperforms Leach-C. I've checked the file ns_leach.tcl, which is called for both protocols, and found that when eq_energy=0 then the calculated threshold of Leach would differ from the conventional one, taking into consideration the proportional current energy of the node to the total energy. hence enhancing the clusterheads election. i'm still confused about this point because Leach is local/distributed clustering algorithm so how the nodes would calculate the total energy without exchanging messages ??? However, if you force Leach to use it's conventional threshold for Heterogeneous then it'll perform worse.

keepwalking 05-05-2011 05:29 AM

hello every body

I'm doing my research based on leader election algorithms for wireless sensor network, may any one who knows other leader election algorithms help me with it installation packages and instruction so that I can add it on ns2.34.

Thank you.

deepa_2111 05-06-2011 12:00 AM

Quote:

Originally Posted by keepwalking (Post 4347182)
hello every body

I'm doing my research based on leader election algorithms for wireless sensor network, may any one who knows other leader election algorithms help me with it installation packages and instruction so that I can add it on ns2.34.

Thank you.

Hello ... What do you mean by leader selection algorithm ? Do you mean cluster heads as in LEACH ?

keepwalking 05-08-2011 01:58 AM

@deepa_2111

Yes I mean cluster heads as in LEACH
thanks

deepa_2111 05-10-2011 12:07 PM

Hmm ...

I am finding a lot of discrepancies with the actual LEACH paper. For example, the avg energy/round plot for different clusters. After porting, I find that the values are 5 times that in the LEACH paper. Do you guys have the same findings ? Can you post your plots if you have ?

deepa_2111 05-10-2011 06:46 PM

What did you want help with ? Adding LEACH code to ns-2 ?

Quote:

Originally Posted by keepwalking (Post 4349779)
@deepa_2111

Yes I mean cluster heads as in LEACH
thanks


keepwalking 05-11-2011 02:17 AM

adding LEACH to Ns2.34
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*)’:
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.o] Error 1
luuh@ubuntu:~/ns-allinone-2.34/ns-2.34$ ns
ns: command not found

can any one help me to to solve this problem.

deepa_2111 05-11-2011 08:08 AM

Quote:

Originally Posted by keepwalking (Post 4352852)
adding LEACH to Ns2.34
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*)’:
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.o] Error 1
luuh@ubuntu:~/ns-allinone-2.34/ns-2.34$ ns
ns: command not found

can any one help me to to solve this problem.

That is because the format_rca declaration has not been added to cmu-trace.h file. Add the code in #ifdef ... #endif
Code:

...
void        format_tora(Packet *p, int offset);
        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


keepwalking 05-12-2011 08:02 AM

hey Deepa 2111

I have added the code you said I must add but it still shows the same error. Please look at this code below for class cmu-trace.h

Code:

/* -*-        Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*-
 *
 * Copyright (c) 1997 Regents of the University of California.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *        This product includes software developed by the Computer Systems
 *        Engineering Group at Lawrence Berkeley Laboratory.
 * 4. Neither the name of the University nor of the Laboratory may be used
 *    to endorse or promote products derived from this software without
 *    specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $Header: /cvsroot/nsnam/ns-2/trace/cmu-trace.h,v 1.28 2009/01/15 06:23:49 tom_henderson Exp $
 */

/* Ported from CMU/Monarch's code, nov'98 -Padma.*/

#ifndef __cmu_trace__
#define __cmu_trace__

#include "trace.h"
#include "god.h"

#ifndef __PRETTY_FUNCTION__
#define __PRETTY_FUNCTION__ ("")
#endif /* !__PRETTY_FUNCTION__ */

/* ======================================================================
  Global Defines
  ====================================================================== */
#define        DROP            'D'
#define        RECV            'r'
#define        SEND            's'
#define        FWRD            'f'

// change wrt Mike's code
#define EOT            'x'



#define TR_ROUTER        0x01
#define TR_MAC                0x02
#define TR_IFQ                0x04
#define TR_AGENT        0x08

#define TR_PHY                0x10

#define DROP_END_OF_SIMULATION                "END"
#define        DROP_MAC_COLLISION                "COL"
#define DROP_MAC_DUPLICATE                "DUP"
#define DROP_MAC_PACKET_ERROR                "ERR"
#define DROP_MAC_RETRY_COUNT_EXCEEDED        "RET"
#define DROP_MAC_INVALID_STATE                "STA"
#define DROP_MAC_BUSY                        "BSY"
#define DROP_MAC_INVALID_DST            "DST"
#define DROP_MAC_SLEEP                  "SLP"  // smac sleep state

#define DROP_RTR_NO_ROUTE                "NRTE"  // no route
#define DROP_RTR_ROUTE_LOOP                "LOOP"  // routing loop
#define DROP_RTR_TTL                    "TTL"  // ttl reached zero
#define DROP_RTR_QFULL                  "IFQ"  // queue full
#define DROP_RTR_QTIMEOUT              "TOUT"  // packet expired
#define DROP_RTR_MAC_CALLBACK          "CBK"  // MAC callback
#define DROP_RTR_SALVAGE                "SAL"

#define DROP_IFQ_QFULL                  "IFQ"  // no buffer space in IFQ
#define DROP_IFQ_ARP_FULL              "ARP"  // dropped by ARP
#define DROP_IFQ_FILTER                "FIL"

#define DROP_OUTSIDE_SUBNET            "OUT"  // dropped by base stations if received rtg updates from nodes outside its domain.

#define MAX_ID_LEN        3
#define MAX_NODE        4096

/**
 * This class allows a dynamic library to define the tracing format
 * for newly defined packet types
 *
 */
class PacketTracer
{
        public:
                PacketTracer();
                virtual ~PacketTracer();
                void setNext(PacketTracer *next);
                PacketTracer *getNext();
                int format_unknow(Packet *p, int offset, BaseTrace *pt_, int newtrace);
        protected:
                virtual int format(Packet *p, int offset, BaseTrace *pt_, int newtrace) = 0;        //return 0 if the packet is unknown
                PacketTracer *next_;
};


class CMUTrace : public Trace {
public:
        CMUTrace(const char *s, char t);
        void        recv(Packet *p, Handler *h);
        void        recv(Packet *p, const char* why);

        static void addPacketTracer(PacketTracer *pt);


private:
        char        tracename[MAX_ID_LEN + 1];
        int        nodeColor[MAX_NODE];
        int    tracetype;
        MobileNode *node_;
        int    newtrace_;

        //<zheng: ns 2.27 removed the following part, but we need it to control the broadcast radius>
        static double  bradius;
        static double  radius_scaling_factor_;
        static double  duration_scaling_factor_;
        static void calculate_broadcast_parameters();
        //</zheng>

        int initialized() { return node_ && 1; }
        int node_energy();
        int        command(int argc, const char*const* argv);
        void        format(Packet *p, const char *why);

        void    nam_format(Packet *p, int offset);

        void        format_phy(Packet *p, int offset);
       
        void        format_mac_common(Packet *p, const char *why, int offset);
        void    format_mac(Packet *p, int offset);
        void    format_smac(Packet *p, int offset);
        void        format_ip(Packet *p, int offset);

        void        format_arp(Packet *p, int offset);
        void    format_hdlc(Packet *p, int offset);
        void        format_dsr(Packet *p, int offset);
        void        format_msg(Packet *p, int offset);
        void        format_tcp(Packet *p, int offset);
        void    format_sctp(Packet *p, int offset);
        void        format_rtp(Packet *p, int offset);
        void        format_tora(Packet *p, int offset);
        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_impe(Packet *p, int offset);
#endif

        // This holds all the tracers added at run-time
        static PacketTracer *pktTrc_;

};

#endif /* __cmu_trace__ */


deepa_2111 05-12-2011 08:40 AM

Hey !

You have not added the format_rca declaration. You have added a "format_impe" declaration. This maybe why the error still persists.
i am not sure if the #ifdef is case sensitive. If it is, change "MIt_uAMPS" to "MIT_uAMPS"

Quote:

Originally Posted by keepwalking (Post 4354278)
hey Deepa 2111

I have added the code you said I must add but it still shows the same error. Please look at this code below for class cmu-trace.h

Code:

        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_impe(Packet *p, int offset);
#endif

        // This holds all the tracers added at run-time
        static PacketTracer *pktTrc_;

};

#endif /* __cmu_trace__ */



keepwalking 05-16-2011 01:54 AM

Thank deepa 2111 for helping me to so out the problem for cra format.

now it gives me the following error and may you please help me to solve this problem.

Code:

trace/cmu-trace.cc:48:17: error: rca.h: No such file or directory
trace/cmu-trace.cc: In member function ‘void CMUTrace::format_rca(Packet*, int)’:
trace/cmu-trace.cc:1532: error: ‘ADV_CHAR’ was not declared in this scope
trace/cmu-trace.cc:1536: error: ‘REQ_CHAR’ was not declared in this scope
trace/cmu-trace.cc:1540: error: ‘DATA_CHAR’ was not declared in this scope
make: *** [trace/cmu-trace.o] Error 1
luuh@ubuntu:~/ns-allinone-2.34/ns-2.34$


deepa_2111 05-16-2011 04:18 PM

@ Keepwalking,

Pls check out this link ::

http://www.linuxquestions.org/questi...368/page4.html

I have answered this question there

deepa_2111 05-17-2011 08:18 AM

Keepwalking,

I got your mail. you said
Quote:

and when I'm running the ./test command it says permission denied can you please help me to solve this problem.
I had this problem when I didn't have admin privileges to modify the folders. I guess that is the problem you have too .

deepa_2111 06-04-2011 02:11 AM

Does ns2.1b5 also show similar results ????

Quote:

Originally Posted by MayTamer (Post 4334166)
The total energy and other statistics are calculated through the tcl file "/mit/uAMPS/stats.tcl". the reason for this unreasonable value is that the expended energy of the node is added to the total energy even when the node is dead, while it should be zero. you can check the individual expended energies by reviewing the output file "leach.energy", so you need to check the status of the current node if it's still alive. otherwise the expended value should be zero.


asrmaster 06-15-2011 10:05 AM

Inconsistent results
 
Hi Deepa,

Thanks for your reply, it solved the problem of calculating the energy consumption.

But I still see problems in the results. For ns-2.1b5 simulation results are approximately as follows:

Parameters:
energy: 2j energy per node;
number of nodes: 100;
network area: 100m x 100m;
number of clusters: 5;
distance from the base station: 75m;

Approximate results in ns-2.1b5:
Lifetime: 560
Amount of data being sent: between 62,000 and 64,000;

Approximate results in ns-2.34:
Lifetime: between 480 and 550;
Amount of data being sent: between 45000 and 55000;

That is, the ns-2.34 the results have a greater sway, with much variation. While ns-2.1b5, the results vary less. Moreover, ns-2.1b5, the results are better than the ns-2.34.

Does anyone know how to explain these differences?

NOTE: Please disregard any typos because my English is not very good.

Quote:

Originally Posted by deepa_2111 (Post 4336329)
Hello ,

Thanks for ur replies. I modified the code as well ::

In \mac\Wireless-Phy.cc:
Code:

if (energy_)
          {
                if(alive_ != 0) // Deepa
                {
                        if (energy_->remove(pktEnergy(Pt_, PXcvr_, ch->size())) != 0)
                        {
                                  printf("alive = 0\n");
                                  alive_ = 0;
                        }
                } // Deepa
          }

i.e., add the <code> if(alive_ != 0) </code> wherever the remove energy function is called,

and in mit\rca\energy.cc :
Code:

int EnergyResource::remove(double amount)
{
  double new_level = energy_level_ - amount;

  if(new_level >= 0 )
  {
          energy_level_ = new_level;
          expended_ += amount;
  } // Deepa

check if the new_level is greater or equal to 0. if it is not, energy cant be removed


asrmaster 06-15-2011 12:58 PM

Complementing, the network consumption in LEACH-C, running on the ns-2.1b5, is around 198j (without your changes in WirelessPhy.cc and Energy.cc) to 100 nodes, with 2j energy, ie it is calculated correctly.

deepa_2111 06-15-2011 11:12 PM

hey asrmaster,

from what i have analysed, the problem is due to the manner in which the channel is implemented. I have posted my reply on the other thread. i havent run on ns2.1b5, but ns2.35 gives me the smae resutls as yours

asrmaster 06-16-2011 11:48 PM

Hi deepa,

Thanks for your reply and help.

But, I have a question.
The your results in ns-2.35 are equivalent to my results in the ns-2.1b5 or ns-2.34?

Quote:

Originally Posted by deepa_2111 (Post 4387123)
hey asrmaster,

from what i have analysed, the problem is due to the manner in which the channel is implemented. I have posted my reply on the other thread. i havent run on ns2.1b5, but ns2.35 gives me the smae resutls as yours


deepa_2111 06-17-2011 11:32 PM

hi asrmaster,

sorry for being unclear.
my ns2.35 results match your ns2.34 results.

am in the process of fixing the channel. Can you please do me a favour ? Can you send me your ns2.1b5 's leach.out ?
can you please enable 'quiet' (set the parameter to 0) in uamps.tcl, re-run it and send me the output file leach.out (in ns2.1b5) ? just want to verify what happens when a cluster head dies on the ns2.1b5 version.

also, can you tell me which version of linux you used to install ns2.1b5 ?

Your help would be appreciated a lot .. thanks in advance
Deepa

louk_88 08-04-2011 07:30 AM

Energy consumption
 
Hello

Can u give me the methode to calculate the energy consumption of nodes in NS2 (scripts or tcl code)? or any other information that can help me.

Thank you

subzero155 08-23-2011 11:27 AM

LEACH on ns2.35
 
@deepa_2111. Can you please explain how you added LEACH on ns2.35? I am using cygwin. Thanks a lot


Quote:

Originally Posted by deepa_2111 (Post 4314733)
hey !

I have just added LEACH to Ns 2.35. HAd to make a couple of changes, but it has passed all the validation tests.
Now, while trying to run LEACH, am stuck at ::

couldn't read file "/usr/local/ns-allinone-2.35-RC4
/ns-2.35/mit/rca
/ns-ranode.tcl": no such file or directory
while executing
"source.orig {/usr/local/ns-allinone-2.35-RC4
/ns-2.35/mit/rca
/ns-ranode.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)/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_leach.tcl" line 187)

I know this is from uamps.tcl. I know the file is there, and the env variables are set. Have seen this question on a couple of forums, but not able to figure out how to fiz this. Please help !


narendra kumar patel 09-27-2011 01:47 AM

mit leach in ns2.34
 
i have installed ns-leach2.34 in ns2.34.the test command in run successfully. but in leach.out file the following errors occured.plz help me. what should i done.





couldn't read file "/home/narendra/simulator/NS-allinone-2.34/NS-2.34/mit/rca/ns-ranode.tcl": no such file or directory
while executing
"source.orig /home/narendra/simulator/NS-allinone-2.34/NS-2.34/mit/rca/ns-ranode.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)/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)

upender 11-13-2011 12:56 AM

help for ns2
 
could you please help me
im doing project with ns2
i have one problem that is how to make a node to dead randomly in ns2

upender 11-13-2011 12:59 AM

pleese help me
 
how to make deadnodes in ns2 help me it's urrgenttt............

scoder 03-04-2012 12:41 PM

@deepa_2111...
i am also trying to implement LEACH on ns2.35.
How did you go about this?? Which patch of LEACH did you use??
Its a little important for my project to kickstart. Kindly help!!
Need steps in brief.
Thx in advance.

scoder 03-05-2012 11:18 AM

LEACH in ns2.35?
 
hi all;
anyone of you has implemented LEACH in ns2.35??
Kindly guide me..as i am stalled because of this.
Please help!!

knudfl 03-05-2012 11:29 AM

# 40, @ scoder.

Post # 249 here
http://www.linuxquestions.org/questi...79/page17.html

scoder 03-05-2012 11:34 AM

@knudfl
I went through the link earlier also. deepa_2111 has not given detailed steps.
Need to implement LEACH to kickstart things.
Any other link??
@deepa_2111...are you reading this?? for benefit of beginners like me, kindly give us steps you took in ns2.35.

knudfl 03-05-2012 03:44 PM

# 42.

Well, you know that you can install leach on ns-2.34, if you have a usable OS.

I.e. you can have as many versions of ns-allinone-2.xx as you want,
installed at the same time.

.

shailu 05-09-2012 03:18 AM

@ knudfl

can u please tell me what pp means in tcl script that is provided in nsleach.

knudfl 05-10-2012 04:48 AM

#44
Quote:

... what pp means in tcl script that is provided in ns-leach.tcl
Don't know.
Another example using pp :
http://wiki.tcl.tk/1821
>>> Powerpoint - export slides to images.
$pp Quit
unset pp

I guess you will have to learn tcl to find an answer.

.

deepa_2111 05-11-2012 06:13 AM

@ Shailu (#44)

pp is a function that prints only when a certain flag is set to 1 (unlike puts). This function is described in one of the tcl files in the mit folder.

Please study properly all the tcl and cc files in the mit library before asking these kind of questions.

nzny 07-13-2012 06:39 PM

leach-energy calculation
 
Hi asrmaster,

I've also tried the code suggested by deepa,but the total expended energy is still much greater than the total initial energy. Could you show me your modified code?

Quote:

Originally Posted by asrmaster (Post 4386517)
Hi Deepa,

Thanks for your reply, it solved the problem of calculating the energy consumption.

But I still see problems in the results. For ns-2.1b5 simulation results are approximately as follows:

Parameters:
energy: 2j energy per node;
number of nodes: 100;
network area: 100m x 100m;
number of clusters: 5;
distance from the base station: 75m;

Approximate results in ns-2.1b5:
Lifetime: 560
Amount of data being sent: between 62,000 and 64,000;

Approximate results in ns-2.34:
Lifetime: between 480 and 550;
Amount of data being sent: between 45000 and 55000;

That is, the ns-2.34 the results have a greater sway, with much variation. While ns-2.1b5, the results vary less. Moreover, ns-2.1b5, the results are better than the ns-2.34.

Does anyone know how to explain these differences?

NOTE: Please disregard any typos because my English is not very good.


nzny 07-13-2012 06:45 PM

leach-energy calculation
 
Hello deepa,

I've tried your code and did make clean and make. However, I still got the total expended energy is much greater than the total initial energy. Did I miss any important step? Really appreciated if you could reply. TQ

Quote:

Originally Posted by deepa_2111 (Post 4336329)
Hello ,

Thanks for ur replies. I modified the code as well ::

In \mac\Wireless-Phy.cc:
Code:

if (energy_)
          {
                if(alive_ != 0) // Deepa
                {
                        if (energy_->remove(pktEnergy(Pt_, PXcvr_, ch->size())) != 0)
                        {
                                  printf("alive = 0\n");
                                  alive_ = 0;
                        }
                } // Deepa
          }

i.e., add the <code> if(alive_ != 0) </code> wherever the remove energy function is called,

and in mit\rca\energy.cc :
Code:

int EnergyResource::remove(double amount)
{
  double new_level = energy_level_ - amount;

  if(new_level >= 0 )
  {
          energy_level_ = new_level;
          expended_ += amount;
  } // Deepa

check if the new_level is greater or equal to 0. if it is not, energy cant be removed


madhudora 02-15-2013 01:24 PM

number of nodes alive
 
hello @deepa_2111
i modified the code in energy.cc file and wireless_phy.cc file.. and i got my energy decreased.. but still my number of alive nodes are 4.. Is there any way to increase it?????

emma166 03-11-2013 07:48 PM

Quote:

Originally Posted by nzny (Post 4727497)
Hi asrmaster,

I've also tried the code suggested by deepa,but the total expended energy is still much greater than the total initial energy. Could you show me your modified code?

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


All times are GMT -5. The time now is 08:04 PM.