📄 obs_stord.pr.c
字号:
/* Process model C form file: OBS_stord.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 OBS_stord_pr_c [] = "MIL_3_Tfile_Hdr_ 80C 30A modeler 7 424D71A9 424D71A9 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 <route.h>
#define PK_IN_STRM 0
#define PK_IN_STRM_RTE 1
#define PK_OUT_STRM 0
//#define ID 99
#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 || op_intrpt_strm () == PK_IN_STRM_RTE) )
#define INTRPT_SELF (op_intrpt_type() == OPC_INTRPT_SELF)
//&& (op_intrpt_code() == ID)
typedef struct {
int id;
Packet * pk;
} BURST_STORDED;
int burst_count_total_send = 0;
int burst_count_total_stay = 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 */
Stathandle bits_rcvd_stathandle;
Stathandle bitssec_rcvd_stathandle;
Stathandle pkts_rcvd_stathandle;
Stathandle pktssec_rcvd_stathandle;
Stathandle ete_delay_stathandle;
Stathandle bits_rcvd_gstathandle;
Stathandle bitssec_rcvd_gstathandle;
Stathandle pkts_rcvd_gstathandle;
Stathandle pktssec_rcvd_gstathandle;
Stathandle ete_delay_gstathandle;
List * stored_burst_list_ptr;
int code;
int burst_count_send;
Stathandle burst_count_send_stathandle;
double burst_size_send;
Stathandle burst_size_send_stathandle;
double burst_avg_size_send;
Stathandle burst_avg_size_send_stathandle;
double burst_size_total_send;
Stathandle burst_count_total_send_stathandle;
Stathandle burst_count_total_stay_stathandle;
} OBS_stord_state;
#define pr_state_ptr ((OBS_stord_state*) SimI_Mod_State_Ptr)
#define bits_rcvd_stathandle pr_state_ptr->bits_rcvd_stathandle
#define bitssec_rcvd_stathandle pr_state_ptr->bitssec_rcvd_stathandle
#define pkts_rcvd_stathandle pr_state_ptr->pkts_rcvd_stathandle
#define pktssec_rcvd_stathandle pr_state_ptr->pktssec_rcvd_stathandle
#define ete_delay_stathandle pr_state_ptr->ete_delay_stathandle
#define bits_rcvd_gstathandle pr_state_ptr->bits_rcvd_gstathandle
#define bitssec_rcvd_gstathandle pr_state_ptr->bitssec_rcvd_gstathandle
#define pkts_rcvd_gstathandle pr_state_ptr->pkts_rcvd_gstathandle
#define pktssec_rcvd_gstathandle pr_state_ptr->pktssec_rcvd_gstathandle
#define ete_delay_gstathandle pr_state_ptr->ete_delay_gstathandle
#define stored_burst_list_ptr pr_state_ptr->stored_burst_list_ptr
#define code pr_state_ptr->code
#define burst_count_send pr_state_ptr->burst_count_send
#define burst_count_send_stathandle pr_state_ptr->burst_count_send_stathandle
#define burst_size_send pr_state_ptr->burst_size_send
#define burst_size_send_stathandle pr_state_ptr->burst_size_send_stathandle
#define burst_avg_size_send pr_state_ptr->burst_avg_size_send
#define burst_avg_size_send_stathandle pr_state_ptr->burst_avg_size_send_stathandle
#define burst_size_total_send pr_state_ptr->burst_size_total_send
#define burst_count_total_send_stathandle pr_state_ptr->burst_count_total_send_stathandle
#define burst_count_total_stay_stathandle pr_state_ptr->burst_count_total_stay_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 OBS_stord_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 OBS_stord (void);
Compcode OBS_stord_init (void **);
void OBS_stord_diag (void);
void OBS_stord_terminate (void);
void OBS_stord_svar (void *, const char *, char **);
#if defined (__cplusplus)
} /* end of 'extern "C"' */
#endif
/* Process model interrupt handling procedure */
void
OBS_stord (void)
{
int _block_origin = 0;
FIN (OBS_stord ());
if (1)
{
Packet* pkptr;
double pk_size;
double ete_delay;
double duration_time;
int i;
int strm_num;
int list_element_num;
int loop_flag_i;
int temp_code;
BURST_STORDED * burst_storded;
BURST_STORDED * burst_storded_ptr;
double temp_time;
int e_s;
int e_d;
int e_id;
double e_time;
FSM_ENTER (OBS_stord)
FSM_BLOCK_SWITCH
{
/*---------------------------------------------------------*/
/** state (INIT) enter executives **/
FSM_STATE_ENTER_FORCED_NOLABEL (0, "INIT", "OBS_stord () [INIT enter execs]")
{
/* Initilaize the statistic handles to keep */
/* track of traffic sinked by this process. */
/*
bits_rcvd_stathandle = op_stat_reg ("Traffic Sink.Traffic Received (bits)", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
bitssec_rcvd_stathandle = op_stat_reg ("Traffic Sink.Traffic Received (bits/sec)", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
pkts_rcvd_stathandle = op_stat_reg ("Traffic Sink.Traffic Received (packets)", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
pktssec_rcvd_stathandle = op_stat_reg ("Traffic Sink.Traffic Received (packets/sec)", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
ete_delay_stathandle = op_stat_reg ("Traffic Sink.End-to-End Delay (seconds)", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
bits_rcvd_gstathandle = op_stat_reg ("Traffic Sink.Traffic Received (bits)", OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);
bitssec_rcvd_gstathandle = op_stat_reg ("Traffic Sink.Traffic Received (bits/sec)", OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);
pkts_rcvd_gstathandle = op_stat_reg ("Traffic Sink.Traffic Received (packets)", OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);
pktssec_rcvd_gstathandle = op_stat_reg ("Traffic Sink.Traffic Received (packets/sec)", OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);
ete_delay_gstathandle = op_stat_reg ("Traffic Sink.End-to-End Delay (seconds)", OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);
*/
//List init
stored_burst_list_ptr = (List *)op_prg_mem_alloc(sizeof(List));
op_prg_list_init(stored_burst_list_ptr);
code = 0;
burst_count_send = 0;
burst_count_send_stathandle = op_stat_reg("BURST_COUNT_SEND", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
burst_size_send = 0;
burst_size_send_stathandle = op_stat_reg("BURST_SIZE_SEND", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
burst_avg_size_send = 0;
burst_avg_size_send_stathandle = op_stat_reg("BURST_AVG_SIZE_SEND", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
burst_count_total_send_stathandle = op_stat_reg("BURST_COUNT_TOTAL_SEND", OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);
burst_count_total_stay_stathandle = op_stat_reg("BURST_COUNT_TOTAL_STAY", OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);
}
/** state (INIT) exit executives **/
FSM_STATE_EXIT_FORCED (0, "INIT", "OBS_stord () [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", "OBS_stord () [wait enter execs]")
{
}
/** blocking after enter executives of unforced state. **/
FSM_EXIT (3,OBS_stord)
/** state (wait) exit executives **/
FSM_STATE_EXIT_UNFORCED (1, "wait", "OBS_stord () [wait exit execs]")
{
}
/** state (wait) transition processing **/
FSM_INIT_COND (BURST_ARRIVAL)
FSM_TEST_COND (END_SIM)
FSM_TEST_COND (INTRPT_SELF)
FSM_TEST_LOGIC ("wait")
FSM_TRANSIT_SWITCH
{
FSM_CASE_TRANSIT (0, 2, state2_enter_exec, ;, "BURST_ARRIVAL", "", "wait", "stored")
FSM_CASE_TRANSIT (1, 4, state4_enter_exec, ;, "END_SIM", "", "wait", "end")
FSM_CASE_TRANSIT (2, 3, state3_enter_exec, ;, "INTRPT_SELF", "", "wait", "send")
}
/*---------------------------------------------------------*/
/** state (stored) enter executives **/
FSM_STATE_ENTER_FORCED (2, state2_enter_exec, "stored", "OBS_stord () [stored enter execs]")
{
strm_num = op_intrpt_strm ();
burst_storded = (BURST_STORDED *)op_prg_mem_alloc(sizeof(BURST_STORDED));
//pkptr = op_pk_get(strm_num);
//op_pk_nfd_get (pkptr, "start", &duration_time);
burst_storded->pk = op_pk_get(strm_num);
//printf("burst_stored1 sim=%f\n",op_sim_time());
//getchar();
op_pk_nfd_get (burst_storded->pk, "start", &duration_time);
op_pk_nfd_set (burst_storded->pk,"sim time",op_sim_time()+ duration_time);
//printf("burst_stored2 sim=%f\n",op_sim_time());
//getchar();
//burst_storded->pk = op_pk_copy (pkptr);
burst_storded->id = code;
//List insert
op_prg_list_insert(stored_burst_list_ptr,burst_storded,OPC_LISTPOS_TAIL);
//List sort
//printf("stord_code=%d\n",code);
//printf("stord_code=%d\n",burst_storded->id);
//printf("1 intrpt time=%f\n",op_sim_time());
op_intrpt_schedule_self(op_sim_time()+ duration_time,code);
//printf("op_sim_time=%f,du_time=%f,op_du=%f\n",op_sim_time(),duration_time,op_sim_time()+ duration_time);
burst_count_total_stay = op_prg_list_size(stored_burst_list_ptr);
op_stat_write(burst_count_total_stay_stathandle,burst_count_total_stay);
//printf("burst:stored:intrpt time=%f\n",op_sim_time());
code++;
//printf("3 intrpt time=%f\n",op_sim_time());
//getchar();
//op_prg_mem_free(burst_storded);
}
/** state (stored) exit executives **/
FSM_STATE_EXIT_FORCED (2, "stored", "OBS_stord () [stored exit execs]")
{
}
/** state (stored) transition processing **/
FSM_TRANSIT_FORCE (1, state1_enter_exec, ;, "default", "", "stored", "wait")
/*---------------------------------------------------------*/
/** state (send) enter executives **/
FSM_STATE_ENTER_FORCED (3, state3_enter_exec, "send", "OBS_stord () [send enter execs]")
{
burst_storded_ptr = (BURST_STORDED *)op_prg_mem_alloc(sizeof(BURST_STORDED));
list_element_num = op_prg_list_size(stored_burst_list_ptr);
i=0;
loop_flag_i = 1;
temp_code = op_intrpt_code();
while(i<list_element_num && loop_flag_i)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -