📄 bursty_source.pr.c
字号:
intrpt_code = op_intrpt_code ();
}
FSM_PROFILE_SECTION_OUT (state1_exit_exec)
/** state (off) transition processing **/
FSM_TRANSIT_ONLY ((INACTIVE_TO_ACTIVE), 2, state2_enter_exec, ;, off, "INACTIVE_TO_ACTIVE", "", "off", "on", "tr_1", "bursty_source [off -> on : INACTIVE_TO_ACTIVE / ]")
/*---------------------------------------------------------*/
/** state (on) enter executives **/
FSM_STATE_ENTER_UNFORCED (2, "on", state2_enter_exec, "bursty_source [on enter execs]")
FSM_PROFILE_SECTION_IN ("bursty_source [on enter execs]", state2_enter_exec)
{
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);
}
}
FSM_PROFILE_SECTION_OUT (state2_enter_exec)
/** blocking after enter executives of unforced state. **/
FSM_EXIT (5,"bursty_source")
/** state (on) exit executives **/
FSM_STATE_EXIT_UNFORCED (2, "on", "bursty_source [on exit execs]")
FSM_PROFILE_SECTION_IN ("bursty_source [on exit execs]", state2_exit_exec)
{
/* Determine the type of interrupt. */
intrpt_type = op_intrpt_type ();
intrpt_code = op_intrpt_code ();
}
FSM_PROFILE_SECTION_OUT (state2_exit_exec)
/** state (on) transition processing **/
FSM_PROFILE_SECTION_IN ("bursty_source [on trans conditions]", state2_trans_conds)
FSM_INIT_COND (ACTIVE_TO_INACTIVE)
FSM_TEST_COND (REMAIN_ACTIVE)
FSM_TEST_LOGIC ("on")
FSM_PROFILE_SECTION_OUT (state2_trans_conds)
FSM_TRANSIT_SWITCH
{
FSM_CASE_TRANSIT (0, 1, state1_enter_exec, ;, "ACTIVE_TO_INACTIVE", "", "on", "off", "tr_3", "bursty_source [on -> off : ACTIVE_TO_INACTIVE / ]")
FSM_CASE_TRANSIT (1, 2, state2_enter_exec, ;, "REMAIN_ACTIVE", "", "on", "on", "tr_4", "bursty_source [on -> on : REMAIN_ACTIVE / ]")
}
/*---------------------------------------------------------*/
}
FSM_EXIT (0,"bursty_source")
}
}
void
_op_bursty_source_diag (OP_SIM_CONTEXT_ARG_OPT)
{
/* No Diagnostic Block */
}
void
_op_bursty_source_terminate (OP_SIM_CONTEXT_ARG_OPT)
{
FIN_MT (_op_bursty_source_terminate ())
/* No Termination Block */
Vos_Poolmem_Dealloc (op_sv_ptr);
FOUT
}
/* Undefine shortcuts to state variables to avoid */
/* syntax error in direct access to fields of */
/* local variable prs_ptr in _op_bursty_source_svar function. */
#undef pid_string
#undef debug_mode
#undef stop_time
#undef off_state_start_time
#undef pksize_stathandle
#undef on_state_dist_handle
#undef off_state_dist_handle
#undef intarrvl_time_dist_handle
#undef packet_size_dist_handle
#undef start_time
#undef bits_sent_stathandle
#undef bitssec_sent_stathandle
#undef pkts_sent_stathandle
#undef pktssec_sent_stathandle
#undef bits_sent_gstathandle
#undef bitssec_sent_gstathandle
#undef pkts_sent_gstathandle
#undef pktssec_sent_gstathandle
#undef segmentation_size
#undef segmentation_buf_handle
#undef FIN_PREAMBLE_DEC
#undef FIN_PREAMBLE_CODE
#define FIN_PREAMBLE_DEC
#define FIN_PREAMBLE_CODE
VosT_Obtype
_op_bursty_source_init (int * init_block_ptr)
{
VosT_Obtype obtype = OPC_NIL;
FIN_MT (_op_bursty_source_init (init_block_ptr))
obtype = Vos_Define_Object_Prstate ("proc state vars (bursty_source)",
sizeof (bursty_source_state));
*init_block_ptr = 0;
FRET (obtype)
}
VosT_Address
_op_bursty_source_alloc (VosT_Obtype obtype, int init_block)
{
#if !defined (VOSD_NO_FIN)
int _op_block_origin = 0;
#endif
bursty_source_state * ptr;
FIN_MT (_op_bursty_source_alloc (obtype))
ptr = (bursty_source_state *)Vos_Alloc_Object (obtype);
if (ptr != OPC_NIL)
{
ptr->_op_current_block = init_block;
#if defined (OPD_ALLOW_ODB)
ptr->_op_current_state = "bursty_source [init enter execs]";
#endif
}
FRET ((VosT_Address)ptr)
}
void
_op_bursty_source_svar (void * gen_ptr, const char * var_name, void ** var_p_ptr)
{
bursty_source_state *prs_ptr;
FIN_MT (_op_bursty_source_svar (gen_ptr, var_name, var_p_ptr))
if (var_name == OPC_NIL)
{
*var_p_ptr = (void *)OPC_NIL;
FOUT
}
prs_ptr = (bursty_source_state *)gen_ptr;
if (strcmp ("pid_string" , var_name) == 0)
{
*var_p_ptr = (void *) (prs_ptr->pid_string);
FOUT
}
if (strcmp ("debug_mode" , var_name) == 0)
{
*var_p_ptr = (void *) (&prs_ptr->debug_mode);
FOUT
}
if (strcmp ("stop_time" , var_name) == 0)
{
*var_p_ptr = (void *) (&prs_ptr->stop_time);
FOUT
}
if (strcmp ("off_state_start_time" , var_name) == 0)
{
*var_p_ptr = (void *) (&prs_ptr->off_state_start_time);
FOUT
}
if (strcmp ("pksize_stathandle" , var_name) == 0)
{
*var_p_ptr = (void *) (&prs_ptr->pksize_stathandle);
FOUT
}
if (strcmp ("on_state_dist_handle" , var_name) == 0)
{
*var_p_ptr = (void *) (&prs_ptr->on_state_dist_handle);
FOUT
}
if (strcmp ("off_state_dist_handle" , var_name) == 0)
{
*var_p_ptr = (void *) (&prs_ptr->off_state_dist_handle);
FOUT
}
if (strcmp ("intarrvl_time_dist_handle" , var_name) == 0)
{
*var_p_ptr = (void *) (&prs_ptr->intarrvl_time_dist_handle);
FOUT
}
if (strcmp ("packet_size_dist_handle" , var_name) == 0)
{
*var_p_ptr = (void *) (&prs_ptr->packet_size_dist_handle);
FOUT
}
if (strcmp ("start_time" , var_name) == 0)
{
*var_p_ptr = (void *) (&prs_ptr->start_time);
FOUT
}
if (strcmp ("bits_sent_stathandle" , var_name) == 0)
{
*var_p_ptr = (void *) (&prs_ptr->bits_sent_stathandle);
FOUT
}
if (strcmp ("bitssec_sent_stathandle" , var_name) == 0)
{
*var_p_ptr = (void *) (&prs_ptr->bitssec_sent_stathandle);
FOUT
}
if (strcmp ("pkts_sent_stathandle" , var_name) == 0)
{
*var_p_ptr = (void *) (&prs_ptr->pkts_sent_stathandle);
FOUT
}
if (strcmp ("pktssec_sent_stathandle" , var_name) == 0)
{
*var_p_ptr = (void *) (&prs_ptr->pktssec_sent_stathandle);
FOUT
}
if (strcmp ("bits_sent_gstathandle" , var_name) == 0)
{
*var_p_ptr = (void *) (&prs_ptr->bits_sent_gstathandle);
FOUT
}
if (strcmp ("bitssec_sent_gstathandle" , var_name) == 0)
{
*var_p_ptr = (void *) (&prs_ptr->bitssec_sent_gstathandle);
FOUT
}
if (strcmp ("pkts_sent_gstathandle" , var_name) == 0)
{
*var_p_ptr = (void *) (&prs_ptr->pkts_sent_gstathandle);
FOUT
}
if (strcmp ("pktssec_sent_gstathandle" , var_name) == 0)
{
*var_p_ptr = (void *) (&prs_ptr->pktssec_sent_gstathandle);
FOUT
}
if (strcmp ("segmentation_size" , var_name) == 0)
{
*var_p_ptr = (void *) (&prs_ptr->segmentation_size);
FOUT
}
if (strcmp ("segmentation_buf_handle" , var_name) == 0)
{
*var_p_ptr = (void *) (&prs_ptr->segmentation_buf_handle);
FOUT
}
*var_p_ptr = (void *)OPC_NIL;
FOUT
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -