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:
struct prach_metrics_t {
uint32_t count;
float avg_ta;
float avg_ta = 0.0f;
float min_ta = +INFINITY;
float max_ta = -INFINITY;
};
struct pucch_metrics_t {
float epre_db_avg = 0.0f;
@ -706,6 +708,8 @@ public:
std::unique_lock<std::mutex> lock(metrics_mutex);
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.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++;
}

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

@ -25,6 +25,7 @@ static double assert_sr_detection_min = 1.000;
static double assert_cqi_detection_min = 1.000;
static double assert_pusch_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)
{
@ -236,34 +237,57 @@ int main(int argc, char** argv)
}
// 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) {
srsran::console("PRACH:\n");
srsran::console(" UE transmitted:\n");
srsran::console(" +------------+------------+\n");
srsran::console(" | %10s | %10s |\n", "preamble", "count");
srsran::console(" +------------+------------+\n");
srsran::console(
" +------------+------------+------------+------------+------------+------------+------------+\n");
srsran::console(" | %10s | %10s | %10s | %10s | %10s | %10s | %10s |\n",
"Preamble",
"Transmit'd",
"Received",
"Detection",
"Avg TA",
"Min TA",
"Max TA");
srsran::console(
" +------------+------------+------------+------------+------------+------------+------------+\n");
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
TESTASSERT(metrics.gnb_stack.prach.count(p.first));
TESTASSERT(metrics.gnb_stack.prach[p.first].count == p.second.count);
// TESTASSERT(metrics.gnb_stack.prach.count(p.first));
// TESTASSERT(metrics.gnb_stack.prach[p.first].count == p.second.count);
TESTASSERT(p.second.count != 0);
prach_tx_count += p.second.count;
gnb_dummy_stack::prach_metrics_t gnb_prach = {};
if (metrics.gnb_stack.prach.count(p.first) > 0) {
gnb_prach = metrics.gnb_stack.prach[p.first];
} else {
gnb_prach.avg_ta = NAN;
gnb_prach.min_ta = NAN;
gnb_prach.max_ta = NAN;
}
srsran::console(" +------------+------------+\n\n");
srsran::console(" GNB detected:\n");
srsran::console(" +------------+------------+------------+\n");
srsran::console(" | %10s | %10s | %10s |\n", "preamble", "count", "avg TA");
srsran::console(" +------------+------------+------------+\n");
for (const auto& p : metrics.gnb_stack.prach) {
srsran::console(" | %10d | %10d | %10.1f |\n", p.first, p.second.count, p.second.avg_ta);
// Ensure all detected preambles were transmitted
TESTASSERT(metrics.ue_stack.prach.count(p.first) > 0);
prach_rx_count += gnb_prach.count;
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");
}
srsran::console(" +------------+------------+------------+\n\n");
if (prach_tx_count > 0) {
prach_detection = (double)prach_rx_count / (double)prach_tx_count;
}
// 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_detection,
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
return SRSRAN_SUCCESS;

Loading…
Cancel
Save