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

📄 obs_proc_q.pr.c

📁 实验室前辈用OPNET做的光突发交换网络的仿真实验
💻 C
📖 第 1 页 / 共 3 页
字号:
/* Process model C form file: OBS_proc_q.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_proc_q_pr_c [] = "MIL_3_Tfile_Hdr_ 80C 30A modeler 7 42549593 42549593 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_RETURN   1
#define PK_OUT_STRM			1
#define PK_OUT_STRM_STORE	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)
#define BCP_ARRIVAL (op_intrpt_type () == OPC_INTRPT_STRM && op_intrpt_strm () == PK_IN_STRM_RETURN)
#define INTRPT_SELF (op_intrpt_type() == OPC_INTRPT_SELF) 
#define INTRPT_REMOTE (op_intrpt_type() == OPC_INTRPT_REMOTE)
int node_count = 0;   

double pk_size_total_send = 0;
int pk_count_total_send	= 0;
double pk_avg_total_size_send = 0;
int subq_count = 6;
int gen_count_total_send = 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;
	Stathandle	             		pk_size_total_send_stathandle;
	Stathandle	             		pk_cnt_total_send_stathandle;
	double	                 		pk_avg_size_send;
	int	                    		pk_count_send_channel0;
	int	                    		pk_count_send_channel1;
	double	                 		pk_size_send_channel0;
	double	                 		pk_size_send_channel1;
	Stathandle	             		pk_avg_size_send_stathandle;
	Stathandle	             		pk_count_send_channel0_stathandle;
	Stathandle	             		pk_size_send_channel0_stathandle;
	Stathandle	             		pk_count_send_channel1_stathandle;
	Stathandle	             		pk_size_send_channel1_stathandle;
	Stathandle	             		pk_avg_total_size_send_stathandle;
	int	                    		id_number;
	int	                    		subq_index;
	Stathandle	             		gen_count_total_send_stathandle;
	int	                    		burst_count_to_node1;
	double	                 		burst_size_to_node1;
	int	                    		burst_count_to_node2;
	double	                 		burst_size_to_node2;
	int	                    		burst_count_to_node3;
	double	                 		burst_size_to_node3;
	int	                    		burst_count_to_node4;
	double	                 		burst_size_to_node4;
	int	                    		burst_count_to_node5;
	double	                 		burst_size_to_node5;
	int	                    		burst_count_to_node6;
	double	                 		burst_size_to_node6;
	Stathandle	             		burst_count_to_node1_stathandle;
	Stathandle	             		burst_count_to_node2_stathandle;
	Stathandle	             		burst_count_to_node3_stathandle;
	Stathandle	             		burst_count_to_node4_stathandle;
	Stathandle	             		burst_count_to_node5_stathandle;
	Stathandle	             		burst_count_to_node6_stathandle;
	Stathandle	             		burst_size_to_node1_stathandle;
	Stathandle	             		burst_size_to_node2_stathandle;
	Stathandle	             		burst_size_to_node3_stathandle;
	Stathandle	             		burst_size_to_node4_stathandle;
	Stathandle	             		burst_size_to_node5_stathandle;
	Stathandle	             		burst_size_to_node6_stathandle;
	} OBS_proc_q_state;

#define pr_state_ptr            		((OBS_proc_q_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
#define pk_size_total_send_stathandle		pr_state_ptr->pk_size_total_send_stathandle
#define pk_cnt_total_send_stathandle		pr_state_ptr->pk_cnt_total_send_stathandle
#define pk_avg_size_send        		pr_state_ptr->pk_avg_size_send
#define pk_count_send_channel0  		pr_state_ptr->pk_count_send_channel0
#define pk_count_send_channel1  		pr_state_ptr->pk_count_send_channel1
#define pk_size_send_channel0   		pr_state_ptr->pk_size_send_channel0
#define pk_size_send_channel1   		pr_state_ptr->pk_size_send_channel1
#define pk_avg_size_send_stathandle		pr_state_ptr->pk_avg_size_send_stathandle
#define pk_count_send_channel0_stathandle		pr_state_ptr->pk_count_send_channel0_stathandle
#define pk_size_send_channel0_stathandle		pr_state_ptr->pk_size_send_channel0_stathandle
#define pk_count_send_channel1_stathandle		pr_state_ptr->pk_count_send_channel1_stathandle
#define pk_size_send_channel1_stathandle		pr_state_ptr->pk_size_send_channel1_stathandle
#define pk_avg_total_size_send_stathandle		pr_state_ptr->pk_avg_total_size_send_stathandle
#define id_number               		pr_state_ptr->id_number
#define subq_index              		pr_state_ptr->subq_index
#define gen_count_total_send_stathandle		pr_state_ptr->gen_count_total_send_stathandle
#define burst_count_to_node1    		pr_state_ptr->burst_count_to_node1
#define burst_size_to_node1     		pr_state_ptr->burst_size_to_node1
#define burst_count_to_node2    		pr_state_ptr->burst_count_to_node2
#define burst_size_to_node2     		pr_state_ptr->burst_size_to_node2
#define burst_count_to_node3    		pr_state_ptr->burst_count_to_node3
#define burst_size_to_node3     		pr_state_ptr->burst_size_to_node3
#define burst_count_to_node4    		pr_state_ptr->burst_count_to_node4
#define burst_size_to_node4     		pr_state_ptr->burst_size_to_node4
#define burst_count_to_node5    		pr_state_ptr->burst_count_to_node5
#define burst_size_to_node5     		pr_state_ptr->burst_size_to_node5
#define burst_count_to_node6    		pr_state_ptr->burst_count_to_node6
#define burst_size_to_node6     		pr_state_ptr->burst_size_to_node6
#define burst_count_to_node1_stathandle		pr_state_ptr->burst_count_to_node1_stathandle
#define burst_count_to_node2_stathandle		pr_state_ptr->burst_count_to_node2_stathandle
#define burst_count_to_node3_stathandle		pr_state_ptr->burst_count_to_node3_stathandle
#define burst_count_to_node4_stathandle		pr_state_ptr->burst_count_to_node4_stathandle
#define burst_count_to_node5_stathandle		pr_state_ptr->burst_count_to_node5_stathandle
#define burst_count_to_node6_stathandle		pr_state_ptr->burst_count_to_node6_stathandle
#define burst_size_to_node1_stathandle		pr_state_ptr->burst_size_to_node1_stathandle
#define burst_size_to_node2_stathandle		pr_state_ptr->burst_size_to_node2_stathandle
#define burst_size_to_node3_stathandle		pr_state_ptr->burst_size_to_node3_stathandle
#define burst_size_to_node4_stathandle		pr_state_ptr->burst_size_to_node4_stathandle
#define burst_size_to_node5_stathandle		pr_state_ptr->burst_size_to_node5_stathandle
#define burst_size_to_node6_stathandle		pr_state_ptr->burst_size_to_node6_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_proc_q_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_proc_q (void);
	Compcode OBS_proc_q_init (void **);
	void OBS_proc_q_diag (void);
	void OBS_proc_q_terminate (void);
	void OBS_proc_q_svar (void *, const char *, char **);
#if defined (__cplusplus)
} /* end of 'extern "C"' */
#endif




/* Process model interrupt handling procedure */


void
OBS_proc_q (void)
	{
	int _block_origin = 0;
	FIN (OBS_proc_q ());
	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;
		int 		jj;
		int 		channel_num;
		double		temp_time;
		double      temp_size;
		int			temp_flag_suc;
		int			id_number_temp;
		int			temp_code;
		
		
		


		FSM_ENTER (OBS_proc_q)

		FSM_BLOCK_SWITCH
			{
			/*---------------------------------------------------------*/
			/** state (init) enter executives **/
			FSM_STATE_ENTER_FORCED_NOLABEL (0, "init", "OBS_proc_q () [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);	
				id_number = 0;
				
				/* 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, NODE_NUM);
				
				/* 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);
				op_intrpt_schedule_self(op_sim_time()+ 0.000001,0);
				
				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);
				
				//pk_size_total_send = 0;
				pk_size_total_send_stathandle = op_stat_reg("PK_SIZE_TOTAL_SEND",OPC_STAT_INDEX_NONE,OPC_STAT_GLOBAL);
				
				//pk_count_total_send = 0;
				pk_cnt_total_send_stathandle = op_stat_reg("PK_COUNT_TOTAL_SEND", OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);
				
				
				//pk_avg_total_size_send = 0;
				pk_avg_total_size_send_stathandle = op_stat_reg("PK_AVG_TOTAL_SIZE_SEND", OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);
				
				
				gen_count_total_send_stathandle = op_stat_reg("GEN_COUNT_TOTAL_SEND", OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);
				
				pk_avg_size_send = 0;
				pk_avg_size_send_stathandle = op_stat_reg("PK_AVG_SIZE_SEND", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
				
				printf("proc:init:,userid=%d\n",node_address);
				subq_index = 0;
				
				burst_count_to_node1 = 0;
				burst_count_to_node1_stathandle = op_stat_reg("BURST_COUNT_TO_NODE1", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
				burst_size_to_node1 = 0;
				burst_size_to_node1_stathandle = op_stat_reg("BURST_SIZE_TO_NODE1", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
				
				burst_count_to_node2 = 0;
				burst_count_to_node2_stathandle = op_stat_reg("BURST_COUNT_TO_NODE2", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
				burst_size_to_node2 = 0;
				burst_size_to_node2_stathandle = op_stat_reg("BURST_SIZE_TO_NODE2", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
				
				burst_count_to_node3 = 0;
				burst_count_to_node3_stathandle = op_stat_reg("BURST_COUNT_TO_NODE3", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
				burst_size_to_node3 = 0;
				burst_size_to_node3_stathandle = op_stat_reg("BURST_SIZE_TO_NODE3", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
				
				burst_count_to_node4 = 0;
				burst_count_to_node4_stathandle = op_stat_reg("BURST_COUNT_TO_NODE4", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
				burst_size_to_node4 = 0;
				burst_size_to_node4_stathandle = op_stat_reg("BURST_SIZE_TO_NODE4", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
				
				burst_count_to_node5 = 0;
				burst_count_to_node5_stathandle = op_stat_reg("BURST_COUNT_TO_NODE5", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
				burst_size_to_node5 = 0;
				burst_size_to_node5_stathandle = op_stat_reg("BURST_SIZE_TO_NODE5", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
				
				burst_count_to_node6 = 0;
				burst_count_to_node6_stathandle = op_stat_reg("BURST_COUNT_TO_NODE6", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
				burst_size_to_node6 = 0;
				burst_size_to_node6_stathandle = op_stat_reg("BURST_SIZE_TO_NODE6", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
				
				
				
				
				pk_count_send_channel0 = 0;
				pk_count_send_channel0_stathandle = op_stat_reg("PK_COUNT_SEND_CHANNEL0", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
				
				pk_size_send_channel0 = 0;
				pk_size_send_channel0_stathandle = op_stat_reg("PK_SIZE_SEND_CHANNEL0", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
				
				pk_count_send_channel1 = 0;
				pk_count_send_channel1_stathandle = op_stat_reg("PK_COUNT_SEND_CHANNEL1", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
				
				pk_size_send_channel1 = 0;
				pk_size_send_channel1_stathandle = op_stat_reg("PK_SIZE_SEND_CHANNEL1", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
				}


			/** state (init) exit executives **/
			FSM_STATE_EXIT_FORCED (0, "init", "OBS_proc_q () [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_proc_q () [wait enter execs]")
				{
				//printf("wait");
				//getchar();
				}


			/** blocking after enter executives of unforced state. **/
			FSM_EXIT (3,OBS_proc_q)


			/** state (wait) exit executives **/

⌨️ 快捷键说明

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