Re: [ns] how to stop the simulation of all those nodes having energy 0.. plz plz help me...

2011-06-02 Thread yogesh bansal

if anyone knows or can help me with this, plz reply asap.


yogesh

On Wed, Jun 1, 2011 at 5:49 PM, yogesh bansal yogesh.uiet...@gmail.comwrote:

 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=falseas 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.comwrote:


 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.it@
 gmail.comwrote:

  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.comwrote:
  
 
  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





Re: [ns] how to stop the simulation of all those nodes having energy 0.. plz plz help me...

2011-06-01 Thread yogesh bansal

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=falseas 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.comwrote:


 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.comwrote:
 
 
  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




Re: [ns] how to stop the simulation of all those nodes having energy 0.. plz plz help me...

2011-05-31 Thread Clederson

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.comwrote:


 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.comwrote:
 
 
  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


Re: [ns] how to stop the simulation of all those nodes having energy 0.. plz plz help me...

2011-05-30 Thread yogesh bansal

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.comwrote:

 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...@gmail.comwrote:


 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??
 *






Re: [ns] how to stop the simulation of all those nodes having energy 0.. plz plz help me...

2011-05-30 Thread yogesh bansal

at line 195 in mobilenode.cc file, this line of code is written.
*
} else if (strcmp(argv[1], off) == 0) {
energy_model()-node_on() = false;*

here we are doing node_on()=false. to stop the simulation.

i m actually modifying the code in this function
MobileNode::log_energy(int flag)in mobilenode.cc file.
{
* if (energy_model_-energy() = 0) {*
 * // here is how can i write node_on()=false;
  ** // my aim is when the node
energy reach to 0, then it stops the simulation by calling the function
node_off()ornode_on() = false.
}*

plz help me in this code ll be very thankful to you.


yogesh


On Tue, May 31, 2011 at 1:21 AM, yogesh bansal yogesh.uiet...@gmail.comwrote:

 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.comwrote:

 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...@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??
 *