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

📄 restoration_rte.pr.c

📁 实验室前辈用OPNET做的光突发交换网络的仿真实验
💻 C
📖 第 1 页 / 共 2 页
字号:
/* Process model C form file: Restoration_rte.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 Restoration_rte_pr_c [] = "MIL_3_Tfile_Hdr_ 80C 30A modeler 7 40E41B69 40E41B69 1 babo123 Administrator 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 	"route.h"

#define		BEG_SIM (op_intrpt_type () == OPC_INTRPT_BEGSIM)
#define 	END_SIM	(op_intrpt_type () == OPC_INTRPT_ENDSIM)

#define 	MAX_HOPS 		15
#define 	PK_ARRIVAL (op_intrpt_type () == OPC_INTRPT_STRM)
#define 	PK_OUT_STRM 	4

double		gap[NODE_NUM][NODE_NUM][WAVE_NUM];
Packet*		pkptr;
FILE 		*fp;
typedef struct {
double 		start;
double 		dtime;
} wave_info;
typedef struct {
double 		start;
double 		dtime;
} wavelength_info;

int			first_time = 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 */
	Route*	                 		current_rptr;
	Objid	                  		subnet_id;
	Objid	                  		next_node_id;
	int	                    		rev_pk_count;
	Stathandle	             		rev_pk_cnt_stathandle;
	Objid	                  		node_objid;
	Objid	                  		self_objid;
	Objid	                  		subnet_objid;
	int	                    		node_pk_count;
	Objid	                  		dst_node_id;
	int	                    		send_ok;
	} Restoration_rte_state;

#define pr_state_ptr            		((Restoration_rte_state*) SimI_Mod_State_Ptr)
#define current_rptr            		pr_state_ptr->current_rptr
#define subnet_id               		pr_state_ptr->subnet_id
#define next_node_id            		pr_state_ptr->next_node_id
#define rev_pk_count            		pr_state_ptr->rev_pk_count
#define rev_pk_cnt_stathandle   		pr_state_ptr->rev_pk_cnt_stathandle
#define node_objid              		pr_state_ptr->node_objid
#define self_objid              		pr_state_ptr->self_objid
#define subnet_objid            		pr_state_ptr->subnet_objid
#define node_pk_count           		pr_state_ptr->node_pk_count
#define dst_node_id             		pr_state_ptr->dst_node_id
#define send_ok                 		pr_state_ptr->send_ok

/* 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	Restoration_rte_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 Restoration_rte (void);
	Compcode Restoration_rte_init (void **);
	void Restoration_rte_diag (void);
	void Restoration_rte_terminate (void);
	void Restoration_rte_svar (void *, const char *, char **);
#if defined (__cplusplus)
} /* end of 'extern "C"' */
#endif




/* Process model interrupt handling procedure */


void
Restoration_rte (void)
	{
	int _block_origin = 0;
	FIN (Restoration_rte ());
	if (1)
		{
		Objid		dest_objid;
		Objid		src_objid;
		Objid		FIS_dest_objid;
		Objid		FIS_src_objid;
		Objid		src_node_objid;
		Objid		dst_node_objid;
		Objid		current_node_objid;
		Objid		next_node_objid;
		Objid		link_objid;
		Objid		tx_objid;
		Objid		strm_objid;
		int			destination_address;
		int			source_address;
		
		int			fail_name;
		int			strm_num;
		int			dst_address;
		int			wave_count;
		int			userid;//init
		char		name_id[10];
		
		int			fis_gen_userid;//fis_gen
		char		fis_gen_name_id[10];
		
		int			next_userid;//send
		int			current_userid;
		
		int			same_userid;//same
		char		same_name_id[10];
		
		int			rte_userid;//all
		char		rte_name_id[10];
		
		int			flag;
		int			PK_type;
		
		Packet*		FIS_pkptr;
		Packet*		r_FIS_pkptr;
		Packet*		ack_pkptr;
		Route*		FIS_min_rptr_copy;
		Route*		FIS_current_rptr;
		Route*		FIS_rptr;
		double		link_cost;
		Route*		pk_rptr;
		Route*		pk_r;
		Route*		route_ptr;
		Route_Link*	link_ptr;
		Route*		min_rptr_copy;
		Route*		route_test;
		Route_Set*	FIS_rset_ptr_t;
		Route*		FIS_min_rptr_t;
		char		node_name[255];
		char		id[20];
		Objid*		node_objid_ptr;
		int			i, num_nodes;
		int			subnet_ids[10], node_ids[10];
		double		cur_time;
		Packet*		cp_pkptr;
		int			next_address;
		double		start_time, dtime_time;
		double		n_start_time;
		double		o_start_time;
		double		start_time_1, dtime_time_1;
		double		start_time_2, dtime_time_2;
		
		int			s_f, num;
		
		int 		j,k;
		
		int 		check_num, num1, num2,num3,num4;
		double		list_table[100][2];
		double		dtime;
		double		stime;
		
		int			delete_num;
		
		int 		FIS_fail_type;
		int 		FIS_node_link;
		int 		FIS_destination;
		int 		FIS_source[17][17];
		int 		x,y;
		int 		PK_source[17][17];
		int 		check, s_f_flag, FIS_s_f_flag ;
		int 		send_check;
		char		file_name[10];
		int			num_routes[17][17];
		int			exit_flag;
		int			l;
		int			comp_flag;
		int			change_flag;
		int 		pk_type;
		int			hop;
		int			bef_address;
		int			reserved_wave;
		
		int			temp_wave;
		double		temp_gap;
		int			insert_flag;
		double		offset_time;
		double		old_offset_time;
		int			loop_stop;
		double		new_start_time;
		
		int			route_flag;
		int			userid_c;
		int			userid_n;
		int			userid_d;
		int			restoration_flag;
		
		
		wave_info*	wave;
		wave_info*	wave_info_table;
		wave_info*	wave_free;
		
		wavelength_info*	wavelength;
		wavelength_info*	wavelength_info_table;
		wavelength_info*	wavelength_free;
		
		
		int			lost_flag;
		int			backup_flag;
		int			need_schedule;
		int			include_flag;
		int			hop_num_back;
		
		
		double		wavelength_list_table[100][2];
		
		
		int 		wavelength_number;
		int			wavelength_num;
		int			wave_break;


		FSM_ENTER (Restoration_rte)

		FSM_BLOCK_SWITCH
			{
			/*---------------------------------------------------------*/
			/** state (init) enter executives **/
			FSM_STATE_ENTER_FORCED_NOLABEL (0, "init", "Restoration_rte () [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);
				
				}


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


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


			/** state (wait) exit executives **/
			FSM_STATE_EXIT_UNFORCED (1, "wait", "Restoration_rte () [wait exit execs]")
				{
				}


			/** state (wait) transition processing **/
			FSM_INIT_COND (END_SIM)
			FSM_TEST_COND (PK_ARRIVAL)
			FSM_TEST_LOGIC ("wait")

			FSM_TRANSIT_SWITCH
				{
				FSM_CASE_TRANSIT (0, 4, state4_enter_exec, ;, "END_SIM", "", "wait", "end")
				FSM_CASE_TRANSIT (1, 2, state2_enter_exec, ;, "PK_ARRIVAL", "", "wait", "get_rte")
				}
				/*---------------------------------------------------------*/



			/** state (get_rte) enter executives **/
			FSM_STATE_ENTER_FORCED (2, state2_enter_exec, "get_rte", "Restoration_rte () [get_rte 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);
				
				strm_num = op_intrpt_strm ();
				pkptr = op_pk_get(strm_num);
				
				op_pk_print(pkptr);
				getchar();
				
				op_pk_nfd_get (pkptr, "destination address", &destination_address);
				op_pk_nfd_get (pkptr, "source address", &source_address);
					
					
				dest_objid = op_id_from_userid (subnet_objid, OPC_OBJTYPE_NDFIX, destination_address);
				src_objid = op_id_from_userid (subnet_objid, OPC_OBJTYPE_NDFIX, source_address);
				op_pk_nfd_get (pkptr, "start", &offset_time);
					
				if(offset_time > 0)
					{
					if (dest_objid == node_objid) 			//this node is the packet's destination
						{
						op_pk_send (pkptr, PK_OUT_STRM); 	//sink
						send_ok = 0;
						}
				
					else
						{
						send_ok = 1;						// send
						}
				
					}
				else 
					{
					op_pk_destroy(pkptr);
					send_ok = 0;
					}
				}


			/** state (get_rte) exit executives **/
			FSM_STATE_EXIT_FORCED (2, "get_rte", "Restoration_rte () [get_rte exit execs]")
				{
				}


			/** state (get_rte) transition processing **/
			FSM_INIT_COND (END_SIM)
			FSM_DFLT_COND
			FSM_TEST_LOGIC ("get_rte")

			FSM_TRANSIT_SWITCH
				{
				FSM_CASE_TRANSIT (0, 4, state4_enter_exec, ;, "END_SIM", "", "get_rte", "end")
				FSM_CASE_TRANSIT (1, 3, state3_enter_exec, ;, "default", "", "get_rte", "send")
				}

⌨️ 快捷键说明

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