mirror of https://github.com/pvnis/srsRAN_4G.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
139 lines
3.1 KiB
C++
139 lines
3.1 KiB
C++
4 years ago
|
/**
|
||
7 years ago
|
*
|
||
4 years ago
|
* \section COPYRIGHT
|
||
7 years ago
|
*
|
||
4 years ago
|
* Copyright 2013-2021 Software Radio Systems Limited
|
||
7 years ago
|
*
|
||
4 years ago
|
* By using this file, you agree to the terms and conditions set
|
||
|
* forth in the LICENSE file which can be found at the top level of
|
||
|
* the distribution.
|
||
7 years ago
|
*
|
||
|
*/
|
||
|
|
||
4 years ago
|
#include "srsran/common/metrics_hub.h"
|
||
|
#include "srsran/srsran.h"
|
||
6 years ago
|
#include "srsue/hdr/metrics_csv.h"
|
||
|
#include "srsue/hdr/metrics_stdout.h"
|
||
|
#include "srsue/hdr/ue_metrics_interface.h"
|
||
7 years ago
|
#include <iostream>
|
||
7 years ago
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
7 years ago
|
#include <strings.h>
|
||
|
#include <unistd.h>
|
||
|
|
||
|
using namespace srsue;
|
||
|
|
||
|
namespace srsue {
|
||
|
|
||
5 years ago
|
char* csv_file_name = NULL;
|
||
7 years ago
|
|
||
7 years ago
|
// fake classes
|
||
|
class ue_dummy : public ue_metrics_interface
|
||
|
{
|
||
|
public:
|
||
6 years ago
|
bool get_metrics(ue_metrics_t* m)
|
||
7 years ago
|
{
|
||
4 years ago
|
*m = {};
|
||
|
|
||
7 years ago
|
// fill dummy values
|
||
6 years ago
|
m->rf.rf_o = 10;
|
||
|
m->phy.nof_active_cc = 2;
|
||
4 years ago
|
m->phy.ch[0].rsrp = -10.0f;
|
||
|
m->phy.ch[0].pathloss = 74;
|
||
6 years ago
|
m->stack.mac[0].rx_pkts = 100;
|
||
|
m->stack.mac[0].rx_errors = 0;
|
||
4 years ago
|
m->stack.mac[0].rx_brate = 200;
|
||
|
m->stack.mac[0].nof_tti = 1;
|
||
6 years ago
|
|
||
4 years ago
|
m->phy.info[1].pci = UINT32_MAX;
|
||
6 years ago
|
m->stack.mac[1].rx_pkts = 100;
|
||
4 years ago
|
m->stack.mac[1].rx_errors = 100;
|
||
4 years ago
|
m->stack.mac[1].rx_brate = 150;
|
||
|
m->stack.mac[1].nof_tti = 1;
|
||
|
|
||
|
// random neighbour cells
|
||
|
if (rand() % 2 == 0) {
|
||
4 years ago
|
phy_meas_t neighbor = {};
|
||
4 years ago
|
neighbor.pci = 8;
|
||
|
neighbor.rsrp = -33;
|
||
4 years ago
|
m->stack.rrc.neighbour_cells.push_back(neighbor);
|
||
|
m->stack.rrc.neighbour_cells.push_back(neighbor); // need to add twice since we use CA
|
||
|
}
|
||
6 years ago
|
|
||
4 years ago
|
m->phy.nof_active_cc = 1;
|
||
|
m->phy.ch[0].rsrp = -10.0f;
|
||
|
m->phy.ch[0].pathloss = 32;
|
||
4 years ago
|
m->stack.mac_nr[0].rx_pkts = 100;
|
||
|
m->stack.mac_nr[0].rx_errors = 2;
|
||
|
m->stack.mac_nr[0].rx_brate = 223;
|
||
|
m->stack.mac_nr[0].nof_tti = 1;
|
||
|
|
||
4 years ago
|
m->stack.rrc.state = (rand() % 2 == 0) ? RRC_STATE_CONNECTED : RRC_STATE_IDLE;
|
||
5 years ago
|
|
||
7 years ago
|
return true;
|
||
|
}
|
||
|
};
|
||
4 years ago
|
|
||
5 years ago
|
} // namespace srsue
|
||
7 years ago
|
|
||
5 years ago
|
void usage(char* prog)
|
||
|
{
|
||
7 years ago
|
printf("Usage: %s -o csv_output_file\n", prog);
|
||
|
}
|
||
|
|
||
5 years ago
|
void parse_args(int argc, char** argv)
|
||
|
{
|
||
7 years ago
|
int opt;
|
||
|
|
||
|
while ((opt = getopt(argc, argv, "o")) != -1) {
|
||
5 years ago
|
switch (opt) {
|
||
7 years ago
|
case 'o':
|
||
|
csv_file_name = argv[optind];
|
||
|
break;
|
||
|
default:
|
||
|
usage(argv[0]);
|
||
|
exit(-1);
|
||
|
}
|
||
|
}
|
||
|
if (!csv_file_name) {
|
||
|
usage(argv[0]);
|
||
|
exit(-1);
|
||
|
}
|
||
|
}
|
||
|
|
||
5 years ago
|
int main(int argc, char** argv)
|
||
7 years ago
|
{
|
||
5 years ago
|
float period = 1.0;
|
||
7 years ago
|
ue_dummy ue;
|
||
|
|
||
7 years ago
|
if (argc < 3) {
|
||
|
usage(argv[0]);
|
||
|
exit(-1);
|
||
|
}
|
||
|
|
||
5 years ago
|
parse_args(argc, argv);
|
||
7 years ago
|
|
||
7 years ago
|
// the default metrics type for stdout output
|
||
|
metrics_stdout metrics_screen;
|
||
|
metrics_screen.set_ue_handle(&ue);
|
||
|
|
||
7 years ago
|
// the CSV file writer
|
||
|
metrics_csv metrics_file(csv_file_name);
|
||
|
metrics_file.set_ue_handle(&ue);
|
||
|
|
||
7 years ago
|
// create metrics hub and register metrics for stdout
|
||
4 years ago
|
srsran::metrics_hub<ue_metrics_t> metricshub;
|
||
7 years ago
|
metricshub.init(&ue, period);
|
||
|
metricshub.add_listener(&metrics_screen);
|
||
7 years ago
|
metricshub.add_listener(&metrics_file);
|
||
7 years ago
|
|
||
|
// enable printing
|
||
|
metrics_screen.toggle_print(true);
|
||
|
|
||
4 years ago
|
std::cout << "Running for 5 seconds .." << std::endl;
|
||
|
usleep(5e6);
|
||
7 years ago
|
|
||
|
metricshub.stop();
|
||
|
return 0;
|
||
|
}
|