op_sim_time()

Abstract

Obtains the current simulation time.

Syntax

op_sim_time ()
Argument Type Description
no arguments

Return Type

double

Current simulation time. This double-precision floating-point number represents the simulation time in seconds, starting with the begin simulation interrupt, at which point op_sim_time() returns a value of zero. (See special case in Details section.)

Example

Excerpt from: example model (models/std/base); process model (acb_fifo); state (svc_start); enter execs

/* get a handle on packet at head of subqueue 0 */
/* (this does not remove the packet) */
pkptr = op_subq_pk_access (0, OPC_QPOS_HEAD);

/* determine the packets length (in bits) */
pk_len = op_pk_total_size_get (pkptr);

/* determine the time required to complete */
/* service of the packet */
pk_svc_time = pk_len / service_rate;

/* schedule an interrupt for this process */
/* at the time where service ends.  */
op_intrpt_schedule_self (op_sim_time () + pk_svc_time, 0);

/* the server is now busy. */
server_busy = 1;

Details

The current simulation time is a double-precision, floating-point number that indicates the time value associated with the simulation event currently being executed. Simulation time does not advance during an invocation of a process; it stands still while a single event is being processed. Simulation time advances only when one event completes (at time T) and the next event begins (at time T + dt). Because time can advance in a punctuated, irregular pattern according to this scheme, it is known as the event-driven simulation method (as opposed to the regular, time-driven simulation method).

Note: If the “sim_time_quantum“ preference has a value other than 0.0, the simulation time returned will be a multiple of the specified quantum.

This KP returns -1 if invoked at two special times (which occur before the simulation starts executing events):

  • Initial invocation of the receiver group pipeline stage of radio transmitter modules
  • Invocation of the init_callback procedure for a wireless domain

Purpose

Provides a mechanism to obtain the current simulation time, which is used for many applications, such as:

  • computing absolute times in the future for scheduling events
  • determining the time delay from some past event to the present simulation time
  • printing time-tagged diagnostic information and debugging statements to the standard output device, or other open files

Errors

  • No errors are trapped.

Reference

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · Documentation compiled and provided by Beijing ZNetLink Technology Co., Ltd.

交流群 · QQ Group:OPNET/智网妙算网络仿真交流群(群号 486383494)

原文档 © 2017 Riverbed Technology · 本站为公益翻译,由 AI 辅助完成,请仔细甄别

Original documentation © 2017 Riverbed Technology. Community translation, AI-assisted. Contact: jiazequn@znetlink.com