void ra_aloha_ss_init(void) { Objid my_objid; FIN(ra_aloha_ss_init()); /* * * stream : MAC [0] -> rt_0 [0] * stream : MAC [1] -> sink [0] * stream : rr_0 [0] -> MAC [0] * stream : traffic [0] -> MAC [1] */ svptr = (struct SS_SVar*) op_prg_mem_alloc(sizeof (struct SS_SVar)); svptr->istrm_hl=1; svptr->istrm_ll=0; svptr->ostrm_hl=1; svptr->ostrm_ll=0; my_objid = op_id_self(); op_ima_obj_attr_get_int32(my_objid, "SS ID", & svptr->ss_id); svptr->sh_load_bits = op_stat_reg("ALOHA SS.Load(bits/sec)", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL); svptr->sh_goodput_bits = op_stat_reg("ALOHA SS.Goodput(bits/sec)", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL); svptr->gsh_load_bits = op_stat_reg("ALOHA SS.Load(bits/sec)", OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL); FOUT; }
/*-------------------------------------------------------------------------------- * Function: wban_source_init * * Description: - initialize the process * - read the values of source attributes * - schedule a self interrupt that will indicate start time * for MSDU generation * * No parameters *--------------------------------------------------------------------------------*/ static void wban_source_init() { Objid own_id; /* Object ID of the surrounding processor or queue */ Objid traffic_source_comp_id; Objid traffic_source_id; char device_mode[20]; /* mode of the device: Hub or Node */ double temp; /* Stack tracing enrty point */ FIN(wban_source_init); /* obtain self object ID of the surrounding processor or queue */ own_id = op_id_self (); /* obtain object ID of the parent object (node) */ parent_id = op_topo_parent (own_id); /* set the initial number of sequence number to 0 */ dataSN = 0; /* get the value to check if this node is PAN coordinator or not */ op_ima_obj_attr_get (parent_id, "Device Mode", device_mode); /* get destination ID */ op_ima_obj_attr_get (own_id, "Destination ID", &destination_id); /* get the name of the node */ op_ima_obj_attr_get (parent_id, "name", node_name); printf("%s User Priority Traffic initialization.\n", node_name); op_ima_obj_attr_get (own_id, "User Priority 7 Traffic Parameters", &traffic_source_id); traffic_source_comp_id = op_topo_child (traffic_source_id, OPC_OBJTYPE_GENERIC, 0); /* Read the values of the up7-MSDU generation parameters, i.e. the attribute values of the surrounding module. */ op_ima_obj_attr_get (traffic_source_comp_id, "MSDU Interval Time", up7_msdu_interarrival_dist_str); op_ima_obj_attr_get (traffic_source_comp_id, "MSDU Size", up7_msdu_size_dist_str); op_ima_obj_attr_get (traffic_source_comp_id, "Start Time", &up7_start_time); op_ima_obj_attr_get (traffic_source_comp_id, "Stop Time", &up7_stop_time); op_ima_obj_attr_get (own_id, "User Priority 6 Traffic Parameters", &traffic_source_id); traffic_source_comp_id = op_topo_child (traffic_source_id, OPC_OBJTYPE_GENERIC, 0); /* Read the values of the up6-MSDU generation parameters, i.e. the attribute values of the surrounding module. */ op_ima_obj_attr_get (traffic_source_comp_id, "MSDU Interval Time", up6_msdu_interarrival_dist_str); op_ima_obj_attr_get (traffic_source_comp_id, "MSDU Size", up6_msdu_size_dist_str); op_ima_obj_attr_get (traffic_source_comp_id, "Start Time", &up6_start_time); op_ima_obj_attr_get (traffic_source_comp_id, "Stop Time", &up6_stop_time); op_ima_obj_attr_get (own_id, "User Priority 5 Traffic Parameters", &traffic_source_id); traffic_source_comp_id = op_topo_child (traffic_source_id, OPC_OBJTYPE_GENERIC, 0); /* Read the values of the up5-MSDU generation parameters, i.e. the attribute values of the surrounding module. */ op_ima_obj_attr_get (traffic_source_comp_id, "MSDU Interval Time", up5_msdu_interarrival_dist_str); op_ima_obj_attr_get (traffic_source_comp_id, "MSDU Size", up5_msdu_size_dist_str); op_ima_obj_attr_get (traffic_source_comp_id, "Start Time", &up5_start_time); op_ima_obj_attr_get (traffic_source_comp_id, "Stop Time", &up5_stop_time); op_ima_obj_attr_get (own_id, "User Priority 4 Traffic Parameters", &traffic_source_id); traffic_source_comp_id = op_topo_child (traffic_source_id, OPC_OBJTYPE_GENERIC, 0); /* Read the values of the up4-MSDU generation parameters, i.e. the attribute values of the surrounding module. */ op_ima_obj_attr_get (traffic_source_comp_id, "MSDU Interval Time", up4_msdu_interarrival_dist_str); op_ima_obj_attr_get (traffic_source_comp_id, "MSDU Size", up4_msdu_size_dist_str); op_ima_obj_attr_get (traffic_source_comp_id, "Start Time", &up4_start_time); op_ima_obj_attr_get (traffic_source_comp_id, "Stop Time", &up4_stop_time); op_ima_obj_attr_get (own_id, "User Priority 3 Traffic Parameters", &traffic_source_id); traffic_source_comp_id = op_topo_child (traffic_source_id, OPC_OBJTYPE_GENERIC, 0); /* Read the values of the up3-MSDU generation parameters, i.e. the attribute values of the surrounding module. */ op_ima_obj_attr_get (traffic_source_comp_id, "MSDU Interval Time", up3_msdu_interarrival_dist_str); op_ima_obj_attr_get (traffic_source_comp_id, "MSDU Size", up3_msdu_size_dist_str); op_ima_obj_attr_get (traffic_source_comp_id, "Start Time", &up3_start_time); op_ima_obj_attr_get (traffic_source_comp_id, "Stop Time", &up3_stop_time); op_ima_obj_attr_get (own_id, "User Priority 2 Traffic Parameters", &traffic_source_id); traffic_source_comp_id = op_topo_child (traffic_source_id, OPC_OBJTYPE_GENERIC, 0); /* Read the values of the up2-MSDU generation parameters, i.e. the attribute values of the surrounding module. */ op_ima_obj_attr_get (traffic_source_comp_id, "MSDU Interval Time", up2_msdu_interarrival_dist_str); op_ima_obj_attr_get (traffic_source_comp_id, "MSDU Size", up2_msdu_size_dist_str); op_ima_obj_attr_get (traffic_source_comp_id, "Start Time", &up2_start_time); op_ima_obj_attr_get (traffic_source_comp_id, "Stop Time", &up2_stop_time); op_ima_obj_attr_get (own_id, "User Priority 1 Traffic Parameters", &traffic_source_id); traffic_source_comp_id = op_topo_child (traffic_source_id, OPC_OBJTYPE_GENERIC, 0); /* Read the values of the up1-MSDU generation parameters, i.e. the attribute values of the surrounding module. */ op_ima_obj_attr_get (traffic_source_comp_id, "MSDU Interval Time", up1_msdu_interarrival_dist_str); op_ima_obj_attr_get (traffic_source_comp_id, "MSDU Size", up1_msdu_size_dist_str); op_ima_obj_attr_get (traffic_source_comp_id, "Start Time", &up1_start_time); op_ima_obj_attr_get (traffic_source_comp_id, "Stop Time", &up1_stop_time); op_ima_obj_attr_get (own_id, "User Priority 0 Traffic Parameters", &traffic_source_id); traffic_source_comp_id = op_topo_child (traffic_source_id, OPC_OBJTYPE_GENERIC, 0); /* Read the values of the up0-MSDU generation parameters, i.e. the attribute values of the surrounding module. */ op_ima_obj_attr_get (traffic_source_comp_id, "MSDU Interval Time", up0_msdu_interarrival_dist_str); op_ima_obj_attr_get (traffic_source_comp_id, "MSDU Size", up0_msdu_size_dist_str); op_ima_obj_attr_get (traffic_source_comp_id, "Start Time", &up0_start_time); op_ima_obj_attr_get (traffic_source_comp_id, "Stop Time", &up0_stop_time); /* if you are Hub do not send packets itself */ if ((strcmp(device_mode, "Hub") == 0) && (destination_id == HUB_ID)) { up7_start_time = SC_INFINITE_TIME; up6_start_time = SC_INFINITE_TIME; up5_start_time = SC_INFINITE_TIME; up4_start_time = SC_INFINITE_TIME; up3_start_time = SC_INFINITE_TIME; up2_start_time = SC_INFINITE_TIME; up1_start_time = SC_INFINITE_TIME; up0_start_time = SC_INFINITE_TIME; } /* Load the PDFs that will be used in computing the MSDU Interval Times and MSDU Sizes. */ up7_msdu_interarrival_dist_ptr = oms_dist_load_from_string (up7_msdu_interarrival_dist_str); up7_msdu_size_dist_ptr = oms_dist_load_from_string (up7_msdu_size_dist_str); /* Load the PDFs that will be used in computing the MSDU Interval Times and MSDU Sizes. */ up6_msdu_interarrival_dist_ptr = oms_dist_load_from_string (up6_msdu_interarrival_dist_str); up6_msdu_size_dist_ptr = oms_dist_load_from_string (up6_msdu_size_dist_str); /* Load the PDFs that will be used in computing the MSDU Interval Times and MSDU Sizes. */ up5_msdu_interarrival_dist_ptr = oms_dist_load_from_string (up5_msdu_interarrival_dist_str); up5_msdu_size_dist_ptr = oms_dist_load_from_string (up5_msdu_size_dist_str); /* Load the PDFs that will be used in computing the MSDU Interval Times and MSDU Sizes. */ up4_msdu_interarrival_dist_ptr = oms_dist_load_from_string (up4_msdu_interarrival_dist_str); up4_msdu_size_dist_ptr = oms_dist_load_from_string (up4_msdu_size_dist_str); /* Load the PDFs that will be used in computing the MSDU Interval Times and MSDU Sizes. */ up3_msdu_interarrival_dist_ptr = oms_dist_load_from_string (up3_msdu_interarrival_dist_str); up3_msdu_size_dist_ptr = oms_dist_load_from_string (up3_msdu_size_dist_str); /* Load the PDFs that will be used in computing the MSDU Interval Times and MSDU Sizes. */ up2_msdu_interarrival_dist_ptr = oms_dist_load_from_string (up2_msdu_interarrival_dist_str); up2_msdu_size_dist_ptr = oms_dist_load_from_string (up2_msdu_size_dist_str); /* Load the PDFs that will be used in computing the MSDU Interval Times and MSDU Sizes. */ up1_msdu_interarrival_dist_ptr = oms_dist_load_from_string (up1_msdu_interarrival_dist_str); up1_msdu_size_dist_ptr = oms_dist_load_from_string (up1_msdu_size_dist_str); /* Load the PDFs that will be used in computing the MSDU Interval Times and MSDU Sizes. */ up0_msdu_interarrival_dist_ptr = oms_dist_load_from_string (up0_msdu_interarrival_dist_str); up0_msdu_size_dist_ptr = oms_dist_load_from_string (up0_msdu_size_dist_str); /* Make sure we have valid start and stop times, i.e. stop time is not earlier than start time. */ if ((up7_stop_time <= up7_start_time) && (up7_stop_time != SC_INFINITE_TIME)) { /* Stop time is earlier than start time. Disable the source. */ up7_start_time = SC_INFINITE_TIME; /* Display an appropriate warning. */ op_prg_odb_print_major ("Warning from a Traffic source model:", "Although the user priority 7 generator is not disabled (start time is set to a finite value) a stop time that is not later than the start time is specified.", "Disabling the user priority 7 generator.", OPC_NIL); } /* Make sure we have valid start and stop times, i.e. stop time is not earlier than start time. */ if ((up6_stop_time <= up6_start_time) && (up6_stop_time != SC_INFINITE_TIME)) { /* Stop time is earlier than start time. Disable the source. */ up6_start_time = SC_INFINITE_TIME; /* Display an appropriate warning. */ op_prg_odb_print_major ("Warning from a Traffic source model:", "Although the user priority 6 generator is not disabled (start time is set to a finite value) a stop time that is not later than the start time is specified.", "Disabling the user priority 6 generator.", OPC_NIL); } /* Make sure we have valid start and stop times, i.e. stop time is not earlier than start time. */ if ((up5_stop_time <= up5_start_time) && (up5_stop_time != SC_INFINITE_TIME)) { /* Stop time is earlier than start time. Disable the source. */ up5_start_time = SC_INFINITE_TIME; /* Display an appropriate warning. */ op_prg_odb_print_major ("Warning from a Traffic source model:", "Although the user priority 5 generator is not disabled (start time is set to a finite value) a stop time that is not later than the start time is specified.", "Disabling the user priority 5 generator.", OPC_NIL); } /* Make sure we have valid start and stop times, i.e. stop time is not earlier than start time. */ if ((up4_stop_time <= up4_start_time) && (up4_stop_time != SC_INFINITE_TIME)) { /* Stop time is earlier than start time. Disable the source. */ up4_start_time = SC_INFINITE_TIME; /* Display an appropriate warning. */ op_prg_odb_print_major ("Warning from a Traffic source model:", "Although the user priority 4 generator is not disabled (start time is set to a finite value) a stop time that is not later than the start time is specified.", "Disabling the user priority 4 generator.", OPC_NIL); } /* Make sure we have valid start and stop times, i.e. stop time is not earlier than start time. */ if ((up3_stop_time <= up3_start_time) && (up3_stop_time != SC_INFINITE_TIME)) { /* Stop time is earlier than start time. Disable the source. */ up3_start_time = SC_INFINITE_TIME; /* Display an appropriate warning. */ op_prg_odb_print_major ("Warning from a Traffic source model:", "Although the user priority 3 generator is not disabled (start time is set to a finite value) a stop time that is not later than the start time is specified.", "Disabling the user priority 3 generator.", OPC_NIL); } /* Make sure we have valid start and stop times, i.e. stop time is not earlier than start time. */ if ((up2_stop_time <= up2_start_time) && (up2_stop_time != SC_INFINITE_TIME)) { /* Stop time is earlier than start time. Disable the source. */ up2_start_time = SC_INFINITE_TIME; /* Display an appropriate warning. */ op_prg_odb_print_major ("Warning from a Traffic source model:", "Although the user priority 2 generator is not disabled (start time is set to a finite value) a stop time that is not later than the start time is specified.", "Disabling the user priority 2 generator.", OPC_NIL); } /* Make sure we have valid start and stop times, i.e. stop time is not earlier than start time. */ if ((up1_stop_time <= up1_start_time) && (up1_stop_time != SC_INFINITE_TIME)) { /* Stop time is earlier than start time. Disable the source. */ up1_start_time = SC_INFINITE_TIME; /* Display an appropriate warning. */ op_prg_odb_print_major ("Warning from a Traffic source model:", "Although the user priority 1 generator is not disabled (start time is set to a finite value) a stop time that is not later than the start time is specified.", "Disabling the user priority 1 generator.", OPC_NIL); } /* Make sure we have valid start and stop times, i.e. stop time is not earlier than start time. */ if ((up0_stop_time <= up0_start_time) && (up0_stop_time != SC_INFINITE_TIME)) { /* Stop time is earlier than start time. Disable the source. */ up0_start_time = SC_INFINITE_TIME; /* Display an appropriate warning. */ op_prg_odb_print_major ("Warning from a Traffic source model:", "Although the user priority 0 generator is not disabled (start time is set to a finite value) a stop time that is not later than the start time is specified.", "Disabling the user priority 0 generator.", OPC_NIL); } /* Schedule a self interrupt that will indicate transition to next state. */ if ((up7_start_time == SC_INFINITE_TIME) && (up6_start_time == SC_INFINITE_TIME) && (up5_start_time == SC_INFINITE_TIME) && (up4_start_time == SC_INFINITE_TIME) && (up3_start_time == SC_INFINITE_TIME) && (up2_start_time == SC_INFINITE_TIME) && (up1_start_time == SC_INFINITE_TIME) && (up0_start_time == SC_INFINITE_TIME) ) { op_intrpt_schedule_self (op_sim_time (), SC_STOP); //DISABLED } else { op_intrpt_schedule_self (op_sim_time (), SC_START); //START /* In this case, also schedule the interrupt for starting of the MSDU generation */ if (up7_start_time != SC_INFINITE_TIME) op_intrpt_schedule_self (up7_start_time, SC_GENERATE_UP7); //UP7_MSDU_GENERATE if (up6_start_time != SC_INFINITE_TIME) op_intrpt_schedule_self (up6_start_time, SC_GENERATE_UP6); //UP6_MSDU_GENERATE if (up5_start_time != SC_INFINITE_TIME) op_intrpt_schedule_self (up5_start_time, SC_GENERATE_UP5); //UP5_MSDU_GENERATE if (up4_start_time != SC_INFINITE_TIME) op_intrpt_schedule_self (up4_start_time, SC_GENERATE_UP4); //UP4_MSDU_GENERATE if (up3_start_time != SC_INFINITE_TIME) op_intrpt_schedule_self (up3_start_time, SC_GENERATE_UP3); //UP3_MSDU_GENERATE if (up2_start_time != SC_INFINITE_TIME) op_intrpt_schedule_self (up2_start_time, SC_GENERATE_UP2); //UP2_MSDU_GENERATE if (up1_start_time != SC_INFINITE_TIME) op_intrpt_schedule_self (up1_start_time, SC_GENERATE_UP1); //UP1_MSDU_GENERATE if (up0_start_time != SC_INFINITE_TIME) op_intrpt_schedule_self (up0_start_time, SC_GENERATE_UP0); //UP0_MSDU_GENERATE /* In this case, also schedule the interrupt when we will stop generating */ /* MSDUs, unless we are configured to run until the end of the simulation. */ if ((up7_stop_time != SC_INFINITE_TIME) && (up6_stop_time != SC_INFINITE_TIME) && (up5_stop_time != SC_INFINITE_TIME) && (up4_stop_time != SC_INFINITE_TIME) && (up3_stop_time != SC_INFINITE_TIME) && (up2_stop_time != SC_INFINITE_TIME) && (up1_stop_time != SC_INFINITE_TIME) && (up0_stop_time != SC_INFINITE_TIME) ){ temp = max_double(max_double(up7_stop_time, up6_stop_time), max_double(up5_stop_time, up4_stop_time)); temp = max_double(temp, max_double(max_double(up3_stop_time, up2_stop_time), max_double(up1_stop_time, up0_stop_time))); op_intrpt_schedule_self (temp, SC_STOP); } } wban_print_parameters (); /* Stack tracing exit point */ FOUT; }