📄 restoration_proc.pr.c
字号:
/* Process model C form file: Restoration_proc.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_proc_pr_c [] = "MIL_3_Tfile_Hdr_ 80C 30A modeler 7 40FBBFAC 40FBBFAC 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 <string.h>
#include <stdlib.h>
#include <route.h>
#define PK_IN_STRM 0
#define PK_OUT_STRM 0
#define MAX_NODES 15
#define END_SIM (op_intrpt_type () == OPC_INTRPT_ENDSIM)
#define BEG_SIM (op_intrpt_type () == OPC_INTRPT_BEGSIM)
#define BURST_ARRIVAL (op_intrpt_type () == OPC_INTRPT_STRM && op_intrpt_strm () == PK_IN_STRM)
int node_count = 0;
//int num_pk_gen = 0;
/* 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 sequence_number_wait;
int sequence_number_current;
int node_address;
int nodes_total;
int queue_size;
int pk_rcvd[MAX_NODES];
Distribution* address_dist;
Objid sar_mod_objid;
Objid node_id;
Objid subnet_id;
Objid next_node_id;
Stathandle num_pk_gen_gsh;
Stathandle dup_pk_gsh;
Route* current_rptr;
int pk_count;
Stathandle pk_cnt_stathandle;
Distribution * start_dist;
Distribution * dtime_dist;
Objid dest_node_objid;
Objid node_objid;
Objid self_objid;
Distribution* wave_dist;
Stathandle pk_size_temp;
double pk_size;
int pik_count;
Stathandle pk_cnt_no1_stathandle;
Stathandle pk_size_no1_stathandle;
} Restoration_proc_state;
#define pr_state_ptr ((Restoration_proc_state*) SimI_Mod_State_Ptr)
#define sequence_number_wait pr_state_ptr->sequence_number_wait
#define sequence_number_current pr_state_ptr->sequence_number_current
#define node_address pr_state_ptr->node_address
#define nodes_total pr_state_ptr->nodes_total
#define queue_size pr_state_ptr->queue_size
#define pk_rcvd pr_state_ptr->pk_rcvd
#define address_dist pr_state_ptr->address_dist
#define sar_mod_objid pr_state_ptr->sar_mod_objid
#define node_id pr_state_ptr->node_id
#define subnet_id pr_state_ptr->subnet_id
#define next_node_id pr_state_ptr->next_node_id
#define num_pk_gen_gsh pr_state_ptr->num_pk_gen_gsh
#define dup_pk_gsh pr_state_ptr->dup_pk_gsh
#define current_rptr pr_state_ptr->current_rptr
#define pk_count pr_state_ptr->pk_count
#define pk_cnt_stathandle pr_state_ptr->pk_cnt_stathandle
#define start_dist pr_state_ptr->start_dist
#define dtime_dist pr_state_ptr->dtime_dist
#define dest_node_objid pr_state_ptr->dest_node_objid
#define node_objid pr_state_ptr->node_objid
#define self_objid pr_state_ptr->self_objid
#define wave_dist pr_state_ptr->wave_dist
#define pk_size_temp pr_state_ptr->pk_size_temp
#define pk_size pr_state_ptr->pk_size
#define pik_count pr_state_ptr->pik_count
#define pk_cnt_no1_stathandle pr_state_ptr->pk_cnt_no1_stathandle
#define pk_size_no1_stathandle pr_state_ptr->pk_size_no1_stathandle
/* 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_proc_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_proc (void);
Compcode Restoration_proc_init (void **);
void Restoration_proc_diag (void);
void Restoration_proc_terminate (void);
void Restoration_proc_svar (void *, const char *, char **);
#if defined (__cplusplus)
} /* end of 'extern "C"' */
#endif
/* Process model interrupt handling procedure */
void
Restoration_proc (void)
{
int _block_origin = 0;
FIN (Restoration_proc ());
if (1)
{
Packet* pkptr_burst;
Packet* pkptr;
int sequence_number_ack;
int sequence_number_rcv;
int source_address;
int destination_address;
int i,j,k;
Route* pk_rptr;
Route* p_min_rptr_copy;
double start_time;
double dtime_time;
double cur_time;
int subnet_ids[10];
int node_ids[20];
int num_nodes;
int userid;
double EXTRA_TIME;
int ok_flag;
int wavelength_number;
int u_id;
Objid strm_objid;
FSM_ENTER (Restoration_proc)
FSM_BLOCK_SWITCH
{
/*---------------------------------------------------------*/
/** state (init) enter executives **/
FSM_STATE_ENTER_FORCED_NOLABEL (0, "init", "Restoration_proc () [init enter execs]")
{
self_objid = op_id_self(); //precess id
node_id = op_topo_parent (self_objid); //node id
subnet_id = op_topo_parent(node_id); //subnet_id 牢单 咯扁辑绰 subnet_id 客 network_id啊 鞍促
node_count++;
node_address = node_count;
op_ima_obj_attr_set (node_id, "user id", node_address); //弊烦 捞霸 user id 甫 父甸绢林绰 苞沥牢啊?
//printf("userid = %d\n",node_address);
//getchar();
/* determine the total number of end nodes connceted to the network */
nodes_total = op_topo_object_count (OPC_OBJTYPE_NDFIX); //Node Difine IndeX
/* set up the address distribution */
//address_dist = op_dist_load ("uniform_int", 1, 2);
/* register global stats and write an init point in each */
//num_pk_gen_gsh = op_stat_reg ("Global application packets generated (pks)", OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);
//op_stat_write (num_pk_gen_gsh, num_pk_gen);
pk_size = 0;
pk_size_no1_stathandle = op_stat_reg("PK_SIZE_NODE1",OPC_STAT_INDEX_NONE,OPC_STAT_LOCAL);
pk_count = 0;
pk_cnt_no1_stathandle = op_stat_reg("PK_COUNT_NODE1", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
}
/** state (init) exit executives **/
FSM_STATE_EXIT_FORCED (0, "init", "Restoration_proc () [init exit execs]")
{
}
/** state (init) transition processing **/
FSM_TRANSIT_ONLY ((BEG_SIM), 1, state1_enter_exec, ;, "init", "BEG_SIM", "", "init", "wait")
/*---------------------------------------------------------*/
/** state (wait) enter executives **/
FSM_STATE_ENTER_UNFORCED (1, state1_enter_exec, "wait", "Restoration_proc () [wait enter execs]")
{
}
/** blocking after enter executives of unforced state. **/
FSM_EXIT (3,Restoration_proc)
/** state (wait) exit executives **/
FSM_STATE_EXIT_UNFORCED (1, "wait", "Restoration_proc () [wait exit execs]")
{
}
/** state (wait) transition processing **/
FSM_INIT_COND (BURST_ARRIVAL)
FSM_TEST_COND (END_SIM)
FSM_TEST_LOGIC ("wait")
FSM_TRANSIT_SWITCH
{
FSM_CASE_TRANSIT (0, 2, state2_enter_exec, ;, "BURST_ARRIVAL", "", "wait", "proc")
FSM_CASE_TRANSIT (1, 3, state3_enter_exec, ;, "END_SIM", "", "wait", "end")
}
/*---------------------------------------------------------*/
/** state (proc) enter executives **/
FSM_STATE_ENTER_FORCED (2, state2_enter_exec, "proc", "Restoration_proc () [proc enter execs]")
{
self_objid = op_id_self ();
node_objid = op_topo_parent(self_objid);
op_ima_obj_attr_get(node_objid, "user id", &userid); //user id甫 掘绢坷绰备唱
/* obtain the app packet*/
//strm_objid = op_intrpt_strm();
pkptr_burst = op_pk_get(op_intrpt_strm());
//pkptr_burst = op_pk_get (strm_objid);
pk_count++;
//printf("userid = %d pk_count= %d time = %f\n",userid, pk_count, op_sim_time());
pk_size = op_pk_total_size_get (pkptr_burst);
//node 1俊辑 惯积茄 burst捞搁
op_stat_write(pk_size_no1_stathandle, pk_size);
op_stat_write(pk_cnt_no1_stathandle, pk_count);
op_pk_destroy (pkptr_burst);
// bcp积己
pkptr =op_pk_create_fmt ("BCP");
op_pk_nfd_set (pkptr, "source address", node_address);
source_address = node_address;
//destination_address = op_dist_outcome (address_dist);
destination_address = 2;
op_pk_nfd_set (pkptr, "destination address", destination_address);
if (min_rptr[source_address][destination_address] == OPC_NIL) //扼快泼 抛捞喉俊 粮犁窍瘤 臼栏搁
{
p_min_rptr_copy = OPC_NIL;
}
else
{
p_min_rptr_copy = op_rte_route_copy (min_rptr[source_address][destination_address]);
}
current_rptr = p_min_rptr_copy;
if (current_rptr == OPC_NIL)
{
//printf("test\n");
op_pk_destroy (pkptr);
}
else
{
//printf("test1\n");
/* insert the route into the packet */
pk_rptr = op_rte_route_copy (current_rptr);
op_rte_pk_route_insert (pkptr, pk_rptr);
num_nodes = op_rte_route_num_nodes (min_rptr[source_address][destination_address]);
dtime_time = (double) pk_size/RATE; //???????????????RATE绰 绢叼俊 急攫等芭具??????????
op_ima_obj_attr_get(self_objid, "EXTRA_TIME", &EXTRA_TIME); //EXTRA_TIME篮 檬扁拳救夌绰单.???????
start_time = (double) PROC_TIME*num_nodes+EXTRA_TIME; //傈价瘤楷篮 公矫窍唱??????????????????
op_pk_nfd_set (pkptr, "start", start_time);
op_pk_nfd_set (pkptr, "dtime", dtime_time);
wave_dist = op_dist_load ("uniform_int", 0, WAVE_NUM-1);
wavelength_number = op_dist_outcome (wave_dist);
op_pk_nfd_set (pkptr, "wavelength", wavelength_number);
if(userid ==1)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -