From 2defe04f8bb93d849320e10193b3210477aa31c5 Mon Sep 17 00:00:00 2001 From: Xuyang Cao Date: Sat, 21 Sep 2024 19:48:58 -0400 Subject: [PATCH] load db at the begin --- nrscope/hdr/nrscope_def.h | 8 + nrscope/hidden_bwp_db/369_ul.txt | 446 ----------------------------- nrscope/src/libs/dci_decoder.cc | 19 +- nrscope/src/libs/nrscope_worker.cc | 1 + nrscope/src/libs/radio_nr.cc | 29 ++ nrscope/src/libs/task_scheduler.cc | 5 + 6 files changed, 49 insertions(+), 459 deletions(-) delete mode 100644 nrscope/hidden_bwp_db/369_ul.txt diff --git a/nrscope/hdr/nrscope_def.h b/nrscope/hdr/nrscope_def.h index 2e84c9a..e82fcef 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_ul.txt b/nrscope/hidden_bwp_db/369_ul.txt deleted file mode 100644 index c4aab2b..0000000 --- a/nrscope/hidden_bwp_db/369_ul.txt +++ /dev/null @@ -1,446 +0,0 @@ -{ - "uplinkBWP-ToAddModList": { - "BWP-Uplink": { - "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": [ - { "k2": 5, "mappingType": 0, "startSymbolAndLength": 55 }, - { "k2": 6, "mappingType": 0, "startSymbolAndLength": 55 }, - { "k2": 7, "mappingType": 0, "startSymbolAndLength": 55 }, - { "k2": 8, "mappingType": 0, "startSymbolAndLength": 55 }, - { "k2": 9, "mappingType": 0, "startSymbolAndLength": 55 }, - { "k2": 10, "mappingType": 0, "startSymbolAndLength": 55 }, - { "k2": 11, "mappingType": 0, "startSymbolAndLength": 55 }, - { "k2": 12, "mappingType": 0, "startSymbolAndLength": 55 }, - { "k2": 13, "mappingType": 0, "startSymbolAndLength": 55 }, - { "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 - } - } - ], - "maxCodeRate": 6, - "simultaneousHARQ-ACK-CSI": 0, - "schedulingRequestResourceToAddModList": [ - { "schedulingRequestResourceId": 1, "schedulingRequestID": 0, "periodicityAndOffset": 5, "resource": 14 } - ], - "resource": [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": { - "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-AlphaSet": { - "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 - } - } - } - } -} diff --git a/nrscope/src/libs/dci_decoder.cc b/nrscope/src/libs/dci_decoder.cc index fde1895..4b5a568 100644 --- a/nrscope/src/libs/dci_decoder.cc +++ b/nrscope/src/libs/dci_decoder.cc @@ -129,25 +129,18 @@ 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); - std::ifstream f("/home/xyc/hidden_bwp_40/NG-Scope-5G/nrscope/hidden_bwp_db/369.txt"); - hidden_dl_bwp_json = json::parse(f); + // std::ifstream f("/home/xyc/hidden_bwp_40/NG-Scope-5G/nrscope/hidden_bwp_db/369.txt"); + // hidden_dl_bwp_json = json::parse(f); is_hidden_bwp = true; - - - printf("[9/16] trigger 1\n"); - master_cell_group.from_json(hidden_dl_bwp_json); - printf("[9/16] trigger 2\n"); - + master_cell_group.from_json(state->js_hidden_bwp); - // 9/16/2024 Only have hidden dl bwp 1 info, so dl use bwp1 and dl use bwp0 still + // 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.init_ul_bwp); + 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()){ diff --git a/nrscope/src/libs/nrscope_worker.cc b/nrscope/src/libs/nrscope_worker.cc index 59daa73..afa9d2e 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/radio_nr.cc b/nrscope/src/libs/radio_nr.cc index 5672008..386170f 100644 --- a/nrscope/src/libs/radio_nr.cc +++ b/nrscope/src/libs/radio_nr.cc @@ -2,6 +2,9 @@ #include #include #include +#include + +using json = nlohmann::json; #define RING_BUF_SIZE 10000 #define RING_BUF_MODULUS (RING_BUF_SIZE - 1) @@ -515,6 +518,32 @@ int Radio::RadioInitandStart(){ rk_initialized = true; } + /** + * 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 + */ + + + /* Initialize the task_scheduler and the workers in it. They will all remain inactive until the MIB is found. */ task_scheduler_nrscope.InitandStart(local_log, to_google, rf_index, diff --git a/nrscope/src/libs/task_scheduler.cc b/nrscope/src/libs/task_scheduler.cc index 72f254f..194a8fa 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,8 @@ 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_; + std::ifstream f("/home/xyc/hidden_bwp_40/NG-Scope-5G/nrscope/hidden_bwp_db/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();