📄 obs_rte.pr.c
字号:
int delete_num;
int FIS_fail_type;
int FIS_node_link;
int FIS_destination;
int FIS_source[17][17];
int x,y;
int PK_source[17][17];
int check, s_f_flag, FIS_s_f_flag ;
int send_check;
char file_name[10];
int num_routes[17][17];
int exit_flag;
int l;
int comp_flag;
int change_flag;
int pk_type;
int hop;
int bef_address;
int reserved_wave;
int temp_wave;
double temp_gap;
int insert_flag;
double offset_time;
double old_offset_time;
int loop_stop;
double new_start_time;
int route_flag;
int userid_c;
int userid_n;
int userid_d;
int restoration_flag;
wave_info* wave;
wave_info* wave_info_table;
wave_info* wave_free;
wavelength_info* wavelength;
wavelength_info* wavelength_info_table;
wavelength_info* wavelength_free;
int lost_flag;
int backup_flag;
int need_schedule;
int include_flag;
int hop_num_back;
double wavelength_list_table[100][2];
int wavelength_number;
int wavelength_num;
int wave_break;
double d_time;
Objid strm_objid1;
int strm_num1;
int temp_channel_num;
//int link_num;
//int channel_count1;
CHANNEL_INFOR * channel_infor;
CHANNEL_INFOR * channel_infor2;
CHANNEL_INFOR * channel_infor3;
CHANNEL_INFOR * channel_infor4;
int current_port;
int list_element_num;
int loop_channel;
int loop_list;
int selected_channel;
int difference_time;
int temp_difference_time;
int loop_flag_i;
int loop_flag_j;
int loop_flag_k;
int pk_id;
int pk_address;
int pkptr_id;
double temp_time;
int e_s;
int e_d;
int e_id;
int temp_flag_suc;
double dropped_burst_size = 0;
int tt,ttt;
FSM_ENTER (OBS_rte)
FSM_BLOCK_SWITCH
{
/*---------------------------------------------------------*/
/** state (init) enter executives **/
FSM_STATE_ENTER_FORCED_NOLABEL (0, "init", "OBS_rte () [init enter execs]")
{
self_objid = op_id_self ();
node_objid = op_topo_parent (self_objid);
subnet_objid = op_topo_parent (node_objid);
op_ima_obj_attr_get(node_objid, "user id", &userid);
bcp_count_lost = 0;
bcp_count_lost_stathandle = op_stat_reg("BCP_COUNT_LOST",OPC_STAT_INDEX_NONE,OPC_STAT_LOCAL);
burst_count_lost = 0;
burst_count_lost_stathandle = op_stat_reg("BURST_COUNT_LOST",OPC_STAT_INDEX_NONE,OPC_STAT_LOCAL);
pk_size_reiv = 0;
pk_size_reiv_stathandle = op_stat_reg("PK_SIZE_REIV",OPC_STAT_INDEX_NONE,OPC_STAT_LOCAL);
pk_count_reiv = 0;
pk_cnt_reiv_stathandle = op_stat_reg("PK_COUNT_REIV", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
//pk_size_total_reiv = 0;
pk_size_total_reiv_stathandle = op_stat_reg("PK_SIZE_TOTAL_REIV",OPC_STAT_INDEX_NONE,OPC_STAT_GLOBAL);
//pk_count_total_reiv = 0;
pk_cnt_total_reiv_stathandle = op_stat_reg("PK_COUNT_TOTAL_REIV", OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);
//pk_avg_total_size_rev = 0;
pk_avg_total_size_rev_stathandle = op_stat_reg("PK_AVG_TOTAL_SIZE_REV",OPC_STAT_INDEX_NONE,OPC_STAT_GLOBAL);
pk_avg_size_rev = 0;
pk_avg_size_rev_stathandle = op_stat_reg("PK_AVG_SIZE_REV",OPC_STAT_INDEX_NONE,OPC_STAT_LOCAL);
burst_count_total_lost_stathandle = op_stat_reg("BURST_COUNT_TOTAL_LOST",OPC_STAT_INDEX_NONE,OPC_STAT_GLOBAL);
pk_cnt_no1 = 0;
pk_rev_cnt_no1_stathandle = op_stat_reg("REV_CNT_NO1",OPC_STAT_INDEX_NONE,OPC_STAT_LOCAL);
pk_cnt_no2 = 0;
pk_rev_cnt_no2_stathandle = op_stat_reg("REV_CNT_NO2",OPC_STAT_INDEX_NONE,OPC_STAT_LOCAL);
pk_cnt_no3 = 0;
pk_rev_cnt_no3_stathandle = op_stat_reg("REV_CNT_NO3",OPC_STAT_INDEX_NONE,OPC_STAT_LOCAL);
pk_cnt_no4 = 0;
pk_rev_cnt_no4_stathandle = op_stat_reg("REV_CNT_NO4",OPC_STAT_INDEX_NONE,OPC_STAT_LOCAL);
pk_cnt_no5 = 0;
pk_rev_cnt_no5_stathandle = op_stat_reg("REV_CNT_NO5",OPC_STAT_INDEX_NONE,OPC_STAT_LOCAL);
pk_cnt_no6 = 0;
pk_rev_cnt_no6_stathandle = op_stat_reg("REV_CNT_NO6",OPC_STAT_INDEX_NONE,OPC_STAT_LOCAL);
pk_count_rev_channel0 = 0;
pk_count_rev_channel0_stathandle = op_stat_reg("PK_COUNT_REV_CHANNEL0",OPC_STAT_INDEX_NONE,OPC_STAT_LOCAL);
pk_size_rev_channel0 = 0;
pk_size_rev_channel0_stathandle = op_stat_reg("PK_SIZE_REV_CHANNEL0",OPC_STAT_INDEX_NONE,OPC_STAT_LOCAL);
pk_count_rev_channel1 = 0;
pk_count_rev_channel1_stathandle = op_stat_reg("PK_COUNT_REV_CHANNEL1",OPC_STAT_INDEX_NONE,OPC_STAT_LOCAL);
pk_size_rev_channel1 = 0;
pk_size_rev_channel1_stathandle = op_stat_reg("PK_SIZE_REV_CHANNEL1",OPC_STAT_INDEX_NONE,OPC_STAT_LOCAL);
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////胶纳临傅阑 困茄 霖厚累诀/////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
link_num = 0;
channel_count1 = 0;
for(i = 1; i <= NODE_NUM; i++)
{
if(i != userid)
{
// printf("userid = %d, i = %d, connect_count = %d\n",userid,i,op_topo_connect_count (userid, i,OPC_OBJMTYPE_LINK));
if(op_topo_connect_count (userid, i,OPC_OBJMTYPE_LINK)==1)
{
link_num++;
op_ima_obj_attr_get (op_topo_connect (userid, i, OPC_OBJTYPE_LKDUP, 0), "channel count", &channel_count1);
// printf("userid = %d, i = %d, channel_count = %d\n",userid,i,channel_count1);
}
}
}
//printf("%d\n",link_num);
node_for_schedule.port = (PORT *)malloc(sizeof(PORT )*link_num);
for(i = 0; i < link_num; i++)
{
// printf("userid=%d, i=%d, link_num=%d, channel_count=%d\n",userid,i,link_num,channel_count1);
node_for_schedule.port[i].channel = (CHANNEL *)malloc(sizeof(CHANNEL )*channel_count1);
for(j = 0; j < channel_count1; j++)
{
// printf("userid=%d, i=%d, j=%d, link_num=%d, channel_count=%d\n",userid,i,j,link_num,channel_count1);
node_for_schedule.port[i].channel[j].horizon = 0;
node_for_schedule.port[i].channel[j].gab_list = (List *)op_prg_mem_alloc(sizeof(List));
node_for_schedule.port[i].channel[j].occupy_list = (List *)op_prg_mem_alloc(sizeof(List));
op_prg_list_init(node_for_schedule.port[i].channel[j].gab_list);
op_prg_list_init(node_for_schedule.port[i].channel[j].occupy_list);
}
}
j=0;
for(i = 1; i <= NODE_NUM; i++)
{
if(i != userid)
{
if(op_topo_connect_count (userid, i,OPC_OBJMTYPE_LINK)==1)
{
node_for_schedule.port[j].next_nodeid = i;
j++;
}
}
}
link_count = j;
//printf("init_rte\n");
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////胶纳临傅阑 困茄 霖厚累诀 场 /////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
}
/** state (init) exit executives **/
FSM_STATE_EXIT_FORCED (0, "init", "OBS_rte () [init exit execs]")
{
}
/** state (init) transition processing **/
FSM_TRANSIT_ONLY ((BEG_SIM), 1, state1_enter_exec, ;, "init", "BEG_SIM", "", "init", "wait")
/*---------------------------------------------------------*/
/** state (wait) enter executives **/
FSM_STATE_ENTER_UNFORCED (1, state1_enter_exec, "wait", "OBS_rte () [wait enter execs]")
{
}
/** blocking after enter executives of unforced state. **/
FSM_EXIT (3,OBS_rte)
/** state (wait) exit executives **/
FSM_STATE_EXIT_UNFORCED (1, "wait", "OBS_rte () [wait exit execs]")
{
}
/** state (wait) transition processing **/
FSM_INIT_COND (END_SIM)
FSM_TEST_COND (PK_ARRIVAL)
FSM_TEST_LOGIC ("wait")
FSM_TRANSIT_SWITCH
{
FSM_CASE_TRANSIT (0, 4, state4_enter_exec, ;, "END_SIM", "", "wait", "end")
FSM_CASE_TRANSIT (1, 2, state2_enter_exec, ;, "PK_ARRIVAL", "", "wait", "get_rte")
}
/*---------------------------------------------------------*/
/** state (get_rte) enter executives **/
FSM_STATE_ENTER_FORCED (2, state2_enter_exec, "get_rte", "OBS_rte () [get_rte enter execs]")
{
self_objid = op_id_self ();
node_objid = op_topo_parent (self_objid);
subnet_objid = op_topo_parent (node_objid);
op_ima_obj_attr_get(node_objid, "user id", &userid);
strm_num = op_intrpt_strm ();
strm_num_from_source = strm_num;
pkptr = op_pk_get(strm_num);
op_pk_nfd_get (pkptr, "destination address", &destination_address);
op_pk_nfd_get (pkptr, "source address", &source_address);
op_pk_nfd_get (pkptr, "id", &pkptr_id);
dest_objid = op_id_from_userid (subnet_objid, OPC_OBJTYPE_NDFIX, destination_address);
src_objid = op_id_from_userid (subnet_objid, OPC_OBJTYPE_NDFIX, source_address);
op_pk_nfd_get (pkptr, "start", &offset_time);
op_pk_nfd_get (pkptr, "type", &packet_type);
if(strm_num == PK_IN_STRM_BURST)
{
//packet recived form burst-part send send-part
send_ok = 1;
}
else
{
if(packet_type == 1)
{
//if packet recived is burst, this packet send burst-part
if(offset_time > 0)
{
if(dest_objid == node_objid) // busrt sucess
{
op_pk_send (pkptr, PK_OUT_STRM); //send sink
send_ok = 0;
}
else
{
send_ok = 1;
}
}
else
{
// printf("burst offset_time over\n");
burst_count_total_lost++;
op_stat_write(burst_count_total_lost_stathandle,burst_count_total_lost);
op_pk_destroy(pkptr);
send_ok = 0;
}
}
else //packet_type == 0
{
//if packet recived is bcp, start to schehed this packet and it is sended to sink-part
if(offset_time > 0)
{
if (dest_objid == node_objid) //this node is the packet's destination
{
send_ok = 0;
op_pk_nfd_get (pkptr, "dtime", &d_time);
pk_size_reiv = d_time * RATE;
op_stat_write(pk_size_reiv_stathandle, pk_size_reiv);
pk_count_reiv++;
op_stat_write(pk_cnt_reiv_stathandle, pk_count_reiv);
pk_count_total_reiv++;
pk_size_total_reiv = pk_size_total_reiv + d_time * RATE;
op_stat_write(pk_size_total_reiv_stathandle, pk_size_total_reiv);
op_stat_write(pk_cnt_total_reiv_stathandle, pk_count_total_reiv);
pk_avg_total_size_rev = (double)(pk_size_total_reiv/(double)pk_count_total_reiv);
op_stat_write(pk_avg_total_size_rev_stathandle,pk_avg_total_size_rev);
if(source_address == 1)
{
pk_cnt_no1++;
op_stat_write(pk_rev_cnt_no1_stathandle,pk_cnt_no1);
}
else if(source_address == 2)
{
pk_cnt_no2++;
op_stat_write(pk_rev_cnt_no2_stathandle,pk_cnt_no2);
}
// if(userid != destination_address)
else if(source_address == 3)
{
pk_cnt_no3++;
op_stat_write(pk_rev_cnt_no3_stathandle,pk_cnt_no3);
}
// if(userid != destination_address)
else if(source_address == 4)
{
pk_cnt_no4++;
op_stat_write(pk_rev_cnt_no4_stathandle,pk_cnt_no4);
}
// if(userid != destination_address)
else if(source_address == 5)
{
pk_cnt_no5++;
op_stat_write(pk_rev_cnt_no5_stathandle,pk_cnt_no5);
}
// if(userid != destination_address)
else if(source_address == 6)
{
pk_cnt_no6++;
op_stat_write(pk_rev_cnt_no6_stathandle,pk_cnt_no6);
}
op_pk_send (pkptr, PK_OUT_STRM); //sink
}
else
{
send_ok = 1; // send
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////// 胶纳临傅颇飘 矫累(LAUC_VF) /////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
op_rte_pk_next_node(pkptr,&subnet_id,&next_node_id);
op_ima_obj_attr_get(next_node_id,"user id",&next_address);
cur_time = op_sim_time();
op_pk_nfd_get(pkptr,"start",&start_time);
op_pk_nfd_get(pkptr,"dtime",&dtime_time);
start_time = cur_time + start_time;
dtime_time = start_time + dtime_time;
for(i=0;i<link_num;i++)
{
if(node_for_schedule.port[i].next_nodeid == next_address)
current_port = i;
}
//channel_infor = (CHANNEL_INFOR *)op_prg_mem_alloc(sizeof(CHANNEL_INFOR));
//channel_infor2 = (CHANNEL_INFOR *)op_prg_mem_alloc(sizeof(CHANNEL_INFOR));
//channel_infor4 = (CHANNEL_INFOR *)op_prg_mem_alloc(sizeof(CHANNEL_INFOR));
for(i=1;i<channel_count1;i++)
{
j=0;
list_element_num = op_prg_list_size(node_for_schedule.port[current_port].channel[i].occupy_list);
while( list_element_num > 0 && j < list_element_num)
{
channel_infor4 = (CHANNEL_INFOR *)op_prg_list_access(node_for_schedule.port[current_port].channel[i].occupy_list,j);
if(cur_time > channel_infor4->duration_time)
{
channel_infor4 = op_prg_list_remove(node_for_schedule.port[current_port].channel[i].occupy_list,j);
op_prg_mem_free(channel_infor4);
op_prg_list_sort(node_for_schedule.port[current_port].channel[i].occupy_list,list_compare);
list_element_num = op_prg_list_size(node_for_schedule.port[current_port].channel[i].occupy_list);
j = 0;
}
else
j++;
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//end of delete
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//list insert
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
selected_channel = -1;
difference_time = -1; // -1 : list 狼 夸家啊 0老锭 , -2 : list 狼 盖第俊 嘿老版快 difference_time捞 公茄洒努锭
temp_difference_time = -1; // -1 : list 狼 夸家啊 0老锭 , -2 : list 狼 盖第俊 嘿老版快 difference_time捞 公茄洒努锭
for(i = 1; i < channel_count1; i++)
{
list_element_num = op_prg_list_size(node_for_schedule.port[current_port].channel[i].occupy_list);
if(list_element_num == 0)
{
temp_difference_time = -1;
difference_fuction(&difference_time,&temp_difference_time,&selected_channel,&i);
}
else if(list_element_num >= 2)
{
for(j=0;j<list_element_num-1;j++)
{
channel_infor = (CHANNEL_INFOR *)op_prg_list_access(node_for_schedule.port[current_port].channel[i].occupy_list,j);
channel_infor2 = (CHANNEL_INFOR *)op_prg_list_access(node_for_schedule.port[current_port].channel[i].occupy_list,j+1);
if(channel_infor->duration_time <= start_time && dtime_time <= channel_infor2->start_time)
{
temp_difference_time = channel_infor2->start_time - dtime_time;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -