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.
422 lines
17 KiB
C++
422 lines
17 KiB
C++
6 years ago
|
/*
|
||
5 years ago
|
* Copyright 2013-2020 Software Radio Systems Limited
|
||
6 years ago
|
*
|
||
|
* This file is part of srsLTE.
|
||
|
*
|
||
6 years ago
|
* srsLTE is free software: you can redistribute it and/or modify
|
||
6 years ago
|
* 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.
|
||
|
*
|
||
6 years ago
|
* srsLTE is distributed in the hope that it will be useful,
|
||
6 years ago
|
* 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
|
#include "srsenb/hdr/stack/mac/sched.h"
|
||
|
#include "srsenb/hdr/stack/mac/sched_carrier.h"
|
||
|
#include "srsenb/hdr/stack/mac/sched_ue.h"
|
||
6 years ago
|
#include <algorithm>
|
||
5 years ago
|
#include <chrono>
|
||
6 years ago
|
#include <random>
|
||
6 years ago
|
#include <set>
|
||
|
#include <srslte/srslte.h>
|
||
|
#include <unistd.h>
|
||
|
|
||
|
#include "srsenb/hdr/phy/phy.h"
|
||
6 years ago
|
#include "srsenb/hdr/stack/mac/mac.h"
|
||
6 years ago
|
|
||
|
#include "srslte/common/log_filter.h"
|
||
|
#include "srslte/interfaces/enb_interfaces.h"
|
||
|
#include "srslte/interfaces/sched_interface.h"
|
||
|
#include "srslte/phy/utils/debug.h"
|
||
|
|
||
4 years ago
|
#include "sched_common_test_suite.h"
|
||
4 years ago
|
#include "sched_sim_ue.h"
|
||
4 years ago
|
#include "sched_test_common.h"
|
||
|
#include "sched_test_utils.h"
|
||
5 years ago
|
#include "srslte/common/test_common.h"
|
||
|
|
||
5 years ago
|
using srslte::tti_point;
|
||
|
|
||
5 years ago
|
/********************************************************
|
||
|
* Random Tester for Scheduler.
|
||
|
* Current Checks:
|
||
5 years ago
|
* - Check correct timing of PRACH, RAR, and Msg3
|
||
|
* - Check whether Msg4 contains ConRes
|
||
|
* - Check allocs of users that no longer exist
|
||
|
* - Check collisions in PDCCH, PUSCH, and PDSCH
|
||
|
* - Unexpected Msg3, RAR allocs or with wrong values
|
||
5 years ago
|
* - Users without data to Tx cannot be allocated in UL
|
||
|
* - Retxs always take precedence
|
||
|
* - Invalid BC SIB index or TBS
|
||
|
* - Harqs:
|
||
|
* - invalid pids scheduled
|
||
|
* - empty harqs scheduled
|
||
|
* - invalid harq TTI
|
||
|
* - consistent NCCE loc
|
||
|
* - invalid retx number
|
||
|
* - DL adaptive retx/new tx <=> PDCCH alloc
|
||
|
*******************************************************/
|
||
|
|
||
4 years ago
|
uint32_t const seed = std::chrono::system_clock::now().time_since_epoch().count();
|
||
5 years ago
|
|
||
6 years ago
|
struct ue_stats_t {
|
||
|
uint64_t nof_dl_rbs = 0;
|
||
|
uint64_t nof_ul_rbs = 0;
|
||
|
};
|
||
|
std::map<uint16_t, ue_stats_t> ue_stats;
|
||
|
|
||
|
/*******************
|
||
|
* Logging *
|
||
|
*******************/
|
||
|
|
||
5 years ago
|
class sched_test_log final : public srslte::test_log_filter
|
||
6 years ago
|
{
|
||
|
public:
|
||
5 years ago
|
sched_test_log() : srslte::test_log_filter("TEST") { exit_on_error = true; }
|
||
|
~sched_test_log() override { log_diagnostics(); }
|
||
5 years ago
|
|
||
|
void log_diagnostics() override
|
||
5 years ago
|
{
|
||
5 years ago
|
info("UE stats:\n");
|
||
5 years ago
|
for (auto& e : ue_stats) {
|
||
5 years ago
|
info("0x%x: {DL RBs: %" PRIu64 ", UL RBs: %" PRIu64 "}\n", e.first, e.second.nof_dl_rbs, e.second.nof_ul_rbs);
|
||
5 years ago
|
}
|
||
5 years ago
|
info("Number of assertion warnings: %u\n", warn_counter);
|
||
|
info("Number of assertion errors: %u\n", error_counter);
|
||
|
info("This was the seed: %u\n", seed);
|
||
6 years ago
|
}
|
||
5 years ago
|
};
|
||
5 years ago
|
srslte::scoped_log<sched_test_log> log_global{};
|
||
6 years ago
|
|
||
|
/*******************
|
||
|
* Dummies *
|
||
|
*******************/
|
||
|
|
||
5 years ago
|
constexpr uint32_t CARRIER_IDX = 0;
|
||
|
|
||
6 years ago
|
// Designed for testing purposes
|
||
5 years ago
|
struct sched_tester : public srsenb::common_sched_tester {
|
||
6 years ago
|
struct tester_user_results {
|
||
5 years ago
|
uint32_t dl_pending_data = 0;
|
||
|
uint32_t ul_pending_data = 0; ///< data pending for UL
|
||
|
bool has_dl_tx = false;
|
||
|
bool has_ul_tx = false; ///< has either tx or retx
|
||
|
bool has_ul_retx = false;
|
||
|
bool has_ul_newtx = false; ///< *no* retx, but has tx
|
||
|
bool ul_retx_got_delayed = false;
|
||
5 years ago
|
srsenb::dl_harq_proc dl_harqs[srsenb::cc_sched_ue::SCHED_MAX_HARQ_PROC];
|
||
5 years ago
|
srsenb::ul_harq_proc ul_harq;
|
||
6 years ago
|
};
|
||
|
struct sched_tti_data {
|
||
5 years ago
|
std::map<uint16_t, tester_user_results> ue_data; ///< stores buffer state of each user
|
||
|
tester_user_results total_ues; ///< stores combined UL/DL buffer state
|
||
6 years ago
|
};
|
||
|
|
||
|
// sched results
|
||
5 years ago
|
sched_tti_data tti_data;
|
||
6 years ago
|
|
||
5 years ago
|
void rem_user(uint16_t rnti) override;
|
||
5 years ago
|
int assert_no_empty_allocs();
|
||
|
int test_harqs();
|
||
6 years ago
|
|
||
|
private:
|
||
5 years ago
|
void new_test_tti() override;
|
||
|
void before_sched() override;
|
||
|
int process_results() override;
|
||
4 years ago
|
int update_ue_stats();
|
||
6 years ago
|
};
|
||
|
|
||
|
void sched_tester::rem_user(uint16_t rnti)
|
||
|
{
|
||
5 years ago
|
common_sched_tester::rem_user(rnti);
|
||
6 years ago
|
tti_data.ue_data.erase(rnti);
|
||
|
}
|
||
|
|
||
5 years ago
|
void sched_tester::new_test_tti()
|
||
6 years ago
|
{
|
||
5 years ago
|
common_sched_tester::new_test_tti();
|
||
6 years ago
|
// NOTE: make a local copy, since some of these variables may be cleared during scheduling
|
||
|
tti_data.ue_data.clear();
|
||
5 years ago
|
tti_data.total_ues = tester_user_results();
|
||
6 years ago
|
}
|
||
|
|
||
|
void sched_tester::before_sched()
|
||
|
{
|
||
|
// check pending data buffers
|
||
5 years ago
|
for (auto& it : ue_db) {
|
||
|
uint16_t rnti = it.first;
|
||
|
srsenb::sched_ue* user = &it.second;
|
||
6 years ago
|
tester_user_results d;
|
||
5 years ago
|
srsenb::ul_harq_proc* hul = user->get_ul_harq(tti_info.tti_params.tti_tx_ul, CARRIER_IDX);
|
||
6 years ago
|
d.ul_pending_data = get_ul_buffer(rnti);
|
||
5 years ago
|
// user->get_pending_ul_new_data(tti_info.tti_params.tti_tx_ul) or hul->has_pending_retx(); //
|
||
|
// get_ul_buffer(rnti);
|
||
6 years ago
|
d.dl_pending_data = get_dl_buffer(rnti);
|
||
|
d.has_ul_retx = hul->has_pending_retx();
|
||
|
d.has_ul_tx = d.has_ul_retx or d.ul_pending_data > 0;
|
||
5 years ago
|
srsenb::dl_harq_proc* hdl = user->get_pending_dl_harq(tti_info.tti_params.tti_tx_dl, CARRIER_IDX);
|
||
5 years ago
|
d.has_dl_tx =
|
||
|
(hdl != nullptr) or
|
||
|
(it.second.get_empty_dl_harq(tti_info.tti_params.tti_tx_dl, CARRIER_IDX) != nullptr and d.dl_pending_data > 0);
|
||
5 years ago
|
d.has_ul_newtx = not d.has_ul_retx and d.ul_pending_data > 0;
|
||
6 years ago
|
tti_data.ue_data.insert(std::make_pair(rnti, d));
|
||
|
tti_data.total_ues.dl_pending_data += d.dl_pending_data;
|
||
|
tti_data.total_ues.ul_pending_data += d.ul_pending_data;
|
||
|
tti_data.total_ues.has_ul_tx |= d.has_ul_tx;
|
||
|
tti_data.total_ues.has_dl_tx |= d.has_dl_tx;
|
||
|
tti_data.total_ues.has_ul_newtx |= d.has_ul_newtx;
|
||
|
|
||
5 years ago
|
for (uint32_t i = 0; i < srsenb::cc_sched_ue::SCHED_MAX_HARQ_PROC; ++i) {
|
||
5 years ago
|
const srsenb::dl_harq_proc& h = user->get_dl_harq(i, CARRIER_IDX);
|
||
|
tti_data.ue_data[rnti].dl_harqs[i] = h;
|
||
6 years ago
|
}
|
||
5 years ago
|
// NOTE: ACK might have just cleared the harq for tti_info.tti_params.tti_tx_ul
|
||
|
tti_data.ue_data[rnti].ul_harq = *user->get_ul_harq(tti_info.tti_params.tti_tx_ul, CARRIER_IDX);
|
||
6 years ago
|
}
|
||
|
|
||
|
// TODO: Check whether pending pending_rar.rar_tti correspond to a prach_tti
|
||
|
}
|
||
|
|
||
5 years ago
|
int sched_tester::process_results()
|
||
6 years ago
|
{
|
||
5 years ago
|
const srsenb::cc_sched_result* cc_result =
|
||
|
sched_results.get_cc(srslte::tti_point{tti_info.tti_params.tti_rx}, CARRIER_IDX);
|
||
4 years ago
|
srsenb::sf_output_res_t sf_out{
|
||
|
sched_cell_params, tti_point{tti_info.tti_params.tti_rx}, tti_info.ul_sched_result, tti_info.dl_sched_result};
|
||
5 years ago
|
TESTASSERT(tti_info.tti_params.tti_rx == cc_result->tti_params.tti_rx);
|
||
5 years ago
|
|
||
4 years ago
|
// Common tests
|
||
4 years ago
|
TESTASSERT(test_pdcch_collisions(sf_out, CARRIER_IDX, &cc_result->pdcch_mask) == SRSLTE_SUCCESS);
|
||
|
TESTASSERT(test_dci_content_common(sf_out, CARRIER_IDX) == SRSLTE_SUCCESS);
|
||
|
TESTASSERT(test_sib_scheduling(sf_out, CARRIER_IDX) == SRSLTE_SUCCESS);
|
||
|
TESTASSERT(test_pusch_collisions(sf_out, CARRIER_IDX, &cc_result->ul_mask) == SRSLTE_SUCCESS);
|
||
|
TESTASSERT(test_pdsch_collisions(sf_out, CARRIER_IDX, &cc_result->dl_mask) == SRSLTE_SUCCESS);
|
||
4 years ago
|
|
||
|
// UE dedicated tests
|
||
4 years ago
|
TESTASSERT(ue_tester->test_all(sf_out) == SRSLTE_SUCCESS);
|
||
6 years ago
|
assert_no_empty_allocs();
|
||
|
test_harqs();
|
||
4 years ago
|
update_ue_stats();
|
||
6 years ago
|
|
||
5 years ago
|
return SRSLTE_SUCCESS;
|
||
6 years ago
|
}
|
||
|
|
||
5 years ago
|
int sched_tester::assert_no_empty_allocs()
|
||
6 years ago
|
{
|
||
|
// Test if allocations only take place for users with pending data or in RAR
|
||
|
for (auto& iter : tti_data.ue_data) {
|
||
5 years ago
|
uint16_t rnti = iter.first;
|
||
|
// srsenb::sched_ue* user = &ue_db[rnti];
|
||
6 years ago
|
|
||
5 years ago
|
if (not iter.second.has_ul_tx) {
|
||
|
for (uint32_t i = 0; i < tti_info.ul_sched_result[CARRIER_IDX].nof_dci_elems; ++i) {
|
||
|
auto& pusch = tti_info.ul_sched_result[CARRIER_IDX].pusch[i];
|
||
|
if (pusch.dci.rnti == rnti and pusch.needs_pdcch) {
|
||
|
// TODO: This test does not work for adaptive re-tx
|
||
5 years ago
|
TESTERROR("There was a user without data that got allocated in UL\n");
|
||
5 years ago
|
}
|
||
|
}
|
||
6 years ago
|
}
|
||
5 years ago
|
// srsenb::ul_harq_proc* hul = user->get_ul_harq(tti_info.tti_params.tti_tx_ul);
|
||
6 years ago
|
iter.second.ul_retx_got_delayed = iter.second.has_ul_retx and iter.second.ul_harq.is_empty(0);
|
||
6 years ago
|
tti_data.total_ues.ul_retx_got_delayed |= iter.second.ul_retx_got_delayed;
|
||
|
// Retxs cannot give space to newtx allocations
|
||
5 years ago
|
CONDERROR(tti_data.total_ues.ul_retx_got_delayed, "There was a retx that was erased for user rnti=0x%x\n", rnti);
|
||
6 years ago
|
}
|
||
|
|
||
5 years ago
|
return SRSLTE_SUCCESS;
|
||
6 years ago
|
}
|
||
|
|
||
5 years ago
|
int sched_tester::test_harqs()
|
||
6 years ago
|
{
|
||
6 years ago
|
/* check consistency of DL harq procedures and allocations */
|
||
5 years ago
|
for (uint32_t i = 0; i < tti_info.dl_sched_result[CARRIER_IDX].nof_data_elems; ++i) {
|
||
|
const auto& data = tti_info.dl_sched_result[CARRIER_IDX].data[i];
|
||
6 years ago
|
uint32_t h_id = data.dci.pid;
|
||
|
uint16_t rnti = data.dci.rnti;
|
||
5 years ago
|
const srsenb::dl_harq_proc& h = ue_db[rnti].get_dl_harq(h_id, CARRIER_IDX);
|
||
5 years ago
|
CONDERROR(h.get_tti() != tti_point{tti_info.tti_params.tti_tx_dl},
|
||
5 years ago
|
"The scheduled DL harq pid=%d does not a valid tti=%u\n",
|
||
6 years ago
|
h_id,
|
||
5 years ago
|
tti_info.tti_params.tti_tx_dl);
|
||
5 years ago
|
CONDERROR(h.get_n_cce() != data.dci.location.ncce, "Harq DCI location does not match with result\n");
|
||
6 years ago
|
}
|
||
|
|
||
5 years ago
|
for (uint32_t i = 0; i < tti_info.ul_sched_result[CARRIER_IDX].nof_dci_elems; ++i) {
|
||
|
const auto& pusch = tti_info.ul_sched_result[CARRIER_IDX].pusch[i];
|
||
5 years ago
|
uint16_t rnti = pusch.dci.rnti;
|
||
6 years ago
|
const auto& ue_data = tti_data.ue_data[rnti];
|
||
5 years ago
|
const srsenb::ul_harq_proc* h = ue_db[rnti].get_ul_harq(tti_info.tti_params.tti_tx_ul, CARRIER_IDX);
|
||
5 years ago
|
CONDERROR(h == nullptr or h->is_empty(), "scheduled UL harq does not exist or is empty\n");
|
||
5 years ago
|
CONDERROR(h->get_tti() != tti_point{tti_info.tti_params.tti_tx_ul},
|
||
5 years ago
|
"The scheduled UL harq does not a valid tti=%u\n",
|
||
5 years ago
|
tti_info.tti_params.tti_tx_ul);
|
||
5 years ago
|
CONDERROR(h->has_pending_ack(), "At the end of the TTI, there shouldnt be any pending ACKs\n");
|
||
6 years ago
|
|
||
|
if (h->has_pending_retx()) {
|
||
|
// retx
|
||
5 years ago
|
CONDERROR(ue_data.ul_harq.is_empty(0), "reTx in an UL harq that was empty\n");
|
||
5 years ago
|
CONDERROR(h->nof_retx(0) != ue_data.ul_harq.nof_retx(0) + 1,
|
||
5 years ago
|
"A retx UL harq was scheduled but with invalid number of retxs\n");
|
||
|
CONDERROR(h->is_adaptive_retx() and not pusch.needs_pdcch, "Adaptive retxs need PDCCH alloc\n");
|
||
6 years ago
|
} else {
|
||
5 years ago
|
CONDERROR(h->nof_retx(0) != 0, "A new harq was scheduled but with invalid number of retxs\n");
|
||
|
CONDERROR(not ue_data.ul_harq.is_empty(0), "UL new tx in a UL harq that was not empty\n");
|
||
6 years ago
|
}
|
||
|
}
|
||
|
|
||
|
/* Check PHICH allocations */
|
||
5 years ago
|
for (uint32_t i = 0; i < tti_info.ul_sched_result[CARRIER_IDX].nof_phich_elems; ++i) {
|
||
|
const auto& phich = tti_info.ul_sched_result[CARRIER_IDX].phich[i];
|
||
6 years ago
|
const auto& hprev = tti_data.ue_data[phich.rnti].ul_harq;
|
||
5 years ago
|
const auto* h = ue_db[phich.rnti].get_ul_harq(tti_info.tti_params.tti_tx_ul, CARRIER_IDX);
|
||
5 years ago
|
CONDERROR(not hprev.has_pending_ack(), "Alloc PHICH did not have any pending ack\n");
|
||
6 years ago
|
bool maxretx_flag = hprev.nof_retx(0) + 1 >= hprev.max_nof_retx();
|
||
|
if (phich.phich == sched_interface::ul_sched_phich_t::ACK) {
|
||
4 years ago
|
// The harq can be either ACKed or Resumed
|
||
|
if (not hprev.is_empty()) {
|
||
|
// In case it was resumed
|
||
|
CONDERROR(h == nullptr or h->is_empty(), "Cannot resume empty UL harq\n");
|
||
|
for (uint32_t j = 0; j < tti_info.ul_sched_result[CARRIER_IDX].nof_dci_elems; ++j) {
|
||
|
auto& pusch = tti_info.ul_sched_result[CARRIER_IDX].pusch[j];
|
||
|
CONDERROR(pusch.dci.rnti == phich.rnti, "Cannot send PHICH::ACK for same harq that got UL grant.\n");
|
||
|
}
|
||
|
}
|
||
6 years ago
|
} else {
|
||
5 years ago
|
CONDERROR(h->get_pending_data() == 0 and !maxretx_flag, "NACKed harq has no pending data\n");
|
||
6 years ago
|
}
|
||
|
}
|
||
5 years ago
|
|
||
|
return SRSLTE_SUCCESS;
|
||
6 years ago
|
}
|
||
|
|
||
4 years ago
|
int sched_tester::update_ue_stats()
|
||
6 years ago
|
{
|
||
5 years ago
|
// update ue stats with number of allocated UL PRBs
|
||
5 years ago
|
for (uint32_t i = 0; i < tti_info.ul_sched_result[CARRIER_IDX].nof_dci_elems; ++i) {
|
||
5 years ago
|
uint32_t L, RBstart;
|
||
5 years ago
|
srslte_ra_type2_from_riv(tti_info.ul_sched_result[CARRIER_IDX].pusch[i].dci.type2_alloc.riv,
|
||
5 years ago
|
&L,
|
||
|
&RBstart,
|
||
5 years ago
|
sched_cell_params[CARRIER_IDX].cfg.cell.nof_prb,
|
||
|
sched_cell_params[CARRIER_IDX].cfg.cell.nof_prb);
|
||
5 years ago
|
ue_stats[tti_info.ul_sched_result[CARRIER_IDX].pusch[i].dci.rnti].nof_ul_rbs += L;
|
||
6 years ago
|
}
|
||
5 years ago
|
|
||
5 years ago
|
// update ue stats with number of DL RB allocations
|
||
5 years ago
|
srslte::bounded_bitset<100, true> alloc_mask(sched_cell_params[CARRIER_IDX].cfg.cell.nof_prb);
|
||
5 years ago
|
for (uint32_t i = 0; i < tti_info.dl_sched_result[CARRIER_IDX].nof_data_elems; ++i) {
|
||
5 years ago
|
TESTASSERT(srsenb::extract_dl_prbmask(sched_cell_params[CARRIER_IDX].cfg.cell,
|
||
5 years ago
|
tti_info.dl_sched_result[CARRIER_IDX].data[i].dci,
|
||
4 years ago
|
alloc_mask) == SRSLTE_SUCCESS);
|
||
5 years ago
|
ue_stats[tti_info.dl_sched_result[CARRIER_IDX].data[i].dci.rnti].nof_dl_rbs += alloc_mask.count();
|
||
6 years ago
|
}
|
||
|
|
||
5 years ago
|
return SRSLTE_SUCCESS;
|
||
6 years ago
|
}
|
||
|
|
||
5 years ago
|
void test_scheduler_rand(sched_sim_events sim)
|
||
6 years ago
|
{
|
||
|
// Create classes
|
||
5 years ago
|
sched_tester tester;
|
||
|
srsenb::sched my_sched;
|
||
6 years ago
|
|
||
5 years ago
|
tester.init(nullptr);
|
||
5 years ago
|
tester.sim_cfg(std::move(sim.sim_args));
|
||
6 years ago
|
|
||
5 years ago
|
tester.test_next_ttis(sim.tti_events);
|
||
6 years ago
|
}
|
||
|
|
||
4 years ago
|
template <typename T>
|
||
|
T pick_random_uniform(std::initializer_list<T> v)
|
||
|
{
|
||
4 years ago
|
return *(v.begin() + std::uniform_int_distribution<size_t>{0, v.size() - 1}(srsenb::get_rand_gen()));
|
||
4 years ago
|
}
|
||
|
|
||
5 years ago
|
sched_sim_events rand_sim_params(uint32_t nof_ttis)
|
||
6 years ago
|
{
|
||
5 years ago
|
auto boolean_dist = []() { return std::uniform_int_distribution<>{0, 1}(srsenb::get_rand_gen()); };
|
||
|
sched_sim_events sim_gen;
|
||
|
uint32_t max_conn_dur = 10000, min_conn_dur = 500;
|
||
|
float P_ul_sr = srsenb::randf() * 0.5, P_dl = srsenb::randf() * 0.5;
|
||
|
float P_prach = 0.99f; // 0.1f + randf()*0.3f;
|
||
|
float ul_sr_exps[] = {1, 4}; // log rand
|
||
|
float dl_data_exps[] = {1, 4}; // log rand
|
||
|
uint32_t max_nof_users = 5;
|
||
5 years ago
|
std::uniform_int_distribution<> connection_dur_dist(min_conn_dur, max_conn_dur);
|
||
|
std::uniform_int_distribution<uint32_t> dist_prb_idx(0, 5);
|
||
|
uint32_t prb_idx = dist_prb_idx(srsenb::get_rand_gen());
|
||
|
uint32_t nof_prb = std::array<uint32_t, 6>({6, 15, 25, 50, 75, 100})[prb_idx];
|
||
|
|
||
|
sched_sim_event_generator generator;
|
||
|
|
||
5 years ago
|
sim_gen.sim_args.cell_cfg = {generate_default_cell_cfg(nof_prb)};
|
||
|
sim_gen.sim_args.default_ue_sim_cfg.ue_cfg = generate_default_ue_cfg();
|
||
|
sim_gen.sim_args.default_ue_sim_cfg.periodic_cqi = true;
|
||
|
sim_gen.sim_args.default_ue_sim_cfg.ue_cfg.maxharq_tx = std::uniform_int_distribution<>{1, 5}(srsenb::get_rand_gen());
|
||
4 years ago
|
sim_gen.sim_args.default_ue_sim_cfg.ue_cfg.measgap_period = pick_random_uniform({0, 40, 80});
|
||
|
sim_gen.sim_args.default_ue_sim_cfg.ue_cfg.measgap_offset = std::uniform_int_distribution<uint32_t>{
|
||
|
0, sim_gen.sim_args.default_ue_sim_cfg.ue_cfg.measgap_period}(srsenb::get_rand_gen());
|
||
|
sim_gen.sim_args.start_tti = 0;
|
||
|
sim_gen.sim_args.sim_log = log_global.get();
|
||
5 years ago
|
sim_gen.sim_args.sched_args.pdsch_mcs =
|
||
|
boolean_dist() ? -1 : std::uniform_int_distribution<>{0, 24}(srsenb::get_rand_gen());
|
||
|
sim_gen.sim_args.sched_args.pusch_mcs =
|
||
|
boolean_dist() ? -1 : std::uniform_int_distribution<>{0, 24}(srsenb::get_rand_gen());
|
||
5 years ago
|
|
||
5 years ago
|
generator.tti_events.resize(nof_ttis);
|
||
|
|
||
|
for (uint32_t tti = 0; tti < nof_ttis; ++tti) {
|
||
|
for (auto& u : generator.current_users) {
|
||
|
uint32_t rnti = u.first;
|
||
|
if (srsenb::randf() < P_ul_sr) {
|
||
|
float exp = ul_sr_exps[0] + srsenb::randf() * (ul_sr_exps[1] - ul_sr_exps[0]);
|
||
|
generator.add_ul_data(rnti, (uint32_t)pow(10, exp));
|
||
6 years ago
|
}
|
||
5 years ago
|
if (srsenb::randf() < P_dl) {
|
||
|
float exp = dl_data_exps[0] + srsenb::randf() * (dl_data_exps[1] - dl_data_exps[0]);
|
||
|
generator.add_dl_data(rnti, (uint32_t)pow(10, exp));
|
||
6 years ago
|
}
|
||
|
}
|
||
|
|
||
|
// may add new user (For now, we only support one UE per PRACH)
|
||
5 years ago
|
bool is_prach_tti =
|
||
|
srslte_prach_tti_opportunity_config_fdd(sim_gen.sim_args.cell_cfg[CARRIER_IDX].prach_config, tti, -1);
|
||
5 years ago
|
if (is_prach_tti and generator.current_users.size() < max_nof_users and srsenb::randf() < P_prach) {
|
||
5 years ago
|
generator.add_new_default_user(connection_dur_dist(srsenb::get_rand_gen()),
|
||
|
sim_gen.sim_args.default_ue_sim_cfg.ue_cfg);
|
||
6 years ago
|
}
|
||
5 years ago
|
generator.step_tti();
|
||
6 years ago
|
}
|
||
|
|
||
5 years ago
|
sim_gen.tti_events = std::move(generator.tti_events);
|
||
|
|
||
5 years ago
|
return sim_gen;
|
||
6 years ago
|
}
|
||
|
|
||
5 years ago
|
int main()
|
||
6 years ago
|
{
|
||
5 years ago
|
// Setup seed
|
||
|
srsenb::set_randseed(seed);
|
||
5 years ago
|
printf("This is the chosen seed: %u\n", seed);
|
||
5 years ago
|
|
||
4 years ago
|
srslte::logmap::set_default_log_level(srslte::LOG_LEVEL_INFO);
|
||
6 years ago
|
uint32_t N_runs = 1, nof_ttis = 10240 + 10;
|
||
|
|
||
|
for (uint32_t n = 0; n < N_runs; ++n) {
|
||
|
printf("Sim run number: %u\n", n + 1);
|
||
5 years ago
|
sched_sim_events sim = rand_sim_params(nof_ttis);
|
||
|
test_scheduler_rand(std::move(sim));
|
||
6 years ago
|
}
|
||
|
|
||
5 years ago
|
return 0;
|
||
6 years ago
|
}
|