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

📄 bursty_source.function block

📁 opnet网络仿真
💻 FUNCTION BLOCK
字号:
static void
bursty_source_sv_init ()
	{
	Prohandle			my_prohandle;
	int					my_pro_id;
	Objid				my_id;
	Objid				traf_gen_comp_attr_objid, traf_conf_objid;
	Objid				pkt_gen_comp_attr_objid, pkt_gen_args_objid;
	char				on_state_string [128], off_state_string [128];
	char				intarrvl_rate_string [128], packet_size_string [128];
	char				start_time_string [128];
	OmsT_Dist_Handle	start_time_dist_handle;

	/**	Initializes state variables associated with		**/
	/**	this process model.								**/
	FIN (bursty_source_sv_init ());

	/*	Determine the prohandle of this process as well as	*/
	/*	the object IDs of the containing module and node.*/
	my_prohandle = op_pro_self ();
	my_pro_id = op_pro_id (my_prohandle);
	my_id = op_id_self ();

	/*	Determine the process ID display string.	*/
	sprintf (pid_string, "bursty_source PID (%d)", my_pro_id);

	/*	Determine whether or not the simulation is in debug	*/
	/*	mode.  Trace statement are only enabled when the	*/
	/*	simulation is in debug mode.						*/
	debug_mode = op_sim_debug ();

	/* Read the traffic generation parameters.	*/
	op_ima_obj_attr_get (my_id, "Traffic Generation Parameters", &traf_gen_comp_attr_objid);
	traf_conf_objid = op_topo_child (traf_gen_comp_attr_objid, OPC_OBJTYPE_GENERIC, 0);

	/* Determine the start time for traffic generation.	*/
	op_ima_obj_attr_get (traf_conf_objid, "Start Time", start_time_string);
	if (strcmp (start_time_string, "Never") != 0)
		{
		start_time_dist_handle = oms_dist_load_from_string (start_time_string);
		start_time = oms_dist_outcome (start_time_dist_handle);
		}
	else
		{
		start_time = -1.0;
		}

	/* Determine the stop time for traffic generation.	*/
	op_ima_obj_attr_get (traf_conf_objid, "Stop Time", &stop_time);
	if (stop_time == -1.0)
		stop_time = OPC_DBL_INFINITY;

	/* If the start time is set to "Infinity", then there	*/
	/* is no need to schedule an interrupt as this node has	*/
	/* been set will not generate any traffic.				*/
	if ((start_time >= 0.0) && (stop_time > start_time))
		{
		/* Load the distribution used to determine the time	*/
		/* for which the process stays in the "ON" state.	*/
		op_ima_obj_attr_get (traf_conf_objid, "ON State Time", on_state_string);
		on_state_dist_handle = oms_dist_load_from_string (on_state_string); 

		/* Load the distribution used to determine the time	*/
		/* for which the process stays in the "OFF" state.	*/
		op_ima_obj_attr_get (traf_conf_objid, "OFF State Time", off_state_string);
		off_state_dist_handle = oms_dist_load_from_string (off_state_string);

		/* Load the distribution used to determine the packet	*/
		/* interarrivals.										*/
		op_ima_obj_attr_get (traf_conf_objid, "Packet Generation Arguments", &pkt_gen_comp_attr_objid);
		pkt_gen_args_objid = op_topo_child (pkt_gen_comp_attr_objid, OPC_OBJTYPE_GENERIC, 0);

		op_ima_obj_attr_get (pkt_gen_args_objid, "Interarrival Time", intarrvl_rate_string);
		intarrvl_time_dist_handle = oms_dist_load_from_string (intarrvl_rate_string);

		/* Load the distribution used to determine the size of	*/
		/* the packets being generated.							*/
		op_ima_obj_attr_get (pkt_gen_args_objid, "Packet Size", packet_size_string);
		packet_size_dist_handle = oms_dist_load_from_string (packet_size_string);

		/*	Initilaize the packet generation status statistic	*/
		/*	to indicate that currently there are no packets 	*/
		/*	being generated.									*/
		pksize_stathandle = op_stat_reg ("Traffic Source.Packet Generation Status", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
		op_stat_write (pksize_stathandle, (double) OPC_FALSE);
		
		/* Initilaize the statistic handles to keep	*/
		/* track of traffic Sourceed by this process.	*/
		bits_sent_stathandle 		= op_stat_reg ("Traffic Source.Traffic Sent (bits)",		OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
		bitssec_sent_stathandle 	= op_stat_reg ("Traffic Source.Traffic Sent (bits/sec)",	OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
		pkts_sent_stathandle 		= op_stat_reg ("Traffic Source.Traffic Sent (packets)",		OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
		pktssec_sent_stathandle 	= op_stat_reg ("Traffic Source.Traffic Sent (packets/sec)",	OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);

		bits_sent_gstathandle 		= op_stat_reg ("Traffic Source.Traffic Sent (bits)",		OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);
		bitssec_sent_gstathandle 	= op_stat_reg ("Traffic Source.Traffic Sent (bits/sec)",	OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);
		pkts_sent_gstathandle 		= op_stat_reg ("Traffic Source.Traffic Sent (packets)",		OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);
		pktssec_sent_gstathandle 	= op_stat_reg ("Traffic Source.Traffic Sent (packets/sec)",	OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);
		
		/* Check if packet segmentation is modeled.	*/
		op_ima_obj_attr_get (pkt_gen_args_objid, "Segmentation Size", &segmentation_size);
		if (segmentation_size != -1)
			{
			segmentation_size *= 8;
			segmentation_buf_handle = op_sar_buf_create (OPC_SAR_BUF_TYPE_SEGMENT, OPC_SAR_BUF_OPT_PK_BNDRY);
			}
		}

	FOUT;
	}

⌨️ 快捷键说明

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