stop simulation

80 views
Skip to first unread message

prakash dey

unread,
Oct 19, 2009, 3:57:17 AM10/19/09
to Castalia Simulator
hi friends

how can I stop simulation when first node dies???
Message has been deleted

Dimos

unread,
Oct 20, 2009, 9:31:37 AM10/20/09
to Castalia Simulator
Dear Prakash,

please refer to http://www.omnetpp.org/doc/omnetpp33/manual/usman.html#sec188

You can also terminate and handle errors by using opp_error() method:
http://www.omnetpp.org/doc/omnetpp33/manual/usman.html#sec232

Dimos

Dimos

unread,
Oct 20, 2009, 9:49:06 AM10/20/09
to Castalia Simulator
Oh, I forgot to mention where to place the methods indicated in the
user manual for terminating the simulation...

Normally, a node may die either because it is out of energy, or
because of physical damages (e.g. a wildfire burns the main board
etc.).

In file $CASTALIA_HOME/src/Node/Resource_Manager/
ResourceGenericManager.cc you will find the consumeEnergy() and
destroyNode() methods.

Each node is an instance of a compound module, and thus, when it
consumes energy or gets damaged, these two functions are called
respectively, independently for each node.

Normally the simulation won't stop when a node becomes dead. However,
you can follow one the following tricks to do so:

---- (A) Stop simulation from within Resource_Manager module ----
Inside consumeEnergy() method's body, locate the following block:
if(remainingEnergy < amount)
At the end of this block (but still inside it), you can add a
simulation termination method call.
Similarly, you may add a simulation termination method call at the end
of the main body of method destroyNode(void).

---- (B) Stop simulation from within Application module ----
If you notice, inside methods consumeEnergy() and destroyNode() there
is code which sends special control messages of kind
RESOURCE_MGR_OUT_OF_ENERGY and RESOURCE_MGR_DESTROY_NODE to the
following modules:
- sensor device manager
- application
- network
- Mac
- Radio
When these modules receive such control messages, they get disabled,
and stop processing incoming messages.
It is should be now clear, that you can alternatively add a simulation
termination method call inside the code of the modules listed above,
at the points that they handle the control messages of type
RESOURCE_MGR_OUT_OF_ENERGY or/and RESOURCE_MGR_DESTROY_NODE

Hope that helps,
Dimos



On 20 Oct, 14:31, Dimos <dimosthe...@gmail.com> wrote:
> Dear Prakash,
>
> please refer tohttp://www.omnetpp.org/doc/omnetpp33/manual/usman.html#sec188

Prakash Dey

unread,
Oct 20, 2009, 1:57:45 PM10/20/09
to castalia-...@googlegroups.com
thanks a lot i think this is going to work

Prakash Dey

unread,
Oct 31, 2009, 6:29:33 AM10/31/09
to castalia-...@googlegroups.com
On 10/20/09, Dimos <dimos...@gmail.com> wrote:
>
hello dimos
i used endSimulation() in the module inconsumeEnergy() but the
simulation stops giving following message in
Castalia-primaryoutput.txt file

<!> Module (ResourceGenericManager) SN.node[7].nodeResourceMgr:
Simulation stopped with endSimulation().


Calling finish() at end of Run #1...

<!> Error in module (ResourceGenericManager)
SN.node[0].nodeResourceMgr: Simulation stopped with endSimulation().

undisposed: (MAC_ControlMessage)
SN.node[7].networkInterface.Radio.state command strobe MAC->radio
undisposed: (MAC_GenericFrame) SN.node[7].networkInterface.Radio.MAC
Data frame (1614.644523)

End run of OMNeT++


>
Reply all
Reply to author
Forward
0 new messages