⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ramimo_proc.pr.c

📁 用OPNET实现802.11MAC协议DCF协议
💻 C
📖 第 1 页 / 共 5 页
字号:
/* Process model C form file: ramimo_proc.pr.c */
/* Portions of this file copyright 1992-2003 by OPNET Technologies, Inc. */



/* This variable carries the header into the object file */
const char ramimo_proc_pr_c [] = "MIL_3_Tfile_Hdr_ 100A 30A modeler 7 40CD8579 40CD8579 1 ibis pdm106 0 0 none none 0 0 none 0 0 0 0 0 0 0 0 90b 2                                                                                                                                                                                                                                                                                                                                                                                                               ";
#include <string.h>



/* OPNET system definitions */
#include <opnet.h>



/* Header Block */

#include <math.h>

//#define PRINT_INIT
//#define PRINT_SRC_ARVL
//#define PRINT_SENSE
//#define PRINT_TX
//#define PRINT_ROB
//#define PRINT_RX_ARVL
//#define PRINT_TIMEOUT
//#define PACKET

#define SRC_QUEUE 1

#define PROC_INT 0

#define TX_STRM 0
#define RX_STRM 0
#define SRC_STRM 1
#define RX_ARVL ( (op_intrpt_type() == OPC_INTRPT_STRM) && (op_intrpt_code() == RX_STRM) )
#define SRC_ARVL ( (op_intrpt_type() == OPC_INTRPT_STRM) && (op_intrpt_code() == SRC_STRM) )

#define RTS_INT 1
#define CTS_INT 2
#define ACK_INT 3
#define DATA_INT 4
#define VCS_BUSY_INT 5
#define VCS_FREE_INT 6
#define ROB_INT 7
#define TX_TIMEOUT_INT 8
#define RX_TIMEOUT_INT 9
#define RTS ( (op_intrpt_type() == OPC_INTRPT_SELF) && (op_intrpt_code() == RTS_INT) )
#define CTS ( (op_intrpt_type() == OPC_INTRPT_SELF) && (op_intrpt_code() == CTS_INT) )
#define ACK ( (op_intrpt_type() == OPC_INTRPT_SELF) && (op_intrpt_code() == ACK_INT) )
#define DATA ( (op_intrpt_type() == OPC_INTRPT_SELF) && (op_intrpt_code() == DATA_INT) )
#define VCS_busy ( (op_intrpt_type() == OPC_INTRPT_SELF) && (op_intrpt_code() == VCS_BUSY_INT) )
#define VCS_free ( (op_intrpt_type() == OPC_INTRPT_SELF) && (op_intrpt_code() == VCS_FREE_INT) )
#define ROB ( (op_intrpt_type() == OPC_INTRPT_SELF) && (op_intrpt_code() == ROB_INT) )
#define TX_TIMEOUT ( (op_intrpt_type() == OPC_INTRPT_SELF) && (op_intrpt_code() == TX_TIMEOUT_INT) )
#define RX_TIMEOUT ( (op_intrpt_type() == OPC_INTRPT_SELF) && (op_intrpt_code() == RX_TIMEOUT_INT) )

#define PCS (op_intrpt_type() == OPC_INTRPT_STAT)

#define END (op_intrpt_type() == OPC_INTRPT_ENDSIM)

struct packet_list_entry
{
	double number;
    int srcid;

};

typedef struct packet_list_entry listentry;


int equality(double* val1, double* val2)
{
    if(*val1 == *val2)
        return(0);
    else
        return(1);
}

int pktar[100][100];
int pktrx[100][100];
int pktdi[100][100];
int pktqu[100][100];

int numgenpkts = 0;
int numrxpkts = 0;
int numdiscpkts = 0;

/* 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	                 		tx_range;
	double	                 		rx_range;
	Objid	                  		proc_id;
	Objid	                  		node_id;
	char	                   		nodename[20];
	int	                    		userid;
	Objid	                  		subnet_id;
	double	                 		xpos;
	double	                 		ypos;
	int	                    		numnodes;
	Objid	                  		tx_id;
	Objid	                  		txcomp_id;
	Objid	                  		txch_id;
	double	                 		difs;
	double	                 		sifs;
	Objid	                  		rx_id;
	Objid	                  		rxcomp_id;
	Objid	                  		rxch_id;
	int	                    		pcs_state;
	int	                    		vcs_state;
	double	                 		vcs_duration;
	Evhandle	               		chfreeint;
	Evhandle	               		nexttxevent;
	Evhandle	               		robevent;
	int	                    		txstate;
	double	                 		rob;
	Objid	                  		srcobjid;
	Prohandle	              		srcprohandle;
	double	                 		datarate;
	double	                 		datapktsize;
	double	                 		ackpktsize;
	double	                 		rtspktsize;
	double	                 		ctspktsize;
	int	                    		busy;
	int	                    		txreq;
	double	                 		cw_vals[7];
	double	                 		aSlotTime;
	int	                    		ssrc;
	int	                    		slrc;
	int	                    		retrylimit;
	int	                    		numretries;
	Evhandle	               		timeout;
	int	                    		phyflag;
	Evhandle	               		vcsresetevent;
	double	                 		cw_current;
	List*	                  		listptr;
	int	                    		r_table[100][3];
	double	                 		sequencenum;
	double	                 		userload;
	Stathandle	             		txstat;
	Stathandle	             		rxstat;
	Stathandle	             		discstat;
	Stathandle	             		linkstat;
	int	                    		commnodeid;
	Stathandle	             		variancedlystat;
	double	                 		lastdelay;
	Stathandle	             		etoedelaystat;
	char	                   		scenario[20];
	double	                 		resulttime;
	Evhandle	               		rxtimeout;
	} ramimo_proc_state;

#define pr_state_ptr            		((ramimo_proc_state*) (OP_SIM_CONTEXT_PTR->mod_state_ptr))
#define tx_range                		pr_state_ptr->tx_range
#define rx_range                		pr_state_ptr->rx_range
#define proc_id                 		pr_state_ptr->proc_id
#define node_id                 		pr_state_ptr->node_id
#define nodename                		pr_state_ptr->nodename
#define userid                  		pr_state_ptr->userid
#define subnet_id               		pr_state_ptr->subnet_id
#define xpos                    		pr_state_ptr->xpos
#define ypos                    		pr_state_ptr->ypos
#define numnodes                		pr_state_ptr->numnodes
#define tx_id                   		pr_state_ptr->tx_id
#define txcomp_id               		pr_state_ptr->txcomp_id
#define txch_id                 		pr_state_ptr->txch_id
#define difs                    		pr_state_ptr->difs
#define sifs                    		pr_state_ptr->sifs
#define rx_id                   		pr_state_ptr->rx_id
#define rxcomp_id               		pr_state_ptr->rxcomp_id
#define rxch_id                 		pr_state_ptr->rxch_id
#define pcs_state               		pr_state_ptr->pcs_state
#define vcs_state               		pr_state_ptr->vcs_state
#define vcs_duration            		pr_state_ptr->vcs_duration
#define chfreeint               		pr_state_ptr->chfreeint
#define nexttxevent             		pr_state_ptr->nexttxevent
#define robevent                		pr_state_ptr->robevent
#define txstate                 		pr_state_ptr->txstate
#define rob                     		pr_state_ptr->rob
#define srcobjid                		pr_state_ptr->srcobjid
#define srcprohandle            		pr_state_ptr->srcprohandle
#define datarate                		pr_state_ptr->datarate
#define datapktsize             		pr_state_ptr->datapktsize
#define ackpktsize              		pr_state_ptr->ackpktsize
#define rtspktsize              		pr_state_ptr->rtspktsize
#define ctspktsize              		pr_state_ptr->ctspktsize
#define busy                    		pr_state_ptr->busy
#define txreq                   		pr_state_ptr->txreq
#define cw_vals                 		pr_state_ptr->cw_vals
#define aSlotTime               		pr_state_ptr->aSlotTime
#define ssrc                    		pr_state_ptr->ssrc
#define slrc                    		pr_state_ptr->slrc
#define retrylimit              		pr_state_ptr->retrylimit
#define numretries              		pr_state_ptr->numretries
#define timeout                 		pr_state_ptr->timeout
#define phyflag                 		pr_state_ptr->phyflag
#define vcsresetevent           		pr_state_ptr->vcsresetevent
#define cw_current              		pr_state_ptr->cw_current
#define listptr                 		pr_state_ptr->listptr
#define r_table                 		pr_state_ptr->r_table
#define sequencenum             		pr_state_ptr->sequencenum
#define userload                		pr_state_ptr->userload
#define txstat                  		pr_state_ptr->txstat
#define rxstat                  		pr_state_ptr->rxstat
#define discstat                		pr_state_ptr->discstat
#define linkstat                		pr_state_ptr->linkstat
#define commnodeid              		pr_state_ptr->commnodeid
#define variancedlystat         		pr_state_ptr->variancedlystat
#define lastdelay               		pr_state_ptr->lastdelay
#define etoedelaystat           		pr_state_ptr->etoedelaystat
#define scenario                		pr_state_ptr->scenario
#define resulttime              		pr_state_ptr->resulttime
#define rxtimeout               		pr_state_ptr->rxtimeout

/* 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	ramimo_proc_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 = ((ramimo_proc_state *)(tcontext_ptr->mod_state_ptr));
#else
#  define FIN_PREAMBLE_DEC	ramimo_proc_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 ramimo_proc (OP_SIM_CONTEXT_ARG_OPT);
	VosT_Obtype ramimo_proc_init (int * init_block_ptr);
	VosT_Address ramimo_proc_alloc (VOS_THREAD_INDEX_ARG_COMMA VosT_Obtype, int);
	void ramimo_proc_diag (OP_SIM_CONTEXT_ARG_OPT);
	void ramimo_proc_terminate (OP_SIM_CONTEXT_ARG_OPT);
	void ramimo_proc_svar (void *, const char *, void **);


	VosT_Fun_Status Vos_Define_Object (VosT_Obtype * _op_obst_ptr, const char * _op_name, unsigned int _op_size, unsigned int _op_init_obs, unsigned int _op_inc_obs);
	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
ramimo_proc (OP_SIM_CONTEXT_ARG_OPT)
	{

#if !defined (VOSD_NO_FIN)
	int _op_block_origin = 0;
#endif
	FIN_MT (ramimo_proc ());
	if (1)
		{
		int namelength = 0;
		int i = 0;
		int j;
		int i_temp = 0;
		int nodenum = 0;
		int tempint = 0;
		int tempint2 = 0;
		Objid other_node_id;
		double other_xpos = 0.0;
		double other_ypos = 0.0;
		double distance = 0.0;
		double tempdouble = 0.0;
		double tempdouble2 = 0.0;
		Objid other_proc_id;
		Objid other_rx_id;
		Objid other_rxcomp_id;
		Objid other_rxch_id;
		int numreceivers = 0;
		Objid *receivers;
		Packet *pktptr;
		Packet *origpktptr;
		Packet *otherpktptr;
		char pktname[20];
		int srcid;
		int destid;
		double seqnum;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -