Enhanced nr_phy_test with better PRACH stats

master
Xavier Arteaga 3 years ago committed by Andre Puschmann
parent 6926754e67
commit 7ecca61d60

@ -36,7 +36,9 @@ class gnb_dummy_stack : public srsenb::stack_interface_phy_nr
public: public:
struct prach_metrics_t { struct prach_metrics_t {
uint32_t count; uint32_t count;
float avg_ta; float avg_ta = 0.0f;
float min_ta = +INFINITY;
float max_ta = -INFINITY;
}; };
struct pucch_metrics_t { struct pucch_metrics_t {
float epre_db_avg = 0.0f; float epre_db_avg = 0.0f;
@ -706,6 +708,8 @@ public:
std::unique_lock<std::mutex> lock(metrics_mutex); std::unique_lock<std::mutex> lock(metrics_mutex);
prach_metrics_t& prach_metrics = metrics.prach[rach_info.preamble]; prach_metrics_t& prach_metrics = metrics.prach[rach_info.preamble];
prach_metrics.avg_ta = SRSRAN_VEC_SAFE_CMA((float)rach_info.time_adv, prach_metrics.avg_ta, prach_metrics.count); prach_metrics.avg_ta = SRSRAN_VEC_SAFE_CMA((float)rach_info.time_adv, prach_metrics.avg_ta, prach_metrics.count);
prach_metrics.min_ta = SRSRAN_MIN((float)rach_info.time_adv, prach_metrics.min_ta);
prach_metrics.max_ta = SRSRAN_MAX((float)rach_info.time_adv, prach_metrics.max_ta);
prach_metrics.count++; prach_metrics.count++;
} }

@ -29,6 +29,7 @@ public:
private: private:
std::mutex rnti_mutex; std::mutex rnti_mutex;
srsran_random_t random_gen = srsran_random_init(0x1323);
srsran_rnti_type_t dl_rnti_type = srsran_rnti_type_c; srsran_rnti_type_t dl_rnti_type = srsran_rnti_type_c;
uint16_t rnti = 0; uint16_t rnti = 0;
bool valid = false; bool valid = false;
@ -58,7 +59,7 @@ public:
{ {
valid = true; valid = true;
} }
~ue_dummy_stack() = default; ~ue_dummy_stack() { srsran_random_free(random_gen); }
void in_sync() override {} void in_sync() override {}
void out_of_sync() override {} void out_of_sync() override {}
void run_tti(const uint32_t tti) override void run_tti(const uint32_t tti) override
@ -68,8 +69,12 @@ public:
uint32_t slot_idx = tti % SRSRAN_NSLOTS_PER_FRAME_NR(srsran_subcarrier_spacing_15kHz); uint32_t slot_idx = tti % SRSRAN_NSLOTS_PER_FRAME_NR(srsran_subcarrier_spacing_15kHz);
uint32_t sfn = tti / SRSRAN_NSLOTS_PER_FRAME_NR(srsran_subcarrier_spacing_15kHz); uint32_t sfn = tti / SRSRAN_NSLOTS_PER_FRAME_NR(srsran_subcarrier_spacing_15kHz);
if (slot_idx == 0 and sfn % prach_period == 0) { if (slot_idx == 0 and sfn % prach_period == 0) {
phy.send_prach(0, prach_preamble, 0.0f, 0.0f); uint32_t prach_preamble_ = prach_preamble;
metrics.prach[prach_preamble].count++; if (prach_preamble_ >= 64) {
prach_preamble_ = srsran_random_uniform_int_dist(random_gen, 0, 63);
}
phy.send_prach(0, prach_preamble_, 0.0f, 0.0f);
metrics.prach[prach_preamble_].count++;
} }
} }
} }

@ -21,10 +21,11 @@
// shorten boost program options namespace // shorten boost program options namespace
namespace bpo = boost::program_options; namespace bpo = boost::program_options;
static double assert_sr_detection_min = 1.000; static double assert_sr_detection_min = 1.000;
static double assert_cqi_detection_min = 1.000; static double assert_cqi_detection_min = 1.000;
static double assert_pusch_bler_max = 0.000; static double assert_pusch_bler_max = 0.000;
static double assert_pdsch_bler_max = 0.000; static double assert_pdsch_bler_max = 0.000;
static double assert_prach_detection_min = 1.000;
test_bench::args_t::args_t(int argc, char** argv) test_bench::args_t::args_t(int argc, char** argv)
{ {
@ -236,34 +237,57 @@ int main(int argc, char** argv)
} }
// Print PRACH // Print PRACH
double prach_detection = 0.0;
uint32_t prach_tx_count = 0;
uint32_t prach_rx_count = 0;
if (metrics.ue_stack.prach.size() > 0) { if (metrics.ue_stack.prach.size() > 0) {
srsran::console("PRACH:\n"); srsran::console("PRACH:\n");
srsran::console(" UE transmitted:\n"); srsran::console(
srsran::console(" +------------+------------+\n"); " +------------+------------+------------+------------+------------+------------+------------+\n");
srsran::console(" | %10s | %10s |\n", "preamble", "count"); srsran::console(" | %10s | %10s | %10s | %10s | %10s | %10s | %10s |\n",
srsran::console(" +------------+------------+\n"); "Preamble",
"Transmit'd",
"Received",
"Detection",
"Avg TA",
"Min TA",
"Max TA");
srsran::console(
" +------------+------------+------------+------------+------------+------------+------------+\n");
for (const auto& p : metrics.ue_stack.prach) { for (const auto& p : metrics.ue_stack.prach) {
srsran::console(" | %10d | %10d |\n", p.first, p.second.count);
// Ensure the detected count matches with transmission // Ensure the detected count matches with transmission
TESTASSERT(metrics.gnb_stack.prach.count(p.first)); // TESTASSERT(metrics.gnb_stack.prach.count(p.first));
TESTASSERT(metrics.gnb_stack.prach[p.first].count == p.second.count); // TESTASSERT(metrics.gnb_stack.prach[p.first].count == p.second.count);
} TESTASSERT(p.second.count != 0);
srsran::console(" +------------+------------+\n\n"); prach_tx_count += p.second.count;
srsran::console(" GNB detected:\n"); gnb_dummy_stack::prach_metrics_t gnb_prach = {};
srsran::console(" +------------+------------+------------+\n"); if (metrics.gnb_stack.prach.count(p.first) > 0) {
srsran::console(" | %10s | %10s | %10s |\n", "preamble", "count", "avg TA"); gnb_prach = metrics.gnb_stack.prach[p.first];
srsran::console(" +------------+------------+------------+\n"); } else {
gnb_prach.avg_ta = NAN;
for (const auto& p : metrics.gnb_stack.prach) { gnb_prach.min_ta = NAN;
srsran::console(" | %10d | %10d | %10.1f |\n", p.first, p.second.count, p.second.avg_ta); gnb_prach.max_ta = NAN;
}
// Ensure all detected preambles were transmitted prach_rx_count += gnb_prach.count;
TESTASSERT(metrics.ue_stack.prach.count(p.first) > 0);
double detection = (double)gnb_prach.count / (double)p.second.count;
srsran::console(" | %10d | %10d | %10d | %10.3f | %10.1f | %10.1f | %10.1f |\n",
p.first,
p.second.count,
gnb_prach.count,
detection,
gnb_prach.avg_ta,
gnb_prach.min_ta,
gnb_prach.max_ta);
} }
srsran::console(" +------------+------------+------------+\n\n"); srsran::console(
" +------------+------------+------------+------------+------------+------------+------------+\n");
}
if (prach_tx_count > 0) {
prach_detection = (double)prach_rx_count / (double)prach_tx_count;
} }
// Print PUCCH // Print PUCCH
@ -410,6 +434,10 @@ int main(int argc, char** argv)
"CQI report detection probability (%f) did not reach the assertion minimum (%f)", "CQI report detection probability (%f) did not reach the assertion minimum (%f)",
cqi_detection, cqi_detection,
assert_sr_detection_min); assert_sr_detection_min);
srsran_assert(prach_tx_count == 0 or prach_detection >= assert_prach_detection_min,
"PRACH detection probability (%f) did not reach the assertion minimum (%f)",
prach_detection,
assert_prach_detection_min);
// If reached here, the test is successful // If reached here, the test is successful
return SRSRAN_SUCCESS; return SRSRAN_SUCCESS;

Loading…
Cancel
Save