srsRAN/srsue/src/metrics_stdout.cc

211 lines
6.0 KiB
C++
Raw Permalink Normal View History

2019-04-26 19:27:38 +00:00
/*
2020-03-13 11:12:52 +00:00
* Copyright 2013-2020 Software Radio Systems Limited
2017-05-30 13:38:04 +00:00
*
2019-04-26 19:27:38 +00:00
* This file is part of srsLTE.
2017-05-30 13:38:04 +00:00
*
2019-04-26 19:27:38 +00:00
* srsLTE is free software: you can redistribute it and/or modify
2017-05-30 13:38:04 +00:00
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
2019-04-26 19:27:38 +00:00
* srsLTE is distributed in the hope that it will be useful,
2017-05-30 13:38:04 +00:00
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* A copy of the GNU Affero General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
#include "srsue/hdr/metrics_stdout.h"
2017-05-30 13:38:04 +00:00
#include <float.h>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <sstream>
#include <stdlib.h>
#include <unistd.h>
2017-05-30 13:38:04 +00:00
#include <stdio.h>
using namespace std;
namespace srsue {
char const* const prefixes[2][9] = {
{
"",
"m",
"u",
"n",
"p",
"f",
"a",
"z",
"y",
},
{
"",
"k",
"M",
"G",
"T",
"P",
"E",
"Z",
"Y",
},
2017-05-30 13:38:04 +00:00
};
void metrics_stdout::set_ue_handle(ue_metrics_interface* ue_)
{
ue = ue_;
}
2017-05-30 13:38:04 +00:00
void metrics_stdout::toggle_print(bool b)
{
do_print = b;
}
metrics_stdout: print new table header if neighbour cells change this fixes an issue where the stdout metrics isn't readable if the only neighbour cell gets removed during the 10s where no table header is printed. --------Signal--------------Neighbor----DL-------------------------------------UL---------------------- cc pci rsrp pl cfo pci rsrp mcs snr turbo brate bler ta_us mcs buff brate bler 0 2 -66 61 -3.3k 1 -76 11 18 1.1 8.4M 3% 0.0 21 262 167k 0% 0 2 -65 60 -3.3k 1 -76 12 19 1.1 9.6M 2% 0.0 22 476 214k 0% 0 2 -65 60 -3.3k 1 -76 16 22 1.3 13M 3% 0.0 23 1.1k 734k 0% 0 2 -64 59 -3.3k 1 -76 17 23 1.3 15M 2% 0.0 23 602 424k 0% 0 2 -63 58 -3.3k 1 -77 20 25 1.4 19M 3% 0.0 23 501 304k 0% 0 2 -62 57 -3.3k 1 -77 22 27 1.8 20M 10% 0.0 22 417 418k 0% 0 2 -61 56 -3.3k 1 -77 24 28 1.8 25M 9% 0.0 23 396 439k 0% 0 2 -61 56 -3.3k 1 -77 26 29 1.5 23M 22% 0.0 23 841 407k 0% 0 2 -60 55 -3.3k 1 -77 27 31 1.3 27M 11% 0.0 23 890 1.1M 0% 0 2 -59 54 -3.3k 1 -77 27 32 1.00 30M 3% 0.0 23 583 524k 0% 0 2 -59 54 -3.3k 1 -77 27 32 0.92 32M 1% 0.0 23 1.1k 503k 0% --------Signal--------------DL-------------------------------------UL---------------------- cc pci rsrp pl cfo mcs snr turbo brate bler ta_us mcs buff brate bler 0 2 -59 54 -3.3k 27 31 1.1 30M 4% 0.0 23 1.2k 529k 0% 0 2 -60 55 -3.3k 27 30 1.4 25M 18% 0.0 23 540 442k 0% 0 2 -61 56 -3.3k 26 29 1.6 23M 21% 0.0 23 536 429k 0% 0 2 -62 57 -3.3k 24 28 1.8 23M 13% 0.0 23 834 456k 0% 0 2 -62 57 -3.3k 1 -78 21 26 1.6 20M 7% 0.0 23 723 425k 0% 0 2 -63 58 -3.3k 1 -76 17 22 1.1 15M 3% 0.0 23 470 267k 0% 0 2 -64 59 -3.3k 1 -77 17 22 1.3 15M 3% 0.0 23 167 280k 0% 0 2 -65 60 -3.3k 1 -76 14 21 1.3 11M 2% 0.0 22 57 223k 0% 0 2 -65 60 -3.3k 1 -76 12 19 1.2 9.0M 3% 0.0 21 135 182k 0% 0 2 -66 61 -3.4k 1 -70 9.3 17 1.0 6.9M 2% 0.0 21 246 126k 0% 0 2 -67 62 -3.3k 1 -75 8.2 16 1.1 4.9M 3% 0.0 20 0.0 122k 0%
2020-09-30 14:29:31 +00:00
void metrics_stdout::print_table(const bool display_neighbours)
{
if (display_neighbours) {
cout << "--------Signal-------------Neighbour--DL-------------------------------------UL----------------------"
<< endl;
cout << "cc pci rsrp pl cfo pci rsrp mcs snr turbo brate bler ta_us mcs buff brate bler"
<< endl;
} else {
cout << "--------Signal--------------DL-------------------------------------UL----------------------" << endl;
cout << "cc pci rsrp pl cfo mcs snr turbo brate bler ta_us mcs buff brate bler" << endl;
}
table_has_neighbours = display_neighbours;
n_reports = 0;
metrics_stdout: print new table header if neighbour cells change this fixes an issue where the stdout metrics isn't readable if the only neighbour cell gets removed during the 10s where no table header is printed. --------Signal--------------Neighbor----DL-------------------------------------UL---------------------- cc pci rsrp pl cfo pci rsrp mcs snr turbo brate bler ta_us mcs buff brate bler 0 2 -66 61 -3.3k 1 -76 11 18 1.1 8.4M 3% 0.0 21 262 167k 0% 0 2 -65 60 -3.3k 1 -76 12 19 1.1 9.6M 2% 0.0 22 476 214k 0% 0 2 -65 60 -3.3k 1 -76 16 22 1.3 13M 3% 0.0 23 1.1k 734k 0% 0 2 -64 59 -3.3k 1 -76 17 23 1.3 15M 2% 0.0 23 602 424k 0% 0 2 -63 58 -3.3k 1 -77 20 25 1.4 19M 3% 0.0 23 501 304k 0% 0 2 -62 57 -3.3k 1 -77 22 27 1.8 20M 10% 0.0 22 417 418k 0% 0 2 -61 56 -3.3k 1 -77 24 28 1.8 25M 9% 0.0 23 396 439k 0% 0 2 -61 56 -3.3k 1 -77 26 29 1.5 23M 22% 0.0 23 841 407k 0% 0 2 -60 55 -3.3k 1 -77 27 31 1.3 27M 11% 0.0 23 890 1.1M 0% 0 2 -59 54 -3.3k 1 -77 27 32 1.00 30M 3% 0.0 23 583 524k 0% 0 2 -59 54 -3.3k 1 -77 27 32 0.92 32M 1% 0.0 23 1.1k 503k 0% --------Signal--------------DL-------------------------------------UL---------------------- cc pci rsrp pl cfo mcs snr turbo brate bler ta_us mcs buff brate bler 0 2 -59 54 -3.3k 27 31 1.1 30M 4% 0.0 23 1.2k 529k 0% 0 2 -60 55 -3.3k 27 30 1.4 25M 18% 0.0 23 540 442k 0% 0 2 -61 56 -3.3k 26 29 1.6 23M 21% 0.0 23 536 429k 0% 0 2 -62 57 -3.3k 24 28 1.8 23M 13% 0.0 23 834 456k 0% 0 2 -62 57 -3.3k 1 -78 21 26 1.6 20M 7% 0.0 23 723 425k 0% 0 2 -63 58 -3.3k 1 -76 17 22 1.1 15M 3% 0.0 23 470 267k 0% 0 2 -64 59 -3.3k 1 -77 17 22 1.3 15M 3% 0.0 23 167 280k 0% 0 2 -65 60 -3.3k 1 -76 14 21 1.3 11M 2% 0.0 22 57 223k 0% 0 2 -65 60 -3.3k 1 -76 12 19 1.2 9.0M 3% 0.0 21 135 182k 0% 0 2 -66 61 -3.4k 1 -70 9.3 17 1.0 6.9M 2% 0.0 21 246 126k 0% 0 2 -67 62 -3.3k 1 -75 8.2 16 1.1 4.9M 3% 0.0 20 0.0 122k 0%
2020-09-30 14:29:31 +00:00
}
2020-01-13 12:14:46 +00:00
void metrics_stdout::set_metrics(const ue_metrics_t& metrics, const uint32_t period_usec)
2017-05-30 13:38:04 +00:00
{
2019-12-03 09:34:00 +00:00
if (ue == nullptr) {
return;
2019-09-24 12:49:03 +00:00
}
// always print RF error
if (metrics.rf.rf_error) {
printf("RF status: O=%d, U=%d, L=%d\n", metrics.rf.rf_o, metrics.rf.rf_u, metrics.rf.rf_l);
}
if (!do_print) {
return;
}
if (metrics.stack.rrc.state != RRC_STATE_CONNECTED) {
cout << "--- disconnected ---" << endl;
2017-05-30 13:38:04 +00:00
return;
}
2017-05-30 13:38:04 +00:00
bool display_neighbours = false;
if (metrics.phy.nof_active_cc > 1) {
display_neighbours = metrics.stack.rrc.neighbour_cells.size() > metrics.phy.nof_active_cc - 1;
} else {
display_neighbours = metrics.stack.rrc.neighbour_cells.size() > 0;
}
metrics_stdout: print new table header if neighbour cells change this fixes an issue where the stdout metrics isn't readable if the only neighbour cell gets removed during the 10s where no table header is printed. --------Signal--------------Neighbor----DL-------------------------------------UL---------------------- cc pci rsrp pl cfo pci rsrp mcs snr turbo brate bler ta_us mcs buff brate bler 0 2 -66 61 -3.3k 1 -76 11 18 1.1 8.4M 3% 0.0 21 262 167k 0% 0 2 -65 60 -3.3k 1 -76 12 19 1.1 9.6M 2% 0.0 22 476 214k 0% 0 2 -65 60 -3.3k 1 -76 16 22 1.3 13M 3% 0.0 23 1.1k 734k 0% 0 2 -64 59 -3.3k 1 -76 17 23 1.3 15M 2% 0.0 23 602 424k 0% 0 2 -63 58 -3.3k 1 -77 20 25 1.4 19M 3% 0.0 23 501 304k 0% 0 2 -62 57 -3.3k 1 -77 22 27 1.8 20M 10% 0.0 22 417 418k 0% 0 2 -61 56 -3.3k 1 -77 24 28 1.8 25M 9% 0.0 23 396 439k 0% 0 2 -61 56 -3.3k 1 -77 26 29 1.5 23M 22% 0.0 23 841 407k 0% 0 2 -60 55 -3.3k 1 -77 27 31 1.3 27M 11% 0.0 23 890 1.1M 0% 0 2 -59 54 -3.3k 1 -77 27 32 1.00 30M 3% 0.0 23 583 524k 0% 0 2 -59 54 -3.3k 1 -77 27 32 0.92 32M 1% 0.0 23 1.1k 503k 0% --------Signal--------------DL-------------------------------------UL---------------------- cc pci rsrp pl cfo mcs snr turbo brate bler ta_us mcs buff brate bler 0 2 -59 54 -3.3k 27 31 1.1 30M 4% 0.0 23 1.2k 529k 0% 0 2 -60 55 -3.3k 27 30 1.4 25M 18% 0.0 23 540 442k 0% 0 2 -61 56 -3.3k 26 29 1.6 23M 21% 0.0 23 536 429k 0% 0 2 -62 57 -3.3k 24 28 1.8 23M 13% 0.0 23 834 456k 0% 0 2 -62 57 -3.3k 1 -78 21 26 1.6 20M 7% 0.0 23 723 425k 0% 0 2 -63 58 -3.3k 1 -76 17 22 1.1 15M 3% 0.0 23 470 267k 0% 0 2 -64 59 -3.3k 1 -77 17 22 1.3 15M 3% 0.0 23 167 280k 0% 0 2 -65 60 -3.3k 1 -76 14 21 1.3 11M 2% 0.0 22 57 223k 0% 0 2 -65 60 -3.3k 1 -76 12 19 1.2 9.0M 3% 0.0 21 135 182k 0% 0 2 -66 61 -3.4k 1 -70 9.3 17 1.0 6.9M 2% 0.0 21 246 126k 0% 0 2 -67 62 -3.3k 1 -75 8.2 16 1.1 4.9M 3% 0.0 20 0.0 122k 0%
2020-09-30 14:29:31 +00:00
// print table header every 10 reports
if (++n_reports > 10) {
metrics_stdout: print new table header if neighbour cells change this fixes an issue where the stdout metrics isn't readable if the only neighbour cell gets removed during the 10s where no table header is printed. --------Signal--------------Neighbor----DL-------------------------------------UL---------------------- cc pci rsrp pl cfo pci rsrp mcs snr turbo brate bler ta_us mcs buff brate bler 0 2 -66 61 -3.3k 1 -76 11 18 1.1 8.4M 3% 0.0 21 262 167k 0% 0 2 -65 60 -3.3k 1 -76 12 19 1.1 9.6M 2% 0.0 22 476 214k 0% 0 2 -65 60 -3.3k 1 -76 16 22 1.3 13M 3% 0.0 23 1.1k 734k 0% 0 2 -64 59 -3.3k 1 -76 17 23 1.3 15M 2% 0.0 23 602 424k 0% 0 2 -63 58 -3.3k 1 -77 20 25 1.4 19M 3% 0.0 23 501 304k 0% 0 2 -62 57 -3.3k 1 -77 22 27 1.8 20M 10% 0.0 22 417 418k 0% 0 2 -61 56 -3.3k 1 -77 24 28 1.8 25M 9% 0.0 23 396 439k 0% 0 2 -61 56 -3.3k 1 -77 26 29 1.5 23M 22% 0.0 23 841 407k 0% 0 2 -60 55 -3.3k 1 -77 27 31 1.3 27M 11% 0.0 23 890 1.1M 0% 0 2 -59 54 -3.3k 1 -77 27 32 1.00 30M 3% 0.0 23 583 524k 0% 0 2 -59 54 -3.3k 1 -77 27 32 0.92 32M 1% 0.0 23 1.1k 503k 0% --------Signal--------------DL-------------------------------------UL---------------------- cc pci rsrp pl cfo mcs snr turbo brate bler ta_us mcs buff brate bler 0 2 -59 54 -3.3k 27 31 1.1 30M 4% 0.0 23 1.2k 529k 0% 0 2 -60 55 -3.3k 27 30 1.4 25M 18% 0.0 23 540 442k 0% 0 2 -61 56 -3.3k 26 29 1.6 23M 21% 0.0 23 536 429k 0% 0 2 -62 57 -3.3k 24 28 1.8 23M 13% 0.0 23 834 456k 0% 0 2 -62 57 -3.3k 1 -78 21 26 1.6 20M 7% 0.0 23 723 425k 0% 0 2 -63 58 -3.3k 1 -76 17 22 1.1 15M 3% 0.0 23 470 267k 0% 0 2 -64 59 -3.3k 1 -77 17 22 1.3 15M 3% 0.0 23 167 280k 0% 0 2 -65 60 -3.3k 1 -76 14 21 1.3 11M 2% 0.0 22 57 223k 0% 0 2 -65 60 -3.3k 1 -76 12 19 1.2 9.0M 3% 0.0 21 135 182k 0% 0 2 -66 61 -3.4k 1 -70 9.3 17 1.0 6.9M 2% 0.0 21 246 126k 0% 0 2 -67 62 -3.3k 1 -75 8.2 16 1.1 4.9M 3% 0.0 20 0.0 122k 0%
2020-09-30 14:29:31 +00:00
print_table(display_neighbours);
2017-05-30 13:38:04 +00:00
}
metrics_stdout: print new table header if neighbour cells change this fixes an issue where the stdout metrics isn't readable if the only neighbour cell gets removed during the 10s where no table header is printed. --------Signal--------------Neighbor----DL-------------------------------------UL---------------------- cc pci rsrp pl cfo pci rsrp mcs snr turbo brate bler ta_us mcs buff brate bler 0 2 -66 61 -3.3k 1 -76 11 18 1.1 8.4M 3% 0.0 21 262 167k 0% 0 2 -65 60 -3.3k 1 -76 12 19 1.1 9.6M 2% 0.0 22 476 214k 0% 0 2 -65 60 -3.3k 1 -76 16 22 1.3 13M 3% 0.0 23 1.1k 734k 0% 0 2 -64 59 -3.3k 1 -76 17 23 1.3 15M 2% 0.0 23 602 424k 0% 0 2 -63 58 -3.3k 1 -77 20 25 1.4 19M 3% 0.0 23 501 304k 0% 0 2 -62 57 -3.3k 1 -77 22 27 1.8 20M 10% 0.0 22 417 418k 0% 0 2 -61 56 -3.3k 1 -77 24 28 1.8 25M 9% 0.0 23 396 439k 0% 0 2 -61 56 -3.3k 1 -77 26 29 1.5 23M 22% 0.0 23 841 407k 0% 0 2 -60 55 -3.3k 1 -77 27 31 1.3 27M 11% 0.0 23 890 1.1M 0% 0 2 -59 54 -3.3k 1 -77 27 32 1.00 30M 3% 0.0 23 583 524k 0% 0 2 -59 54 -3.3k 1 -77 27 32 0.92 32M 1% 0.0 23 1.1k 503k 0% --------Signal--------------DL-------------------------------------UL---------------------- cc pci rsrp pl cfo mcs snr turbo brate bler ta_us mcs buff brate bler 0 2 -59 54 -3.3k 27 31 1.1 30M 4% 0.0 23 1.2k 529k 0% 0 2 -60 55 -3.3k 27 30 1.4 25M 18% 0.0 23 540 442k 0% 0 2 -61 56 -3.3k 26 29 1.6 23M 21% 0.0 23 536 429k 0% 0 2 -62 57 -3.3k 24 28 1.8 23M 13% 0.0 23 834 456k 0% 0 2 -62 57 -3.3k 1 -78 21 26 1.6 20M 7% 0.0 23 723 425k 0% 0 2 -63 58 -3.3k 1 -76 17 22 1.1 15M 3% 0.0 23 470 267k 0% 0 2 -64 59 -3.3k 1 -77 17 22 1.3 15M 3% 0.0 23 167 280k 0% 0 2 -65 60 -3.3k 1 -76 14 21 1.3 11M 2% 0.0 22 57 223k 0% 0 2 -65 60 -3.3k 1 -76 12 19 1.2 9.0M 3% 0.0 21 135 182k 0% 0 2 -66 61 -3.4k 1 -70 9.3 17 1.0 6.9M 2% 0.0 21 246 126k 0% 0 2 -67 62 -3.3k 1 -75 8.2 16 1.1 4.9M 3% 0.0 20 0.0 122k 0%
2020-09-30 14:29:31 +00:00
// also print table header if neighbours are added/removed in between
if (display_neighbours != table_has_neighbours) {
print_table(display_neighbours);
}
2019-04-23 08:53:11 +00:00
for (uint32_t r = 0; r < metrics.phy.nof_active_cc; r++) {
2019-12-03 09:34:00 +00:00
cout << std::setw(2) << r;
cout << std::setw(4) << metrics.phy.info[r].pci << std::setw(0);
cout << float_to_string(metrics.phy.ch[r].rsrp, 2);
cout << float_to_string(metrics.phy.ch[r].pathloss, 2);
cout << float_to_eng_string(metrics.phy.sync[r].cfo, 2);
// Find strongest neighbour for this EARFCN (cells are ordered)
if (display_neighbours) {
bool has_neighbour = false;
for (auto& c : metrics.stack.rrc.neighbour_cells) {
if (c.earfcn == metrics.phy.info[r].dl_earfcn && c.pci != metrics.phy.info[r].pci) {
cout << std::setw(4) << c.pci << std::setw(0);
cout << float_to_string(c.rsrp, 2);
has_neighbour = true;
break;
}
}
if (!has_neighbour) {
cout << " n/a";
cout << " n/a";
}
}
2019-04-23 08:53:11 +00:00
cout << float_to_string(metrics.phy.dl[r].mcs, 2);
cout << float_to_string(metrics.phy.ch[r].sinr, 2);
2019-04-23 08:53:11 +00:00
cout << float_to_string(metrics.phy.dl[r].turbo_iters, 2);
cout << float_to_eng_string((float)metrics.stack.mac[r].rx_brate / (metrics.stack.mac[r].nof_tti * 1e-3), 2);
if (metrics.stack.mac[r].rx_pkts > 0) {
cout << float_to_string((float)100 * metrics.stack.mac[r].rx_errors / metrics.stack.mac[r].rx_pkts, 1) << "%";
2019-04-23 08:53:11 +00:00
} else {
cout << float_to_string(0, 1) << "%";
}
cout << float_to_string(metrics.phy.sync[r].ta_us, 2);
2019-04-23 08:53:11 +00:00
cout << float_to_string(metrics.phy.ul[r].mcs, 2);
cout << float_to_eng_string((float)metrics.stack.mac[r].ul_buffer, 2);
cout << float_to_eng_string((float)metrics.stack.mac[r].tx_brate / (metrics.stack.mac[r].nof_tti * 1e-3), 2);
if (metrics.stack.mac[r].tx_pkts > 0) {
cout << float_to_string((float)100 * metrics.stack.mac[r].tx_errors / metrics.stack.mac[r].tx_pkts, 1) << "%";
2019-04-23 08:53:11 +00:00
} else {
cout << float_to_string(0, 1) << "%";
}
cout << endl;
2017-05-30 13:38:04 +00:00
}
2019-04-23 08:53:11 +00:00
if (metrics.rf.rf_error) {
2017-05-30 13:38:04 +00:00
printf("RF status: O=%d, U=%d, L=%d\n", metrics.rf.rf_o, metrics.rf.rf_u, metrics.rf.rf_l);
}
}
std::string metrics_stdout::float_to_string(float f, int digits)
{
std::ostringstream os;
const int precision =
SRSLTE_MIN((int)((f == 0.0f || f == 100.0f) ? digits - 1 : digits - log10f(fabsf(f)) - 2 * FLT_EPSILON), 3);
2017-05-30 13:38:04 +00:00
os << std::setw(6) << std::fixed << std::setprecision(precision) << f;
return os.str();
}
std::string metrics_stdout::float_to_eng_string(float f, int digits)
{
const int degree = (f == 0.0) ? 0 : lrint(floor(log10f(fabs(f)) / 3));
2017-05-30 13:38:04 +00:00
std::string factor;
2019-02-21 15:27:53 +00:00
if (abs(degree) < 9) {
if (degree < 0)
factor = prefixes[0][abs(degree)];
2017-05-30 13:38:04 +00:00
else
factor = prefixes[1][abs(degree)];
2017-05-30 13:38:04 +00:00
} else {
return "failed";
}
const double scaled = f * pow(1000.0, -degree);
2017-05-30 13:38:04 +00:00
if (degree != 0) {
return float_to_string(scaled, digits) + factor;
} else {
return " " + float_to_string(scaled, digits) + factor;
}
}
} // namespace srsue