ScenarioManager

Package: inet.common.scenario

ScenarioManager

simple module

C++ definition

~ScenarioManager is for setting up and controlling simulation experiments. You can schedule certain events to take place at specified times, like changing a parameter value, changing the bit error rate of a connection, removing or adding connections, removing or adding routes in a routing table, etc, so that you can observe the transient behavior.

~ScenarioManager executes a script specified in XML. It has a few built-in commands, while other commands are dispatched to be carried out by given simple modules. (The C++ class of these simple modules' needs to implement the ~IScriptable interface, and the processCommand() method must be redefined accordingly).

An example script:

<scenario>
    <set-param t="10" module="host[1].mobility" par="speed" value="5"/>
    <set-param t="20" module="host[1].mobility" par="speed" expr="20+10"/>
    <set-param t="30" module="host[1].mobility" par="displayStringTextFormat" value='p: %p\nv: %v'/>
    <set-param t="30" module="host[1].mobility" par="displayStringTextFormat" expr='"p: %p\nv: %v"'/>
    <at t="50">
        <set-param module="host[2].mobility" par="speed" value="10"/>
        <set-param module="host[3].mobility" par="speed" value="10"/>
        <connect src-module="host[2]" src-gate="ppp[0]"
                 dest-module="host[1]" dest-gate="ppp[0]"
                 channel-type="DatarateChannel">
            <param name="datarate" value="10Mbps" />
            <param name="delay" value="0.1us" />
        </connect>
    </at>
    <at t="60">
        <disconnect src-module="host[2]" src-gate="ppp[0]" />
    </at>
    <at t="2s">
        <initiate module="Router2" operation="shutdown"/>
        <shutdown module="Router2"/>
        <start module="Router2"/>
        <crash module="Router2"/>
    </at>
</scenario>

Built-in commands: <at>, <set-param>, <set-channel-param>, <create-module>, <delete-module>, <connect>, <disconnect>, <initiate>, <startup>, <shutdown>, <crash>

All commands have a t attribute which carries the simulation time at which the command has to be carried out. You can group several commands to be carried out at the same simulation time using <at>, and then only the <at> command is needed to have a t attribute.

Supported attributes:

  • <set-param>: module, par, value|expr. module: path to module (required) par: name of settable parameter of module (required) value: new value for parameter expr: expression to calculate new value of parameter Note: value and expr are exclusive, one is required
  • <set-channel-param>: src-module, src-gate|dest-module, par, value|expr. src-module: path to source module (required) src-gate: name of source gate dest-module: path to destination module par: name of settable parameter of module (required) value: new value for parameter expr: expression to calculate new value of parameter Note: src-gate and dest-module are exclusive, one is required; value and expr are exclusive, one is required; if dest-module is present, there must be exactly one connection between src-module and dest-module (which may be bidirectional); if src-gate references an inout gate, the parameter will be set on the channel of both directions.
  • <connect>: src-module, src-gate, dest-module, dest-gate, channel-type src-module: path to source module (required) src-gate: name of source gate (required) dest-module: path to destination module (required) dest-gate: name of destination gate (required) channel-type: fully qualified NED type of connection channel (required), e.g., DatarateChannel
    • <param>: name, value|expr name: name of settable parameter of channel (required) value: new value for parameter expr: expression to calculate new value of parameter Note: value and expr are exclusive, one is required
  • <disconnect>: src-module, src-gate|dest-module src-module: path to source module (required) src-gate: name of source gate dest-module: path to destination module Note: src-gate and dest-module are exclusive, one is required; if dest-module is present, there must be exactly one connection between src-module and dest-module (which may be bidirectional); if src-gate references an inout gate, both directions will be disconnected.
  • <create-module>: parent, submodule, type, vector parent: parent module path (required) submodule: name of created module (required) type: NED type of created module (required), e.g., PingApp vector: boolean, if true, the module is created as a vector element with the next index, if false, the module is created as a single module, if missing, detects existing vector by submodule name
  • <delete-module>: module module: path to module (required)

Inheritance diagram

The following diagram shows inheritance relationships for this type. Unresolved types are missing from the diagram.

Used in

Name Type Description
AODVNetwork network (no description)
AutomaticFailureProtectionShowcase network (no description)
AutomaticMultipathConfigurationShowcase network (no description)
Byte_order network (no description)
ClientServerWithSM network (no description)
ClientServerWithSM network (no description)
DHCPShutdownReboot network (no description)
Dplpmtud network (no description)
DsdvNetwork network

TODO

DYMONetwork network

TODO

DynamicRadioNetwork network (no description)
DynamicTest network (no description)
DynamicTest network (no description)
EigrpTestNetwork network (no description)
EigrpTestNetwork network (no description)
EigrpTestNetwork network (no description)
EigrpTestNetwork network (no description)
EigrpTestNetwork network (no description)
EigrpTestNetwork network (no description)
EigrpTestNetwork network (no description)
EigrpTestNetwork network (no description)
EigrpTestNetwork network (no description)
EmptyNetwork network (no description)
Freshness network (no description)
GPSRNetworkRandom network

TODO

GptpAndTasShowcase network (no description)
HostsWithBus network (no description)
HostsWithHub network (no description)
InterfaceNetworkType network (no description)
LDPTEST network (no description)
ManualConfigurationShowcase network (no description)
MixedNetwork network

TODO Auto-generated network

MobileNetwork network (no description)
Mrp4 network (no description)
MrpRing network (no description)
multiple_areas2 network (no description)
NClients network (no description)
NeighborCacheTest network (no description)
Network network (no description)
Network2 network (no description)
NetworkPathRIPShowcase network (no description)
OSPF_Area_External_Forwarding network (no description)
OSPF_AreaTest network (no description)
OSPF_BackboneAndOneStubTest network (no description)
OSPF_BackboneAndTwoStubsTest network (no description)
OSPF_BackboneTest network (no description)
OSPF_Default_Route_Distribution network (no description)
OSPF_LoopAvoidance network (no description)
OSPF_mininet network (no description)
OSPF_Route_Selection network (no description)
OSPF_Suboptimal network (no description)
OSPF_Summary_LSA network (no description)
OspfNetwork network (no description)
Persistent_congestion network (no description)
RIPInfinityCountTest network (no description)
RipNetworkA network (no description)
RipNetworkB network (no description)
RipNetworkC network (no description)
RouterLSA network (no description)
RSVPTE4 network

Example network to demonstrate Rsvp-TE.

RSVPTE4 network

Example network to demonstrate Rsvp-TE.

RSVPTE4 network

Example network to demonstrate Rsvp-TE.

RSVPTE4 network

Example network to demonstrate Rsvp-TE.

RSVPTE4 network

Example network to demonstrate Rsvp-TE.

ShortestPath network (no description)
SimpleRREQ network (no description)
SimpleRREQ2 network (no description)
SimpleTest network (no description)
SwitchNetwork network (no description)
TopologyChange network (no description)
TwoMasterClocksRingGptpShowcase network (no description)
UdpClientServer network (no description)
v3_2_routers network (no description)
VirtualLink network (no description)
VirtualLink_2 network (no description)

Extends

Name Type Description
SimpleModule simple module

Base module for all INET simple modules.

Parameters

Name Type Default value Description
displayStringTextFormat string "total %c changes, %l left\nnext at: %t"

Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information

script xml xml("")

Properties

Name Value Description
class ScenarioManager
display i=block/control
labels node

Source code

//
// ~ScenarioManager is for setting up and controlling simulation experiments.
// You can schedule certain events to take place at specified times,
// like changing a parameter value, changing the bit error rate of
// a connection, removing or adding connections, removing or
// adding routes in a routing table, etc, so that you can observe the
// transient behavior.
//
// ~ScenarioManager executes a script specified in XML. It has a few
// built-in commands, while other commands are dispatched to be carried out
// by given simple modules. (The C++ class of these simple modules' needs
// to implement the ~IScriptable interface, and the `processCommand()` method
// must be redefined accordingly).
//
// An example script:
//
// <pre>
// <scenario>
//     <set-param t="10" module="host[1].mobility" par="speed" value="5"/>
//     <set-param t="20" module="host[1].mobility" par="speed" expr="20+10"/>
//     <set-param t="30" module="host[1].mobility" par="displayStringTextFormat" value='p: %p\nv: %v'/>
//     <set-param t="30" module="host[1].mobility" par="displayStringTextFormat" expr='"p: %p\nv: %v"'/>
//     <at t="50">
//         <set-param module="host[2].mobility" par="speed" value="10"/>
//         <set-param module="host[3].mobility" par="speed" value="10"/>
//         <connect src-module="host[2]" src-gate="ppp[0]"
//                  dest-module="host[1]" dest-gate="ppp[0]"
//                  channel-type="ned.DatarateChannel">
//             <param name="datarate" value="10Mbps" />
//             <param name="delay" value="0.1us" />
//         </connect>
//     </at>
//     <at t="60">
//         <disconnect src-module="host[2]" src-gate="ppp[0]" />
//     </at>
//     <at t="2s">
//         <initiate module="Router2" operation="shutdown"/>
//         <shutdown module="Router2"/>
//         <start module="Router2"/>
//         <crash module="Router2"/>
//     </at>
// </scenario>
// </pre>
//
// Built-in commands: <at>, <set-param>, <set-channel-param>,
// <create-module>, <delete-module>, <connect>, <disconnect>,
// <initiate>, <startup>, <shutdown>, <crash>
//
// All commands have a t attribute which carries the simulation time
// at which the command has to be carried out. You can group several commands
// to be carried out at the same simulation time using <at>, and
// then only the <at> command is needed to have a t attribute.
//
// Supported attributes:
// - <set-param>: module, par, value|expr.
//       module: path to module (required)
//       par: name of settable parameter of module (required)
//       value: new value for parameter
//       expr: expression to calculate new value of parameter
//       Note: value and expr are exclusive, one is required
// - <set-channel-param>: src-module, src-gate|dest-module, par, value|expr.
//       src-module: path to source module (required)
//       src-gate: name of source gate
//       dest-module: path to destination module
//       par: name of settable parameter of module (required)
//       value: new value for parameter
//       expr: expression to calculate new value of parameter
//       Note: src-gate and dest-module are exclusive, one is required;
//             value and expr are exclusive, one is required;
//             if dest-module is present, there must be exactly one connection
//             between src-module and dest-module (which may be bidirectional);
//             if src-gate references an inout gate, the parameter will be set
//             on the channel of both directions.
// - <connect>: src-module, src-gate, dest-module, dest-gate, channel-type
//       src-module: path to source module (required)
//       src-gate: name of source gate (required)
//       dest-module: path to destination module (required)
//       dest-gate: name of destination gate (required)
//       channel-type: fully qualified NED type of connection channel (required), e.g., `ned.DatarateChannel`
//     - <param>: name, value|expr
//       name: name of settable parameter of channel (required)
//       value: new value for parameter
//       expr: expression to calculate new value of parameter
//       Note: value and expr are exclusive, one is required
// - <disconnect>: src-module, src-gate|dest-module
//       src-module: path to source module (required)
//       src-gate: name of source gate
//       dest-module: path to destination module
//       Note: src-gate and dest-module are exclusive, one is required;
//       if dest-module is present, there must be exactly one connection
//       between src-module and dest-module (which may be bidirectional);
//       if src-gate references an inout gate, both directions will be disconnected.
// - <create-module>: parent, submodule, type, vector
//       parent: parent module path (required)
//       submodule: name of created module (required)
//       type: NED type of created module (required), e.g., `inet.applications.pingapp.PingApp`
//       vector: boolean, if true, the module is created as a vector element with the next index,
//               if false, the module is created as a single module,
//               if missing, detects existing vector by submodule name
// - <delete-module>: module
//       module: path to module (required)
//
simple ScenarioManager extends SimpleModule
{
    parameters:
        @class(ScenarioManager);
        xml script = default(xml("<script></script>"));

        // Format for the text displayed above the module icon.
        // Directives: %c: numChanges, %d: numDone, %l: numLeft, %t: nextEventTime, %n: nextEventName
        displayStringTextFormat = default("total %c changes, %l left\nnext at: %t");

        @display("i=block/control");
        @labels(node,mpls-node);
}

File: src/inet/common/scenario/ScenarioManager.ned