Package Overview
The Sim (Simulation) package is a collection of Kernel Procedures concerned with providing simulation-wide services.
Many protocols and algorithms have the need to determine time values, so that they can measure time differences and schedule future events. For instance, self interrupts are scheduled for absolute times, which are usually computed as the sum of fixed intervals and the current simulation time. The KP op_sim_time() returns the current value of the global simulation clock. The KP op_sim_base_time_get() returns the start time for a network model.
There are several ways in which a simulation can terminate. Automatic termination, which stops a simulation when the global simulation clock reaches the value specified for the duration preference, is the most common strategy. Simulations can also be terminated based on dynamic conditions. When an executing process determines that the simulation stopping condition has been attained, it can invoke the KP op_sim_end(), which immediately (but cleanly) terminates the simulation.
As simulations execute, they can communicate information to users using a variety of mechanisms, such as:
- standard screen I/O features of the host operating system
- standard file I/O features of the host operating system
- procedures from graphics libraries
When short textual messages need to be printed to indicate the progress of a simulation, the most convenient mechanism is the KP op_sim_message(), which prints a three-line message onto the standard output device. You can print error messages that include the current state of the simulation with op_sim_error().
Information about the progress of a simulation or the application version being used is available via the KP op_sim_info_get().
Developing simulations usually entails a debugging phase, in which special tools are used to confirm the proper execution of process logic. These tools include the debug mode of the simulation and special print statements which provide information about dynamic execution. The KP op_sim_debug() combines both tools by permitting debug print statements to be permanently embedded into simulations; they will only print when the simulation is executing under the debug mode.
When running on Linux, you can programmatically force a checkpoint to be taken with op_sim_checkpoint(). Any files opened directly (that is, not via Riverbed APIs) should be registered using op_sim_file_register_fopen() or op_sim_file_register_open() so that they can be reopened after a restart.