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

📄 on enter execs

📁 opnet网络仿真
💻
字号:
if (op_intrpt_code () == OFF_TO_ON)
	{
	/*	Determine the time at which this process will	*/
	/*	enter the next	"OFF" state.					*/
	on_period = oms_dist_positive_outcome_with_error_msg (on_state_dist_handle, 
		"This occurs for ON period distribution in bursty_source process model.");
	
	off_state_start_time = op_sim_time () + on_period;

	/*	Schedule a self-interrupt to transit to "OFF"	*/
	/*	state when the "ON" state duration expires.		*/
	op_intrpt_schedule_self (off_state_start_time, ON_TO_OFF);
	}

/*	Generate the packets based on the loaded parameters	*/
/*	for traffic generation.								*/
next_packet_arrival_time = op_sim_time () + oms_dist_positive_outcome_with_error_msg (intarrvl_time_dist_handle,
					"This occurs for packet inter-arrival time distribution in bursty_source process model.");

/* Whenever the ON state is entered, we should always	*/
/* send atleast one packet.								*/

/*	Create a packet using the outcome of the loaded	*/
/*	distribution.									*/
pksize = floor ((double) oms_dist_positive_outcome_with_error_msg (packet_size_dist_handle, 
					"This occurs for packet size distribution in bursty_source process model."));
pksize *= 8;
pkptr  = op_pk_create (pksize);

/*	Record statistics to indicate that a packet 	*/
/*	was generated at the current simulation time.	*/
op_stat_write (pksize_stathandle, (double) OPC_TRUE);

/* Update local statistics.				*/
op_stat_write (bits_sent_stathandle, 		pksize);
op_stat_write (pkts_sent_stathandle, 		1.0);
	
op_stat_write (bitssec_sent_stathandle, 	pksize);
op_stat_write (bitssec_sent_stathandle, 	0.0);
op_stat_write (pktssec_sent_stathandle, 	1.0);
op_stat_write (pktssec_sent_stathandle, 	0.0);

/* Update global statistics.				*/
op_stat_write (bits_sent_gstathandle, 		pksize);
op_stat_write (pkts_sent_gstathandle, 		1.0);
	op_stat_write (bitssec_sent_gstathandle, 	pksize);
op_stat_write (bitssec_sent_gstathandle, 	0.0);
op_stat_write (pktssec_sent_gstathandle, 	1.0);
op_stat_write (pktssec_sent_gstathandle, 	0.0);

/* Loop through to remove segments of the original application packet and   */
/* send them out to the lower layer.                                        */
if (segmentation_size > 0  && pksize > segmentation_size)
   {
   /* Insert the packet into the segmentation buffer and pull out segments */
   /* of size specified by the attribute segment size.                     */

   op_sar_segbuf_pk_insert (segmentation_buf_handle, pkptr, 0);
	  
   while (pksize > 0)
	   {
       /* Remove segments of size equal to the segment size and send them to   */
       /* transport layer. If the number of available bits in the buffer is    */
       /* is lesser than the segment size a packet will be created only with   */
       /* remaining bits.                                                      */
       pkptr = op_sar_srcbuf_seg_remove (segmentation_buf_handle, segmentation_size);
		  
       /* Update the pk_size remaining to reflect the reduced size.    */
       pksize -= segmentation_size;
          
	   /* Send the packet to the lower layer.	*/
       op_pk_send (pkptr, 0);
	   }
    }
else
	{
	/* Send the packet to the lower layer.	*/
	op_pk_send (pkptr, 0);
	}

/*	Check if the next packet arrival time is within the	*/
/*	time in which the process remains in "ON" (active)	*/
/*	state or not.										*/
/*	Schedule the next packet arrival.					*/
if ((next_packet_arrival_time + PRECISION_RECOVERY < off_state_start_time) &&
	(next_packet_arrival_time + PRECISION_RECOVERY < stop_time))
	{
	op_intrpt_schedule_self (next_packet_arrival_time, ON_TO_ON);
	}

⌨️ 快捷键说明

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