Fix division by zero in JSON metrics

master
Ismael Gomez 3 years ago
parent 821e6834d9
commit 6bdeb2d6b6

@ -90,7 +90,7 @@ static void fill_ue_metrics(mset_ue_container& ue, const enb_metrics_t& m, unsig
if (!std::isnan(m.phy[i].dl.mcs)) { if (!std::isnan(m.phy[i].dl.mcs)) {
ue.write<metric_dl_mcs>(std::max(0.1f, m.phy[i].dl.mcs)); ue.write<metric_dl_mcs>(std::max(0.1f, m.phy[i].dl.mcs));
} }
if (m.stack.mac.ues[i].tx_brate > 0) { if (m.stack.mac.ues[i].tx_brate > 0 && m.stack.mac.ues[i].nof_tti > 0) {
ue.write<metric_dl_bitrate>( ue.write<metric_dl_bitrate>(
std::max(0.1f, (float)m.stack.mac.ues[i].tx_brate / (m.stack.mac.ues[i].nof_tti * 0.001f))); std::max(0.1f, (float)m.stack.mac.ues[i].tx_brate / (m.stack.mac.ues[i].nof_tti * 0.001f)));
} }
@ -103,7 +103,7 @@ static void fill_ue_metrics(mset_ue_container& ue, const enb_metrics_t& m, unsig
if (!std::isnan(m.phy[i].ul.mcs)) { if (!std::isnan(m.phy[i].ul.mcs)) {
ue.write<metric_ul_mcs>(std::max(0.1f, m.phy[i].ul.mcs)); ue.write<metric_ul_mcs>(std::max(0.1f, m.phy[i].ul.mcs));
} }
if (m.stack.mac.ues[i].rx_brate > 0) { if (m.stack.mac.ues[i].rx_brate > 0 && m.stack.mac.ues[i].nof_tti > 0) {
ue.write<metric_ul_bitrate>( ue.write<metric_ul_bitrate>(
std::max(0.1f, (float)m.stack.mac.ues[i].rx_brate / (m.stack.mac.ues[i].nof_tti * 0.001f))); std::max(0.1f, (float)m.stack.mac.ues[i].rx_brate / (m.stack.mac.ues[i].nof_tti * 0.001f)));
} }

@ -153,6 +153,10 @@ void metrics_json::set_metrics(const ue_metrics_t& metrics, const uint32_t perio
auto& carrier_list = ctx.get<mlist_carriers>(); auto& carrier_list = ctx.get<mlist_carriers>();
carrier_list.resize(metrics.phy.nof_active_cc); carrier_list.resize(metrics.phy.nof_active_cc);
for (uint32_t i = 0, e = carrier_list.size(); i != e; ++i) { for (uint32_t i = 0, e = carrier_list.size(); i != e; ++i) {
if (metrics.stack.mac[i].nof_tti == 0) {
continue;
}
auto& carrier = carrier_list[i]; auto& carrier = carrier_list[i];
// PHY. // PHY.

Loading…
Cancel
Save