/* Process model C form file: gpr_source.pr.c */
/* Portions of this file copyright 1992-2003 by OPNET Technologies, Inc. */
/* This variable carries the header into the object file */
const char gpr_source_pr_c [] = "MIL_3_Tfile_Hdr_ 100A 30A modeler 7 436ECAA9 436ECAA9 1 Tyler Administrator 0 0 none none 0 0 none 0 0 0 0 0 0 0 0 8f3 1 ";
#include <string.h>
/* OPNET system definitions */
#include <opnet.h>
/* Header Block */
/* Include files. */
#include "oms_dist_support.h"
#include <math.h>
/* Define constants used in the process model. */
#define OFF_TO_ON 10
#define ON_TO_ON 20
#define ON_TO_OFF 30
/* State transition macro definitions. */
#define INACTIVE_TO_ACTIVE (intrpt_type == OPC_INTRPT_SELF && intrpt_code == OFF_TO_ON)
#define REMAIN_ACTIVE (intrpt_type == OPC_INTRPT_SELF && intrpt_code == ON_TO_ON)
#define ACTIVE_TO_INACTIVE (intrpt_type == OPC_INTRPT_SELF && intrpt_code == ON_TO_OFF)
/* Function Declarations. */
static void bursty_source_sv_init ();
/*
OmsT_Dist_Handle on_state_dist_handle;
OmsT_Dist_Handle off_state_dist_handle;
OmsT_Dist_Handle intarrvl_time_dist_handle;
OmsT_Dist_Handle packet_size_dist_handle; */
/* End of Header Block */
#if !defined (VOSD_NO_FIN)
#undef BIN
#undef BOUT
#define BIN FIN_LOCAL_FIELD(_op_last_line_passed) = __LINE__ - _op_block_origin;
#define BOUT BIN
#define BINIT FIN_LOCAL_FIELD(_op_last_line_passed) = 0; _op_block_origin = __LINE__;
#else
#define BINIT
#endif /* #if !defined (VOSD_NO_FIN) */
/* State variable definitions */
typedef struct
{
/* Internal state tracking for FSM */
FSM_SYS_STATE
/* State Variables */
char pid_string [64];
Boolean debug_mode;
double stop_time;
double off_state_start_time;
Stathandle pksize_stathandle;
OmsT_Dist_Handle on_state_dist_handle;
OmsT_Dist_Handle off_state_dist_handle;
OmsT_Dist_Handle intarrvl_time_dist_handle;
OmsT_Dist_Handle packet_size_dist_handle;
double start_time;
Stathandle bits_sent_stathandle;
Stathandle bitssec_sent_stathandle;
Stathandle pkts_sent_stathandle;
Stathandle pktssec_sent_stathandle;
Stathandle bits_sent_gstathandle;
Stathandle bitssec_sent_gstathandle;
Stathandle pkts_sent_gstathandle;
Stathandle pktssec_sent_gstathandle;
int segmentation_size;
Sbhandle segmentation_buf_handle;
double mean_pkt_interval;
int g_pkt_sent;
} gpr_source_state;
#define pr_state_ptr ((gpr_source_state*) (OP_SIM_CONTEXT_PTR->mod_state_ptr))
#define pid_string pr_state_ptr->pid_string
#define debug_mode pr_state_ptr->debug_mode
#define stop_time pr_state_ptr->stop_time
#define off_state_start_time pr_state_ptr->off_state_start_time
#define pksize_stathandle pr_state_ptr->pksize_stathandle
#define on_state_dist_handle pr_state_ptr->on_state_dist_handle
#define off_state_dist_handle pr_state_ptr->off_state_dist_handle
#define intarrvl_time_dist_handle pr_state_ptr->intarrvl_time_dist_handle
#define packet_size_dist_handle pr_state_ptr->packet_size_dist_handle
#define start_time pr_state_ptr->start_time
#define bits_sent_stathandle pr_state_ptr->bits_sent_stathandle
#define bitssec_sent_stathandle pr_state_ptr->bitssec_sent_stathandle
#define pkts_sent_stathandle pr_state_ptr->pkts_sent_stathandle
#define pktssec_sent_stathandle pr_state_ptr->pktssec_sent_stathandle
#define bits_sent_gstathandle pr_state_ptr->bits_sent_gstathandle
#define bitssec_sent_gstathandle pr_state_ptr->bitssec_sent_gstathandle
#define pkts_sent_gstathandle pr_state_ptr->pkts_sent_gstathandle
#define pktssec_sent_gstathandle pr_state_ptr->pktssec_sent_gstathandle
#define segmentation_size pr_state_ptr->segmentation_size
#define segmentation_buf_handle pr_state_ptr->segmentation_buf_handle
#define mean_pkt_interval pr_state_ptr->mean_pkt_interval
#define g_pkt_sent pr_state_ptr->g_pkt_sent
/* These macro definitions will define a local variable called */
/* "op_sv_ptr" in each function containing a FIN statement. */
/* This variable points to the state variable data structure, */
/* and can be used from a C debugger to display their values. */
#undef FIN_PREAMBLE_DEC
#undef FIN_PREAMBLE_CODE
#if defined (OPD_PARALLEL)
# define FIN_PREAMBLE_DEC gpr_source_state *op_sv_ptr; OpT_Sim_Context * tcontext_ptr;
# define FIN_PREAMBLE_CODE \
if (VosS_Mt_Perform_Lock) \
VOS_THREAD_SPECIFIC_DATA_GET (VosI_Globals.simi_mt_context_data_key, tcontext_ptr, SimT_Context *); \
else \
tcontext_ptr = VosI_Globals.simi_sequential_context_ptr; \
op_sv_ptr = ((gpr_source_state *)(tcontext_ptr->mod_state_ptr));
#else
# define FIN_PREAMBLE_DEC gpr_source_state *op_sv_ptr;
# define FIN_PREAMBLE_CODE op_sv_ptr = pr_state_ptr;
#endif
/* Function Block */
#if !defined (VOSD_NO_FIN)
enum { _op_block_origin = __LINE__ };
#endif
static void
bursty_source_sv_init ()
{
Prohandle my_prohandle;
int my_pro_id;
Objid my_id;
Objid traf_gen_comp_attr_objid, traf_conf_objid;
Objid pkt_gen_comp_attr_objid, pkt_gen_args_objid;
char on_state_string [128], off_state_string [128];
char intarrvl_rate_string [128], packet_size_string [128];
char start_time_string [128];
OmsT_Dist_Handle start_time_dist_handle;
/** Initializes state variables associated with **/
/** this process model. **/
FIN (bursty_source_sv_init ());
/* Determine the prohandle of this process as well as */
/* the object IDs of the containing module and node.*/
my_prohandle = op_pro_self ();
my_pro_id = op_pro_id (my_prohandle);
my_id = op_id_self ();
/* Determine the process ID display string. */
sprintf (pid_string, "bursty_source PID (%d)", my_pro_id);
/* Determine whether or not the simulation is in debug */
/* mode. Trace statement are only enabled when the */
/* simulation is in debug mode. */
debug_mode = op_sim_debug ();
/* Read the traffic generation parameters. */
op_ima_obj_attr_get (my_id, "Traffic Generation Parameters", &traf_gen_comp_attr_objid);
traf_conf_objid = op_topo_child (traf_gen_comp_attr_objid, OPC_OBJTYPE_GENERIC, 0);
/* Determine the start time for traffic generation. */
op_ima_obj_attr_get (traf_conf_objid, "Start Time", start_time_string);
if (strcmp (start_time_string, "Never") != 0)
{
start_time_dist_handle = oms_dist_load_from_string (start_time_string);
start_time = oms_dist_outcome (start_time_dist_handle);
}
else
{
start_time = -1.0;
}
/* Determine the stop time for traffic generation. */
op_ima_obj_attr_get (traf_conf_objid, "Stop Time", &stop_time);
if (stop_time == -1.0)
stop_time = OPC_DBL_INFINITY;
/* If the start time is set to "Infinity", then there */
/* is no need to schedule an interrupt as this node has */
/* been set will not generate any traffic. */
if ((start_time >= 0.0) && (stop_time > start_time))
{
/* Load the distribution used to determine the time */
/* for which the process stays in the "ON" state. */
op_ima_o