You are on page 1of 3

/* acquire the arriving packet */ /* multiple arriving streams are supported.

*/ pkptr = op_pk_get (op_intrpt_strm ());

tnow=op_sim_time () ;

/* attempt to enqueue the packet at tail of subqueue 0 */

rand=op_dist_uniform (1) ; //printf("\n%lg \n %lg",rand,initial_drop_probability);

//op_stat_write (rand_cnt_stathandle,rand );

if(rand<initial_drop_probability) { op_pk_destroy (pkptr); insert_ok = 0; printf("\nrand :%lg init:%lg",rand,initial_drop_probability); //op_stat_write (pk_cnt_stathandle,initial_drop_probability ); } else{

status=op_subq_pk_insert (OPC_QSEL_MAX_PKSIZE , pkptr, OPC_QPOS_TAIL); printf("status %d, fail:%d",status,OPC_QINS_FAIL);

if (status == OPC_QINS_FAIL) { if((tnow-last_time)>freeze_time_period) { initial_drop_probability=initial_drop_probability+ increase_drop_probability; last_time=tnow; } /* the insertion failed (due to a full queue) */ /* deallocate the packet */ op_pk_destroy (pkptr); printf("\ndrop packet"); /* set flag indicating insertion fail */ /* this flag is used to determine transition */ /* out of this state */ insert_ok=0;

} else {

if((tnow-last_time)>freeze_time_period) { initial_drop_probability=initial_drop_probabilitydecrease_drop_probability; if(initial_drop_probability<0)

initial_drop_probability=0;

last_time=tnow; }

/* insertion was successful */ printf("ok"); //op_subq_pk_insert (0, pkptr, OPC_QPOS_TAIL); insert_ok = 1;

} }

You might also like