rrc_meas_test failing

master
Francisco Paisana 5 years ago
parent 9a1f69113f
commit d2dd30c8cb

@ -148,7 +148,7 @@ public:
protected: protected:
// Moved to protected to be accessible by unit tests // Moved to protected to be accessible by unit tests
void set_serving_cell(phy_interface_rrc_lte::phy_cell_t phy_cell, bool discard_serving); void set_serving_cell(phy_interface_rrc_lte::phy_cell_t phy_cell, bool discard_serving);
bool has_neighbour_cell(const uint32_t earfcn, const uint32_t pci); bool has_neighbour_cell(uint32_t earfcn, uint32_t pci) const;
int start_cell_select(); int start_cell_select();
private: private:
@ -239,25 +239,10 @@ private:
} }
// List of strongest neighbour cell // List of strongest neighbour cell
const static int NEIGHBOUR_TIMEOUT = 5; cell_list neighbour_cells;
const static int NOF_NEIGHBOUR_CELLS = 8;
typedef std::unique_ptr<cell_t> unique_cell_t; typedef std::unique_ptr<cell_t> unique_cell_t;
std::vector<unique_cell_t> neighbour_cells;
unique_cell_t serving_cell = nullptr; unique_cell_t serving_cell = nullptr;
void set_serving_cell(uint32_t cell_idx);
unique_cell_t remove_neighbour_cell(const uint32_t earfcn, const uint32_t pci);
cell_t* get_neighbour_cell_handle(const uint32_t earfcn, const uint32_t pci);
int find_neighbour_cell(uint32_t earfcn, uint32_t pci);
bool add_neighbour_cell(phy_meas_t meas);
bool add_neighbour_cell(unique_cell_t new_cell);
void log_neighbour_cells();
void sort_neighbour_cells();
void clean_neighbours();
void delete_last_neighbour();
std::string print_neighbour_cells();
std::set<uint32_t> get_neighbour_pcis(uint32_t earfcn);
bool initiated = false; bool initiated = false;
asn1::rrc::reest_cause_e m_reest_cause = asn1::rrc::reest_cause_e::nulltype; asn1::rrc::reest_cause_e m_reest_cause = asn1::rrc::reest_cause_e::nulltype;

@ -134,19 +134,37 @@ private:
class cell_list class cell_list
{ {
public: public:
const static int NEIGHBOUR_TIMEOUT = 5;
const static int MAX_NEIGHBOUR_CELLS = 8; const static int MAX_NEIGHBOUR_CELLS = 8;
typedef std::unique_ptr<cell_t> unique_cell_t; typedef std::unique_ptr<cell_t> unique_cell_t;
bool add_neighbour(unique_cell_t cell); bool add_neighbour_cell_unsorted(const rrc_interface_phy_lte::phy_meas_t& meas);
void rem_last_neighbour(); bool add_neighbour_cell(unique_cell_t cell);
bool add_neighbour_cell_unsorted(unique_cell_t cell);
cell_t* get_neighbour_cell_handle(uint32_t earfcn, uint32_t pci); void rem_last_neighbour();
void log_neighbour_cells() const; unique_cell_t remove_neighbour_cell(uint32_t earfcn, uint32_t pci);
void clean_neighbours();
void sort_neighbour_cells();
cell_t* get_neighbour_cell_handle(uint32_t earfcn, uint32_t pci);
const cell_t* get_neighbour_cell_handle(uint32_t earfcn, uint32_t pci) const;
void log_neighbour_cells() const;
std::string print_neighbour_cells() const;
std::set<uint32_t> get_neighbour_pcis(uint32_t earfcn) const;
bool has_neighbour_cell(uint32_t earfcn, uint32_t pci) const;
size_t nof_neighbours() const { return neighbour_cells.size(); }
cell_t& operator[](size_t idx) { return *neighbour_cells[idx]; }
const cell_t& operator[](size_t idx) const { return *neighbour_cells[idx]; }
cell_t& at(size_t idx) { return *neighbour_cells.at(idx); }
using iterator = std::vector<unique_cell_t>::iterator;
iterator begin() { return neighbour_cells.begin(); }
iterator end() { return neighbour_cells.end(); }
private: private:
void sort_neighbour_cells(); srslte::log_ref log_h{"RRC"};
srslte::log_ref log_h{"RRC"}; unique_cell_t serving_cell;
std::vector<unique_cell_t> neighbour_cells; std::vector<unique_cell_t> neighbour_cells;
}; };

@ -167,7 +167,7 @@ void rrc::get_metrics(rrc_metrics_t& m)
{ {
m.state = state; m.state = state;
// Save strongest cells metrics // Save strongest cells metrics
for (auto& c : neighbour_cells) { for (unique_cell_t& c : neighbour_cells) {
rrc_interface_phy_lte::phy_meas_t meas = {}; rrc_interface_phy_lte::phy_meas_t meas = {};
meas.cfo_hz = c->get_cfo_hz(); meas.cfo_hz = c->get_cfo_hz();
meas.earfcn = c->get_earfcn(); meas.earfcn = c->get_earfcn();
@ -250,7 +250,7 @@ void rrc::run_tti()
// Clean old neighbours // Clean old neighbours
cell_clean_cnt++; cell_clean_cnt++;
if (cell_clean_cnt == 1000) { if (cell_clean_cnt == 1000) {
clean_neighbours(); neighbour_cells.clean_neighbours();
cell_clean_cnt = 0; cell_clean_cnt = 0;
} }
} }
@ -358,7 +358,7 @@ void rrc::process_cell_meas()
} }
process_new_cell_meas(m); process_new_cell_meas(m);
} }
sort_neighbour_cells(); neighbour_cells.sort_neighbour_cells();
} }
void rrc::process_new_cell_meas(const std::vector<phy_meas_t>& meas) void rrc::process_new_cell_meas(const std::vector<phy_meas_t>& meas)
@ -376,7 +376,7 @@ void rrc::process_new_cell_meas(const std::vector<phy_meas_t>& meas)
} }
// Or update/add RRC neighbour cell database // Or update/add RRC neighbour cell database
} else { } else {
c = get_neighbour_cell_handle(m.earfcn, m.pci); c = neighbour_cells.get_neighbour_cell_handle(m.earfcn, m.pci);
} }
// Filter RSRP/RSRQ measurements if cell exits // Filter RSRP/RSRQ measurements if cell exits
if (c != nullptr) { if (c != nullptr) {
@ -385,7 +385,7 @@ void rrc::process_new_cell_meas(const std::vector<phy_meas_t>& meas)
c->set_cfo(m.cfo_hz); c->set_cfo(m.cfo_hz);
} else { } else {
// or just set initial value // or just set initial value
neighbour_added = add_neighbour_cell(m); neighbour_added |= neighbour_cells.add_neighbour_cell_unsorted(m);
} }
if (m.earfcn == 0) { if (m.earfcn == 0) {
@ -489,7 +489,7 @@ void rrc::cell_reselection(float rsrp, float rsrq)
phy->meas_stop(); phy->meas_stop();
} else { } else {
// UE must start intra-frequency measurements // UE must start intra-frequency measurements
auto pci = get_neighbour_pcis(serving_cell->get_earfcn()); auto pci = neighbour_cells.get_neighbour_pcis(serving_cell->get_earfcn());
phy->set_cells_to_meas(serving_cell->get_earfcn(), pci); phy->set_cells_to_meas(serving_cell->get_earfcn(), pci);
} }
@ -501,19 +501,20 @@ void rrc::set_serving_cell(phy_interface_rrc_lte::phy_cell_t phy_cell, bool disc
{ {
if (has_neighbour_cell(phy_cell.earfcn, phy_cell.pci)) { if (has_neighbour_cell(phy_cell.earfcn, phy_cell.pci)) {
// Remove future serving cell from neighbours to make space for current serving cell // Remove future serving cell from neighbours to make space for current serving cell
unique_cell_t new_serving_cell = remove_neighbour_cell(phy_cell.earfcn, phy_cell.pci); unique_cell_t new_serving_cell = neighbour_cells.remove_neighbour_cell(phy_cell.earfcn, phy_cell.pci);
bool same_cell = (phy_cell.earfcn == serving_cell->get_earfcn() and phy_cell.pci == serving_cell->get_pci()); bool same_cell = (phy_cell.earfcn == serving_cell->get_earfcn() and phy_cell.pci == serving_cell->get_pci());
// Move serving cell to neighbours list // Move serving cell to neighbours list
if (serving_cell->is_valid() and not same_cell and not discard_serving) { if (serving_cell->is_valid() and not same_cell and not discard_serving) {
if (not add_neighbour_cell(std::move(serving_cell))) { if (not neighbour_cells.add_neighbour_cell(std::move(serving_cell))) {
rrc_log->info("Serving cell not added to list of neighbours. Worse than current neighbours\n"); rrc_log->info("Serving cell not added to list of neighbours. Worse than current neighbours\n");
} }
} }
// Set new serving cell // Set new serving cell
serving_cell = std::move(new_serving_cell); serving_cell = std::move(new_serving_cell);
rrc_log->info( rrc_log->info("Setting serving cell %s, nof_neighbours=%zd\n",
"Setting serving cell %s, nof_neighbours=%zd\n", serving_cell->to_string().c_str(), neighbour_cells.size()); serving_cell->to_string().c_str(),
neighbour_cells.nof_neighbours());
} else { } else {
rrc_log->error("Setting serving cell: Unknown cell with earfcn=%d, PCI=%d\n", phy_cell.earfcn, phy_cell.pci); rrc_log->error("Setting serving cell: Unknown cell with earfcn=%d, PCI=%d\n", phy_cell.earfcn, phy_cell.pci);
} }
@ -529,166 +530,9 @@ int rrc::start_cell_select()
return SRSLTE_SUCCESS; return SRSLTE_SUCCESS;
} }
void rrc::delete_last_neighbour() bool rrc::has_neighbour_cell(uint32_t earfcn, uint32_t pci) const
{ {
if (not neighbour_cells.empty()) { return neighbour_cells.has_neighbour_cell(earfcn, pci);
auto& it = neighbour_cells.back();
rrc_log->debug("Delete cell %s from neighbor list.\n", (*it).to_string().c_str());
neighbour_cells.pop_back();
}
}
/* Called by main RRC thread to remove neighbours from which measurements have not been received in a while
*/
void rrc::clean_neighbours()
{
struct timeval now;
gettimeofday(&now, NULL);
for (auto it = neighbour_cells.begin(); it != neighbour_cells.end();) {
if ((*it)->timeout_secs(now) > NEIGHBOUR_TIMEOUT) {
rrc_log->info("Neighbour PCI=%d timed out. Deleting\n", (*it)->get_pci());
it = neighbour_cells.erase(it);
} else {
++it;
}
}
}
void rrc::log_neighbour_cells()
{
if (not neighbour_cells.empty()) {
const int32_t MAX_STR_LEN = 512;
char ordered[MAX_STR_LEN] = {};
int n = 0;
n += snprintf(ordered, MAX_STR_LEN, "[%s", neighbour_cells[0]->to_string().c_str());
for (uint32_t i = 1; i < neighbour_cells.size(); i++) {
if (n < MAX_STR_LEN) { // make sure there is still room left
int m = snprintf(&ordered[n], (size_t)MAX_STR_LEN - n, " | %s", neighbour_cells[i]->to_string().c_str());
if (m > 0) {
n += m;
}
}
}
rrc_log->debug("Neighbours: %s]\n", ordered);
} else {
rrc_log->debug("Neighbours: Empty\n");
}
}
// Sort neighbour cells by decreasing order of RSRP
void rrc::sort_neighbour_cells()
{
std::sort(std::begin(neighbour_cells), std::end(neighbour_cells), [](const unique_cell_t& a, const unique_cell_t& b) {
return a->greater(b.get());
});
log_neighbour_cells();
}
bool rrc::add_neighbour_cell(unique_cell_t new_cell)
{
bool ret = false;
// Make sure cell is valid
if (!new_cell->is_valid()) {
rrc_log->error("Trying to add cell %s but is not valid", new_cell->to_string().c_str());
return ret;
}
// If cell exists, update RSRP value
cell_t* existing_cell = get_neighbour_cell_handle(new_cell->get_earfcn(), new_cell->get_pci());
if (existing_cell != nullptr) {
if (std::isnormal(new_cell.get()->get_rsrp())) {
existing_cell->set_rsrp(new_cell.get()->get_rsrp());
}
ret = true;
} else {
// If doesn't exists, add it if there is enough space
if (neighbour_cells.size() < NOF_NEIGHBOUR_CELLS) {
ret = true;
// If there isn't space, keep the strongest only
} else if (new_cell->greater(neighbour_cells.back().get())) {
// delete last neighbour cell
delete_last_neighbour();
ret = true;
}
}
if (ret) {
rrc_log->info(
"Adding neighbour cell %s, nof_neighbours=%zd\n", new_cell->to_string().c_str(), neighbour_cells.size() + 1);
neighbour_cells.push_back(std::move(new_cell));
} else {
rrc_log->warning("Could not add cell %s: no space in neighbours\n", new_cell->to_string().c_str());
}
sort_neighbour_cells();
return ret;
}
// If only neighbour PCI is provided, copy full cell from serving cell
bool rrc::add_neighbour_cell(phy_meas_t meas)
{
phy_interface_rrc_lte::phy_cell_t phy_cell = {};
phy_cell.earfcn = meas.earfcn;
phy_cell.pci = meas.pci;
unique_cell_t c = unique_cell_t(new cell_t(phy_cell));
c.get()->set_rsrp(meas.rsrp);
c.get()->set_rsrq(meas.rsrq);
c.get()->set_cfo(meas.cfo_hz);
return add_neighbour_cell(std::move(c));
}
// This will remove the cell from the current neighbour list
rrc::unique_cell_t rrc::remove_neighbour_cell(const uint32_t earfcn, const uint32_t pci)
{
auto it = find_if(neighbour_cells.begin(), neighbour_cells.end(), [&](const unique_cell_t& cell) {
return cell->equals(earfcn, pci);
});
if (it != neighbour_cells.end()) {
auto retval = std::move(*it);
it = neighbour_cells.erase(it);
return retval;
}
return nullptr;
}
cell_t* rrc::get_neighbour_cell_handle(const uint32_t earfcn, const uint32_t pci)
{
for (auto& cell : neighbour_cells) {
if (cell->equals(earfcn, pci)) {
return cell.get();
}
}
return nullptr;
}
bool rrc::has_neighbour_cell(const uint32_t earfcn, const uint32_t pci)
{
return get_neighbour_cell_handle(earfcn, pci) != nullptr;
}
std::string rrc::print_neighbour_cells()
{
if (neighbour_cells.empty()) {
return "";
}
std::string s;
s.reserve(256);
for (auto it = neighbour_cells.begin(); it != neighbour_cells.end() - 1; ++it) {
s += (*it)->to_string() + ", ";
}
s += neighbour_cells.back()->to_string();
return s;
}
std::set<uint32_t> rrc::get_neighbour_pcis(uint32_t earfcn)
{
std::set<uint32_t> pcis = {};
for (auto& cell : neighbour_cells) {
if (cell->get_earfcn() == earfcn) {
pcis.insert(cell->get_pci());
}
}
return pcis;
} }
/******************************************************************************* /*******************************************************************************
@ -1251,27 +1095,19 @@ void rrc::send_srb1_msg(const ul_dcch_msg_s& msg)
std::set<uint32_t> rrc::get_cells(const uint32_t earfcn) std::set<uint32_t> rrc::get_cells(const uint32_t earfcn)
{ {
return get_neighbour_pcis(earfcn); return neighbour_cells.get_neighbour_pcis(earfcn);
} }
float rrc::get_cell_rsrp(const uint32_t earfcn, const uint32_t pci) float rrc::get_cell_rsrp(const uint32_t earfcn, const uint32_t pci)
{ {
cell_t* c = get_neighbour_cell_handle(earfcn, pci); cell_t* c = neighbour_cells.get_neighbour_cell_handle(earfcn, pci);
if (c != nullptr) { return (c != nullptr) ? c->get_rsrp() : NAN;
return c->get_rsrp();
} else {
return NAN;
}
} }
float rrc::get_cell_rsrq(const uint32_t earfcn, const uint32_t pci) float rrc::get_cell_rsrq(const uint32_t earfcn, const uint32_t pci)
{ {
cell_t* c = get_neighbour_cell_handle(earfcn, pci); cell_t* c = neighbour_cells.get_neighbour_cell_handle(earfcn, pci);
if (c != nullptr) { return (c != nullptr) ? c->get_rsrq() : NAN;
return c->get_rsrq();
} else {
return NAN;
}
} }
cell_t* rrc::get_serving_cell() cell_t* rrc::get_serving_cell()

@ -152,15 +152,43 @@ uint16_t cell_t::get_mnc() const
cell_t* cell_list::get_neighbour_cell_handle(uint32_t earfcn, uint32_t pci) cell_t* cell_list::get_neighbour_cell_handle(uint32_t earfcn, uint32_t pci)
{ {
for (unique_cell_t& cell : neighbour_cells) { auto it = find_if(neighbour_cells.begin(), neighbour_cells.end(), [&](const unique_cell_t& cell) {
if (cell->equals(earfcn, pci)) { return cell->equals(earfcn, pci);
return cell.get(); });
} return it != neighbour_cells.end() ? it->get() : nullptr;
}
const cell_t* cell_list::get_neighbour_cell_handle(uint32_t earfcn, uint32_t pci) const
{
auto it = find_if(neighbour_cells.begin(), neighbour_cells.end(), [&](const unique_cell_t& cell) {
return cell->equals(earfcn, pci);
});
return it != neighbour_cells.end() ? it->get() : nullptr;
}
// If only neighbour PCI is provided, copy full cell from serving cell
bool cell_list::add_neighbour_cell_unsorted(const rrc_interface_phy_lte::phy_meas_t& meas)
{
phy_interface_rrc_lte::phy_cell_t phy_cell = {};
phy_cell.earfcn = meas.earfcn;
phy_cell.pci = meas.pci;
unique_cell_t c = unique_cell_t(new cell_t(phy_cell));
c.get()->set_rsrp(meas.rsrp);
c.get()->set_rsrq(meas.rsrq);
c.get()->set_cfo(meas.cfo_hz);
return add_neighbour_cell_unsorted(std::move(c));
}
bool cell_list::add_neighbour_cell(unique_cell_t new_cell)
{
bool ret = add_neighbour_cell_unsorted(std::move(new_cell));
if (ret) {
sort_neighbour_cells();
} }
return nullptr; return ret;
} }
bool cell_list::add_neighbour(unique_cell_t new_cell) bool cell_list::add_neighbour_cell_unsorted(unique_cell_t new_cell)
{ {
// Make sure cell is valid // Make sure cell is valid
if (!new_cell->is_valid()) { if (!new_cell->is_valid()) {
@ -191,8 +219,6 @@ bool cell_list::add_neighbour(unique_cell_t new_cell)
log_h->info( log_h->info(
"Adding neighbour cell %s, nof_neighbours=%zd\n", new_cell->to_string().c_str(), neighbour_cells.size() + 1); "Adding neighbour cell %s, nof_neighbours=%zd\n", new_cell->to_string().c_str(), neighbour_cells.size() + 1);
neighbour_cells.push_back(std::move(new_cell)); neighbour_cells.push_back(std::move(new_cell));
sort_neighbour_cells();
return true; return true;
} }
@ -205,6 +231,19 @@ void cell_list::rem_last_neighbour()
} }
} }
cell_list::unique_cell_t cell_list::remove_neighbour_cell(uint32_t earfcn, uint32_t pci)
{
auto it = find_if(neighbour_cells.begin(), neighbour_cells.end(), [&](const unique_cell_t& cell) {
return cell->equals(earfcn, pci);
});
if (it != neighbour_cells.end()) {
auto retval = std::move(*it);
it = neighbour_cells.erase(it);
return retval;
}
return nullptr;
}
// Sort neighbour cells by decreasing order of RSRP // Sort neighbour cells by decreasing order of RSRP
void cell_list::sort_neighbour_cells() void cell_list::sort_neighbour_cells()
{ {
@ -236,4 +275,50 @@ void cell_list::log_neighbour_cells() const
} }
} }
//! Called by main RRC thread to remove neighbours from which measurements have not been received in a while
void cell_list::clean_neighbours()
{
struct timeval now;
gettimeofday(&now, nullptr);
for (auto it = neighbour_cells.begin(); it != neighbour_cells.end();) {
if ((*it)->timeout_secs(now) > NEIGHBOUR_TIMEOUT) {
log_h->info("Neighbour PCI=%d timed out. Deleting\n", (*it)->get_pci());
it = neighbour_cells.erase(it);
} else {
++it;
}
}
}
std::string cell_list::print_neighbour_cells() const
{
if (neighbour_cells.empty()) {
return "";
}
std::string s;
s.reserve(256);
for (auto it = neighbour_cells.begin(); it != neighbour_cells.end() - 1; ++it) {
s += (*it)->to_string() + ", ";
}
s += neighbour_cells.back()->to_string();
return s;
}
std::set<uint32_t> cell_list::get_neighbour_pcis(uint32_t earfcn) const
{
std::set<uint32_t> pcis = {};
for (const unique_cell_t& cell : neighbour_cells) {
if (cell->get_earfcn() == earfcn) {
pcis.insert(cell->get_pci());
}
}
return pcis;
}
bool cell_list::has_neighbour_cell(uint32_t earfcn, uint32_t pci) const
{
return get_neighbour_cell_handle(earfcn, pci) != nullptr;
}
} // namespace srsue } // namespace srsue

@ -121,7 +121,7 @@ proc_outcome_t rrc::cell_search_proc::handle_cell_found(const phy_interface_rrc_
Info("Cell found in this frequency. Setting new serving cell EARFCN=%d PCI=%d ...\n", new_cell.earfcn, new_cell.pci); Info("Cell found in this frequency. Setting new serving cell EARFCN=%d PCI=%d ...\n", new_cell.earfcn, new_cell.pci);
// Create a cell with NaN RSRP. Will be updated by new_phy_meas() during SIB search. // Create a cell with NaN RSRP. Will be updated by new_phy_meas() during SIB search.
if (not rrc_ptr->add_neighbour_cell(unique_cell_t(new cell_t(new_cell)))) { if (not rrc_ptr->neighbour_cells.add_neighbour_cell(unique_cell_t(new cell_t(new_cell)))) {
Error("Could not add new found cell\n"); Error("Could not add new found cell\n");
return proc_outcome_t::error; return proc_outcome_t::error;
} }
@ -494,7 +494,8 @@ rrc::cell_selection_proc::cell_selection_proc(rrc* parent_) : rrc_ptr(parent_) {
*/ */
proc_outcome_t rrc::cell_selection_proc::init() proc_outcome_t rrc::cell_selection_proc::init()
{ {
if (rrc_ptr->neighbour_cells.empty() and rrc_ptr->phy_sync_state == phy_in_sync and rrc_ptr->phy->cell_is_camping()) { if (rrc_ptr->neighbour_cells.nof_neighbours() == 0 and rrc_ptr->phy_sync_state == phy_in_sync and
rrc_ptr->phy->cell_is_camping()) {
// don't bother with cell selection if there are no neighbours and we are already camping // don't bother with cell selection if there are no neighbours and we are already camping
Debug("Skipping Cell Selection Procedure as there are no neighbour and cell is camping.\n"); Debug("Skipping Cell Selection Procedure as there are no neighbour and cell is camping.\n");
cs_result = cs_result_t::same_cell; cs_result = cs_result_t::same_cell;
@ -502,7 +503,7 @@ proc_outcome_t rrc::cell_selection_proc::init()
} }
Info("Starting...\n"); Info("Starting...\n");
Info("Current neighbor cells: [%s]\n", rrc_ptr->print_neighbour_cells().c_str()); Info("Current neighbor cells: [%s]\n", rrc_ptr->neighbour_cells.print_neighbour_cells().c_str());
Info("Current PHY state: %s\n", rrc_ptr->phy_sync_state == phy_in_sync ? "in-sync" : "out-of-sync"); Info("Current PHY state: %s\n", rrc_ptr->phy_sync_state == phy_in_sync ? "in-sync" : "out-of-sync");
if (rrc_ptr->serving_cell->has_sib3()) { if (rrc_ptr->serving_cell->has_sib3()) {
Info("Cell selection criteria: Qrxlevmin=%f, Qrxlevminoffset=%f\n", Info("Cell selection criteria: Qrxlevmin=%f, Qrxlevminoffset=%f\n",
@ -559,23 +560,23 @@ proc_outcome_t rrc::cell_selection_proc::start_serv_cell_selection()
proc_outcome_t rrc::cell_selection_proc::start_cell_selection() proc_outcome_t rrc::cell_selection_proc::start_cell_selection()
{ {
// Neighbour cells are sorted in descending order of RSRP // Neighbour cells are sorted in descending order of RSRP
for (; neigh_index < rrc_ptr->neighbour_cells.size(); ++neigh_index) { for (; neigh_index < rrc_ptr->neighbour_cells.nof_neighbours(); ++neigh_index) {
// If the serving cell is stronger, attempt to select it // If the serving cell is stronger, attempt to select it
if (not serv_cell_select_attempted and rrc_ptr->cell_selection_criteria(rrc_ptr->serving_cell->get_rsrp()) and if (not serv_cell_select_attempted and rrc_ptr->cell_selection_criteria(rrc_ptr->serving_cell->get_rsrp()) and
rrc_ptr->serving_cell->greater(rrc_ptr->neighbour_cells[neigh_index].get())) { rrc_ptr->serving_cell->greater(&rrc_ptr->neighbour_cells[neigh_index])) {
return start_serv_cell_selection(); return start_serv_cell_selection();
} }
/*TODO: CHECK that PLMN matches. Currently we don't receive SIB1 of neighbour cells /*TODO: CHECK that PLMN matches. Currently we don't receive SIB1 of neighbour cells
* neighbour_cells[i]->plmn_equals(selected_plmn_id) && */ * neighbour_cells[i]->plmn_equals(selected_plmn_id) && */
// Matches S criteria // Matches S criteria
float rsrp = rrc_ptr->neighbour_cells.at(neigh_index)->get_rsrp(); float rsrp = rrc_ptr->neighbour_cells.at(neigh_index).get_rsrp();
if (rrc_ptr->phy_sync_state != phy_in_sync or if (rrc_ptr->phy_sync_state != phy_in_sync or
(rrc_ptr->cell_selection_criteria(rsrp) and rsrp > rrc_ptr->serving_cell->get_rsrp() + 5)) { (rrc_ptr->cell_selection_criteria(rsrp) and rsrp > rrc_ptr->serving_cell->get_rsrp() + 5)) {
// currently connected and verifies cell selection criteria // currently connected and verifies cell selection criteria
// Try to select Cell // Try to select Cell
rrc_ptr->set_serving_cell(rrc_ptr->neighbour_cells.at(neigh_index)->phy_cell, discard_serving); rrc_ptr->set_serving_cell(rrc_ptr->neighbour_cells.at(neigh_index).phy_cell, discard_serving);
discard_serving = false; discard_serving = false;
Info("Selected cell: %s\n", rrc_ptr->serving_cell->to_string().c_str()); Info("Selected cell: %s\n", rrc_ptr->serving_cell->to_string().c_str());
@ -635,7 +636,7 @@ srslte::proc_outcome_t rrc::cell_selection_proc::step_serv_cell_camp(const cell_
rrc_ptr->phy_sync_state = phy_unknown_sync; rrc_ptr->phy_sync_state = phy_unknown_sync;
rrc_ptr->serving_cell->set_rsrp(-INFINITY); rrc_ptr->serving_cell->set_rsrp(-INFINITY);
Warning("Could not camp on serving cell.\n"); Warning("Could not camp on serving cell.\n");
return neigh_index >= rrc_ptr->neighbour_cells.size() ? proc_outcome_t::error : proc_outcome_t::yield; return neigh_index >= rrc_ptr->neighbour_cells.nof_neighbours() ? proc_outcome_t::error : proc_outcome_t::yield;
} }
proc_outcome_t rrc::cell_selection_proc::step_wait_in_sync() proc_outcome_t rrc::cell_selection_proc::step_wait_in_sync()
@ -1129,7 +1130,8 @@ rrc::cell_reselection_proc::cell_reselection_proc(srsue::rrc* rrc_) : rrc_ptr(rr
proc_outcome_t rrc::cell_reselection_proc::init() proc_outcome_t rrc::cell_reselection_proc::init()
{ {
if (rrc_ptr->neighbour_cells.empty() and rrc_ptr->phy_sync_state == phy_in_sync and rrc_ptr->phy->cell_is_camping()) { if (rrc_ptr->neighbour_cells.nof_neighbours() == 0 and rrc_ptr->phy_sync_state == phy_in_sync and
rrc_ptr->phy->cell_is_camping()) {
// don't bother with cell selection if there are no neighbours and we are already camping // don't bother with cell selection if there are no neighbours and we are already camping
return proc_outcome_t::success; return proc_outcome_t::success;
} }
@ -1448,7 +1450,8 @@ srslte::proc_outcome_t rrc::ho_proc::react(srsue::cell_select_event_t ev)
return proc_outcome_t::yield; return proc_outcome_t::yield;
} }
// Check if cell has not been deleted in the meantime // Check if cell has not been deleted in the meantime
cell_t* target_cell = rrc_ptr->get_neighbour_cell_handle(target_earfcn, recfg_r8.mob_ctrl_info.target_pci); cell_t* target_cell =
rrc_ptr->neighbour_cells.get_neighbour_cell_handle(target_earfcn, recfg_r8.mob_ctrl_info.target_pci);
if (target_cell == nullptr) { if (target_cell == nullptr) {
Error("Cell removed from list of neighbours. Aborting handover preparation\n"); Error("Cell removed from list of neighbours. Aborting handover preparation\n");
return proc_outcome_t::error; return proc_outcome_t::error;
@ -1535,7 +1538,8 @@ srslte::proc_outcome_t rrc::ho_proc::step()
rrc_ptr->apply_rr_config_dedicated(&recfg_r8.rr_cfg_ded); rrc_ptr->apply_rr_config_dedicated(&recfg_r8.rr_cfg_ded);
} }
cell_t* target_cell = rrc_ptr->get_neighbour_cell_handle(target_earfcn, recfg_r8.mob_ctrl_info.target_pci); cell_t* target_cell =
rrc_ptr->neighbour_cells.get_neighbour_cell_handle(target_earfcn, recfg_r8.mob_ctrl_info.target_pci);
if (not rrc_ptr->phy_cell_selector.launch(*target_cell)) { if (not rrc_ptr->phy_cell_selector.launch(*target_cell)) {
Error("Failed to launch the selection of target cell %s\n", target_cell->to_string().c_str()); Error("Failed to launch the selection of target cell %s\n", target_cell->to_string().c_str());
return proc_outcome_t::error; return proc_outcome_t::error;

Loading…
Cancel
Save