CyberT_Effect_Proc_Ptr

Abstract

Callback: Called when a cyber effect is to be executed.

Syntax

<effect_proc_name> (cmd_iface_ptr, effect_args_vptr, model_data_vptr)

Argument Type Description
cmd_iface_ptr CyberT_Cmd_Iface* Interface between the cyber-effects manager and any client. Used to pass information between the cyber_effects_mgr (and each child instruction_mgr) and the client modules.
effect_args_vptr void* Pointer to a data structure containing argument values for the effect (must be cast to an appropriate type).
model_data_vptr void * Data the client module wants to pass for the execution of the effect callback (must be cast to an appropriate type).

Return Type

void

no return value

cyber_effects.h

Example

From ip_rte_central_cpu function block:

void 
cyber_effect_change_service_rate_to_cmd_proc (CyberT_Cmd_Iface* cmd_iface_ptr, void* effect_args_vptr, void* model_data_vptr)
   {
   CyberT_IP_Change_Rate_Args*    effect_args_ptr;
   double*                        one_over_service_rate_ptr;
   double                         change_rate, percentage;

   /** Callback that represents the effect of changing the **/
   /** IP forwarding rate.                                 **/
   FIN (cyber_effect_change_service_rate_to_cmd_proc (effect_args_vptr, model_data_vptr));

   /* Obtain the arguments sent for this Cyber Effect. */
   effect_args_ptr = (CyberT_IP_Change_Rate_Args*) effect_args_vptr;

   /* Obtain the data provided by the local process (ip_rte_central_cpu). */
   /* In this case it is a reference to the variable holding the current  */
   /* fowarding date (stored as one over the service rate).               */
   one_over_service_rate_ptr =(double*) model_data_vptr;

   /* When decreasing the rate, the percentage of the change must be less than */
   /* 100% (allowing 100% decrease would block completely the forwarding in    */
   /* this node. That could translate in increase memory in the simulation.    */
   if (!effect_args_ptr->is_increase && effect_args_ptr->percentage >=1.0)
      percentage = 0.99;
   else
      /* Otherwise use the percentage change requested. */
      percentage =  effect_args_ptr->percentage;

   /* Compute the change rate. */
   change_rate = percentage * (1 / (*one_over_service_rate_ptr));

   /* Now compute the new once over service rate value. */
   if (effect_args_ptr->is_increase)
      {
      *one_over_service_rate_ptr = 1.0 / (change_rate + (1 / (*one_over_service_rate_ptr)));
      }
   else
      {
      *one_over_service_rate_ptr = 1.0 / ((1.0 / (*one_over_service_rate_ptr)) - change_rate);
      }

   FOUT;
   }

Details

This callback prototype specifies how functions that represent a cyber effect in a client module must be defined. It is also used for functions that represent the cancellation of an effect.

The callback function implements an effect by changing the behavior of the process model calling it, usually by changing a parameter value. The arguments effect_args_vptr and model_data_vptr are critical to this process. Both must be cast to local structures so that the callback can get the information needed to make the necessary changes.

  • effect_args_vptr provides access to any arguments used by the effect
  • model_data_vptr provides access to any variables in the client module that are needed for calculations or that will be changed to cause the desired effect. These variables store model parameter values and are usually state variables.

Callbacks of this type are registered with cyber_effects_cmd_register().

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · 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