📄 restoration_sink.pr.c
字号:
/* Process model C form file: Restoration_sink.pr.c */
/* Portions of this file copyright 1992-2001 by OPNET Technologies, Inc. */
/* This variable carries the header into the object file */
static const char Restoration_sink_pr_c [] = "MIL_3_Tfile_Hdr_ 80C 30A modeler 7 40E41B3E 40E41B3E 1 babo123 Administrator 0 0 none none 0 0 none 0 0 0 0 0 0 ";
#include <string.h>
/* OPNET system definitions */
#include <opnet.h>
#if defined (__cplusplus)
extern "C" {
#endif
FSM_EXT_DECS
#if defined (__cplusplus)
} /* end of 'extern "C"' */
#endif
/* Header Block */
#include "route.h"
#define END_SIM (op_intrpt_type () == OPC_INTRPT_ENDSIM)
#define BEG_SIM (op_intrpt_type () == OPC_INTRPT_BEGSIM)
#define ARRIVAL (op_intrpt_type () == OPC_INTRPT_STRM)
int rev_pk_gen;
/* End of Header Block */
#if !defined (VOSD_NO_FIN)
#undef BIN
#undef BOUT
#define BIN FIN_LOCAL_FIELD(last_line_passed) = __LINE__ - _block_origin;
#define BOUT BIN
#define BINIT FIN_LOCAL_FIELD(last_line_passed) = 0; _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 */
int r_count;
Stathandle r_cnt_stathandle;
Stathandle ete_gsh;
Stathandle rev_pk_gen_gsh;
} Restoration_sink_state;
#define pr_state_ptr ((Restoration_sink_state*) SimI_Mod_State_Ptr)
#define r_count pr_state_ptr->r_count
#define r_cnt_stathandle pr_state_ptr->r_cnt_stathandle
#define ete_gsh pr_state_ptr->ete_gsh
#define rev_pk_gen_gsh pr_state_ptr->rev_pk_gen_gsh
/* This macro definition 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
#define FIN_PREAMBLE Restoration_sink_state *op_sv_ptr = pr_state_ptr;
/* No Function Block */
enum { _block_origin = __LINE__ };
/* Undefine optional tracing in FIN/FOUT/FRET */
/* The FSM has its own tracing code and the other */
/* functions should not have any tracing. */
#undef FIN_TRACING
#define FIN_TRACING
#undef FOUTRET_TRACING
#define FOUTRET_TRACING
#if defined (__cplusplus)
extern "C" {
#endif
void Restoration_sink (void);
Compcode Restoration_sink_init (void **);
void Restoration_sink_diag (void);
void Restoration_sink_terminate (void);
void Restoration_sink_svar (void *, const char *, char **);
#if defined (__cplusplus)
} /* end of 'extern "C"' */
#endif
/* Process model interrupt handling procedure */
void
Restoration_sink (void)
{
int _block_origin = 0;
FIN (Restoration_sink ());
if (1)
{
double ete_delay, delay;
packet* pktr;
int i;
int j;
int userid;
Objid self_objid;
Objid node_objid;
Objid subnet_objid;
int flag, hop, source_address,route_flag;
double average_hop[15][15];
double b_average_hop[15][15];
double loss;
int fis_loss;
double loss_rate[15][15];
double total_average_hop, b_total_average_hop;
double average_delay[15][15], b_average_delay[15][15];
double total_average_delay, b_total_average_delay;
double utilization;
char file_name[10];
char f_name[50];
int backup_count;
FILE *fp;
int total_gen_bcp, total_all_succ;
double throughput;
int s_bcp, f_bcp;
double start_time;
double back_average_delay;
double back_average_hop;
double back_throughput;
double back_loss;
double back_utilization;
double sim_time;
FSM_ENTER (Restoration_sink)
FSM_BLOCK_SWITCH
{
/*---------------------------------------------------------*/
/** state (init) enter executives **/
FSM_STATE_ENTER_FORCED_NOLABEL (0, "init", "Restoration_sink () [init enter execs]")
{
self_objid = op_id_self ();
node_objid = op_topo_parent(self_objid);
op_ima_obj_attr_get(node_objid, "user id", &userid);
}
/** state (init) exit executives **/
FSM_STATE_EXIT_FORCED (0, "init", "Restoration_sink () [init exit execs]")
{
}
/** state (init) transition processing **/
FSM_TRANSIT_ONLY ((BEG_SIM), 1, state1_enter_exec, ;, "init", "BEG_SIM", "", "init", "idle")
/*---------------------------------------------------------*/
/** state (idle) enter executives **/
FSM_STATE_ENTER_UNFORCED (1, state1_enter_exec, "idle", "Restoration_sink () [idle enter execs]")
{
}
/** blocking after enter executives of unforced state. **/
FSM_EXIT (3,Restoration_sink)
/** state (idle) exit executives **/
FSM_STATE_EXIT_UNFORCED (1, "idle", "Restoration_sink () [idle exit execs]")
{
}
/** state (idle) transition processing **/
FSM_INIT_COND (ARRIVAL)
FSM_TEST_COND (END_SIM)
FSM_DFLT_COND
FSM_TEST_LOGIC ("idle")
FSM_TRANSIT_SWITCH
{
FSM_CASE_TRANSIT (0, 2, state2_enter_exec, ;, "ARRIVAL", "", "idle", "arrival")
FSM_CASE_TRANSIT (1, 3, state3_enter_exec, ;, "END_SIM", "", "idle", "end")
FSM_CASE_TRANSIT (2, 1, state1_enter_exec, ;, "default", "", "idle", "idle")
}
/*---------------------------------------------------------*/
/** state (arrival) enter executives **/
FSM_STATE_ENTER_FORCED (2, state2_enter_exec, "arrival", "Restoration_sink () [arrival enter execs]")
{
self_objid = op_id_self ();
node_objid = op_topo_parent(self_objid);
op_ima_obj_attr_get(node_objid, "user id", &userid);
pktr = op_pk_get (op_intrpt_strm());
op_pk_nfd_get(pktr, "source address", &source_address);
op_pk_nfd_get(pktr, "start", &start_time);
printf("userid = %d, s = %d\n", userid, source_address);
op_pk_destroy (pktr);
}
/** state (arrival) exit executives **/
FSM_STATE_EXIT_FORCED (2, "arrival", "Restoration_sink () [arrival exit execs]")
{
}
/** state (arrival) transition processing **/
FSM_INIT_COND ((1))
FSM_TEST_COND (END_SIM)
FSM_TEST_LOGIC ("arrival")
FSM_TRANSIT_SWITCH
{
FSM_CASE_TRANSIT (0, 1, state1_enter_exec, ;, "", "", "arrival", "idle")
FSM_CASE_TRANSIT (1, 3, state3_enter_exec, ;, "END_SIM", "", "arrival", "end")
}
/*---------------------------------------------------------*/
/** state (end) enter executives **/
FSM_STATE_ENTER_UNFORCED (3, state3_enter_exec, "end", "Restoration_sink () [end enter execs]")
{
self_objid = op_id_self ();
node_objid = op_topo_parent (self_objid);
subnet_objid = op_topo_parent (node_objid);
op_ima_obj_attr_get(node_objid, "user id", &userid);
if(userid == 14)
{
op_ima_obj_attr_get(self_objid, "file name", &file_name);
op_ima_obj_attr_get(self_objid, "sim_time", &sim_time);
loss = 0.0;
fis_loss = 0;
total_average_hop = 0.0;
b_total_average_hop = 0.0;
total_average_delay = 0.0;
b_total_average_delay = 0.0;
total_gen_bcp = 0;
total_all_succ = 0;
utilization = 0.0;
backup_count = 0;
s_bcp = 0;
f_bcp = 0;
/////////////////////////////// loss rate hop delay ////////////////////////////
for(i=1;i<NODE_NUM;i++)
{
for(j=1;j<NODE_NUM;j++)
{
if(i != j)
{
fail[i][j] = fail[i][j] + fis_fail[i][j];
s_bcp = s_bcp + succ[i][j];
f_bcp = f_bcp + fail[i][j];
if(fail[i][j] == 0) loss_rate[i][j] = 0;
else loss_rate[i][j] = (double)fail[i][j] / ((double)succ[i][j]+(double)fail[i][j]);
loss = loss + loss_rate[i][j];
fis_loss = fis_loss + fis_fail[i][j];
if(sum_hop[i][j] == 0) average_hop[i][j] = 0;
else average_hop[i][j] = (double)sum_hop[i][j] / (double)succ[i][j];
if(b_sum_hop[i][j] == 0) b_average_hop[i][j] = 0;
else
{
b_average_hop[i][j] = (double)b_sum_hop[i][j] / (double)b_succ[i][j];
backup_count++;
}
total_average_hop = (double)(total_average_hop + average_hop[i][j]);
b_total_average_hop = (double)(b_total_average_hop+b_average_hop[i][j]);
if(sum_delay == 0) average_delay[i][j] = 0;
else average_delay[i][j] = (double)sum_delay[i][j] / (double)succ[i][j];
if(b_sum_delay[i][j] == 0) b_average_delay[i][j] = 0;
else b_average_delay[i][j] = (double)b_sum_delay[i][j] / (double)b_succ[i][j];
total_average_delay = total_average_delay + average_delay[i][j];
b_total_average_delay = b_total_average_delay + b_average_delay[i][j];
utilization = utilization + burst_time[i][j];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -