hello to all,

@clederson - my thesis is on "detection and isolation of selfish nodes in
mobile ad hoc network."

if from a total of 50 nodes, let's say 10 nodes energy level reach to 0,
then their simulation should stop so that i can say i have isolated them
from the network. this is exactly i want..

how can i use node_off() function in mobilenode.cc file to do this or should
i use node_on=false    as suggested by hemant??

plz reply..


yogesh

On Wed, Jun 1, 2011 at 1:40 AM, Clederson <clederso...@gmail.com> wrote:

> The code I used (the first one) was useful only to know WHEN the first node
> dies.
> When it happens the ns2 must exit, or abort.
> Dont know what you exactly need.
>
>
> On Tue, May 31, 2011 at 2:21 AM, yogesh bansal 
> <yogesh.uiet...@gmail.com>wrote:
>
>>
>> with the help of hemang advice, i changed my code from this
>>
>> *// MY INCLUDED CODE
>>  if (energy_model_->energy() <= 0) {
>>     fprintf(stdout,"DEATH -t %f -n %d -e %.20f", s.clock(),address_,
>> energy_model_->energy());
>>     fprintf(stderr,"DEATH -t %f -n %d -e %.20f", s.clock(),address_,
>> energy_model_->energy());
>>   //exit(1);
>>  }
>> // END OF MY INCLUDED CODE*
>>
>> to this
>>
>> *// MY INCLUDED CODE
>> if (energy_model_->energy() <= 0) {
>>         fprintf(stdout,"DEATH -t %f -n %d -e %.20f", s.clock(),address_,
>> energy_model_->node_off());
>>          fprintf(stderr,"DEATH -t %f -n %d -e %.20f", s.clock(),address_,
>> energy_model_->node_off());
>>       //exit(1);
>>      // return TCL_ERROR;
>> }
>> // END OF MY INCLUDED CODE*
>>
>> in mobilenode.cc file.
>>
>>
>> is it ok guys?? itz urgent.. am i wrong at some point.. i ll be very
>> thankful to u..
>>
>> where should i write return TCL_ERROR;
>>
>>
>> On Tue, May 31, 2011 at 12:37 AM, yogesh bansal <yogesh.uiet...@gmail.com
>> >wrote:
>>
>> > thanks a lot hemang for giving me so valueable idea....
>> >
>> >
>> >
>> >
>> >
>> > yogesh
>> >
>> >
>> > On Tue, May 31, 2011 at 12:18 AM, hemang kothari <
>> > hemangkothari...@gmail.com> wrote:
>> >
>> >> you can make it by using on/off function provided by mobilenode.cc file
>> >>
>> >> when energy reach to zero it will automatically switch off.
>> >>
>> >> On Tue, May 31, 2011 at 6:01 AM, yogesh bansal <yogesh.uiet.it@
>> gmail.com>wrote:
>> >>
>> >>>
>> >>> hi to all ns users,
>> >>>
>> >>> hello sir/mam,
>> >>>
>> >>> plz plz help me.
>> >>>
>> >>> i want to stop the simulation of all those nodes having energy 0 and
>> >>> simulation of other nodes should continue having energy greater than
>> 0.
>> >>>
>> >>>
>> >>> I've been trying to abort the execution in the Mobilenode::log_energy
>> >>> method
>> >>> in mobilenode.cc file in common folder.
>> >>> I'm doing something like this:
>> >>>
>> >>> *//this code is already present.*
>> >>> void
>> >>> MobileNode::log_energy(int flag)
>> >>> {
>> >>>  if (!log_target_)
>> >>>   return;
>> >>>  Scheduler &s = Scheduler::instance();
>> >>>  if (flag) {
>> >>> //    sprintf(log_target_->pt_->buffer(),"N -t %f -n %d -e %f",
>> >>> s.clock(),
>> >>>   sprintf(log_target_->pt_->buffer(),"N -t %f -n %d -e %.20f",
>> >>> s.clock(),address_, energy_model_->energy());
>> >>>  } else {
>> >>>   sprintf(log_target_->pt_->buffer(),"N -t %f -n %d -e 0 ", s.clock(),
>> >>>     address_);
>> >>>  }
>> >>> *// MY INCLUDED CODE
>> >>>  if (energy_model_->energy() <= 0) {
>> >>>   fprintf(stdout,"DEATH -t %f -n %d -e %.20f", s.clock(),
>> >>>     address_, energy_model_->energy());
>> >>>   fprintf(stderr,"DEATH -t %f -n %d -e %.20f", s.clock(),
>> >>>     address_, energy_model_->energy());
>> >>>   exit(1);
>> >>>  }
>> >>> // END OF MY INCLUDED CODE*
>> >>>  log_target_->pt_->dump();
>> >>> }
>> >>>
>> >>>
>> >>> *// by exit(1) the network exits. so where should i use exit??
>> >>>
>> >>>
>> >>> if i use return (TCL_ERROR); where should i write this in tcl file or
>> >>> here??
>> >>> *
>> >>>
>> >>
>> >>
>> >
>>
>
>
>
> --
> Clederson
>
>

Reply via email to