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

📄 dsr_support.ex.c

📁 opnet11.5 manet dsr和aodv协议
💻 C
📖 第 1 页 / 共 3 页
字号:
	/* Add the first line	*/	sprintf (temp_str, "%-12.2f%-38s\t%-40s\t%-15d\t%s\n", op_sim_time (), src_str, dest_str, total_hops, src_str);	Oms_Ext_File_Info_Append (ext_file_handle, temp_str);		for (count = 0; count < num_intermediate_nodes; count++)		{		/* Access each hop	*/		hop_address_ptr = (InetT_Address*) op_prg_list_access (intermediate_route_lptr, count);				/* Get the IP address string	*/		inet_address_ptr_print (hop_addr_str, hop_address_ptr);				/* Get the name of the node	*/		inet_address_to_hname (*hop_address_ptr, hop_node_name);			/* Append the two	*/		sprintf (hop_str, "%s (%s)", hop_addr_str, hop_node_name);				sprintf (temp_str, "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t%s\n", hop_str);		Oms_Ext_File_Info_Append (ext_file_handle, temp_str);		}		/* Add the destination	*/	sprintf (temp_str, "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t%s\n", dest_str);	Oms_Ext_File_Info_Append (ext_file_handle, temp_str);		/* Add a separator	*/	strcpy (temp_str, "----------------------------------------------------------------------------------------------------------------------------------------\n");	Oms_Ext_File_Info_Append (ext_file_handle, temp_str);		FOUT;	}voiddsr_support_route_print_to_ot_initialize (void)	{	OmaT_Ot_Writer* 		ot_writer_ptr = OPC_NIL;	static Boolean			initialized_flag = OPC_FALSE;	OmaT_Ot_Template 		*ot_routes_report_table_template = OPC_NIL;		/** Initializes the OT package for routes export	*/	FIN (dsr_support_route_print_to_ot (<args>));		if (initialized_flag == OPC_FALSE)		{		/* Open the OT file	*/		ot_writer_ptr =	Oms_Ot_File_Open ();			/* If do not yet have the tamplate then */		/* get the template for this table		*/		ot_routes_report_table_template = Oms_Ot_Template_Create (routes_export_columns_name_array, routes_export_columns_name_array_size);				/* Create the Routes Report Table for this node	*/		ot_routes_report_table = Oma_Ot_Writer_Table_Add (ot_writer_ptr, OmaC_Table_Type_Global, "", "", 											"DSR.DSR Routes Report", ot_routes_report_table_template);				/* Set the flag to true	*/		initialized_flag = OPC_TRUE;		}		FOUT;	}voiddsr_support_route_print_to_ot_close (void* PRG_ARG_UNUSED (ptr), int PRG_ARG_UNUSED (code))	{	static Boolean		closed_flag = OPC_FALSE;		/** Closes the OT file for a route print	**/	FIN (dsr_support_route_print_to_ot_close (void));		if (closed_flag == OPC_FALSE)		{		/* Destroy the table	*/		if (ot_routes_report_table != OPC_NIL)			Oma_Ot_Table_Destroy (ot_routes_report_table);			/* Close the file	*/		Oms_Ot_File_Close ();				/* Set the flag to true	*/		closed_flag = OPC_TRUE;		}		FOUT;	}voiddsr_support_route_print_to_ot (IpT_Dgram_Fields* ip_dgram_fd_ptr, List* intermediate_route_lptr)	{	InetT_Address*					hop_address_ptr;	int								num_intermediate_nodes; 	int								total_hops, count;	char							temp_str [128] = "";	char							src_addr_str [INETC_ADDR_STR_LEN];	char							src_node_name [OMSC_HNAME_MAX_LEN];	char							dest_addr_str [INETC_ADDR_STR_LEN];	char							dest_node_name [OMSC_HNAME_MAX_LEN];	char							hop_addr_str [INETC_ADDR_STR_LEN];	char							hop_node_name [OMSC_HNAME_MAX_LEN];	char							src_str [512];	char							dest_str [512];	char							hop_str [512];		/** Export the routes taken to an output table file	**/		FIN (dsr_support_route_print_to_ot (<args>));		/* If the source address is invalid, do not export	*/	if (!inet_address_valid (ip_dgram_fd_ptr->src_addr))		FOUT;		/* Get the time string	*/	sprintf (temp_str, "%f", op_sim_time ());		/* Write out column value */	Oma_Ot_Table_Cell_Value_Set (ot_routes_report_table, routes_export_columns_name_array [0], temp_str);		/* Get the IP address string	*/	inet_address_print (src_addr_str, ip_dgram_fd_ptr->src_addr);			/* Get the name of the node	*/	inet_address_to_hname (ip_dgram_fd_ptr->src_addr, src_node_name);		/* Append the two	*/	sprintf (src_str, "%s (%s)", src_addr_str, src_node_name);		/* Write out the source node information	*/	Oma_Ot_Table_Cell_Value_Set (ot_routes_report_table, routes_export_columns_name_array [1], src_str);		/* Get the IP address string	*/	inet_address_print (dest_addr_str, ip_dgram_fd_ptr->dest_addr);			/* Get the name of the node	*/	inet_address_to_hname (ip_dgram_fd_ptr->dest_addr, dest_node_name);		/* Append the two	*/	sprintf (dest_str, "%s (%s)", dest_addr_str, dest_node_name);		/* Write out the destination node information	*/	Oma_Ot_Table_Cell_Value_Set (ot_routes_report_table, routes_export_columns_name_array [2], dest_str);		/* Determine the total number of hops in the route	*/	num_intermediate_nodes = op_prg_list_size (intermediate_route_lptr);	total_hops = num_intermediate_nodes + 1;		/* Write out the number of hops	*/	sprintf (temp_str, "%d", total_hops);	Oma_Ot_Table_Cell_Value_Set (ot_routes_report_table, routes_export_columns_name_array [3], temp_str);		/* Write out the first hop as the source node	*/	Oma_Ot_Table_Cell_Value_Set (ot_routes_report_table, routes_export_columns_name_array [4], src_str);		/* Write out the rows constructed to each corresponding table		*/	Oma_Ot_Table_Row_Write (ot_routes_report_table);		for (count = 0; count < num_intermediate_nodes; count++)		{		/* Access each hop	*/		hop_address_ptr = (InetT_Address*) op_prg_list_access (intermediate_route_lptr, count);				/* Get the IP address string	*/		inet_address_ptr_print (hop_addr_str, hop_address_ptr);				/* Get the name of the node	*/		inet_address_to_hname (*hop_address_ptr, hop_node_name);			/* Append the two	*/		sprintf (hop_str, "%s (%s)", hop_addr_str, hop_node_name);				/* Write out each intermediate hop	*/		Oma_Ot_Table_Cell_Value_Set (ot_routes_report_table, routes_export_columns_name_array [4], hop_str);				/* Write out the rows constructed to each corresponding table		*/		Oma_Ot_Table_Row_Write (ot_routes_report_table);		}		/* Add the destination	*/	Oma_Ot_Table_Cell_Value_Set (ot_routes_report_table, routes_export_columns_name_array [4], dest_str);		/* Write out the rows constructed to each corresponding table		*/	Oma_Ot_Table_Row_Write (ot_routes_report_table);		/* Write out a blank row */	Oma_Ot_Table_Row_Write (ot_routes_report_table);		FOUT;	}Booleandsr_support_route_export_sim_attr_get (void)	{	static Boolean		val_obtained = OPC_FALSE;	static Boolean		sim_attr_val = OPC_FALSE;		/** Obtains the simulation attribute	**/	FIN (dsr_support_route_export_sim_attr_get (void));		if (!val_obtained)		{		/* Set the flag	*/		val_obtained = OPC_TRUE;				if (!op_ima_sim_attr_exists ("DSR Routes Export") ||			!op_ima_sim_attr_get (OPC_IMA_TOGGLE, "DSR Routes Export", &sim_attr_val))			{			/* This simulation attribute does not exist	*/			/* Do not export the routes to a file		*/			sim_attr_val = OPC_FALSE;			}		}		/* Initialize the file handles */	Oms_Ext_File_Handle_Get (OMSC_EXT_FILE_PROJ_SCEN_NAME, "dsr_routes", OMSC_EXT_FILE_GDF);	Oms_Ext_File_Handle_Get (OMSC_EXT_FILE_PROJ_SCEN_NAME, "manet_routes_dump", OMSC_EXT_FILE_GDF);		FRET (sim_attr_val);	}Booleandsr_support_route_record_sim_attr_get (void)	{	static Boolean		val_obtained = OPC_FALSE;	static Boolean		sim_attr_val = OPC_FALSE;		/** Obtains the simulation attribute	**/	FIN (dsr_support_route_record_sim_attr_get (void));		if (!val_obtained)		{		/* Set the flag	*/		val_obtained = OPC_TRUE;				if (!op_ima_sim_attr_exists ("DSR Record Routes") ||			!op_ima_sim_attr_get (OPC_IMA_TOGGLE, "DSR Record Routes", &sim_attr_val))			{			/* This simulation attribute does not exist	*/			/* Do not export the routes to a file		*/			sim_attr_val = OPC_FALSE;			}		}		FRET (sim_attr_val);	}DsrT_Global_Stathandles*dsr_support_global_stat_handles_obtain (void)	{	static Boolean		   					stat_handles_registered = OPC_FALSE;	static DsrT_Global_Stathandles*			stat_handle_ptr = OPC_NIL;		/** Registers the global statistics and returns a	**/	/** handle to the global statistics					**/	FIN (dsr_support_global_stat_handles_obtain (void));		if (stat_handles_registered == OPC_FALSE)		{		/* The statistic handles have not yet been registered	*/		/* Register the global statistic handles				*/		stat_handle_ptr = (DsrT_Global_Stathandles*) op_prg_mem_alloc (sizeof (DsrT_Global_Stathandles));				stat_handle_ptr->route_discovery_time_global_shandle = op_stat_reg ("DSR.Route Discovery Time", OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);		stat_handle_ptr->num_hops_global_shandle = op_stat_reg ("DSR.Number of Hops per Route", OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);		stat_handle_ptr->num_pkts_discard_global_shandle = op_stat_reg ("DSR.Total Packets Dropped", OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);		stat_handle_ptr->rte_traf_rcvd_bps_global_shandle = op_stat_reg ("DSR.Routing Traffic Received (bits/sec)", OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);		stat_handle_ptr->rte_traf_rcvd_pps_global_shandle = op_stat_reg ("DSR.Routing Traffic Received (pkts/sec)", OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);		stat_handle_ptr->rte_traf_sent_bps_global_shandle = op_stat_reg ("DSR.Routing Traffic Sent (bits/sec)", OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);		stat_handle_ptr->rte_traf_sent_pps_global_shandle = op_stat_reg ("DSR.Routing Traffic Sent (pkts/sec)", OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);		stat_handle_ptr->total_traf_rcvd_bps_global_shandle = op_stat_reg ("DSR.Total Traffic Received (bits/sec)", OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);		stat_handle_ptr->total_traf_rcvd_pps_global_shandle = op_stat_reg ("DSR.Total Traffic Received (pkts/sec)", OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);		stat_handle_ptr->total_traf_sent_bps_global_shandle = op_stat_reg ("DSR.Total Traffic Sent (bits/sec)", OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);		stat_handle_ptr->total_traf_sent_pps_global_shandle = op_stat_reg ("DSR.Total Traffic Sent (pkts/sec)", OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);				stat_handle_ptr->total_requests_sent_global_shandle = op_stat_reg ("DSR.Total Route Requests Sent", OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);		stat_handle_ptr->total_non_prop_requests_sent_global_shandle = op_stat_reg ("DSR.Total Non Propagating Requests Sent", OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);		stat_handle_ptr->total_prop_requests_sent_global_shandle = op_stat_reg ("DSR.Total Propagating Requests Sent", OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);		stat_handle_ptr->total_replies_sent_global_shandle = op_stat_reg ("DSR.Total Route Replies Sent", OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);		stat_handle_ptr->total_replies_sent_from_dest_global_shandle = op_stat_reg ("DSR.Total Replies Sent from Destination", OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);		stat_handle_ptr->total_cached_replies_sent_global_shandle = op_stat_reg ("DSR.Total Cached Replies Sent", OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);		stat_handle_ptr->total_ack_requests_sent_global_shandle = op_stat_reg ("DSR.Total Acknowledgement Requests Sent", OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);		stat_handle_ptr->total_acks_sent_global_shandle = op_stat_reg ("DSR.Total Acknowledgements Sent", OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);		stat_handle_ptr->total_route_errors_sent_global_shandle = op_stat_reg ("DSR.Total Route Errors Sent", OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);		stat_handle_ptr->total_pkts_salvaged_global_shandle = op_stat_reg ("DSR.Total Packets Salvaged", OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);						/* Set the flag to indicate that the statistics	*/		/* have been registered							*/

⌨️ 快捷键说明

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