📄 tan_noc_worm_fifo_out.pr.c
字号:
/* Process model C form file: tan_noc_worm_FIFO_OUT.pr.c */
/* Portions of this file copyright 1992-2004 by OPNET Technologies, Inc. */
/* This variable carries the header into the object file */
const char tan_noc_worm_FIFO_OUT_pr_c [] = "MIL_3_Tfile_Hdr_ 105A 30A modeler 7 49DD5F52 49DD5F52 1 05934b0918b5482 Administrator 0 0 none none 0 0 none 0 0 0 0 0 0 0 0 a0a 3 ";
#include <string.h>
/* OPNET system definitions */
#include <opnet.h>
/* Header Block */
#define QUEUE_EMPTY (op_q_empty())
#define SVC_COMPLETION op_intrpt_type() == OPC_INTRPT_SELF
#define ARRIVAL op_intrpt_type() == OPC_INTRPT_STRM
#define FLOW_CONTROL (op_intrpt_type() == OPC_INTRPT_STAT)
#define NEXT_FIFO_FULL_0 0
#define NEXT_FIFO_FULL_1 1
#define NEXT_FIFO_FULL_2 2
#define NEXT_FIFO_FULL_3 3
#define NEXT_FIFO_FULL_4 4
/* 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 */
double service_rate ;
int server_busy ;
Objid own_id ;
Stathandle fifo_full ;
Stathandle pk_destroy ;
int next_0 ;
Stathandle pk_delay_local ;
int next_1 ;
int next_2 ;
int next_3 ;
int next_4 ;
Sar_Buffer* rsm_sbh ;
} tan_noc_worm_FIFO_OUT_state;
#define pr_state_ptr ((tan_noc_worm_FIFO_OUT_state*) (OP_SIM_CONTEXT_PTR->mod_state_ptr))
#define service_rate pr_state_ptr->service_rate
#define server_busy pr_state_ptr->server_busy
#define own_id pr_state_ptr->own_id
#define fifo_full pr_state_ptr->fifo_full
#define pk_destroy pr_state_ptr->pk_destroy
#define next_0 pr_state_ptr->next_0
#define pk_delay_local pr_state_ptr->pk_delay_local
#define next_1 pr_state_ptr->next_1
#define next_2 pr_state_ptr->next_2
#define next_3 pr_state_ptr->next_3
#define next_4 pr_state_ptr->next_4
#define rsm_sbh pr_state_ptr->rsm_sbh
/* 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 tan_noc_worm_FIFO_OUT_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 = ((tan_noc_worm_FIFO_OUT_state *)(tcontext_ptr->mod_state_ptr));
#else
# define FIN_PREAMBLE_DEC tan_noc_worm_FIFO_OUT_state *op_sv_ptr;
# define FIN_PREAMBLE_CODE op_sv_ptr = pr_state_ptr;
#endif
/* No Function Block */
#if !defined (VOSD_NO_FIN)
enum { _op_block_origin = __LINE__ };
#endif
/* 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 tan_noc_worm_FIFO_OUT (OP_SIM_CONTEXT_ARG_OPT);
VosT_Obtype tan_noc_worm_FIFO_OUT_init (int * init_block_ptr);
VosT_Address tan_noc_worm_FIFO_OUT_alloc (VOS_THREAD_INDEX_ARG_COMMA VosT_Obtype, int);
void tan_noc_worm_FIFO_OUT_diag (OP_SIM_CONTEXT_ARG_OPT);
void tan_noc_worm_FIFO_OUT_terminate (OP_SIM_CONTEXT_ARG_OPT);
void tan_noc_worm_FIFO_OUT_svar (void *, const char *, void **);
VosT_Obtype Vos_Define_Object_Prstate (const char * _op_name, unsigned int _op_size);
VosT_Address Vos_Alloc_Object_MT (VOS_THREAD_INDEX_ARG_COMMA VosT_Obtype _op_ob_hndl);
VosT_Fun_Status Vos_Poolmem_Dealloc_MT (VOS_THREAD_INDEX_ARG_COMMA VosT_Address _op_ob_ptr);
#if defined (__cplusplus)
} /* end of 'extern "C"' */
#endif
/* Process model interrupt handling procedure */
void
tan_noc_worm_FIFO_OUT (OP_SIM_CONTEXT_ARG_OPT)
{
#if !defined (VOSD_NO_FIN)
int _op_block_origin = 0;
#endif
FIN_MT (tan_noc_worm_FIFO_OUT ());
{
/* Temporary Variables */
Packet* pkptr;
OpT_Packet_Size pk_len;
//Sar_Buffer * rsm_sbh;
double pk_svc_time;
int insert_ok;
int dest_address;
int count, i;
int val;
//bit
//struct SimT_vvec_Vector * des;
//struct SimT_Vvec_Vector *
Vvec_Vector des;
/* End of Temporary Variables */
FSM_ENTER ("tan_noc_worm_FIFO_OUT")
FSM_BLOCK_SWITCH
{
/*---------------------------------------------------------*/
/** state (init) enter executives **/
FSM_STATE_ENTER_FORCED_NOLABEL (0, "init", "tan_noc_worm_FIFO_OUT [init enter execs]")
FSM_PROFILE_SECTION_IN ("tan_noc_worm_FIFO_OUT [init enter execs]", state0_enter_exec)
{
// initially the server is idle
server_busy = 0;
// get queue module's own object id
own_id = op_id_self();
// get assigned value of server processing rate
op_ima_obj_attr_get(own_id, "service_rate", &service_rate);
// regdit stathand
fifo_full = op_stat_reg("FULL", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
pk_destroy = op_stat_reg("PK_DES", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
pk_delay_local = op_stat_reg("PK_DELAY_LOCAL", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
// Create a reassembly buffer
rsm_sbh = op_sar_buf_create(OPC_SAR_BUF_TYPE_REASSEMBLY, OPC_SAR_BUF_OPT_DEFAULT);
next_0 = 0;
next_1 = 0;
next_2 = 0;
next_3 = 0;
next_4 = 0;
}
FSM_PROFILE_SECTION_OUT (state0_enter_exec)
/** state (init) exit executives **/
FSM_STATE_EXIT_FORCED (0, "init", "tan_noc_worm_FIFO_OUT [init exit execs]")
/** state (init) transition processing **/
FSM_PROFILE_SECTION_IN ("tan_noc_worm_FIFO_OUT [init trans conditions]", state0_trans_conds)
FSM_INIT_COND (ARRIVAL)
FSM_DFLT_COND
FSM_TEST_LOGIC ("init")
FSM_PROFILE_SECTION_OUT (state0_trans_conds)
FSM_TRANSIT_SWITCH
{
FSM_CASE_TRANSIT (0, 1, state1_enter_exec, ;, "ARRIVAL", "", "init", "arrival")
FSM_CASE_TRANSIT (1, 2, state2_enter_exec, ;, "default", "", "init", "idle")
}
/*---------------------------------------------------------*/
/** state (arrival) enter executives **/
FSM_STATE_ENTER_FORCED (1, "arrival", state1_enter_exec, "tan_noc_worm_FIFO_OUT [arrival enter execs]")
FSM_PROFILE_SECTION_IN ("tan_noc_worm_FIFO_OUT [arrival enter execs]", state1_enter_exec)
{
// Receive an incoming packet.
pkptr = op_pk_get(op_intrpt_strm());
//op_pk_fd_get(pkptr, 0, &dest_address);
//op_pk_convert_from_vvec(pkptr, "tan_noc_worm_head");
op_pk_convert_to_vvec(pkptr);
op_pk_vvec_get(pkptr, &des);
printf("fifo out vvec size : %d , %d\n", op_vvec_size_get(des), des);
op_vvec_print(des);
op_vvec_to_value(des, OPC_VVEC_BYTE_ORDER_BIG_ENDIAN, OPC_VVEC_BITFORMAT_BINARY, OPC_VVEC_NATIVE_INT, &i);
printf("i : %d\n", i);
/*
for(i = 0; i < op_vvec_size_get(des); i++) {
//op_vvec_value_get(des, i, &val);
//if(val == 0) printf("val : %d 0\n", i);
//else printf("val : %d 1\n", i);
printf("val : %d\n", des[i]);
}
*/
//op_pk_nfd_get(pkptr, "dest_address", &dest_address);
//printf("dest_address : %d\n", dest_address);
//op_pk_nfd_get(pkptr, "sour_address", &dest_address);
//printf("sour_address : %d\n", dest_address);
/*
op_pk_convert_to_vvec(pkptr);
op_pk_vvec_get(pkptr, &des);
dest_address = 0;
for(i = 0; i < 4; i++) {
op_vvec_value_get(des, i, &dest_address);
printf("val : %d %d ", dest_address, des);
}
dest_address = 0;
printf("pkptr size : %d %d\n", op_pk_total_size_get(pkptr), dest_address);
*/
//printf("pkptr fd size : %d\n", op_pk_fd_size(pkptr, 0));
// create the rsm buffer.
//rsm_sbh = op_sar_buf_create(OPC_SAR_BUF_TYPE_REASSEMBLY, OPC_SAR_BUF_OPT_PK_BNDRY);
// Determine if the received packet is a segment, or normal packet.
if(op_sar_pk_is_segment(pkptr) == OPC_TRUE) {
// Received a segment, add to reassembly buffer.
op_sar_rsmbuf_seg_insert(rsm_sbh, pkptr);
// See if any packets are ready to be removed from reassembly buffer.
insert_ok = 0;
while((pkptr = op_sar_rsmbuf_pk_remove(rsm_sbh)) != OPC_NIL) {
// attempt to enqueue the packet at tail of subqueue 0.
op_pk_nfd_get(pkptr, "dest_address", &dest_address);
op_pk_nfd_get(pkptr, "count_num", &count);
printf("dest_address, count_num : %d %d\n", dest_address, count);
//printf("pkptr fd size : %d\n", op_pk_fd_size(pkptr, 0));
if(op_subq_pk_insert(0, pkptr, OPC_QPOS_TAIL) != OPC_QINS_OK) {
// the insertion failed (due to a full queue) deallocate the packet.
op_pk_destroy(pkptr);
op_stat_write(pk_destroy, 1.0);
// set flag indicating insertion fail
insert_ok = 0;
//printf("insert : %d\n", insert_ok);
}
else {
// insertion is successful.
insert_ok = 1;
}
}
}
else {
// Received a normal packet; insert it.
if(op_subq_pk_insert(0, pkptr, OPC_QPOS_TAIL) != OPC_QINS_OK) {
// the insertion failed (due to a full queue) deallocate the packet.
op_pk_destroy(pkptr);
op_stat_write(pk_destroy, 1.0);
// set flag indicating insertion fail.
insert_ok = 0;
}
else {
// insertion is successful.
insert_ok = 1;
op_stat_write(pk_delay_local, op_sim_time() - op_pk_creation_time_get(pkptr));
}
}
printf("insert : %d\n", insert_ok);
}
FSM_PROFILE_SECTION_OUT (state1_enter_exec)
/** state (arrival) exit executives **/
FSM_STATE_EXIT_FORCED (1, "arrival", "tan_noc_worm_FIFO_OUT [arrival exit execs]")
/** state (arrival) transition processing **/
FSM_PROFILE_SECTION_IN ("tan_noc_worm_FIFO_OUT [arrival trans conditions]", state1_trans_conds)
FSM_INIT_COND (server_busy || QUEUE_EMPTY)
FSM_TEST_COND (!server_busy&&insert_ok&&!QUEUE_EMPTY)
FSM_TEST_LOGIC ("arrival")
FSM_PROFILE_SECTION_OUT (state1_trans_conds)
FSM_TRANSIT_SWITCH
{
FSM_CASE_TRANSIT (0, 2, state2_enter_exec, ;, "server_busy || QUEUE_EMPTY", "", "arrival", "idle")
FSM_CASE_TRANSIT (1, 3, state3_enter_exec, ;, "!server_busy&&insert_ok&&!QUEUE_EMPTY", "", "arrival", "svc_start")
}
/*---------------------------------------------------------*/
/** state (idle) enter executives **/
FSM_STATE_ENTER_UNFORCED (2, "idle", state2_enter_exec, "tan_noc_worm_FIFO_OUT [idle enter execs]")
/** blocking after enter executives of unforced state. **/
FSM_EXIT (5,"tan_noc_worm_FIFO_OUT")
/** state (idle) exit executives **/
FSM_STATE_EXIT_UNFORCED (2, "idle", "tan_noc_worm_FIFO_OUT [idle exit execs]")
/** state (idle) transition processing **/
FSM_PROFILE_SECTION_IN ("tan_noc_worm_FIFO_OUT [idle trans conditions]", state2_trans_conds)
FSM_INIT_COND (ARRIVAL)
FSM_TEST_COND (FLOW_CONTROL)
FSM_TEST_COND (SVC_COMPLETION)
FSM_TEST_LOGIC ("idle")
FSM_PROFILE_SECTION_OUT (state2_trans_conds)
FSM_TRANSIT_SWITCH
{
FSM_CASE_TRANSIT (0, 1, state1_enter_exec, ;, "ARRIVAL", "", "idle", "arrival")
FSM_CASE_TRANSIT (1, 5, state5_enter_exec, ;, "FLOW_CONTROL", "", "idle", "FLOW_CON")
FSM_CASE_TRANSIT (2, 4, state4_enter_exec, ;, "SVC_COMPLETION", "", "idle", "svc_complete")
}
/*---------------------------------------------------------*/
/** state (svc_start) enter executives **/
FSM_STATE_ENTER_FORCED (3, "svc_start", state3_enter_exec, "tan_noc_worm_FIFO_OUT [svc_start enter execs]")
FSM_PROFILE_SECTION_IN ("tan_noc_worm_FIFO_OUT [svc_start enter execs]", state3_enter_exec)
{
/* get a handle on packet at head of subqueue 0 */
/* (this does not remove the packet) */
pkptr = op_subq_pk_access (0, OPC_QPOS_HEAD);
/* determine the packets length (in bits) */
pk_len = op_pk_total_size_get (pkptr);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -