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.
204 lines
6.2 KiB
C
204 lines
6.2 KiB
C
5 years ago
|
/*
|
||
5 years ago
|
* Copyright 2013-2020 Software Radio Systems Limited
|
||
5 years ago
|
*
|
||
|
* This file is part of srsLTE.
|
||
|
*
|
||
|
* srsLTE is free software: you can redistribute it and/or modify
|
||
|
* 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.
|
||
|
*
|
||
|
* srsLTE is distributed in the hope that it will be useful,
|
||
|
* 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/.
|
||
|
*
|
||
|
*/
|
||
|
|
||
4 years ago
|
#ifndef SRSLTE_SCHED_TEST_COMMON_H
|
||
|
#define SRSLTE_SCHED_TEST_COMMON_H
|
||
5 years ago
|
|
||
4 years ago
|
#include "sched_sim_ue.h"
|
||
4 years ago
|
#include "sched_test_utils.h"
|
||
|
#include "srsenb/hdr/stack/mac/sched.h"
|
||
5 years ago
|
#include <random>
|
||
5 years ago
|
|
||
|
namespace srsenb {
|
||
|
|
||
5 years ago
|
/***************************
|
||
|
* Random Utils
|
||
|
**************************/
|
||
|
|
||
|
void set_randseed(uint64_t seed);
|
||
|
float randf();
|
||
|
std::default_random_engine& get_rand_gen();
|
||
|
|
||
|
/**************************
|
||
|
* Testers
|
||
|
*************************/
|
||
|
|
||
5 years ago
|
using dl_sched_res_list = std::vector<sched_interface::dl_sched_res_t>;
|
||
|
using ul_sched_res_list = std::vector<sched_interface::ul_sched_res_t>;
|
||
|
|
||
5 years ago
|
struct ue_ctxt_test {
|
||
5 years ago
|
// args
|
||
5 years ago
|
srslte::log_ref log_h{"TEST"};
|
||
|
ue_ctxt_test_cfg sim_cfg;
|
||
5 years ago
|
|
||
5 years ago
|
// prach args
|
||
|
uint16_t rnti;
|
||
|
|
||
|
/* state */
|
||
5 years ago
|
srsenb::sched_interface::ue_cfg_t user_cfg;
|
||
|
srslte::tti_point current_tti_rx;
|
||
5 years ago
|
|
||
5 years ago
|
struct cc_ue_ctxt_test {
|
||
5 years ago
|
uint32_t ue_cc_idx = 0;
|
||
|
uint32_t enb_cc_idx = 0;
|
||
|
};
|
||
5 years ago
|
std::vector<cc_ue_ctxt_test> active_ccs;
|
||
4 years ago
|
ue_sim* ue_ctxt;
|
||
5 years ago
|
|
||
5 years ago
|
bool drb_cfg_flag = false;
|
||
5 years ago
|
|
||
4 years ago
|
ue_ctxt_test(uint16_t rnti_, srslte::tti_point prach_tti, const ue_ctxt_test_cfg& cfg_, ue_sim& ue_ctxt_);
|
||
5 years ago
|
|
||
|
int set_cfg(const sched::ue_cfg_t& ue_cfg_);
|
||
|
cc_ue_ctxt_test* get_cc_state(uint32_t enb_cc_idx);
|
||
5 years ago
|
|
||
|
int new_tti(sched* sched_ptr, srslte::tti_point tti_rx);
|
||
5 years ago
|
int test_sched_result(uint32_t enb_cc_idx,
|
||
|
const sched::dl_sched_res_t& dl_result,
|
||
|
const sched::ul_sched_res_t& ul_result);
|
||
5 years ago
|
|
||
|
private:
|
||
|
int fwd_pending_acks(sched* sched_ptr);
|
||
|
|
||
|
struct cc_result {
|
||
|
uint32_t enb_cc_idx;
|
||
|
const sched::dl_sched_res_t* dl_result;
|
||
|
const sched::ul_sched_res_t* ul_result;
|
||
|
};
|
||
5 years ago
|
//! Test correct activation of SCells
|
||
|
int test_scell_activation(cc_result result);
|
||
5 years ago
|
int schedule_acks(cc_result result);
|
||
|
|
||
|
struct pending_ack_t {
|
||
|
srslte::tti_point tti_ack;
|
||
|
uint32_t cc_idx, ue_cc_idx, tb, pid;
|
||
|
bool ack;
|
||
|
bool operator<(const pending_ack_t& other) const { return tti_ack > other.tti_ack; }
|
||
|
};
|
||
5 years ago
|
std::priority_queue<pending_ack_t> pending_dl_acks, pending_ul_acks;
|
||
5 years ago
|
};
|
||
|
|
||
5 years ago
|
class user_state_sched_tester
|
||
|
{
|
||
|
public:
|
||
|
explicit user_state_sched_tester(const std::vector<srsenb::sched::cell_cfg_t>& cell_params_) :
|
||
|
cell_params(cell_params_)
|
||
5 years ago
|
{}
|
||
5 years ago
|
|
||
5 years ago
|
void new_tti(sched* sched_ptr, uint32_t tti_rx);
|
||
|
bool user_exists(uint16_t rnti) const { return users.find(rnti) != users.end(); }
|
||
5 years ago
|
const ue_ctxt_test* get_user_ctxt(uint16_t rnti) const
|
||
5 years ago
|
{
|
||
|
return users.count(rnti) > 0 ? &users.find(rnti)->second : nullptr;
|
||
|
}
|
||
5 years ago
|
const sched::ue_cfg_t* get_user_cfg(uint16_t rnti) const
|
||
|
{
|
||
|
return users.count(rnti) > 0 ? &users.find(rnti)->second.user_cfg : nullptr;
|
||
|
}
|
||
5 years ago
|
|
||
5 years ago
|
/* Config users */
|
||
5 years ago
|
int add_user(uint16_t rnti, uint32_t preamble_idx, const ue_ctxt_test_cfg& cfg);
|
||
5 years ago
|
int user_reconf(uint16_t rnti, const srsenb::sched_interface::ue_cfg_t& ue_cfg);
|
||
|
int bearer_cfg(uint16_t rnti, uint32_t lcid, const srsenb::sched_interface::ue_bearer_cfg_t& bearer_cfg);
|
||
5 years ago
|
void rem_user(uint16_t rnti);
|
||
|
|
||
4 years ago
|
int test_all(const sf_output_res_t& sf_out);
|
||
5 years ago
|
|
||
|
private:
|
||
5 years ago
|
const std::vector<srsenb::sched::cell_cfg_t>& cell_params;
|
||
5 years ago
|
|
||
4 years ago
|
ue_db_sim sim_users;
|
||
5 years ago
|
std::map<uint16_t, ue_ctxt_test> users;
|
||
5 years ago
|
srslte::tti_point tic;
|
||
5 years ago
|
};
|
||
|
|
||
5 years ago
|
class sched_result_stats
|
||
|
{
|
||
|
public:
|
||
|
explicit sched_result_stats(std::vector<srsenb::sched::cell_cfg_t> cell_params_) :
|
||
|
cell_params(std::move(cell_params_))
|
||
5 years ago
|
{}
|
||
5 years ago
|
|
||
|
void process_results(const tti_params_t& tti_params,
|
||
|
const std::vector<sched_interface::dl_sched_res_t>& dl_result,
|
||
|
const std::vector<sched_interface::ul_sched_res_t>& ul_result);
|
||
|
|
||
|
struct user_stats {
|
||
|
uint16_t rnti;
|
||
|
std::vector<uint64_t> tot_dl_sched_data; // includes retxs
|
||
|
std::vector<uint64_t> tot_ul_sched_data;
|
||
|
};
|
||
|
|
||
|
std::map<uint16_t, user_stats> users;
|
||
|
|
||
|
private:
|
||
|
user_stats* get_user(uint16_t rnti);
|
||
|
|
||
|
const std::vector<srsenb::sched::cell_cfg_t> cell_params;
|
||
|
};
|
||
|
|
||
5 years ago
|
// Intrusive Scheduler Tester
|
||
|
class common_sched_tester : public sched
|
||
|
{
|
||
|
public:
|
||
|
struct tti_info_t {
|
||
|
tti_params_t tti_params{10241};
|
||
|
uint32_t nof_prachs = 0;
|
||
|
std::vector<sched_interface::dl_sched_res_t> dl_sched_result;
|
||
|
std::vector<sched_interface::ul_sched_res_t> ul_sched_result;
|
||
|
};
|
||
|
|
||
5 years ago
|
~common_sched_tester() override = default;
|
||
|
|
||
5 years ago
|
const ue_cfg_t* get_current_ue_cfg(uint16_t rnti) const;
|
||
|
|
||
5 years ago
|
int sim_cfg(sim_sched_args args);
|
||
5 years ago
|
virtual int add_user(uint16_t rnti, const ue_ctxt_test_cfg& ue_cfg_);
|
||
4 years ago
|
virtual int reconf_user(uint16_t rnti, const sched_interface::ue_cfg_t& ue_cfg_);
|
||
5 years ago
|
virtual void rem_user(uint16_t rnti);
|
||
|
virtual int process_results();
|
||
|
int process_tti_events(const tti_ev& tti_ev);
|
||
5 years ago
|
|
||
5 years ago
|
int test_next_ttis(const std::vector<tti_ev>& tti_events);
|
||
|
int run_tti(const tti_ev& tti_events);
|
||
5 years ago
|
|
||
|
// args
|
||
|
sim_sched_args sim_args0; ///< arguments used to generate TTI events
|
||
|
srslte::log* tester_log = nullptr;
|
||
|
|
||
|
// tti specific params
|
||
5 years ago
|
tti_info_t tti_info;
|
||
|
srslte::tti_point tic;
|
||
|
uint32_t tti_count = 0;
|
||
5 years ago
|
|
||
|
// testers
|
||
|
std::unique_ptr<user_state_sched_tester> ue_tester;
|
||
|
std::unique_ptr<sched_result_stats> sched_stats;
|
||
|
|
||
|
protected:
|
||
5 years ago
|
virtual void new_test_tti();
|
||
|
virtual void before_sched() {}
|
||
5 years ago
|
};
|
||
|
|
||
5 years ago
|
} // namespace srsenb
|
||
|
|
||
4 years ago
|
#endif // SRSLTE_SCHED_TEST_COMMON_H
|