diff --git a/openair2/LAYER2/MAC/extern_NB_IoT.h b/openair2/LAYER2/MAC/extern_NB_IoT.h index 65ef5fae13f3cf3dc344669277ea6c87a9400200..f8fdcf74203c61293245d7419e342ce02af08f49 100644 --- a/openair2/LAYER2/MAC/extern_NB_IoT.h +++ b/openair2/LAYER2/MAC/extern_NB_IoT.h @@ -132,7 +132,9 @@ extern const int BSR_table[64]; extern const int dl_rep[3]; extern const uint32_t dci_rep[3]; extern const uint32_t harq_rep[3]; -extern int cooooount; + +extern int preamble_trigger; +extern int preamble_sfn; //SIBs extern int extend_space[2]; extern int extend_alpha_offset[2]; diff --git a/openair2/LAYER2/MAC/main_NB_IoT.c b/openair2/LAYER2/MAC/main_NB_IoT.c index 1a6e5e404d28b9ff4afa885c17756a688c14bcfc..28dc4a36e3a9be963a5b6815fa5365dcd33ca6d0 100644 --- a/openair2/LAYER2/MAC/main_NB_IoT.c +++ b/openair2/LAYER2/MAC/main_NB_IoT.c @@ -144,8 +144,11 @@ void init_mac_NB_IoT(eNB_MAC_INST_NB_IoT *mac_inst) //Initialize uplink resource from nprach configuration Initialize_Resource(); //add_UL_Resource(mac_inst); - extend_available_resource_DL(mac_inst, mac_inst->current_subframe + 1 + 160); - cooooount = 0; + extend_available_resource_DL(mac_inst, mac_inst->current_subframe + 1 + 160); + + // for fixed scheduling + preamble_trigger = 0; + preamble_sfn = 0; } diff --git a/openair2/LAYER2/MAC/output_handler_NB_IoT.c b/openair2/LAYER2/MAC/output_handler_NB_IoT.c index 6fef7a7767b72d787b5b42199e4b0de3f799abb2..0704b1c59ceea6fa5d518ec9bc2f167bb02b6430 100644 --- a/openair2/LAYER2/MAC/output_handler_NB_IoT.c +++ b/openair2/LAYER2/MAC/output_handler_NB_IoT.c @@ -37,47 +37,50 @@ #define fixed_scheduling 1 -int init_time=0; +int delay_time=0; +int rar_transmit = 0; int fixed_scheduler(uint32_t frame, uint32_t subframe, Sched_Rsp_NB_IoT_t *SCHED_info) { + int RARNTI = 0; nfapi_dl_config_request_pdu_t *dl_config_pdu; - - if(cooooount==1) - { - init_time++; - } - if(cooooount==1 && init_time==6) + if(preamble_trigger==1 && subframe==7 && rar_transmit==0) { + RARNTI = 1 + preamble_sfn/4; //DCI LOG_I(MAC,"[frame:%2d][subframe:%2d]NB-IoT fill DL_DCI\n",frame,subframe); - dl_config_pdu = SCHED_info->DL_req->dl_config_request_body.dl_config_pdu_list; - SCHED_info->DL_req->dl_config_request_body.number_dci = 1; - SCHED_info->DL_req->dl_config_request_body.number_pdu = 1; - // not consider the case transmitting 2 DCIs for the moment also not consider N2 now - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_NPDCCH_PDU_TYPE; - dl_config_pdu->pdu_size = 2+sizeof(nfapi_dl_config_npdcch_pdu_rel13_t); - dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.length = 7; - dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.pdu_index = 1; - dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.ncce_index = 0; - dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.aggregation_level = 1; - dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.rnti_type = 1; // 1 = - dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.rnti = 133; // RA-RNTI = 1+floor(SFN/4) - dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.dci_format = 0; // N1 - dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.scheduling_delay = 0; - dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.resource_assignment = 0; - dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.repetition_number = 2; - dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.mcs = 4; - dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.new_data_indicator = 0; - dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.harq_ack_resource = 0; - dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.npdcch_order_indication = 0; - dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.dci_subframe_repetition_number = 2; + dl_config_pdu = SCHED_info->DL_req->dl_config_request_body.dl_config_pdu_list; + SCHED_info->DL_req->dl_config_request_body.number_dci = 1; + SCHED_info->DL_req->dl_config_request_body.number_pdu = 1; + // not consider the case transmitting 2 DCIs for the moment also not consider N2 now + dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_NPDCCH_PDU_TYPE; + dl_config_pdu->pdu_size = 2+sizeof(nfapi_dl_config_npdcch_pdu_rel13_t); + dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.length = 7; + dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.pdu_index = 1; + dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.ncce_index = 0; + dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.aggregation_level = 1; + dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.rnti_type = 1; // 1 = + dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.rnti = RARNTI; // RA-RNTI = 1+floor(SFN/4) + dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.dci_format = 0; // N1 + dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.scheduling_delay = 0; + dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.resource_assignment = 0; + dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.repetition_number = 2; + dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.mcs = 4; + dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.new_data_indicator = 0; + dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.harq_ack_resource = 0; + dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.npdcch_order_indication = 0; + dl_config_pdu->npdcch_pdu.npdcch_pdu_rel13.dci_subframe_repetition_number = 2; + rar_transmit=1; + delay_time=1; return 1; } - if(cooooount==1 && init_time==15) + if(rar_transmit==1) + delay_time++; + if(rar_transmit==1 && delay_time==10) { - LOG_I(MAC,"[frame:%2d][subframe:%2d]NB-IoT fill DL Data\n",frame,subframe); + LOG_I(MAC,"[frame:%2d][subframe:%2d]NB-IoT fill DL Data\n",frame,subframe); + RARNTI = 1 + preamble_sfn/4; uint8_t *rar_pdu; rar_pdu = (uint8_t *)malloc(7*sizeof(uint8_t)); rar_pdu[0] = 64; // + preamble index @@ -88,21 +91,22 @@ int fixed_scheduler(uint32_t frame, uint32_t subframe, Sched_Rsp_NB_IoT_t *SCHED rar_pdu[5] = 255; rar_pdu[6] = 242; - dl_config_pdu = SCHED_info->DL_req->dl_config_request_body.dl_config_pdu_list; - SCHED_info->DL_req->dl_config_request_body.number_pdu = 1; - dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_NDLSCH_PDU_TYPE; - dl_config_pdu->pdu_size = 2+sizeof(nfapi_dl_config_ndlsch_pdu_rel13_t); - dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.length = 7; - dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.pdu_index = 1; - dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.rnti_type = 1; - dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.rnti = 133; // C-RNTI - dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.resource_assignment = 0; - dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.repetition_number = 2; - dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.modulation = 2; - dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.number_of_subframes_for_resource_assignment = get_num_sf(dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.resource_assignment); - SCHED_info->TX_req->tx_request_body.tx_pdu_list[dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.pdu_index].segments[0].segment_data = rar_pdu; - cooooount =0; - init_time =0; + dl_config_pdu = SCHED_info->DL_req->dl_config_request_body.dl_config_pdu_list; + SCHED_info->DL_req->dl_config_request_body.number_pdu = 1; + dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_NDLSCH_PDU_TYPE; + dl_config_pdu->pdu_size = 2+sizeof(nfapi_dl_config_ndlsch_pdu_rel13_t); + dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.length = 7; + dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.pdu_index = 1; + dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.rnti_type = 1; + dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.rnti = RARNTI; // RA-RNTI + dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.resource_assignment = 0; + dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.repetition_number = 2; + dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.modulation = 2; + dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.number_of_subframes_for_resource_assignment = get_num_sf(dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.resource_assignment); + SCHED_info->TX_req->tx_request_body.tx_pdu_list[dl_config_pdu->ndlsch_pdu.ndlsch_pdu_rel13.pdu_index].segments[0].segment_data = rar_pdu; + rar_transmit = 0; + preamble_trigger =0; + delay_time =0; return 1; } return 0; diff --git a/openair2/LAYER2/MAC/vars_NB_IoT.h b/openair2/LAYER2/MAC/vars_NB_IoT.h index f9c6714d2d445341328ca3fa272ba3a28bee2b3c..1d01c16b610e043e77e90773a54a178de8dbb472 100644 --- a/openair2/LAYER2/MAC/vars_NB_IoT.h +++ b/openair2/LAYER2/MAC/vars_NB_IoT.h @@ -39,7 +39,8 @@ //#include "PHY_INTERFACE/defs.h" //#include "COMMON/mac_rrc_primitives.h" -int cooooount; +int preamble_trigger; +int preamble_sfn; //IF_Module_NB_IoT_t *if_inst_NB_IoT; //NB-IoT-------------------------------------- diff --git a/openair2/PHY_INTERFACE/IF_Module_L2_primitives_NB_IoT.c b/openair2/PHY_INTERFACE/IF_Module_L2_primitives_NB_IoT.c index 5c81c982d2b34f5ec9aa591d7770694ad9688f65..593c1afa52f2feb9d49b49d42f6dd908c973b69c 100644 --- a/openair2/PHY_INTERFACE/IF_Module_L2_primitives_NB_IoT.c +++ b/openair2/PHY_INTERFACE/IF_Module_L2_primitives_NB_IoT.c @@ -46,7 +46,8 @@ void UL_indication_NB_IoT(UL_IND_NB_IoT_t *UL_INFO) //UE_TEMPLATE_NB_IoT *UE_info; enable_preamble_simulation(UL_INFO,0); - if(cooooount==0) + + if(preamble_trigger==0) { //If there is a preamble, do the initiate RA procedure if(UL_INFO->nrach_ind.number_of_initial_scs_detected>0) @@ -67,7 +68,8 @@ void UL_indication_NB_IoT(UL_IND_NB_IoT_t *UL_INFO) (UL_INFO->nrach_ind.nrach_pdu_list+i)->nrach_indication_rel13.timing_advance*16 );*/ LOG_D(MAC,"Init_RA_NB_IoT Out\n"); - cooooount=1; + preamble_trigger=1; + preamble_sfn = UL_INFO->frame; } } }