diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c445c28..8b23f43b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -749,4 +749,7 @@ configure_file(${PROJECT_SOURCE_DIR}/nrscope/src/tests/bigquery_table_create.py ${CMAKE_CURRENT_BINARY_DIR}/nrscope/src/tests/bigquery_table_create.py) configure_file(${PROJECT_SOURCE_DIR}/nrscope/src/libs/to_google.py -${CMAKE_CURRENT_BINARY_DIR}/nrscope/src/to_google.py) \ No newline at end of file +${CMAKE_CURRENT_BINARY_DIR}/nrscope/src/to_google.py) + +configure_file(${PROJECT_SOURCE_DIR}/nrscope/hidden_bwp_db/369.txt +${CMAKE_CURRENT_BINARY_DIR}/nrscope/src/369.txt) \ No newline at end of file diff --git a/README.md b/README.md index 41aa99ec..ee12a900 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,19 @@ sudo ldconfig # to double check, libs should appear at /usr/local/lib and header liquid.h should appear at /usr/local/include/liquid/ ``` +[Currently Internal] We need [json](https://github.com/nlohmann/json) for accessing our database for hidden BWP detection: +``` +# download source codes +git clone https://github.com/nlohmann/json.git +cd json +mkdir build +cd build +cmake ../ +make +sudo make install +# to double check, nlohmann should appear at /usr/local/include/ +``` + For different USRP daughterboard, different `config.yaml` should be used. Please refer to the sample `config.yaml` in `./nrscope/config/config.yaml` and the explanatory comment in it. diff --git a/lib/include/srsran/asn1/rrc_nr.h b/lib/include/srsran/asn1/rrc_nr.h index 524769cf..74a29af4 100644 --- a/lib/include/srsran/asn1/rrc_nr.h +++ b/lib/include/srsran/asn1/rrc_nr.h @@ -31,6 +31,9 @@ #include "asn1_utils.h" #include #include +#include + +using json = nlohmann::json; namespace asn1 { namespace rrc_nr { @@ -20336,6 +20339,7 @@ struct cell_group_cfg_s { // sequence methods SRSASN_CODE pack(bit_ref& bref) const; SRSASN_CODE unpack(cbit_ref& bref); + SRSASN_CODE from_json(json js_in); void to_json(json_writer& j) const; }; diff --git a/lib/src/asn1/rrc_nr.cc b/lib/src/asn1/rrc_nr.cc index 16a93751..761661a9 100644 --- a/lib/src/asn1/rrc_nr.cc +++ b/lib/src/asn1/rrc_nr.cc @@ -21,9 +21,13 @@ #include "srsran/asn1/rrc_nr.h" #include +#include +#include +#include using namespace asn1; using namespace asn1::rrc_nr; +using json = nlohmann::json; /******************************************************************************* * Struct Methods @@ -48625,6 +48629,624 @@ SRSASN_CODE cell_group_cfg_s::unpack(cbit_ref& bref) } return SRSASN_SUCCESS; } + +SRSASN_CODE cell_group_cfg_s::from_json(json js_in) { + + // TO-DO: Currently assume input only dl+ul bwp lists; write other part parsing of master cell group + + // Assume we load those hidden bwp configs only once, so essentially everything is treated + // as ADD (NOT MOD), and hence we just need to append to array, rather than search if the + // config might already exist and modify accordingly + + /** + * + * NON-INITIAL UL BWP(S) CONFIG EXTRACTION + * + */ + if (js_in["spCellConfigDedicated"].contains("uplinkConfig")) { + sp_cell_cfg.sp_cell_cfg_ded.ul_cfg_present = true; + // printf("[9/21] trigger 3.1\n"); + } + if (js_in["spCellConfigDedicated"]["uplinkConfig"]["uplinkBWP-ToAddModList"].is_array()) { + auto& ul_bwp_to_add_mod_list = sp_cell_cfg.sp_cell_cfg_ded.ul_cfg.ul_bwp_to_add_mod_list; + json js_ul_bwp_to_add_mod_list = js_in["spCellConfigDedicated"]["uplinkConfig"]["uplinkBWP-ToAddModList"]; + + /* uplinkBWP-ToAddModList */ + for (auto& js_cur_ul_bwp_el : js_ul_bwp_to_add_mod_list.items()) { + // printf("[9/21] trigger 3.2\n"); + json js_cur_ul_bwp = js_cur_ul_bwp_el.value(); + bwp_ul_s cur_ul_bwp; + cur_ul_bwp.bwp_id = js_cur_ul_bwp["bwp-Id"]; + + /* bwp-Common */ + cur_ul_bwp.bwp_common_present = js_cur_ul_bwp.contains("bwp-Common"); + + /* bwp-Common -- genericParameters */ + json js_cur_ul_bwp_common_generic = js_cur_ul_bwp["bwp-Common"]["genericParameters"]; + + cur_ul_bwp.bwp_common.generic_params.location_and_bw = js_cur_ul_bwp_common_generic["locationAndBandwidth"]; + cur_ul_bwp.bwp_common.generic_params.subcarrier_spacing = (asn1::rrc_nr::subcarrier_spacing_e)js_cur_ul_bwp_common_generic["subcarrierSpacing"]; + + /* bwp-Common -- rach-ConfigCommon */ + cur_ul_bwp.bwp_common.rach_cfg_common_present = js_cur_ul_bwp["bwp-Common"].contains("rach-ConfigCommon"); + // skip rach-related config copy as it's not related to DCI computation + + /* bwp-Common -- pusch-ConfigCommon */ + cur_ul_bwp.bwp_common.pusch_cfg_common_present = js_cur_ul_bwp["bwp-Common"].contains("pusch-ConfigCommon"); + if (cur_ul_bwp.bwp_common.pusch_cfg_common_present) { + json js_cur_ul_bwp_common_pusch_common = js_cur_ul_bwp["bwp-Common"]["pusch-ConfigCommon"]; + + json js_cur_ul_bwp_common_pusch_common_time_alloc_list = js_cur_ul_bwp_common_pusch_common["pusch-TimeDomainAllocationList"]; + cur_ul_bwp.bwp_common.pusch_cfg_common.set_setup().pusch_time_domain_alloc_list; + for (auto& js_cur_ul_bwp_common_pusch_common_time_alloc_el : js_cur_ul_bwp_common_pusch_common_time_alloc_list.items()) { + json js_cur_ul_bwp_common_pusch_common_time_alloc = js_cur_ul_bwp_common_pusch_common_time_alloc_el.value()["PUSCH-TimeDomainResourceAllocation"]; + pusch_time_domain_res_alloc_s cur_ul_bwp_common_pusch_common_time_alloc; + cur_ul_bwp_common_pusch_common_time_alloc.k2_present = true; + cur_ul_bwp_common_pusch_common_time_alloc.k2 = js_cur_ul_bwp_common_pusch_common_time_alloc["k2"]; + cur_ul_bwp_common_pusch_common_time_alloc.map_type = (asn1::rrc_nr::pusch_time_domain_res_alloc_s::map_type_e_)js_cur_ul_bwp_common_pusch_common_time_alloc["mappingType"]; + cur_ul_bwp_common_pusch_common_time_alloc.start_symbol_and_len = js_cur_ul_bwp_common_pusch_common_time_alloc["startSymbolAndLength"]; + + cur_ul_bwp.bwp_common.pusch_cfg_common.set_setup().pusch_time_domain_alloc_list.push_back(cur_ul_bwp_common_pusch_common_time_alloc); + } + + cur_ul_bwp.bwp_common.pusch_cfg_common.set_setup().msg3_delta_preamb_present = js_cur_ul_bwp_common_pusch_common.contains("msg3-DeltaPreamble"); + if (cur_ul_bwp.bwp_common.pusch_cfg_common.setup().msg3_delta_preamb_present) { + cur_ul_bwp.bwp_common.pusch_cfg_common.set_setup().msg3_delta_preamb = js_cur_ul_bwp_common_pusch_common["msg3-DeltaPreamble"]; + } + + cur_ul_bwp.bwp_common.pusch_cfg_common.set_setup().p0_nominal_with_grant_present = js_cur_ul_bwp_common_pusch_common.contains("p0-NominalWithGrant"); + if (cur_ul_bwp.bwp_common.pusch_cfg_common.setup().p0_nominal_with_grant_present) { + cur_ul_bwp.bwp_common.pusch_cfg_common.set_setup().p0_nominal_with_grant = js_cur_ul_bwp_common_pusch_common["p0-NominalWithGrant"]; + } + } + // printf("[9/21] trigger 3.3\n"); + + /* bwp-Common -- pucch-ConfigCommon */ + cur_ul_bwp.bwp_common.pucch_cfg_common_present = js_cur_ul_bwp["bwp-Common"].contains("pucch-ConfigCommon"); + if (cur_ul_bwp.bwp_common.pucch_cfg_common_present) { + json js_cur_ul_bwp_common_pucch_common = js_cur_ul_bwp["bwp-Common"]["pucch-ConfigCommon"]; + + cur_ul_bwp.bwp_common.pucch_cfg_common.set_setup().pucch_res_common_present = js_cur_ul_bwp_common_pucch_common.contains("pucch-ResourceCommon"); + if (cur_ul_bwp.bwp_common.pucch_cfg_common.setup().pucch_res_common_present) { + cur_ul_bwp.bwp_common.pucch_cfg_common.set_setup().pucch_res_common = js_cur_ul_bwp_common_pucch_common["pucch-ResourceCommon"]; + } + cur_ul_bwp.bwp_common.pucch_cfg_common.set_setup().pucch_group_hop = (asn1::rrc_nr::pucch_cfg_common_s::pucch_group_hop_e_)js_cur_ul_bwp_common_pucch_common["pucch-GroupHopping"]; + + cur_ul_bwp.bwp_common.pucch_cfg_common.set_setup().p0_nominal_present = js_cur_ul_bwp_common_pucch_common.contains("p0-nominal"); + + if (cur_ul_bwp.bwp_common.pucch_cfg_common.setup().p0_nominal_present) { + cur_ul_bwp.bwp_common.pucch_cfg_common.set_setup().p0_nominal = js_cur_ul_bwp_common_pucch_common["p0-nominal"]; + } + } + // printf("[9/21] trigger 3.4\n"); + + /* bwp-Dedicated */ + cur_ul_bwp.bwp_ded_present = js_cur_ul_bwp.contains("bwp-Dedicated"); + + /* bwp-Dedicated -- pucch-Config */ + cur_ul_bwp.bwp_ded.pucch_cfg_present = js_cur_ul_bwp["bwp-Dedicated"].contains("pucch-Config"); + if (cur_ul_bwp.bwp_ded.pucch_cfg_present) { + json js_cur_ul_bwp_ded_pucch = js_cur_ul_bwp["bwp-Dedicated"]["pucch-Config"]; + + /* resourceSetToAddModList */ + for (auto& js_cur_ul_bwp_ded_pucch_res_set_el : js_cur_ul_bwp_ded_pucch["resourceSetToAddModList"].items()) { + json js_cur_ul_bwp_ded_pucch_res_set = js_cur_ul_bwp_ded_pucch_res_set_el.value(); + pucch_res_set_s cur_ul_bwp_ded_pucch_res_set; + + cur_ul_bwp_ded_pucch_res_set.pucch_res_set_id = js_cur_ul_bwp_ded_pucch_res_set["PUCCH-ResourceSetId"]; + for (auto& js_cur_ul_bwp_ded_pucch_res_set_res_el : js_cur_ul_bwp_ded_pucch_res_set["resourceList"].items()) { + json js_cur_res_id = js_cur_ul_bwp_ded_pucch_res_set_res_el.value(); + cur_ul_bwp_ded_pucch_res_set.res_list.push_back(js_cur_res_id); + } + + cur_ul_bwp.bwp_ded.pucch_cfg.set_setup().res_set_to_add_mod_list.push_back(cur_ul_bwp_ded_pucch_res_set); + } + + // printf("[9/21] trigger 3.41\n"); + + /* resourceToAddModList */ + for (auto& js_cur_ul_bwp_ded_pucch_res_el : js_cur_ul_bwp_ded_pucch["resourceToAddModList"].items()) { + json js_cur_ul_bwp_ded_pucch_res = js_cur_ul_bwp_ded_pucch_res_el.value(); + pucch_res_s cur_ul_bwp_ded_pucch_res; + + cur_ul_bwp_ded_pucch_res.pucch_res_id = js_cur_ul_bwp_ded_pucch_res["pucch-ResourceId"]; + cur_ul_bwp_ded_pucch_res.start_prb = js_cur_ul_bwp_ded_pucch_res["startingPRB"]; + + // Need to distinguish/infer format type + /* Format 0 */ + if (js_cur_ul_bwp_ded_pucch_res["format"].contains("initialCyclicShift")) { + cur_ul_bwp_ded_pucch_res.format.set_format0().init_cyclic_shift = js_cur_ul_bwp_ded_pucch_res["format"]["initialCyclicShift"]; + cur_ul_bwp_ded_pucch_res.format.set_format0().nrof_symbols = js_cur_ul_bwp_ded_pucch_res["format"]["nrofSymbols"]; + cur_ul_bwp_ded_pucch_res.format.set_format0().start_symbol_idx = js_cur_ul_bwp_ded_pucch_res["format"]["startingSymbolIndex"]; + } + + /* Format 2 */ + if (js_cur_ul_bwp_ded_pucch_res["format"].contains("nrofPRBs")) { + cur_ul_bwp_ded_pucch_res.format.set_format2().nrof_prbs = js_cur_ul_bwp_ded_pucch_res["format"]["nrofPRBs"]; + cur_ul_bwp_ded_pucch_res.format.set_format2().nrof_symbols = js_cur_ul_bwp_ded_pucch_res["format"]["nrofSymbols"]; + cur_ul_bwp_ded_pucch_res.format.set_format2().start_symbol_idx = js_cur_ul_bwp_ded_pucch_res["format"]["startingSymbolIndex"]; + } + + cur_ul_bwp.bwp_ded.pucch_cfg.set_setup().res_to_add_mod_list.push_back(cur_ul_bwp_ded_pucch_res); + } + + // printf("[9/21] trigger 3.42\n"); + + cur_ul_bwp.bwp_ded.pucch_cfg.set_setup().format2_present = js_cur_ul_bwp_ded_pucch.contains("format2"); + if (cur_ul_bwp.bwp_ded.pucch_cfg.setup().format2_present) { + cur_ul_bwp.bwp_ded.pucch_cfg.set_setup().format2.set_setup().max_code_rate = (asn1::rrc_nr::pucch_max_code_rate_e)js_cur_ul_bwp_ded_pucch["format2"]["maxCodeRate"]; + cur_ul_bwp.bwp_ded.pucch_cfg.set_setup().format2.set_setup().simul_harq_ack_csi_present = js_cur_ul_bwp_ded_pucch["format2"]["simultaneousHARQ-ACK-CSI"] == 0 ? true : false; + } + + // printf("[9/21] trigger 3.43\n"); + + /* schedulingRequestResourceToAddModList */ + for (auto& js_cur_ul_bwp_ded_pucch_sch_req_res_el : js_cur_ul_bwp_ded_pucch["schedulingRequestResourceToAddModList"].items()) { + json js_cur_ul_bwp_ded_pucch_sch_req_res = js_cur_ul_bwp_ded_pucch_sch_req_res_el.value(); + sched_request_res_cfg_s cur_ul_bwp_ded_pucch_sch_req_res; + cur_ul_bwp_ded_pucch_sch_req_res.sched_request_res_id = js_cur_ul_bwp_ded_pucch_sch_req_res["schedulingRequestResourceId"]; + cur_ul_bwp_ded_pucch_sch_req_res.sched_request_id = js_cur_ul_bwp_ded_pucch_sch_req_res["schedulingRequestID"]; + cur_ul_bwp_ded_pucch_sch_req_res.periodicity_and_offset_present = js_cur_ul_bwp_ded_pucch_sch_req_res.contains("periodicityAndOffset"); + if (cur_ul_bwp_ded_pucch_sch_req_res.periodicity_and_offset_present) { + // Hardcode for now + // TO-DO: fix this + cur_ul_bwp_ded_pucch_sch_req_res.periodicity_and_offset.set_sl80(); + } + cur_ul_bwp_ded_pucch_sch_req_res.res_present = js_cur_ul_bwp_ded_pucch_sch_req_res.contains("resource"); + if (cur_ul_bwp_ded_pucch_sch_req_res.res_present) { + cur_ul_bwp_ded_pucch_sch_req_res.res = js_cur_ul_bwp_ded_pucch_sch_req_res["resource"]; + } + + cur_ul_bwp.bwp_ded.pucch_cfg.set_setup().sched_request_res_to_add_mod_list.push_back(cur_ul_bwp_ded_pucch_sch_req_res); + } + + // printf("[9/21] trigger 3.44\n"); + + /* multi-CSI-PUCCH-ResourceList */ + for (auto& js_cur_ul_bwp_ded_pucch_mul_csi_pucch_res_el : js_cur_ul_bwp_ded_pucch["multi-CSI-PUCCH-ResourceList"].items()) { + json js_cur_ul_bwp_ded_pucch_mul_csi_pucch_res = js_cur_ul_bwp_ded_pucch_mul_csi_pucch_res_el.value(); + + cur_ul_bwp.bwp_ded.pucch_cfg.set_setup().multi_csi_pucch_res_list.push_back(js_cur_ul_bwp_ded_pucch_mul_csi_pucch_res); + } + + // printf("[9/21] trigger 3.45\n"); + + /* dl-DataToUL-ACK */ + for (auto& js_cur_ul_bwp_ded_pucch_dl_data_to_ul_ack_el : js_cur_ul_bwp_ded_pucch["dl-DataToUL-ACK"].items()) { + json js_cur_ul_bwp_ded_pucch_dl_data_to_ul_ack = js_cur_ul_bwp_ded_pucch_dl_data_to_ul_ack_el.value(); + + cur_ul_bwp.bwp_ded.pucch_cfg.set_setup().dl_data_to_ul_ack.push_back(js_cur_ul_bwp_ded_pucch_dl_data_to_ul_ack); + } + + // printf("[9/21] trigger 3.46\n"); + + /* pucch-PowerControl */ + cur_ul_bwp.bwp_ded.pucch_cfg.set_setup().pucch_pwr_ctrl_present = js_cur_ul_bwp_ded_pucch.contains("pucch-PowerControl"); + if (cur_ul_bwp.bwp_ded.pucch_cfg.setup().pucch_pwr_ctrl_present) { + cur_ul_bwp.bwp_ded.pucch_cfg.set_setup().pucch_pwr_ctrl.delta_f_pucch_f0_present = js_cur_ul_bwp_ded_pucch["pucch-PowerControl"].contains("deltaF-PUCCH-f0"); + if (cur_ul_bwp.bwp_ded.pucch_cfg.setup().pucch_pwr_ctrl.delta_f_pucch_f0_present) { + cur_ul_bwp.bwp_ded.pucch_cfg.setup().pucch_pwr_ctrl.delta_f_pucch_f0 = js_cur_ul_bwp_ded_pucch["pucch-PowerControl"]["deltaF-PUCCH-f0"]; + } + + cur_ul_bwp.bwp_ded.pucch_cfg.set_setup().pucch_pwr_ctrl.delta_f_pucch_f1_present = js_cur_ul_bwp_ded_pucch["pucch-PowerControl"].contains("deltaF-PUCCH-f1"); + if (cur_ul_bwp.bwp_ded.pucch_cfg.setup().pucch_pwr_ctrl.delta_f_pucch_f1_present) { + cur_ul_bwp.bwp_ded.pucch_cfg.setup().pucch_pwr_ctrl.delta_f_pucch_f1 = js_cur_ul_bwp_ded_pucch["pucch-PowerControl"]["deltaF-PUCCH-f1"]; + } + + cur_ul_bwp.bwp_ded.pucch_cfg.set_setup().pucch_pwr_ctrl.delta_f_pucch_f2_present = js_cur_ul_bwp_ded_pucch["pucch-PowerControl"].contains("deltaF-PUCCH-f2"); + if (cur_ul_bwp.bwp_ded.pucch_cfg.setup().pucch_pwr_ctrl.delta_f_pucch_f2_present) { + cur_ul_bwp.bwp_ded.pucch_cfg.setup().pucch_pwr_ctrl.delta_f_pucch_f2 = js_cur_ul_bwp_ded_pucch["pucch-PowerControl"]["deltaF-PUCCH-f2"]; + } + + cur_ul_bwp.bwp_ded.pucch_cfg.set_setup().pucch_pwr_ctrl.delta_f_pucch_f3_present = js_cur_ul_bwp_ded_pucch["pucch-PowerControl"].contains("deltaF-PUCCH-f3"); + if (cur_ul_bwp.bwp_ded.pucch_cfg.setup().pucch_pwr_ctrl.delta_f_pucch_f3_present) { + cur_ul_bwp.bwp_ded.pucch_cfg.setup().pucch_pwr_ctrl.delta_f_pucch_f3 = js_cur_ul_bwp_ded_pucch["pucch-PowerControl"]["deltaF-PUCCH-f3"]; + } + + cur_ul_bwp.bwp_ded.pucch_cfg.set_setup().pucch_pwr_ctrl.delta_f_pucch_f4_present = js_cur_ul_bwp_ded_pucch["pucch-PowerControl"].contains("deltaF-PUCCH-f4"); + if (cur_ul_bwp.bwp_ded.pucch_cfg.setup().pucch_pwr_ctrl.delta_f_pucch_f4_present) { + cur_ul_bwp.bwp_ded.pucch_cfg.setup().pucch_pwr_ctrl.delta_f_pucch_f4 = js_cur_ul_bwp_ded_pucch["pucch-PowerControl"]["deltaF-PUCCH-f4"]; + } + + for (auto& js_cur_ul_bwp_ded_pucch_pc_p0_el : js_cur_ul_bwp_ded_pucch["pucch-PowerControl"]["p0-Set"].items()) { + json js_cur_ul_bwp_ded_pucch_pc_p0 = js_cur_ul_bwp_ded_pucch_pc_p0_el.value(); + + p0_pucch_s cur_ul_bwp_ded_pucch_pc_p0; + cur_ul_bwp_ded_pucch_pc_p0.p0_pucch_id = js_cur_ul_bwp_ded_pucch_pc_p0["p0-PUCCH-Id"]; + cur_ul_bwp_ded_pucch_pc_p0.p0_pucch_value = js_cur_ul_bwp_ded_pucch_pc_p0["p0-PUCCH-Value"]; + + cur_ul_bwp.bwp_ded.pucch_cfg.set_setup().pucch_pwr_ctrl.p0_set.push_back(cur_ul_bwp_ded_pucch_pc_p0); + } + + } + + // printf("[9/21] trigger 3.47\n"); + } + // printf("[9/21] trigger 3.5\n"); + + /* bwp-Dedicated -- pusch-Config */ + cur_ul_bwp.bwp_ded.pusch_cfg_present = js_cur_ul_bwp["bwp-Dedicated"].contains("pusch-Config"); + if (cur_ul_bwp.bwp_ded.pusch_cfg_present) { + json js_cur_ul_bwp_ded_pusch = js_cur_ul_bwp["bwp-Dedicated"]["pusch-Config"]; + + cur_ul_bwp.bwp_ded.pusch_cfg.set_setup().data_scrambling_id_pusch_present = js_cur_ul_bwp_ded_pusch.contains("dataScramblingIdentityPUSCH"); + + if (cur_ul_bwp.bwp_ded.pusch_cfg.setup().data_scrambling_id_pusch_present) { + cur_ul_bwp.bwp_ded.pusch_cfg.set_setup().data_scrambling_id_pusch = js_cur_ul_bwp_ded_pusch["dataScramblingIdentityPUSCH"]; + } + + cur_ul_bwp.bwp_ded.pusch_cfg.set_setup().tx_cfg_present = js_cur_ul_bwp_ded_pusch.contains("txConfig"); + + if (cur_ul_bwp.bwp_ded.pusch_cfg.setup().tx_cfg_present) { + if (js_cur_ul_bwp_ded_pusch["txConfig"].contains("codebook")) { + cur_ul_bwp.bwp_ded.pusch_cfg.set_setup().tx_cfg = asn1::rrc_nr::pusch_cfg_s::tx_cfg_e_::codebook; + } + + // For non_codebook and nulltype, will add here once encountered + } + + /* dmrs-UplinkForPUSCH-MappingTypeA */ + cur_ul_bwp.bwp_ded.pusch_cfg.set_setup().dmrs_ul_for_pusch_map_type_a_present = js_cur_ul_bwp_ded_pusch.contains("dmrs-UplinkForPUSCH-MappingTypeA"); + if (cur_ul_bwp.bwp_ded.pusch_cfg.setup().dmrs_ul_for_pusch_map_type_a_present) { + cur_ul_bwp.bwp_ded.pusch_cfg.set_setup().dmrs_ul_for_pusch_map_type_a.set_setup().dmrs_add_position_present = js_cur_ul_bwp_ded_pusch["dmrs-UplinkForPUSCH-MappingTypeA"].contains("dmrs-AdditionalPosition"); + if (cur_ul_bwp.bwp_ded.pusch_cfg.setup().dmrs_ul_for_pusch_map_type_a.setup().dmrs_add_position_present) { + cur_ul_bwp.bwp_ded.pusch_cfg.set_setup().dmrs_ul_for_pusch_map_type_a.set_setup().dmrs_add_position = + (asn1::rrc_nr::dmrs_ul_cfg_s::dmrs_add_position_e_)js_cur_ul_bwp_ded_pusch["dmrs-UplinkForPUSCH-MappingTypeA"]["dmrs-AdditionalPosition"]; + } + + cur_ul_bwp.bwp_ded.pusch_cfg.set_setup().dmrs_ul_for_pusch_map_type_a.set_setup().transform_precoding_disabled_present = js_cur_ul_bwp_ded_pusch["dmrs-UplinkForPUSCH-MappingTypeA"].contains("transformPrecodingDisabled"); + if (cur_ul_bwp.bwp_ded.pusch_cfg.setup().dmrs_ul_for_pusch_map_type_a.setup().transform_precoding_disabled_present) { + cur_ul_bwp.bwp_ded.pusch_cfg.set_setup().dmrs_ul_for_pusch_map_type_a.set_setup().transform_precoding_disabled.scrambling_id0_present = + js_cur_ul_bwp_ded_pusch["dmrs-UplinkForPUSCH-MappingTypeA"]["transformPrecodingDisabled"].contains("scramblingID0"); + if (cur_ul_bwp.bwp_ded.pusch_cfg.setup().dmrs_ul_for_pusch_map_type_a.setup().transform_precoding_disabled.scrambling_id0_present) { + cur_ul_bwp.bwp_ded.pusch_cfg.set_setup().dmrs_ul_for_pusch_map_type_a.set_setup().transform_precoding_disabled.scrambling_id0 = + js_cur_ul_bwp_ded_pusch["dmrs-UplinkForPUSCH-MappingTypeA"]["transformPrecodingDisabled"]["scramblingID0"]; + } + } + } + + // printf("[9/21] trigger 3.51\n"); + + /* pusch-PowerControl */ + cur_ul_bwp.bwp_ded.pusch_cfg.set_setup().pusch_pwr_ctrl_present = js_cur_ul_bwp_ded_pusch.contains("pusch-PowerControl"); + if (cur_ul_bwp.bwp_ded.pusch_cfg.setup().pusch_pwr_ctrl_present) { + // printf("[9/21] trigger 3.510\n"); + cur_ul_bwp.bwp_ded.pusch_cfg.set_setup().pusch_pwr_ctrl.tpc_accumulation_present = js_cur_ul_bwp_ded_pusch["pusch-PowerControl"]["tpc-Accumulation"] == 1 ? true : false; + + cur_ul_bwp.bwp_ded.pusch_cfg.set_setup().pusch_pwr_ctrl.msg3_alpha_present = js_cur_ul_bwp_ded_pusch["pusch-PowerControl"].contains("msg3-Alpha"); + if (cur_ul_bwp.bwp_ded.pusch_cfg.setup().pusch_pwr_ctrl.msg3_alpha_present) { + cur_ul_bwp.bwp_ded.pusch_cfg.set_setup().pusch_pwr_ctrl.msg3_alpha = (asn1::rrc_nr::alpha_e)js_cur_ul_bwp_ded_pusch["pusch-PowerControl"]["msg3-Alpha"]; + } + + // printf("[9/21] trigger 3.511\n"); + + for (auto& js_cur_ul_bwp_ded_pusch_pc_p0_el : js_cur_ul_bwp_ded_pusch["pusch-PowerControl"]["p0-AlphaSets"].items()) { + json js_cur_ul_bwp_ded_pusch_pc_p0 = js_cur_ul_bwp_ded_pusch_pc_p0_el.value(); + p0_pusch_alpha_set_s cur_ul_bwp_ded_pusch_pc_p0; + cur_ul_bwp_ded_pusch_pc_p0.p0_pusch_alpha_set_id = js_cur_ul_bwp_ded_pusch_pc_p0["p0-PUSCH-AlphaSetId"]; + cur_ul_bwp_ded_pusch_pc_p0.p0_present = js_cur_ul_bwp_ded_pusch_pc_p0.contains("p0"); + if (cur_ul_bwp_ded_pusch_pc_p0.p0_present) { + cur_ul_bwp_ded_pusch_pc_p0.p0 = js_cur_ul_bwp_ded_pusch_pc_p0["p0"]; + } + + // printf("[9/21] trigger 3.5111\n"); + + cur_ul_bwp_ded_pusch_pc_p0.alpha_present = js_cur_ul_bwp_ded_pusch_pc_p0.contains("alpha"); + if (cur_ul_bwp_ded_pusch_pc_p0.alpha_present) { + cur_ul_bwp_ded_pusch_pc_p0.alpha = (asn1::rrc_nr::alpha_e)js_cur_ul_bwp_ded_pusch_pc_p0["alpha"]; + } + + cur_ul_bwp.bwp_ded.pusch_cfg.set_setup().pusch_pwr_ctrl.p0_alpha_sets.push_back(cur_ul_bwp_ded_pusch_pc_p0); + } + + // printf("[9/21] trigger 3.512\n"); + } + + // printf("[9/21] trigger 3.52\n"); + + /* resourceAllocation */ + cur_ul_bwp.bwp_ded.pusch_cfg.set_setup().res_alloc = (asn1::rrc_nr::pusch_cfg_s::res_alloc_e_)js_cur_ul_bwp_ded_pusch["resourceAllocation"]; + + /* pusch-TimeDomainAllocationList */ + cur_ul_bwp.bwp_ded.pusch_cfg.set_setup().pusch_time_domain_alloc_list_present = js_cur_ul_bwp_ded_pusch.contains("pusch-TimeDomainAllocationList"); + if (cur_ul_bwp.bwp_ded.pusch_cfg.setup().pusch_time_domain_alloc_list_present) { + + for (auto& js_cur_ul_bwp_ded_pusch_time_alloc_el : js_cur_ul_bwp_ded_pusch["pusch-TimeDomainAllocationList"].items()) { + json js_cur_ul_bwp_ded_pusch_time_alloc = js_cur_ul_bwp_ded_pusch_time_alloc_el.value()["PUSCH-TimeDomainResourceAllocation"]; + pusch_time_domain_res_alloc_s cur_ul_bwp_ded_pusch_time_alloc; + cur_ul_bwp_ded_pusch_time_alloc.k2_present = js_cur_ul_bwp_ded_pusch_time_alloc.contains("K2"); + if (cur_ul_bwp_ded_pusch_time_alloc.k2_present) { + cur_ul_bwp_ded_pusch_time_alloc.k2 = js_cur_ul_bwp_ded_pusch_time_alloc["k2"]; + } + + cur_ul_bwp_ded_pusch_time_alloc.map_type = (asn1::rrc_nr::pusch_time_domain_res_alloc_s::map_type_e_)js_cur_ul_bwp_ded_pusch_time_alloc["mappingType"]; + cur_ul_bwp_ded_pusch_time_alloc.start_symbol_and_len = js_cur_ul_bwp_ded_pusch_time_alloc["startSymbolAndLength"]; + + cur_ul_bwp.bwp_ded.pusch_cfg.set_setup().pusch_time_domain_alloc_list.set_setup().push_back(cur_ul_bwp_ded_pusch_time_alloc); + } + } + + // printf("[9/21] trigger 3.53\n"); + + cur_ul_bwp.bwp_ded.pusch_cfg.set_setup().mcs_table_present = js_cur_ul_bwp_ded_pusch.contains("mcs-Table"); + if (cur_ul_bwp.bwp_ded.pusch_cfg.setup().mcs_table_present) { + cur_ul_bwp.bwp_ded.pusch_cfg.set_setup().mcs_table = (asn1::rrc_nr::pusch_cfg_s::mcs_table_e_)js_cur_ul_bwp_ded_pusch["mcs-Table"]; + } + + cur_ul_bwp.bwp_ded.pusch_cfg.set_setup().transform_precoder_present = js_cur_ul_bwp_ded_pusch.contains("transformPrecoder"); + if (cur_ul_bwp.bwp_ded.pusch_cfg.setup().transform_precoder_present) { + cur_ul_bwp.bwp_ded.pusch_cfg.set_setup().transform_precoder = (asn1::rrc_nr::pusch_cfg_s::transform_precoder_e_)js_cur_ul_bwp_ded_pusch["transformPrecoder"]; + } + + cur_ul_bwp.bwp_ded.pusch_cfg.set_setup().codebook_subset_present = js_cur_ul_bwp_ded_pusch.contains("codebookSubset"); + if (cur_ul_bwp.bwp_ded.pusch_cfg.setup().codebook_subset_present) { + cur_ul_bwp.bwp_ded.pusch_cfg.set_setup().codebook_subset = (asn1::rrc_nr::pusch_cfg_s::codebook_subset_e_)js_cur_ul_bwp_ded_pusch["codebookSubset"]; + } + + cur_ul_bwp.bwp_ded.pusch_cfg.set_setup().max_rank_present = js_cur_ul_bwp_ded_pusch.contains("maxRank"); + if (cur_ul_bwp.bwp_ded.pusch_cfg.setup().max_rank_present) { + cur_ul_bwp.bwp_ded.pusch_cfg.set_setup().max_rank = js_cur_ul_bwp_ded_pusch["maxRank"]; + } + + cur_ul_bwp.bwp_ded.pusch_cfg.set_setup().uci_on_pusch_present = js_cur_ul_bwp_ded_pusch.contains("uci-OnPUSCH"); + if (cur_ul_bwp.bwp_ded.pusch_cfg.setup().uci_on_pusch_present) { + cur_ul_bwp.bwp_ded.pusch_cfg.set_setup().uci_on_pusch.set_setup().beta_offsets_present = true; + cur_ul_bwp.bwp_ded.pusch_cfg.set_setup().uci_on_pusch.set_setup().scaling = (asn1::rrc_nr::uci_on_pusch_s::scaling_e_)js_cur_ul_bwp_ded_pusch["uci-OnPUSCH"]["scaling"]; + } + } + // printf("[9/21] trigger 3.6\n"); + + /* bwp-Dedicated -- srs-Config */ + cur_ul_bwp.bwp_ded.srs_cfg_present = js_cur_ul_bwp["bwp-Dedicated"].contains("srs-Config"); + if (cur_ul_bwp.bwp_ded.srs_cfg_present) { + json js_cur_ul_bwp_ded_srs = js_cur_ul_bwp["bwp-Dedicated"]["srs-Config"]; + + cur_ul_bwp.bwp_ded.srs_cfg.set_setup().srs_res_set_to_add_mod_list; + + /* srs-ResourceSetToAddModList */ + for (auto& js_cur_ul_bwp_ded_srs_res_set_el : js_cur_ul_bwp_ded_srs["srs-ResourceSetToAddModList"].items()) { + json js_cur_ul_bwp_ded_srs_res_set = js_cur_ul_bwp_ded_srs_res_set_el.value()["SRS-ResourceSet"]; + srs_res_set_s cur_ul_bwp_ded_srs_res_set; + cur_ul_bwp_ded_srs_res_set.srs_res_set_id = js_cur_ul_bwp_ded_srs_res_set["srs-ResourceSetId"]; + if (js_cur_ul_bwp_ded_srs_res_set["resourceType"].contains("aperiodicSRS-ResourceTrigger")) { + cur_ul_bwp_ded_srs_res_set.res_type.set_aperiodic().aperiodic_srs_res_trigger = + js_cur_ul_bwp_ded_srs_res_set["resourceType"]["aperiodicSRS-ResourceTrigger"]; + } + + for (auto& js_cur_ul_bwp_ded_srs_res_set_res_id_el : js_cur_ul_bwp_ded_srs_res_set["srs-ResourceIdList"].items()) { + json js_cur_ul_bwp_ded_srs_res_set_res_id = js_cur_ul_bwp_ded_srs_res_set_res_id_el.value(); + cur_ul_bwp_ded_srs_res_set.srs_res_id_list.push_back(js_cur_ul_bwp_ded_srs_res_set_res_id); + } + + cur_ul_bwp_ded_srs_res_set.usage = (asn1::rrc_nr::srs_res_set_s::usage_e_)js_cur_ul_bwp_ded_srs_res_set["usage"]; + + cur_ul_bwp_ded_srs_res_set.p0_present = js_cur_ul_bwp_ded_srs_res_set.contains("p0"); + if (cur_ul_bwp_ded_srs_res_set.p0_present) { + cur_ul_bwp_ded_srs_res_set.p0 = js_cur_ul_bwp_ded_srs_res_set["p0"]; + } + + cur_ul_bwp.bwp_ded.srs_cfg.set_setup().srs_res_set_to_add_mod_list.push_back(cur_ul_bwp_ded_srs_res_set); + } + + /* srs-ResourceToAddModList */ + for (auto& js_cur_ul_bwp_ded_srs_res_el : js_cur_ul_bwp_ded_srs["srs-ResourceToAddModList"].items()) { + json js_cur_ul_bwp_ded_srs_res = js_cur_ul_bwp_ded_srs_res_el.value()["SRS-Resource"]; + srs_res_s cur_ul_bwp_ded_srs_res; + cur_ul_bwp_ded_srs_res.srs_res_id = js_cur_ul_bwp_ded_srs_res["srs-ResourceId"]; + // Just add the id for now + + cur_ul_bwp.bwp_ded.srs_cfg.set_setup().srs_res_to_add_mod_list.push_back(cur_ul_bwp_ded_srs_res); + } + + } /* bwp-Dedicated -- srs-Config End */ + // printf("[9/21] trigger 3.7\n"); + + /* Done processing this new ul bwp; store... */ + ul_bwp_to_add_mod_list.push_back(cur_ul_bwp); + } /* uplinkBWP-ToAddModList End */ + } + + /** + * + * NON-INITIAL DL BWP(S) CONFIG EXTRACTION + * + */ + + // TO-DO: a lot of exists check needed before accessing fields + if (js_in["spCellConfigDedicated"]["downlinkBWP-ToAddModList"].is_array()) { + // printf("[9/16] trigger 1.1\n"); + auto& dl_bwp_to_add_mod_list = sp_cell_cfg.sp_cell_cfg_ded.dl_bwp_to_add_mod_list; + json js_dl_bwp_to_add_mod_list = js_in["spCellConfigDedicated"]["downlinkBWP-ToAddModList"]; + for (auto& js_cur_dl_bwp_el : js_dl_bwp_to_add_mod_list.items()) { + // printf("[9/16] trigger 1.2\n"); + json js_cur_dl_bwp = js_cur_dl_bwp_el.value(); + bwp_dl_s cur_dl_bwp; + cur_dl_bwp.bwp_id = js_cur_dl_bwp["bwp-Id"]; + + /* bwp-Common */ + cur_dl_bwp.bwp_common_present = js_cur_dl_bwp.contains("bwp-Common"); + + /* bwp-Common -- genericParameters */ + json js_cur_dl_bwp_common_generic = js_cur_dl_bwp["bwp-Common"]["genericParameters"]; + cur_dl_bwp.bwp_common.generic_params.location_and_bw = js_cur_dl_bwp_common_generic["locationAndBandwidth"]; + assert(js_cur_dl_bwp_common_generic["subcarrierSpacing"].is_number()); + cur_dl_bwp.bwp_common.generic_params.subcarrier_spacing = (asn1::rrc_nr::subcarrier_spacing_e)js_cur_dl_bwp_common_generic["subcarrierSpacing"]; + // printf("[9/16] trigger 1.3\n"); + /* bwp-Common -- pdsch-ConfigCommon */ + json js_cur_dl_bwp_common_pdsch_time_alloc_list = js_cur_dl_bwp["bwp-Common"]["pdsch-ConfigCommon"]["pdsch-TimeDomainAllocationList"]; + + assert(js_cur_dl_bwp_common_pdsch_time_alloc_list.is_array()); + + for (auto& js_cur_dl_bwp_common_pdsch_time_alloc_el : js_cur_dl_bwp_common_pdsch_time_alloc_list.items()) { + // printf("[9/16] trigger 1.4\n"); + json js_cur_dl_bwp_common_pdsch_time_alloc = js_cur_dl_bwp_common_pdsch_time_alloc_el.value()["PDSCH-TimeDomainResourceAllocation"]; + // printf("[9/16] trigger 1.41\n"); + pdsch_time_domain_res_alloc_s cur_pdsch_time_alloc; + + cur_pdsch_time_alloc.k0_present = js_cur_dl_bwp_common_pdsch_time_alloc.contains("k0"); + if (cur_pdsch_time_alloc.k0_present) { + cur_pdsch_time_alloc.k0 = js_cur_dl_bwp_common_pdsch_time_alloc["k0"]; + } + cur_pdsch_time_alloc.map_type = (asn1::rrc_nr::pdsch_time_domain_res_alloc_s::map_type_e_)js_cur_dl_bwp_common_pdsch_time_alloc["mappingType"]; + cur_pdsch_time_alloc.start_symbol_and_len = js_cur_dl_bwp_common_pdsch_time_alloc["startSymbolAndLength"]; + + cur_dl_bwp.bwp_common.pdsch_cfg_common.set_setup().pdsch_time_domain_alloc_list.push_back(cur_pdsch_time_alloc); + } + + // printf("[9/16] trigger 1.5\n"); + + /* bwp-Dedicated */ + cur_dl_bwp.bwp_ded_present = js_cur_dl_bwp.contains("bwp-Dedicated"); + + /* bwp-Dedicated -- pdcch-Config */ + json js_cur_dl_bwp_dedicated_pdcch = js_cur_dl_bwp["bwp-Dedicated"]["pdcch-Config"]; + + /* bwp-Dedicated -- pdcch-Config -- controlResourceSetToAddModList */ + json js_cur_dl_bwp_dedicated_pdcch_coreset_list = js_cur_dl_bwp_dedicated_pdcch["controlResourceSetToAddModList"]; + // printf("[9/16] trigger 1.6\n"); + for (auto& js_cur_dl_bwp_dedicated_pdcch_coreset_el : js_cur_dl_bwp_dedicated_pdcch_coreset_list.items()) { + json js_cur_dl_bwp_dedicated_pdcch_coreset = js_cur_dl_bwp_dedicated_pdcch_coreset_el.value(); + ctrl_res_set_s cur_dl_bwp_dedicated_pdcch_coreset; + + cur_dl_bwp_dedicated_pdcch_coreset.ctrl_res_set_id = js_cur_dl_bwp_dedicated_pdcch_coreset["controlResourceSetId"]; + + // str format: "FF FF 80 00 00 00" + std::string hex_space_str = js_cur_dl_bwp_dedicated_pdcch_coreset["frequencyDomainResources"]; + hex_space_str.erase(remove_if(hex_space_str.begin(), hex_space_str.end(), isspace), hex_space_str.end()); + std::cout << "hex_space_str: " << hex_space_str << std::endl; + std::stringstream ss_helper; + ss_helper << std::hex << hex_space_str; + unsigned long val; + ss_helper >> val; + std::bitset<45> b(val); + cur_dl_bwp_dedicated_pdcch_coreset.freq_domain_res.from_string(b.to_string()); + std::cout << "b.to_string(): " << b.to_string() << "; and size: " << b.to_string().size() << std::endl; + + cur_dl_bwp_dedicated_pdcch_coreset.dur = js_cur_dl_bwp_dedicated_pdcch_coreset["duration"]; + + // Assume cce_reg_map_type is null (default) now; TO-DO: implement this + + cur_dl_bwp_dedicated_pdcch_coreset.precoder_granularity = (asn1::rrc_nr::ctrl_res_set_s::precoder_granularity_e_)js_cur_dl_bwp_dedicated_pdcch_coreset["precoderGranularity"]; + + cur_dl_bwp_dedicated_pdcch_coreset.pdcch_dmrs_scrambling_id_present = js_cur_dl_bwp_dedicated_pdcch_coreset.contains("pdcch-DMRS-ScramblingID"); + if (cur_dl_bwp_dedicated_pdcch_coreset.pdcch_dmrs_scrambling_id_present) { + cur_dl_bwp_dedicated_pdcch_coreset.pdcch_dmrs_scrambling_id = js_cur_dl_bwp_dedicated_pdcch_coreset["pdcch-DMRS-ScramblingID"]; + } + + // Ignore TCI-related setup now + + cur_dl_bwp.bwp_ded.pdcch_cfg.set_setup().ctrl_res_set_to_add_mod_list.push_back(cur_dl_bwp_dedicated_pdcch_coreset); + } + // printf("[9/16] trigger 1.7\n"); + /* bwp-Dedicated -- pdcch-Config -- searchSpacesToAddModList */ + json js_cur_dl_bwp_dedicated_pdcch_searchspace_list = js_cur_dl_bwp_dedicated_pdcch["searchSpacesToAddModList"]; + + for (auto& js_cur_dl_bwp_dedicated_pdcch_searchspace_el : js_cur_dl_bwp_dedicated_pdcch_searchspace_list.items()) { + json js_cur_dl_bwp_dedicated_pdcch_searchspace = js_cur_dl_bwp_dedicated_pdcch_searchspace_el.value(); + search_space_s cur_dl_bwp_dedicated_pdcch_searchspace; + + cur_dl_bwp_dedicated_pdcch_searchspace.search_space_id = js_cur_dl_bwp_dedicated_pdcch_searchspace["searchSpaceId"]; + cur_dl_bwp_dedicated_pdcch_searchspace.ctrl_res_set_id_present = js_cur_dl_bwp_dedicated_pdcch_searchspace.contains("controlResourceSetId"); + if (cur_dl_bwp_dedicated_pdcch_searchspace.ctrl_res_set_id_present) { + cur_dl_bwp_dedicated_pdcch_searchspace.ctrl_res_set_id = js_cur_dl_bwp_dedicated_pdcch_searchspace["controlResourceSetId"]; + } + + // Since we monitor every slot, looks like duration, monitoringSymbolsWithinSlot don't matter, so skip + + /* nrofCandidates */ + cur_dl_bwp_dedicated_pdcch_searchspace.nrof_candidates_present = js_cur_dl_bwp_dedicated_pdcch_searchspace.contains("nrofCandidates"); + if (js_cur_dl_bwp_dedicated_pdcch_searchspace.contains("nrofCandidates")) { + cur_dl_bwp_dedicated_pdcch_searchspace.nrof_candidates.aggregation_level1 = + (asn1::rrc_nr::search_space_s::nrof_candidates_s_::aggregation_level1_e_)js_cur_dl_bwp_dedicated_pdcch_searchspace["nrofCandidates"]["aggregationLevel1"]; + + cur_dl_bwp_dedicated_pdcch_searchspace.nrof_candidates.aggregation_level2 = + (asn1::rrc_nr::search_space_s::nrof_candidates_s_::aggregation_level2_e_)js_cur_dl_bwp_dedicated_pdcch_searchspace["nrofCandidates"]["aggregationLevel2"]; + + cur_dl_bwp_dedicated_pdcch_searchspace.nrof_candidates.aggregation_level4 = + (asn1::rrc_nr::search_space_s::nrof_candidates_s_::aggregation_level4_e_)js_cur_dl_bwp_dedicated_pdcch_searchspace["nrofCandidates"]["aggregationLevel4"]; + + cur_dl_bwp_dedicated_pdcch_searchspace.nrof_candidates.aggregation_level8 = + (asn1::rrc_nr::search_space_s::nrof_candidates_s_::aggregation_level8_e_)js_cur_dl_bwp_dedicated_pdcch_searchspace["nrofCandidates"]["aggregationLevel8"]; + + cur_dl_bwp_dedicated_pdcch_searchspace.nrof_candidates.aggregation_level16 = + (asn1::rrc_nr::search_space_s::nrof_candidates_s_::aggregation_level16_e_)js_cur_dl_bwp_dedicated_pdcch_searchspace["nrofCandidates"]["aggregationLevel16"]; + } + + + cur_dl_bwp_dedicated_pdcch_searchspace.search_space_type_present = js_cur_dl_bwp_dedicated_pdcch_searchspace.contains("searchSpaceType"); + if (cur_dl_bwp_dedicated_pdcch_searchspace.search_space_type_present) { + // Assume only ue-specific is possible + cur_dl_bwp_dedicated_pdcch_searchspace.search_space_type.set_ue_specific(); + } + + + cur_dl_bwp.bwp_ded.pdcch_cfg.set_setup().search_spaces_to_add_mod_list.push_back(cur_dl_bwp_dedicated_pdcch_searchspace); + } + + // printf("[9/16] trigger 1.8\n"); + + /* bwp-Dedicated -- pdsch-Config */ + cur_dl_bwp.bwp_ded.pdsch_cfg_present = js_cur_dl_bwp["bwp-Dedicated"].contains("pdsch-Config"); + json js_cur_dl_bwp_dedicated_pdsch = js_cur_dl_bwp["bwp-Dedicated"]["pdsch-Config"]; + + cur_dl_bwp.bwp_ded.pdsch_cfg.set_setup().data_scrambling_id_pdsch_present = js_cur_dl_bwp_dedicated_pdsch.contains("dataScramblingIdentityPDSCH"); + + if (cur_dl_bwp.bwp_ded.pdsch_cfg.setup().data_scrambling_id_pdsch_present) { + cur_dl_bwp.bwp_ded.pdsch_cfg.set_setup().data_scrambling_id_pdsch = js_cur_dl_bwp_dedicated_pdsch["dataScramblingIdentityPDSCH"]; + } + + cur_dl_bwp.bwp_ded.pdsch_cfg.set_setup().dmrs_dl_for_pdsch_map_type_a_present = js_cur_dl_bwp_dedicated_pdsch.contains("dmrs-DownlinkForPDSCH-MappingTypeA"); + if (cur_dl_bwp.bwp_ded.pdsch_cfg.setup().dmrs_dl_for_pdsch_map_type_a_present) { + cur_dl_bwp.bwp_ded.pdsch_cfg.set_setup().dmrs_dl_for_pdsch_map_type_a.set_setup().dmrs_add_position_present = + js_cur_dl_bwp_dedicated_pdsch["dmrs-DownlinkForPDSCH-MappingTypeA"].contains("dmrs-AdditionalPosition"); + + if (cur_dl_bwp.bwp_ded.pdsch_cfg.setup().dmrs_dl_for_pdsch_map_type_a.setup().dmrs_add_position_present) { + cur_dl_bwp.bwp_ded.pdsch_cfg.set_setup().dmrs_dl_for_pdsch_map_type_a.set_setup().dmrs_add_position = + (asn1::rrc_nr::dmrs_dl_cfg_s::dmrs_add_position_e_)js_cur_dl_bwp_dedicated_pdsch["dmrs-DownlinkForPDSCH-MappingTypeA"]["dmrs-AdditionalPosition"]; + } + } + + // printf("[9/16] trigger 1.9\n"); + + cur_dl_bwp.bwp_ded.pdsch_cfg.set_setup().res_alloc = (asn1::rrc_nr::pdsch_cfg_s::res_alloc_e_)js_cur_dl_bwp_dedicated_pdsch["resourceAllocation"]; + + /* pdsch-TimeDomainAllocationList */ + cur_dl_bwp.bwp_ded.pdsch_cfg.set_setup().pdsch_time_domain_alloc_list_present = js_cur_dl_bwp_dedicated_pdsch.contains("pdsch-TimeDomainAllocationList"); + json js_cur_dl_bwp_dedicated_pdsch_time_alloc_list = js_cur_dl_bwp_dedicated_pdsch["pdsch-TimeDomainAllocationList"]; + for (auto& js_cur_dl_bwp_dedicated_pdsch_time_alloc_el : js_cur_dl_bwp_dedicated_pdsch_time_alloc_list.items()) { + json js_cur_dl_bwp_dedicated_pdsch_time_alloc = js_cur_dl_bwp_dedicated_pdsch_time_alloc_el.value()["PDSCH-TimeDomainResourceAllocation"]; + pdsch_time_domain_res_alloc_s cur_pdsch_time_alloc; + + cur_pdsch_time_alloc.k0_present = js_cur_dl_bwp_dedicated_pdsch_time_alloc.contains("k0"); + if (cur_pdsch_time_alloc.k0_present) { + cur_pdsch_time_alloc.k0 = js_cur_dl_bwp_dedicated_pdsch_time_alloc["k0"]; + } + + cur_pdsch_time_alloc.map_type = (asn1::rrc_nr::pdsch_time_domain_res_alloc_s::map_type_e_)js_cur_dl_bwp_dedicated_pdsch_time_alloc["mappingType"]; + cur_pdsch_time_alloc.start_symbol_and_len = js_cur_dl_bwp_dedicated_pdsch_time_alloc["startSymbolAndLength"]; + + cur_dl_bwp.bwp_ded.pdsch_cfg.set_setup().pdsch_time_domain_alloc_list.set_setup().push_back(cur_pdsch_time_alloc); + } + + cur_dl_bwp.bwp_ded.pdsch_cfg.set_setup().rbg_size = (asn1::rrc_nr::pdsch_cfg_s::rbg_size_e_)js_cur_dl_bwp_dedicated_pdsch["rbg-Size"]; + cur_dl_bwp.bwp_ded.pdsch_cfg.set_setup().mcs_table = (asn1::rrc_nr::pdsch_cfg_s::mcs_table_e_)js_cur_dl_bwp_dedicated_pdsch["mcs-Table"]; + cur_dl_bwp.bwp_ded.pdsch_cfg.set_setup().max_nrof_code_words_sched_by_dci = + (asn1::rrc_nr::pdsch_cfg_s::max_nrof_code_words_sched_by_dci_e_)js_cur_dl_bwp_dedicated_pdsch["maxNrofCodeWordsScheduledByDCI"]; + + // Assume only static type now; seems no option for bundle size + cur_dl_bwp.bwp_ded.pdsch_cfg.set_setup().prb_bundling_type.set_static_bundling(); + + + /* Done processing this new dl bwp; store... */ + dl_bwp_to_add_mod_list.push_back(cur_dl_bwp); + + // printf("[9/16] trigger 1.10\n"); + } + } + + return SRSASN_SUCCESS; +} + void cell_group_cfg_s::to_json(json_writer& j) const { j.start_obj(); diff --git a/lib/src/phy/phch/pdcch_nr.c b/lib/src/phy/phch/pdcch_nr.c index e5c6a87e..0840880e 100644 --- a/lib/src/phy/phch/pdcch_nr.c +++ b/lib/src/phy/phch/pdcch_nr.c @@ -1128,6 +1128,7 @@ int srsran_pdcch_nr_decode_with_rnti_nrscope_dciloop(srsran_pdcch_nr_t* q, uint32_t checksum1 = srsran_crc_checksum(&q->crc24c, q->c, q->K); uint32_t checksum2 = srsran_bit_pack(&ptr, 24); res->crc = checksum1 == checksum2; + // printf("[hidden bwp crc check] res->crc: %u; dci size: %u\n", res->crc, dci_msg->nof_bits); // printf("CRC={%06x, %06x}; msg=", checksum1, checksum2); // srsran_vec_fprint_hex(stdout, c, dci_msg->nof_bits); @@ -1149,6 +1150,11 @@ int srsran_pdcch_nr_decode_with_rnti_nrscope_dciloop(srsran_pdcch_nr_t* q, // Copy DCI message srsran_vec_u8_copy(dci_msg->payload, c, dci_msg->nof_bits); + // printf("[hidden bwp dci bits]: "); + // srsran_vec_fprint_hex(stdout, c, dci_msg->nof_bits); + // if (res->crc) { + // printf("[hidden bwp dci dir and bwp val] dir: %u; bwp: %u\n", c[0], c[1]); + // } if (q->meas_time_en) { gettimeofday(&t[2], NULL); diff --git a/lib/src/phy/ue/ue_dl_nr.c b/lib/src/phy/ue/ue_dl_nr.c index 6d2e4296..5beb3064 100644 --- a/lib/src/phy/ue/ue_dl_nr.c +++ b/lib/src/phy/ue/ue_dl_nr.c @@ -603,6 +603,33 @@ static int ue_dl_nr_find_dci_ncce_nrscope_dciloop(srsran_ue_dl_nr_t* q, return SRSRAN_ERROR; } + /** + * SCAN a range of dci size for getting the right dci size for cross validation + * something similar patented: https://patents.google.com/patent/CN113541866A/zh + * + * Will see if this can be used later (temporarily put as comment here) + */ + // uint32_t original_nof_bits = dci_msg->nof_bits; + + // // something similar patented: https://patents.google.com/patent/CN113541866A/zh + // uint32_t dci_size_guess_lb = 40; + // uint32_t dci_size_guess_ub = 50; + // printf("[hidden bwp] try dci size guess\n"); + // for (uint32_t i = dci_size_guess_lb; i <= dci_size_guess_ub; ++i) { + // dci_msg->nof_bits = i; + // printf("[hidden bwp] try dci size %u\n", i); + // // Decode PDCCH + // if (srsran_pdcch_nr_decode_with_rnti_nrscope_dciloop(&q->pdcch, q->sf_symbols[0], + // q->pdcch_ce, dci_msg, pdcch_res) < SRSRAN_SUCCESS) { + // // if (srsran_pdcch_nr_decode(&q->pdcch, q->sf_symbols[0], q->pdcch_ce, dci_msg, pdcch_res) < SRSRAN_SUCCESS) { + // ERROR("Error decoding PDCCH"); + // return SRSRAN_ERROR; + // } + // } + + // printf("[hidden bwp] now the actually original_nof_bits: %u\n", original_nof_bits); + // dci_msg->nof_bits = original_nof_bits; + // Decode PDCCH if (srsran_pdcch_nr_decode_with_rnti_nrscope_dciloop(&q->pdcch, q->sf_symbols[0], q->pdcch_ce, dci_msg, pdcch_res) < SRSRAN_SUCCESS) { @@ -1024,6 +1051,14 @@ static int ue_dl_nr_find_dci_ss_nrscope_dciloop(srsran_ue_dl_nr_t* q, L < SRSRAN_SEARCH_SPACE_NOF_AGGREGATION_LEVELS_NR && q->dl_dci_msg_count < SRSRAN_MAX_DCI_MSG_NR; L++) { + + // debug skip (MOSOLAB fault under 40MHz multi bwp where 36 cces have a level-8(3) candidate) + // Keep an eye, and should not hurt for short term + // TO-DO: remove this once we no longer need the MOSOLAB 40MHz scenario + if (L == 3) { + continue; + } + // Calculate possible PDCCH DCI candidates uint32_t candidates[SRSRAN_SEARCH_SPACE_MAX_NOF_CANDIDATES_NR] = {}; int nof_candidates = srsran_pdcch_nr_locations_coreset( diff --git a/nrscope/hdr/nrscope_def.h b/nrscope/hdr/nrscope_def.h index 2e84c9af..e82fcefd 100644 --- a/nrscope/hdr/nrscope_def.h +++ b/nrscope/hdr/nrscope_def.h @@ -23,6 +23,7 @@ #include #include #include +#include #include "srsran/common/band_helper.h" #include "srsran/common/band_helper.h" @@ -52,6 +53,8 @@ #define NR_FAILURE -1 #define NR_SUCCESS 0 +using json = nlohmann::json; + struct cell_searcher_args_t { // Generic parameters double srate_hz = 11.52e6; @@ -204,6 +207,11 @@ typedef struct WorkState_ WorkState; uint32_t nof_known_rntis; std::vector known_rntis; + + // Ground-truth config for hidden bwp + // TO-DO: this will be an array alike when interface with the real db + // so we will search the right hidden bwp based on PCI or alike. + json js_hidden_bwp; }; typedef struct SlotResult_ SlotResult; diff --git a/nrscope/hidden_bwp_db/369.txt b/nrscope/hidden_bwp_db/369.txt new file mode 100644 index 00000000..ae9beb66 --- /dev/null +++ b/nrscope/hidden_bwp_db/369.txt @@ -0,0 +1,558 @@ +{ + "spCellConfigDedicated": { + "downlinkBWP-ToAddModList": [ + { + "bwp-Id": 1, + "bwp-Common": { + "genericParameters": { + "locationAndBandwidth": 28875, + "subcarrierSpacing": 1 + }, + "pdsch-ConfigCommon": { + "pdsch-TimeDomainAllocationList": [ + { + "PDSCH-TimeDomainResourceAllocation": { + "k0": 0, + "mappingType": 0, + "startSymbolAndLength": 40 + } + }, + { + "PDSCH-TimeDomainResourceAllocation": { + "k0": 0, + "mappingType": 0, + "startSymbolAndLength": 54 + } + }, + { + "PDSCH-TimeDomainResourceAllocation": { + "k0": 0, + "mappingType": 0, + "startSymbolAndLength": 57 + } + } + ] + } + }, + "bwp-Dedicated": { + "pdcch-Config": { + "controlResourceSetToAddModList": [ + { + "controlResourceSetId": 2, + "frequencyDomainResources": "FF FF 80 00 00 00", + "duration": 1, + "cce-REG-MappingType": "NULL", + "precoderGranularity": 1, + "tci-StatesPDCCH-ToAddList": [0], + "pdcch-DMRS-ScramblingID": 369 + } + ], + "searchSpacesToAddModList": [ + { + "searchSpaceId": 3, + "controlResourceSetId": 2, + "monitoringSlotPeriodicityAndOffset": "sl1 NULL", + "monitoringSymbolsWithinSlot": "80 00", + "nrofCandidates": { + "aggregationLevel1": 4, + "aggregationLevel2": 4, + "aggregationLevel4": 2, + "aggregationLevel8": 1, + "aggregationLevel16": 0 + }, + "searchSpaceType": { + "dci-Formats": 1 + } + } + ] + }, + "pdsch-Config": { + "dataScramblingIdentityPDSCH": 369, + "dmrs-DownlinkForPDSCH-MappingTypeA": { + "dmrs-AdditionalPosition": 1 + }, + "resourceAllocation": 1, + "pdsch-TimeDomainAllocationList": [ + { + "PDSCH-TimeDomainResourceAllocation": { + "k0": 0, + "mappingType": 0, + "startSymbolAndLength": 40 + } + }, + { + "PDSCH-TimeDomainResourceAllocation": { + "k0": 0, + "mappingType": 0, + "startSymbolAndLength": 54 + } + }, + { + "PDSCH-TimeDomainResourceAllocation": { + "k0": 0, + "mappingType": 0, + "startSymbolAndLength": 57 + } + } + ], + "rbg-Size": 0, + "mcs-Table": 0, + "maxNrofCodeWordsScheduledByDCI": 0, + "prb-BundlingType": { + "bundleSize": 1 + } + } + } + } + ], + + "uplinkConfig": { + "uplinkBWP-ToAddModList": [ + { + "bwp-Id": 1, + "bwp-Common": { + "genericParameters": { + "locationAndBandwidth": 28875, + "subcarrierSpacing": 1 + }, + "rach-ConfigCommon": { + "rach-ConfigGeneric": { + "prach-ConfigurationIndex": 154, + "msg1-FDM": 0, + "msg1-FrequencyStart": 0, + "zeroCorrelationZoneConfig": 12, + "preambleReceivedTargetPower": -104, + "preambleTransMax": 6, + "powerRampingStep": 1, + "ra-ResponseWindow": 7 + }, + "ssb-perRACH-OccasionAndCB-PreamblesPerSSB": 0, + "groupBconfigured": { + "ra-Msg3SizeGroupA": 0, + "messagePowerOffsetGroupB": 1, + "numberOfRA-PreamblesGroupA": 1 + }, + "ra-ContentionResolutionTimer": 4, + "rsrp-ThresholdSSB": 0, + "prach-RootSequenceIndex": 0, + "msg1-SubcarrierSpacing": 1, + "restrictedSetConfig": 0 + }, + "pusch-ConfigCommon": { + "pusch-TimeDomainAllocationList": [ + {"PUSCH-TimeDomainResourceAllocation": { "k2": 5, "mappingType": 0, "startSymbolAndLength": 55 }}, + {"PUSCH-TimeDomainResourceAllocation": { "k2": 6, "mappingType": 0, "startSymbolAndLength": 55 }}, + {"PUSCH-TimeDomainResourceAllocation": { "k2": 7, "mappingType": 0, "startSymbolAndLength": 55 }}, + {"PUSCH-TimeDomainResourceAllocation": { "k2": 8, "mappingType": 0, "startSymbolAndLength": 55 }}, + {"PUSCH-TimeDomainResourceAllocation": { "k2": 9, "mappingType": 0, "startSymbolAndLength": 55 }}, + {"PUSCH-TimeDomainResourceAllocation": { "k2": 10, "mappingType": 0, "startSymbolAndLength": 55 }}, + {"PUSCH-TimeDomainResourceAllocation": { "k2": 11, "mappingType": 0, "startSymbolAndLength": 55 }}, + {"PUSCH-TimeDomainResourceAllocation": { "k2": 12, "mappingType": 0, "startSymbolAndLength": 55 }}, + {"PUSCH-TimeDomainResourceAllocation": { "k2": 13, "mappingType": 0, "startSymbolAndLength": 55 }}, + {"PUSCH-TimeDomainResourceAllocation": { "k2": 14, "mappingType": 0, "startSymbolAndLength": 55 }} + ], + "msg3-DeltaPreamble": 0, + "p0-NominalWithGrant": -76 + }, + "pucch-ConfigCommon": { + "pucch-ResourceCommon": 3, + "pucch-GroupHopping": 0, + "p0-nominal": -80 + } + }, + "bwp-Dedicated": { + "pucch-Config": { + "resourceSetToAddModList": [ + { + "PUCCH-ResourceSetId": 0, + "resourceList": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] + }, + { + "PUCCH-ResourceSetId": 1, + "resourceList": [15, 16, 17, 18, 19, 20, 21, 22] + } + ], + "resourceToAddModList": [ + { + "pucch-ResourceId": 0, + "startingPRB": 16, + "format": { + "initialCyclicShift": 0, + "nrofSymbols": 1, + "startingSymbolIndex": 12 + } + }, + { + "pucch-ResourceId": 1, + "startingPRB": 16, + "format": { + "initialCyclicShift": 1, + "nrofSymbols": 1, + "startingSymbolIndex": 12 + } + }, + { + "pucch-ResourceId": 2, + "startingPRB": 16, + "format": { + "initialCyclicShift": 2, + "nrofSymbols": 1, + "startingSymbolIndex": 12 + } + }, + { + "pucch-ResourceId": 3, + "startingPRB": 16, + "format": { + "initialCyclicShift": 3, + "nrofSymbols": 1, + "startingSymbolIndex": 12 + } + }, + { + "pucch-ResourceId": 4, + "startingPRB": 16, + "format": { + "initialCyclicShift": 4, + "nrofSymbols": 1, + "startingSymbolIndex": 12 + } + }, + { + "pucch-ResourceId": 5, + "startingPRB": 16, + "format": { + "initialCyclicShift": 5, + "nrofSymbols": 1, + "startingSymbolIndex": 12 + } + }, + { + "pucch-ResourceId": 6, + "startingPRB": 17, + "format": { + "initialCyclicShift": 0, + "nrofSymbols": 1, + "startingSymbolIndex": 12 + } + }, + { + "pucch-ResourceId": 7, + "startingPRB": 17, + "format": { + "initialCyclicShift": 1, + "nrofSymbols": 1, + "startingSymbolIndex": 12 + } + }, + { + "pucch-ResourceId": 8, + "startingPRB": 17, + "format": { + "initialCyclicShift": 2, + "nrofSymbols": 1, + "startingSymbolIndex": 12 + } + }, + { + "pucch-ResourceId": 9, + "startingPRB": 17, + "format": { + "initialCyclicShift": 3, + "nrofSymbols": 1, + "startingSymbolIndex": 12 + } + }, + { + "pucch-ResourceId": 10, + "startingPRB": 17, + "format": { + "initialCyclicShift": 4, + "nrofSymbols": 1, + "startingSymbolIndex": 12 + } + }, + { + "pucch-ResourceId": 11, + "startingPRB": 17, + "format": { + "initialCyclicShift": 5, + "nrofSymbols": 1, + "startingSymbolIndex": 12 + } + }, + { + "pucch-ResourceId": 12, + "startingPRB": 18, + "format": { + "initialCyclicShift": 0, + "nrofSymbols": 1, + "startingSymbolIndex": 12 + } + }, + { + "pucch-ResourceId": 13, + "startingPRB": 18, + "format": { + "initialCyclicShift": 1, + "nrofSymbols": 1, + "startingSymbolIndex": 12 + } + }, + { + "pucch-ResourceId": 14, + "startingPRB": 12, + "format": { + "initialCyclicShift": 0, + "nrofSymbols": 1, + "startingSymbolIndex": 12 + } + }, + { + "pucch-ResourceId": 15, + "startingPRB": 19, + "format": { + "nrofPRBs": 1, + "nrofSymbols": 1, + "startingSymbolIndex": 12 + } + }, + { + "pucch-ResourceId": 16, + "startingPRB": 20, + "format": { + "nrofPRBs": 1, + "nrofSymbols": 1, + "startingSymbolIndex": 12 + } + }, + { + "pucch-ResourceId": 17, + "startingPRB": 21, + "format": { + "nrofPRBs": 1, + "nrofSymbols": 1, + "startingSymbolIndex": 12 + } + }, + { + "pucch-ResourceId": 18, + "startingPRB": 22, + "format": { + "nrofPRBs": 1, + "nrofSymbols": 1, + "startingSymbolIndex": 12 + } + }, + { + "pucch-ResourceId": 19, + "startingPRB": 23, + "format": { + "nrofPRBs": 1, + "nrofSymbols": 1, + "startingSymbolIndex": 12 + } + }, + { + "pucch-ResourceId": 20, + "startingPRB": 24, + "format": { + "nrofPRBs": 1, + "nrofSymbols": 1, + "startingSymbolIndex": 12 + } + }, + { + "pucch-ResourceId": 21, + "startingPRB": 25, + "format": { + "nrofPRBs": 1, + "nrofSymbols": 1, + "startingSymbolIndex": 12 + } + }, + { + "pucch-ResourceId": 22, + "startingPRB": 26, + "format": { + "nrofPRBs": 1, + "nrofSymbols": 1, + "startingSymbolIndex": 12 + } + } + ], + "format2": { + "maxCodeRate": 6, + "simultaneousHARQ-ACK-CSI": 0 + }, + "schedulingRequestResourceToAddModList": [ + { "schedulingRequestResourceId": 1, "schedulingRequestID": 0, "periodicityAndOffset": 5, "resource": 14 } + ], + "multi-CSI-PUCCH-ResourceList": [22], + "dl-DataToUL-ACK": [4, 5, 6, 7, 8, 9, 10, 11], + "pucch-PowerControl": { + "deltaF-PUCCH-f0": 0, + "deltaF-PUCCH-f1": 0, + "deltaF-PUCCH-f2": 0, + "deltaF-PUCCH-f3": 0, + "deltaF-PUCCH-f4": 0, + "p0-Set": [ + { + "p0-PUCCH-Id": 1, + "p0-PUCCH-Value": 0 + } + ] + } + }, + "pusch-Config": { + "dataScramblingIdentityPUSCH": 369, + "txConfig": { + "codebook": 0 + }, + "dmrs-UplinkForPUSCH-MappingTypeA": { + "dmrs-AdditionalPosition": 1, + "transformPrecodingDisabled": { + "scramblingID0": 369 + } + }, + "pusch-PowerControl": { + "tpc-Accumulation": 0, + "msg3-Alpha": 7, + "p0-AlphaSets": [ + { + "p0-PUSCH-AlphaSetId": 0, + "p0": 0, + "alpha": 7 + } + ], + "deltaMCS": 0 + }, + "resourceAllocation": 1, + "pusch-TimeDomainAllocationList": [ + { + "PUSCH-TimeDomainResourceAllocation": { + "k2": 4, + "mappingType": 0, + "startSymbolAndLength": 55 + } + }, + { + "PUSCH-TimeDomainResourceAllocation": { + "k2": 5, + "mappingType": 0, + "startSymbolAndLength": 55 + } + }, + { + "PUSCH-TimeDomainResourceAllocation": { + "k2": 6, + "mappingType": 0, + "startSymbolAndLength": 55 + } + }, + { + "PUSCH-TimeDomainResourceAllocation": { + "k2": 7, + "mappingType": 0, + "startSymbolAndLength": 55 + } + }, + { + "PUSCH-TimeDomainResourceAllocation": { + "k2": 8, + "mappingType": 0, + "startSymbolAndLength": 55 + } + }, + { + "PUSCH-TimeDomainResourceAllocation": { + "k2": 9, + "mappingType": 0, + "startSymbolAndLength": 55 + } + }, + { + "PUSCH-TimeDomainResourceAllocation": { + "k2": 10, + "mappingType": 0, + "startSymbolAndLength": 55 + } + }, + { + "PUSCH-TimeDomainResourceAllocation": { + "k2": 11, + "mappingType": 0, + "startSymbolAndLength": 55 + } + }, + { + "PUSCH-TimeDomainResourceAllocation": { + "k2": 12, + "mappingType": 0, + "startSymbolAndLength": 55 + } + } + ], + "mcs-Table": 0, + "transformPrecoder": 1, + "codebookSubset": 2, + "maxRank": 1, + "uci-OnPUSCH": { + "betaOffsets": { + "betaOffsetACK-Index1": 0, + "betaOffsetACK-Index2": 0, + "betaOffsetACK-Index3": 0 + }, + "scaling": 0 + } + }, + "srs-Config": { + "srs-ResourceSetToAddModList": [ + { + "SRS-ResourceSet": { + "srs-ResourceSetId": 0, + "srs-ResourceIdList": [0], + "resourceType": { + "aperiodicSRS-ResourceTrigger": 1 + }, + "usage": 1, + "p0": 0 + } + } + ], + "srs-ResourceToAddModList": [ + { + "SRS-Resource": { + "srs-ResourceId": 0, + "nrofSRS-Ports": 0, + "transmissionComb": { + "combOffset-n2": 0, + "cyclicShift-n2": 0 + }, + "resourceMapping": { + "startPosition": 0, + "nrofSymbols": 0, + "repetitionFactor": 0 + }, + "freqDomainPosition": 0, + "freqDomainShift": 0, + "freqHopping": { + "c-SRS": 25, + "b-SRS": 0, + "b-hop": 0 + }, + "groupOrSequenceHopping": 0, + "resourceType": { + "sequenceId": 0 + } + } + } + ], + "tpc-Accumulation": 0 + } + } + } + ] + } + } +} \ No newline at end of file diff --git a/nrscope/src/libs/dci_decoder.cc b/nrscope/src/libs/dci_decoder.cc index a5a76690..2e9bef88 100644 --- a/nrscope/src/libs/dci_decoder.cc +++ b/nrscope/src/libs/dci_decoder.cc @@ -1,4 +1,7 @@ #include "nrscope/hdr/dci_decoder.h" +#include + +using json = nlohmann::json; DCIDecoder::DCIDecoder(uint32_t max_nof_rntis){ @@ -74,6 +77,8 @@ int DCIDecoder::DCIDecoderandReceptionInit(WorkState* state, asn1::rrc_nr::bwp_dl_ded_s * bwp_dl_ded_s_ptr = NULL; asn1::rrc_nr::bwp_ul_ded_s * bwp_ul_ded_s_ptr = NULL; + bool is_hidden_bwp = false; + // assume ul bwp n and dl bwp n should be activated and used at the same time (lso for sure for TDD) if (bwp_id == 0) { bwp_dl_ded_s_ptr = @@ -123,11 +128,19 @@ int DCIDecoder::DCIDecoderandReceptionInit(WorkState* state, } if (bwp_dl_ded_s_ptr == NULL || bwp_ul_ded_s_ptr == NULL) { - ERROR("bwp id %d ul or dl config never appears in RRCSetup (what we assume " - "now only checking in RRCSetup). Currently please bring back nof_bwps" - " back to 1 in config.yaml as we are working on encrypted" - "RRCReconfiguration-based BWP config monitoring.\n", bwp_id); - return SRSRAN_ERROR; + // now use hidden bwp logic + printf("bwp id %d ul or dl config never appears in " + "RRCSetup; use hidden bwp detection logic\n", bwp_id); + + is_hidden_bwp = true; + master_cell_group.from_json(state->js_hidden_bwp); + + // 9/21/2024 Only have hidden dl bwp 1 and ul bwp 1 info, so dl use bwp1 and ul use bwp + // TO-DOs: we shall select the right hidden bwp config here whe + bwp_dl_ded_s_ptr = &(master_cell_group.sp_cell_cfg.sp_cell_cfg_ded. + dl_bwp_to_add_mod_list[0].bwp_ded); + bwp_ul_ded_s_ptr = &(master_cell_group.sp_cell_cfg.sp_cell_cfg_ded. + ul_cfg.ul_bwp_to_add_mod_list[0].bwp_ded); } if(bwp_dl_ded_s_ptr->pdcch_cfg.is_setup()){ @@ -334,7 +347,7 @@ int DCIDecoder::DCIDecoderandReceptionInit(WorkState* state, /// Format 0_1 specific configuration (for PUSCH only) ///< Number of UL BWPs excluding the initial UL BWP, mentioned in the TS as N_BWP_RRC dci_cfg.nof_ul_bwp = master_cell_group.sp_cell_cfg.sp_cell_cfg_ded.ul_cfg. - ul_bwp_to_add_mod_list.size(); + ul_bwp_to_add_mod_list.size(); ///< Number of dedicated PUSCH time domain resource assigment, set to 0 for default dci_cfg.nof_ul_time_res = bwp_ul_ded_s_ptr->pusch_cfg.setup(). pusch_time_domain_alloc_list_present ? @@ -533,7 +546,8 @@ int DCIDecoder::DCIDecoderandReceptionInit(WorkState* state, dl_bwp_to_add_mod_list.size(); dci_cfg.nof_dl_time_res = bwp_dl_ded_s_ptr->pdsch_cfg.setup(). pdsch_time_domain_alloc_list_present ? - bwp_dl_ded_s_ptr->pdsch_cfg.setup().pdsch_time_domain_alloc_list.setup(). + bwp_dl_ded_s_ptr->pdsch_cfg.setup(). + pdsch_time_domain_alloc_list.setup(). size() : ( sib1.serving_cell_cfg_common.dl_cfg_common.init_dl_bwp. pdsch_cfg_common_present ? sib1.serving_cell_cfg_common.dl_cfg_common. init_dl_bwp.pdsch_cfg_common.setup().pdsch_time_domain_alloc_list.size() : 0 diff --git a/nrscope/src/libs/nrscope_worker.cc b/nrscope/src/libs/nrscope_worker.cc index 59daa731..afa9d2eb 100644 --- a/nrscope/src/libs/nrscope_worker.cc +++ b/nrscope/src/libs/nrscope_worker.cc @@ -39,6 +39,7 @@ int NRScopeWorker::InitWorker(WorkState task_scheduler_state, int worker_id_){ worker_state.args_t = task_scheduler_state.args_t; worker_state.slot_sz = task_scheduler_state.slot_sz; worker_state.cpu_affinity = task_scheduler_state.cpu_affinity; + worker_state.js_hidden_bwp = task_scheduler_state.js_hidden_bwp; /* Size of one subframe */ rx_buffer = srsran_vec_cf_malloc(SRSRAN_NOF_SLOTS_PER_SF_NR( worker_state.args_t.ssb_scs) * worker_state.slot_sz); diff --git a/nrscope/src/libs/task_scheduler.cc b/nrscope/src/libs/task_scheduler.cc index 72f254f3..10ffa710 100644 --- a/nrscope/src/libs/task_scheduler.cc +++ b/nrscope/src/libs/task_scheduler.cc @@ -1,4 +1,7 @@ #include "nrscope/hdr/task_scheduler.h" +#include + +using json = nlohmann::json; namespace NRScopeTask{ @@ -39,6 +42,32 @@ int TaskSchedulerNRScope::InitandStart(bool local_log_, SRSRAN_NOF_SLOTS_PER_SF_NR(args_t.ssb_scs)); task_scheduler_state.cpu_affinity = cpu_affinity; nof_workers = nof_workers_; + + /** + * Load the hidden bwp db early + * + * Currently in "proof-of-concept" mode, where the db contains just + * the MOSOLAB 369 cell's hidden bwp info in 40 MHz mode. More specifically, + * + * BWP0: start RB 0 and Num RB 78 + * BWP1: start RB 0 and Num RB 106 + * + * TO-DOs: + * (1) test on commerical/MOSOLAB cells where BWP1 may start at a higher location + * (so we need to guess the start which is multiple of 6 RB) + * + * (2) interface with the actual db (ready) + * + * (3) for more than one non-initial bwp, use energy detection method to map to the + * right hidden bwp config, as discussed in our meeting + * + * Nice to have: + * (1) CRC check for different dci size(s) for cross-validation, where use the + * dci size with CRC == 1 to serve as a target and maybe use dynamic programming + * to tune the dci-size parameters towards the target size + */ + std::ifstream f("369.txt"); + task_scheduler_state.js_hidden_bwp = json::parse(f); std::cout << "Starting workers..." << std::endl; for (uint32_t i = 0; i < nof_workers; i ++) { NRScopeWorker *worker = new NRScopeWorker();