📄 eer.pr.c
字号:
/* Process model C form file: EER.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 EER_pr_c [] = "MIL_3_Tfile_Hdr_ 80C 30A modeler 7 42952EC8 42952EC8 1 wani wani123 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 "header.h"
#define PK_IN_STRM 0
#define END_SIM (op_intrpt_type () == OPC_INTRPT_ENDSIM)
#define BEG_SIM (op_intrpt_type () == OPC_INTRPT_BEGSIM)
#define BCP_ARRIVAL (op_intrpt_type () == OPC_INTRPT_STRM && op_intrpt_strm () == PK_IN_STRM )
#define BURST_ARRIVAL (op_intrpt_type () == OPC_INTRPT_STRM && op_intrpt_strm () != PK_IN_STRM )
//start of sturct for routing table
typedef struct {
int source;
int destination;
int hop_count;
Objid output_link;
int strm_control;
//int strm_data;
} ROUTING_TABLE;
//end of sturct for routing table
typedef struct {
double start_time; //offset time
double duration_time; // duration time of burst
int source;
int destination;
int outstrm_num;
int instrm_num;
} CHANNEL_INFOR;
typedef struct
{
double horizon;
List * gab_list;
List * occupy_list;
} CHANNEL;
typedef struct
{
CHANNEL * channel;
int next_nodeid;
Objid tx_objid;
} PORT;
typedef struct
{
PORT * port;
} NODE;
int total_burst_receive_count = 0;
int total_burst_receive_but_count = 0;
int total_bcp_receive_count = 0;
int total_bcp_receive_but_count = 0;
int hop_count = 0;
float avg_hop_count = 0;
double total_burst_size = 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 userid;
ROUTING_TABLE * routing_table;
NODE node_for_schedule;
int link_num;
int channel_count;
double PROC_TIME;
double RATE;
} EER_state;
#define pr_state_ptr ((EER_state*) SimI_Mod_State_Ptr)
#define userid pr_state_ptr->userid
#define routing_table pr_state_ptr->routing_table
#define node_for_schedule pr_state_ptr->node_for_schedule
#define link_num pr_state_ptr->link_num
#define channel_count pr_state_ptr->channel_count
#define PROC_TIME pr_state_ptr->PROC_TIME
#define RATE pr_state_ptr->RATE
/* 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 EER_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 EER (void);
Compcode EER_init (void **);
void EER_diag (void);
void EER_terminate (void);
void EER_svar (void *, const char *, char **);
#if defined (__cplusplus)
} /* end of 'extern "C"' */
#endif
/* Process model interrupt handling procedure */
void
EER (void)
{
int _block_origin = 0;
FIN (EER ());
if (1)
{
int total_node_num = 0;
//int node_num = 0;
//int link_num = 0;
char node_name[20];
int i,j,k;
Objid node_objid_ptr, link_objid,tx_objid;
Route* min_route;
int subnet_id_ptr, node_id_ptr;
int strm_num, channel_count1, link_count;
double pk_size;
Objid temp_tx_objid;
int cur_port, difference_time, reservation_flag, temp_difference_time, cur_channel;
int d_time;
CHANNEL_INFOR * temp_channel_infor;
int temp_outstrm_num,cur_por,temp_occupy_count;
int output_strm;
int pktype;
Packet* pkptr_burst;
Packet* pkptr;
int source_address;
int destination_address;
Route* pk_rptr;
double start_time;
double dtime_time;
double cur_time;
int subnet_ids[10];
int node_ids[20];
int num_nodes;
Objid strm_objid;
int channel_num;
Objid temp_src_objid, temp_dest_objid;
Route_Set* temp_routeset;
Route* temp_min_route;
FILE * in;
char filename[20];
char temp_file_name[20];
double burst_size = 0;
Topology * topo_objid;
Objid self_objid,node_objid,subnet_objid;
FSM_ENTER (EER)
FSM_BLOCK_SWITCH
{
/*---------------------------------------------------------*/
/** state (init) enter executives **/
FSM_STATE_ENTER_FORCED_NOLABEL (0, "init", "EER () [init 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);
//printf("EER,userid=%duserid,op_time\n",userid,op_sim_time());
}
/** state (init) exit executives **/
FSM_STATE_EXIT_FORCED (0, "init", "EER () [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", "EER () [wait enter execs]")
{
}
/** blocking after enter executives of unforced state. **/
FSM_EXIT (3,EER)
/** state (wait) exit executives **/
FSM_STATE_EXIT_UNFORCED (1, "wait", "EER () [wait exit execs]")
{
}
/** state (wait) transition processing **/
FSM_INIT_COND (BURST_ARRIVAL)
FSM_TEST_COND (BCP_ARRIVAL)
FSM_TEST_COND (END_SIM)
FSM_TEST_LOGIC ("wait")
FSM_TRANSIT_SWITCH
{
FSM_CASE_TRANSIT (0, 3, state3_enter_exec, ;, "BURST_ARRIVAL", "", "wait", "data_recieve")
FSM_CASE_TRANSIT (1, 2, state2_enter_exec, ;, "BCP_ARRIVAL", "", "wait", "control_recieve")
FSM_CASE_TRANSIT (2, 4, state4_enter_exec, ;, "END_SIM", "", "wait", "end")
}
/*---------------------------------------------------------*/
/** state (control_recieve) enter executives **/
FSM_STATE_ENTER_FORCED (2, state2_enter_exec, "control_recieve", "EER () [control_recieve enter execs]")
{
self_objid = op_id_self ();
node_objid = op_topo_parent (self_objid);
//subnet_objid = op_topo_parent (node_objid);
//topo_objid = op_rte_topo_from_objids();
op_ima_obj_attr_get(node_objid, "user id", &userid);
pkptr = op_pk_get (op_intrpt_strm());
op_pk_nfd_get (pkptr, "type", &pktype);
op_pk_nfd_get (pkptr, "source address", &source_address);
op_pk_nfd_get (pkptr, "destination address", &destination_address);
if(userid == destination_address)
{
total_bcp_receive_count++;
}
else
{
//failed transmission
total_bcp_receive_but_count++;
}
op_pk_destroy(pkptr);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -