adding nr metrics

master
yagoda 3 years ago committed by Andre Puschmann
parent 86938e8474
commit 82bda02b36

@ -49,6 +49,7 @@ struct enb_metrics_t {
srsran::rf_metrics_t rf;
std::vector<phy_metrics_t> phy;
stack_metrics_t stack;
stack_metrics_t nr_stack;
srsran::sys_metrics_t sys;
bool running;
};

@ -37,7 +37,7 @@ public:
void stop(){};
private:
void set_metrics_helper(uint32_t num_ue, const mac_metrics_t& mac, const std::vector<phy_metrics_t>& phy);
void set_metrics_helper(uint32_t num_ue, const mac_metrics_t& mac, const std::vector<phy_metrics_t>& phy, bool is_nr);
std::string float_to_string(float f, int digits, int field_width = 6);
std::string float_to_eng_string(float f, int digits);

@ -35,8 +35,17 @@ struct mac_ue_metrics_t {
float dl_ri;
float dl_pmi;
float phr;
};
// NR-only UL PHY metrics
float pusch_sinr;
float pucch_sinr;
float ul_rssi;
float fec_iters;
float dl_mcs;
int dl_mcs_samples;
float ul_mcs;
int ul_mcs_samples;
};
/// MAC misc information for each cc.
struct mac_cc_info_t {
/// PCI value.

@ -60,6 +60,8 @@ public:
void metrics_dl_ri(uint32_t dl_cqi);
void metrics_dl_pmi(uint32_t dl_cqi);
void metrics_dl_cqi(uint32_t dl_cqi);
void metrics_dl_mcs(uint32_t mcs);
void metrics_ul_mcs(uint32_t mcs);
void metrics_cnt();
uint32_t read_pdu(uint32_t lcid, uint8_t* payload, uint32_t requested_bytes) final;

@ -116,7 +116,7 @@ public:
bool is_inactive() { return state == rrc_nr_state_t::RRC_INACTIVE; }
bool is_endc() { return endc; }
uint16_t get_eutra_rnti() { return eutra_rnti; }
void get_metrics(rrc_ue_metrics_t& ue_metrics) { ue_metrics = {}; /*TODO fill RRC metrics*/ };
// setters
int pack_rrc_reconfiguraiton();

@ -202,6 +202,9 @@ bool enb::get_metrics(enb_metrics_t* m)
if (eutra_stack) {
eutra_stack->get_metrics(&m->stack);
}
if (nr_stack) {
nr_stack->get_metrics(&m->nr_stack);
}
m->running = true;
m->sys = sys_proc.get_metrics();
return true;

@ -73,11 +73,12 @@ static bool iszero(float x)
void metrics_stdout::set_metrics_helper(uint32_t num_ue,
const mac_metrics_t& mac,
const std::vector<phy_metrics_t>& phy)
const std::vector<phy_metrics_t>& phy,
bool is_nr)
{
for (size_t i = 0; i < num_ue; i++) {
// make sure we have stats for MAC and PHY layer too
if (i >= mac.ues.size() || i >= phy.size()) {
if (i >= mac.ues.size() || ((i >= phy.size()) && !is_nr)) {
break;
}
if (mac.ues[i].tx_errors > mac.ues[i].tx_pkts) {
@ -87,15 +88,17 @@ void metrics_stdout::set_metrics_helper(uint32_t num_ue
fmt::print("rx caution errors {} > {}\n", mac.ues[i].rx_errors, mac.ues[i].rx_pkts);
}
fmt::print("{:>4x}", mac.ues[i].rnti);
fmt::print("{:>3.5}", (is_nr) ? "nr" : "lte");
fmt::print("{:>5x}", mac.ues[i].rnti);
if (not iszero(mac.ues[i].dl_cqi)) {
fmt::print(" {:>3}", int(mac.ues[i].dl_cqi));
} else {
fmt::print(" {:>3.3}", "n/a");
}
fmt::print(" {:>1}", int(mac.ues[i].dl_ri));
if (not isnan(phy[i].dl.mcs)) {
fmt::print(" {:>2}", int(phy[i].dl.mcs));
float dl_mcs = (is_nr) ? mac.ues[i].dl_mcs : phy[i].dl.mcs;
if (not isnan(dl_mcs)) {
fmt::print(" {:>2}", int(dl_mcs));
} else {
fmt::print(" {:>2}", 0);
}
@ -123,22 +126,22 @@ void metrics_stdout::set_metrics_helper(uint32_t num_ue
}
return sinr;
};
if (not isnan(phy[i].ul.pusch_sinr) and not iszero(phy[i].ul.pusch_sinr)) {
fmt::print(" {:>5.1f}", clamp_sinr(phy[i].ul.pusch_sinr));
float pusch_sinr = (is_nr) ? mac.ues[i].pusch_sinr : phy[i].ul.pusch_sinr;
if (not isnan(pusch_sinr) and not iszero(pusch_sinr)) {
fmt::print(" {:>5.1f}", clamp_sinr(pusch_sinr));
} else {
fmt::print(" {:>5.5}", "n/a");
}
if (not isnan(phy[i].ul.pucch_sinr) and not iszero(phy[i].ul.pucch_sinr)) {
fmt::print(" {:>5.1f}", clamp_sinr(phy[i].ul.pucch_sinr));
float pucch_sinr = (is_nr) ? mac.ues[i].pucch_sinr : phy[i].ul.pucch_sinr;
if (not isnan(pucch_sinr) and not iszero(pucch_sinr)) {
fmt::print(" {:>5.1f}", clamp_sinr(pucch_sinr));
} else {
fmt::print(" {:>5.5}", "n/a");
}
fmt::print(" {:>3}", int(mac.ues[i].phr));
if (not isnan(phy[i].ul.mcs)) {
fmt::print(" {:>2}", int(phy[i].ul.mcs));
int phr = (is_nr) ? mac.ues[i].phr : mac.ues[i].phr;
fmt::print(" {:>3}", int(phr));
if (not isnan(phr)) {
fmt::print(" {:>2}", int(phr));
} else {
fmt::print(" {:>2}", 0);
}
@ -177,11 +180,12 @@ void metrics_stdout::set_metrics(const enb_metrics_t& metrics, const uint32_t pe
if (++n_reports > 10) {
n_reports = 0;
fmt::print("\n");
fmt::print(" -----------------DL----------------|-------------------------UL-------------------------\n");
fmt::print("rnti cqi ri mcs brate ok nok (%) | pusch pucch phr mcs brate ok nok (%) bsr\n");
fmt::print(" -----------------DL----------------|-------------------------UL-------------------------\n");
fmt::print("rat rnti cqi ri mcs brate ok nok (%) | pusch pucch phr mcs brate ok nok (%) bsr\n");
}
set_metrics_helper(metrics.stack.rrc.ues.size(), metrics.stack.mac, metrics.phy);
set_metrics_helper(metrics.stack.rrc.ues.size(), metrics.stack.mac, metrics.phy, false);
set_metrics_helper(metrics.nr_stack.mac.ues.size(), metrics.nr_stack.mac, metrics.phy, true);
}
std::string metrics_stdout::float_to_string(float f, int digits, int field_width)

@ -305,6 +305,7 @@ int mac_nr::get_dl_sched(const srsran_slot_cfg_t& slot_cfg, dl_sched_t& dl_sched
uint32_t pid = 0; // TODO: get PID from PDCCH struct?
pcap->write_dl_crnti_nr(tb_data->msg, tb_data->N_bytes, rnti, pid, slot_cfg.idx);
}
ue_db[rnti]->metrics_dl_mcs(pdsch.sch.grant.tb->mcs);
}
}
} else if (pdsch.sch.grant.rnti_type == srsran_rnti_type_ra) {
@ -313,18 +314,28 @@ int mac_nr::get_dl_sched(const srsran_slot_cfg_t& slot_cfg, dl_sched_t& dl_sched
pdsch.data[0] = assemble_rar(rar.grants);
}
}
for (auto& u : ue_db) {
u.second->metrics_cnt();
}
return SRSRAN_SUCCESS;
}
int mac_nr::get_ul_sched(const srsran_slot_cfg_t& slot_cfg, ul_sched_t& ul_sched)
{
int ret = 0;
if (not pusch_slot.valid()) {
pusch_slot = srsran::slot_point{NUMEROLOGY_IDX, slot_cfg.idx};
} else {
pusch_slot++;
}
return sched.get_ul_sched(pusch_slot, 0, ul_sched);
ret = sched.get_ul_sched(pusch_slot, 0, ul_sched);
for (auto& pusch : ul_sched.pusch) {
if (ue_db.contains(pusch.sch.grant.rnti)) {
ue_db[pusch.sch.grant.rnti]->metrics_ul_mcs(pusch.sch.grant.tb->mcs);
}
}
return ret;
}
int mac_nr::pucch_info(const srsran_slot_cfg_t& slot_cfg, const mac_interface_phy_nr::pucch_info_t& pucch_info)
@ -343,6 +354,9 @@ bool mac_nr::handle_uci_data(const uint16_t rnti, const srsran_uci_cfg_nr_t& cfg
const srsran_harq_ack_bit_t* ack_bit = &cfg_.ack.bits[i];
bool is_ok = (value.ack[i] == 1) and value.valid;
sched.dl_ack_info(rnti, 0, ack_bit->pid, 0, is_ok);
if (ue_db.contains(rnti)) {
ue_db[rnti]->metrics_tx(is_ok, 0 /*TODO get size of packet from scheduler somehow*/);
}
}
// Process SR
@ -354,8 +368,8 @@ bool mac_nr::handle_uci_data(const uint16_t rnti, const srsran_uci_cfg_nr_t& cfg
int mac_nr::pusch_info(const srsran_slot_cfg_t& slot_cfg, mac_interface_phy_nr::pusch_info_t& pusch_info)
{
uint16_t rnti = pusch_info.rnti;
uint16_t rnti = pusch_info.rnti;
uint32_t nof_bytes = pusch_info.pdu->N_bytes;
// Handle UCI data
if (not handle_uci_data(rnti, pusch_info.uci_cfg, pusch_info.pusch_data.uci)) {
logger.error("Error handling UCI data from PUCCH reception");
@ -381,7 +395,10 @@ int mac_nr::pusch_info(const srsran_slot_cfg_t& slot_cfg, mac_interface_phy_nr::
};
stack_task_queue.try_push(std::bind(process_pdu_task, std::move(pusch_info.pdu)));
}
if (ue_db.contains(rnti)) {
ue_db[rnti]->metrics_rx(pusch_info.pusch_data.tb[0].crc, nof_bytes);
ue_db[rnti]->metrics_dl_cqi(15); // TODO extract correct CQI measurments
}
return SRSRAN_SUCCESS;
}

@ -177,8 +177,7 @@ void ue_nr::metrics_read(mac_ue_metrics_t* metrics_)
auto it = std::find(cc_list.begin(), cc_list.end(), 0);
ue_metrics.cc_idx = std::distance(cc_list.begin(), it);
*metrics_ = ue_metrics;
*metrics_ = ue_metrics;
phr_counter = 0;
dl_cqi_counter = 0;
ue_metrics = {};
@ -213,6 +212,18 @@ void ue_nr::metrics_tx(bool crc, uint32_t tbs)
ue_metrics.tx_pkts++;
}
void ue_nr::metrics_dl_mcs(uint32_t mcs)
{
ue_metrics.dl_mcs = SRSRAN_VEC_CMA((float)mcs, ue_metrics.dl_mcs, ue_metrics.dl_mcs_samples);
ue_metrics.dl_mcs_samples++;
}
void ue_nr::metrics_ul_mcs(uint32_t mcs)
{
ue_metrics.ul_mcs = SRSRAN_VEC_CMA((float)mcs, ue_metrics.ul_mcs, ue_metrics.ul_mcs_samples);
ue_metrics.ul_mcs_samples++;
}
void ue_nr::metrics_cnt()
{
std::lock_guard<std::mutex> lock(metrics_mutex);

@ -371,7 +371,13 @@ int rrc_nr::read_pdu_bcch_dlsch(uint32_t sib_index, srsran::unique_byte_buffer_t
void rrc_nr::get_metrics(srsenb::rrc_metrics_t& m)
{
// return metrics
if (running) {
for (auto& ue : users) {
rrc_ue_metrics_t ue_metrics;
ue.second->get_metrics(ue_metrics);
m.ues.push_back(ue_metrics);
}
}
}
void rrc_nr::handle_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t pdu)

@ -37,7 +37,7 @@ public:
{
// first entry
metrics[0].rf.rf_o = 10;
metrics[0].stack.rrc.ues.resize(1);
metrics[0].stack.rrc.ues.resize(2);
metrics[0].stack.mac.ues.resize(metrics[0].stack.rrc.ues.size());
metrics[0].stack.mac.ues[0].rnti = 0x46;
metrics[0].stack.mac.ues[0].tx_pkts = 1000;
@ -52,12 +52,32 @@ public:
metrics[0].stack.mac.ues[0].dl_ri = 1.5;
metrics[0].stack.mac.ues[0].dl_pmi = 1.0;
metrics[0].stack.mac.ues[0].phr = 12.0;
metrics[0].phy.resize(1);
metrics[0].phy.resize(2);
metrics[0].phy[0].dl.mcs = 28.0;
metrics[0].phy[0].ul.mcs = 20.2;
metrics[0].phy[0].ul.pucch_sinr = 14.2;
metrics[0].phy[0].ul.pusch_sinr = 14.2;
metrics[0].rf.rf_o = 10;
metrics[0].nr_stack.mac.ues.resize(1);
metrics[0].nr_stack.mac.ues[0].rnti = 0x4601;
metrics[0].nr_stack.mac.ues[0].tx_pkts = 2000;
metrics[0].nr_stack.mac.ues[0].tx_errors = 2000;
metrics[0].nr_stack.mac.ues[0].tx_brate = 0;
metrics[0].nr_stack.mac.ues[0].rx_pkts = 50;
metrics[0].nr_stack.mac.ues[0].rx_errors = 49;
metrics[0].nr_stack.mac.ues[0].rx_brate = 2;
metrics[0].nr_stack.mac.ues[0].ul_buffer = 100;
metrics[0].nr_stack.mac.ues[0].dl_buffer = 200;
metrics[0].nr_stack.mac.ues[0].dl_cqi = 15.9;
metrics[0].nr_stack.mac.ues[0].dl_ri = 1.5;
metrics[0].nr_stack.mac.ues[0].dl_pmi = 1.0;
metrics[0].nr_stack.mac.ues[0].phr = 12.0;
metrics[0].nr_stack.mac.ues[0].dl_mcs = 28;
metrics[0].nr_stack.mac.ues[0].ul_mcs = 22;
metrics[0].nr_stack.mac.ues[0].pusch_sinr = 14;
metrics[0].nr_stack.mac.ues[0].pucch_sinr = 14.7;
// second
metrics[1].rf.rf_o = 10;
metrics[1].stack.rrc.ues.resize(1);
@ -106,7 +126,7 @@ public:
// fourth entry with incomple PHY and MAC stats
metrics[3].rf.rf_o = 10;
metrics[3].stack.rrc.ues.resize(2);
metrics[3].stack.rrc.ues.resize(1);
metrics[3].stack.mac.ues.resize(metrics[3].stack.rrc.ues.size());
metrics[3].stack.mac.ues[0].rnti = 0x1;
metrics[3].stack.mac.ues[0].tx_pkts = 9999;

Loading…
Cancel
Save