enb,metrics: add helper method to print MAC metrics

preparation to be used to print MAC metrics for EUTRA and NR cells
master
Andre Puschmann 3 years ago
parent 6a46931144
commit e2b1bbe2dc

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

@ -71,62 +71,43 @@ static bool iszero(float x)
return fabsf(x) < 2 * DBL_EPSILON; return fabsf(x) < 2 * DBL_EPSILON;
} }
void metrics_stdout::set_metrics(const enb_metrics_t& metrics, const uint32_t period_usec) void metrics_stdout::set_metrics_helper(uint32_t num_ue,
const mac_metrics_t& mac,
const std::vector<phy_metrics_t>& phy)
{ {
if (!do_print || enb == nullptr) { for (size_t i = 0; i < num_ue; i++) {
return;
}
if (metrics.rf.rf_error) {
fmt::print("RF status: O={}, U={}, L={}\n", metrics.rf.rf_o, metrics.rf.rf_u, metrics.rf.rf_l);
}
if (metrics.stack.rrc.ues.size() == 0) {
return;
}
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");
}
for (size_t i = 0; i < metrics.stack.rrc.ues.size(); i++) {
// make sure we have stats for MAC and PHY layer too // make sure we have stats for MAC and PHY layer too
if (i >= metrics.stack.mac.ues.size() || i >= metrics.phy.size()) { if (i >= mac.ues.size() || i >= phy.size()) {
break; break;
} }
if (metrics.stack.mac.ues[i].tx_errors > metrics.stack.mac.ues[i].tx_pkts) { if (mac.ues[i].tx_errors > mac.ues[i].tx_pkts) {
fmt::print("tx caution errors {} > {}\n", metrics.stack.mac.ues[i].tx_errors, metrics.stack.mac.ues[i].tx_pkts); fmt::print("tx caution errors {} > {}\n", mac.ues[i].tx_errors, mac.ues[i].tx_pkts);
} }
if (metrics.stack.mac.ues[i].rx_errors > metrics.stack.mac.ues[i].rx_pkts) { if (mac.ues[i].rx_errors > mac.ues[i].rx_pkts) {
fmt::print("rx caution errors {} > {}\n", metrics.stack.mac.ues[i].rx_errors, metrics.stack.mac.ues[i].rx_pkts); fmt::print("rx caution errors {} > {}\n", mac.ues[i].rx_errors, mac.ues[i].rx_pkts);
} }
fmt::print("{:>4x}", metrics.stack.mac.ues[i].rnti); fmt::print("{:>4x}", mac.ues[i].rnti);
if (not iszero(metrics.stack.mac.ues[i].dl_cqi)) { if (not iszero(mac.ues[i].dl_cqi)) {
fmt::print(" {:>3}", int(metrics.stack.mac.ues[i].dl_cqi)); fmt::print(" {:>3}", int(mac.ues[i].dl_cqi));
} else { } else {
fmt::print(" {:>3.3}", "n/a"); fmt::print(" {:>3.3}", "n/a");
} }
fmt::print(" {:>1}", int(metrics.stack.mac.ues[i].dl_ri)); fmt::print(" {:>1}", int(mac.ues[i].dl_ri));
if (not isnan(metrics.phy[i].dl.mcs)) { if (not isnan(phy[i].dl.mcs)) {
fmt::print(" {:>2}", int(metrics.phy[i].dl.mcs)); fmt::print(" {:>2}", int(phy[i].dl.mcs));
} else { } else {
fmt::print(" {:>2}", 0); fmt::print(" {:>2}", 0);
} }
if (metrics.stack.mac.ues[i].tx_brate > 0) { if (mac.ues[i].tx_brate > 0) {
fmt::print( fmt::print(" {:>6.6}", float_to_eng_string((float)mac.ues[i].tx_brate / (mac.ues[i].nof_tti * 1e-3), 1));
" {:>6.6}",
float_to_eng_string((float)metrics.stack.mac.ues[i].tx_brate / (metrics.stack.mac.ues[i].nof_tti * 1e-3), 1));
} else { } else {
fmt::print(" {:>6}", 0); fmt::print(" {:>6}", 0);
} }
fmt::print(" {:>4}", metrics.stack.mac.ues[i].tx_pkts - metrics.stack.mac.ues[i].tx_errors); fmt::print(" {:>4}", mac.ues[i].tx_pkts - mac.ues[i].tx_errors);
fmt::print(" {:>4}", metrics.stack.mac.ues[i].tx_errors); fmt::print(" {:>4}", mac.ues[i].tx_errors);
if (metrics.stack.mac.ues[i].tx_pkts > 0 && metrics.stack.mac.ues[i].tx_errors) { if (mac.ues[i].tx_pkts > 0 && mac.ues[i].tx_errors) {
fmt::print(" {:>3}%", int((float)100 * metrics.stack.mac.ues[i].tx_errors / metrics.stack.mac.ues[i].tx_pkts)); fmt::print(" {:>3}%", int((float)100 * mac.ues[i].tx_errors / mac.ues[i].tx_pkts));
} else { } else {
fmt::print(" {:>3}%", 0); fmt::print(" {:>3}%", 0);
} }
@ -143,44 +124,66 @@ void metrics_stdout::set_metrics(const enb_metrics_t& metrics, const uint32_t pe
return sinr; return sinr;
}; };
if (not isnan(metrics.phy[i].ul.pusch_sinr) and not iszero(metrics.phy[i].ul.pusch_sinr)) { if (not isnan(phy[i].ul.pusch_sinr) and not iszero(phy[i].ul.pusch_sinr)) {
fmt::print(" {:>5.1f}", clamp_sinr(metrics.phy[i].ul.pusch_sinr)); fmt::print(" {:>5.1f}", clamp_sinr(phy[i].ul.pusch_sinr));
} else { } else {
fmt::print(" {:>5.5}", "n/a"); fmt::print(" {:>5.5}", "n/a");
} }
if (not isnan(metrics.phy[i].ul.pucch_sinr) and not iszero(metrics.phy[i].ul.pucch_sinr)) { if (not isnan(phy[i].ul.pucch_sinr) and not iszero(phy[i].ul.pucch_sinr)) {
fmt::print(" {:>5.1f}", clamp_sinr(metrics.phy[i].ul.pucch_sinr)); fmt::print(" {:>5.1f}", clamp_sinr(phy[i].ul.pucch_sinr));
} else { } else {
fmt::print(" {:>5.5}", "n/a"); fmt::print(" {:>5.5}", "n/a");
} }
fmt::print(" {:>3}", int(metrics.stack.mac.ues[i].phr)); fmt::print(" {:>3}", int(mac.ues[i].phr));
if (not isnan(metrics.phy[i].ul.mcs)) { if (not isnan(phy[i].ul.mcs)) {
fmt::print(" {:>2}", int(metrics.phy[i].ul.mcs)); fmt::print(" {:>2}", int(phy[i].ul.mcs));
} else { } else {
fmt::print(" {:>2}", 0); fmt::print(" {:>2}", 0);
} }
if (metrics.stack.mac.ues[i].rx_brate > 0) { if (mac.ues[i].rx_brate > 0) {
fmt::print( fmt::print(" {:>6.6}", float_to_eng_string((float)mac.ues[i].rx_brate / (mac.ues[i].nof_tti * 1e-3), 1));
" {:>6.6}",
float_to_eng_string((float)metrics.stack.mac.ues[i].rx_brate / (metrics.stack.mac.ues[i].nof_tti * 1e-3), 1));
} else { } else {
fmt::print(" {:>6}", 0); fmt::print(" {:>6}", 0);
} }
fmt::print(" {:>4}", metrics.stack.mac.ues[i].rx_pkts - metrics.stack.mac.ues[i].rx_errors); fmt::print(" {:>4}", mac.ues[i].rx_pkts - mac.ues[i].rx_errors);
fmt::print(" {:>4}", metrics.stack.mac.ues[i].rx_errors); fmt::print(" {:>4}", mac.ues[i].rx_errors);
if (metrics.stack.mac.ues[i].rx_pkts > 0 && metrics.stack.mac.ues[i].rx_errors > 0) { if (mac.ues[i].rx_pkts > 0 && mac.ues[i].rx_errors > 0) {
fmt::print(" {:>3}%", int((float)100 * metrics.stack.mac.ues[i].rx_errors / metrics.stack.mac.ues[i].rx_pkts)); fmt::print(" {:>3}%", int((float)100 * mac.ues[i].rx_errors / mac.ues[i].rx_pkts));
} else { } else {
fmt::print(" {:>3}%", 0); fmt::print(" {:>3}%", 0);
} }
fmt::print(" {:>6.6}", float_to_eng_string(metrics.stack.mac.ues[i].ul_buffer, 2)); fmt::print(" {:>6.6}", float_to_eng_string(mac.ues[i].ul_buffer, 2));
fmt::print("\n"); fmt::print("\n");
} }
} }
void metrics_stdout::set_metrics(const enb_metrics_t& metrics, const uint32_t period_usec)
{
if (!do_print || enb == nullptr) {
return;
}
if (metrics.rf.rf_error) {
fmt::print("RF status: O={}, U={}, L={}\n", metrics.rf.rf_o, metrics.rf.rf_u, metrics.rf.rf_l);
}
if (metrics.stack.rrc.ues.size() == 0) {
return;
}
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");
}
set_metrics_helper(metrics.stack.rrc.ues.size(), metrics.stack.mac, metrics.phy);
}
std::string metrics_stdout::float_to_string(float f, int digits, int field_width) std::string metrics_stdout::float_to_string(float f, int digits, int field_width)
{ {
std::ostringstream os; std::ostringstream os;

Loading…
Cancel
Save