SRSUE: RRC Reest Procedure Refactor

master
Xavier Arteaga 5 years ago committed by Xavier Arteaga
parent dbdb699a78
commit f5e4ff9f4d

@ -239,17 +239,16 @@ public:
static const char* name() { return "Connection re-establishment"; } static const char* name() { return "Connection re-establishment"; }
private: private:
enum class state_t { init, cell_reselection, cell_configuration, cell_criteria, success, error } state; enum class state_t { cell_reselection, cell_configuration } state;
rrc* rrc_ptr = nullptr; rrc* rrc_ptr = nullptr;
asn1::rrc::reest_cause_e reest_cause = asn1::rrc::reest_cause_e::nulltype; asn1::rrc::reest_cause_e reest_cause = asn1::rrc::reest_cause_e::nulltype;
uint16_t reest_rnti = 0; uint16_t reest_rnti = 0;
uint16_t reest_source_pci = 0; uint16_t reest_source_pci = 0;
void step_init(); srslte::proc_outcome_t step_cell_reselection();
void step_cell_reselection(); srslte::proc_outcome_t step_cell_configuration();
void step_cell_configuration(); srslte::proc_outcome_t cell_criteria();
void step_cell_criteria();
}; };
} // namespace srsue } // namespace srsue

@ -873,7 +873,7 @@ proc_outcome_t rrc::cell_reselection_proc::step()
* RRC Connection Re-establishment procedure * RRC Connection Re-establishment procedure
*************************************/ *************************************/
rrc::connection_reest_proc::connection_reest_proc(srsue::rrc* rrc_) : rrc_ptr(rrc_), state(state_t::init) {} rrc::connection_reest_proc::connection_reest_proc(srsue::rrc* rrc_) : rrc_ptr(rrc_), state(state_t::cell_reselection) {}
proc_outcome_t rrc::connection_reest_proc::init(asn1::rrc::reest_cause_e cause) proc_outcome_t rrc::connection_reest_proc::init(asn1::rrc::reest_cause_e cause)
{ {
@ -892,25 +892,7 @@ proc_outcome_t rrc::connection_reest_proc::init(asn1::rrc::reest_cause_e cause)
// the initiation of reestablishment procedure as indicates in 3GPP 36.331 Section 5.3.7.2 // the initiation of reestablishment procedure as indicates in 3GPP 36.331 Section 5.3.7.2
// Cannot be called from here because it has PHY-MAC re-configuration that should be performed in a different thread // Cannot be called from here because it has PHY-MAC re-configuration that should be performed in a different thread
Info("Conditions are meet\n"); Info("Conditions are meet. Initiating RRC Connection Reestablishment Procedure\n");
state = state_t::init;
} else {
// 3GPP 36.331 Section 5.3.7.1
// If AS security has not been activated, the UE does not initiate the procedure but instead
// moves to RRC_IDLE directly
Info("Conditions are NOT meet\n");
rrc_ptr->start_go_idle();
state = state_t::success;
}
return proc_outcome_t::yield;
}
void rrc::connection_reest_proc::step_init()
{
// initiation of reestablishment procedure as indicates in 3GPP 36.331 Section 5.3.7.2
Info("Initiating RRC Connection Reestablishment Procedure\n");
// stop timer T310, if running; // stop timer T310, if running;
rrc_ptr->t310.stop(); rrc_ptr->t310.stop();
@ -938,81 +920,91 @@ void rrc::connection_reest_proc::step_init()
rrc_ptr->apply_mac_config_dedicated_default(); rrc_ptr->apply_mac_config_dedicated_default();
// Launch cell reselection // Launch cell reselection
if (rrc_ptr->cell_reselector.launch()) { if (not rrc_ptr->cell_reselector.launch()) {
Error("Failed to initiate a Cell re-selection procedure...\n");
return proc_outcome_t::error;
}
state = state_t::cell_reselection; state = state_t::cell_reselection;
} else { } else {
Error("Failed to initiate a Cell re-selection procedure...\n"); // 3GPP 36.331 Section 5.3.7.1
state = state_t::error; // If AS security has not been activated, the UE does not initiate the procedure but instead
// moves to RRC_IDLE directly
Info("Conditions are NOT meet\n");
rrc_ptr->start_go_idle();
return proc_outcome_t::success;
} }
return proc_outcome_t::yield;
} }
void rrc::connection_reest_proc::step_cell_reselection() srslte::proc_outcome_t rrc::connection_reest_proc::step_cell_reselection()
{ {
if (!rrc_ptr->t311.is_running()) {
Info("During cell reselection, T311 expired. Aborting.\n"); // Run cell reselection
state = state_t::success; if (not rrc_ptr->cell_reselector.run()) {
} else if (rrc_ptr->cell_reselector.run()) { // Cell reselection finished or not started
// Keep running, do nothing if (rrc_ptr->serving_cell->in_sync) {
} else if (!rrc_ptr->serving_cell->in_sync) { // In-sync, check SIBs
Info("Serving cell is out-of-sync, re-launching re-selection procedure\n"); if (rrc_ptr->serving_cell->has_sib1() && rrc_ptr->serving_cell->has_sib2() && rrc_ptr->serving_cell->has_sib3()) {
if (rrc_ptr->cell_reselector.launch()) {
state = state_t::cell_reselection;
} else {
// Error launching procedure
state = state_t::error;
}
} else if (rrc_ptr->serving_cell->has_sib1() && rrc_ptr->serving_cell->has_sib2() &&
rrc_ptr->serving_cell->has_sib3()) {
Info("In-sync, SIBs available. Going to cell criteria\n"); Info("In-sync, SIBs available. Going to cell criteria\n");
state = state_t::cell_criteria; return cell_criteria();
} else { } else {
Info("SIBs missing (%d, %d, %d), launching serving cell configuration procedure\n", Info("SIBs missing (%d, %d, %d), launching serving cell configuration procedure\n",
rrc_ptr->serving_cell->has_sib1(), rrc_ptr->serving_cell->has_sib1(),
rrc_ptr->serving_cell->has_sib2(), rrc_ptr->serving_cell->has_sib2(),
rrc_ptr->serving_cell->has_sib3()); rrc_ptr->serving_cell->has_sib3());
std::vector<uint32_t> required_sibs = {1, 2, 3}; std::vector<uint32_t> required_sibs = {1, 2, 3};
if (rrc_ptr->serv_cell_cfg.launch(required_sibs)) { if (!rrc_ptr->serv_cell_cfg.launch(required_sibs)) {
Error("Failed to initiate configure serving cell\n");
return proc_outcome_t::error;
}
state = state_t::cell_configuration; state = state_t::cell_configuration;
}
} else { } else {
Error("Failed to initiate configure serving cell\n"); // Out-of-sync, relaunch reselection
state = state_t::error; Info("Serving cell is out-of-sync, re-launching re-selection procedure\n");
if (!rrc_ptr->cell_reselector.launch()) {
return proc_outcome_t::error;
}
} }
} }
return proc_outcome_t::yield;
} }
void rrc::connection_reest_proc::step_cell_configuration() proc_outcome_t rrc::connection_reest_proc::step_cell_configuration()
{ {
if (!rrc_ptr->t311.is_running()) { if (not rrc_ptr->serv_cell_cfg.run()) {
Info("During cell configuration, T311 expired. Aborting.\n"); // SIBs adquisition not started or finished
state = state_t::success; if (rrc_ptr->serving_cell->in_sync) {
} else if (rrc_ptr->serv_cell_cfg.run()) { // In-sync
// Keep running, do nothing if (rrc_ptr->serving_cell->has_sib1() && rrc_ptr->serving_cell->has_sib2() && rrc_ptr->serving_cell->has_sib3()) {
} else if (!rrc_ptr->serving_cell->in_sync) { // All SIBs are available
Info("Serving cell is out-of-sync, re-launching re-selection procedure\n"); return cell_criteria();
if (rrc_ptr->cell_reselector.launch()) {
state = state_t::cell_reselection;
} else { } else {
Error("Failed to initiate a Cell re-selection procedure...\n"); // Required SIBs are not available
state = state_t::error; Error("Failed to configure serving cell\n");
return proc_outcome_t::error;
} }
} else if (rrc_ptr->serving_cell->has_sib1() && rrc_ptr->serving_cell->has_sib2() &&
rrc_ptr->serving_cell->has_sib3()) {
Info("SIBs available. Going to cell criteria\n");
state = state_t::cell_criteria;
} else { } else {
Error("Failed to configure serving cell\n"); // Out-of-sync, relaunch reselection
state = state_t::error; Info("Serving cell is out-of-sync, re-launching re-selection procedure\n");
if (!rrc_ptr->cell_reselector.launch()) {
Error("Failed to initiate a Cell re-selection procedure...\n");
return proc_outcome_t::error;
} }
state = state_t::cell_reselection;
}
}
return proc_outcome_t::yield;
} }
void rrc::connection_reest_proc::step_cell_criteria() srslte::proc_outcome_t rrc::connection_reest_proc::cell_criteria()
{ {
// Wait until we're synced and have obtained SIBs
// Perform cell selection in accordance to 36.304 // Perform cell selection in accordance to 36.304
if (!rrc_ptr->t311.is_running()) { if (rrc_ptr->cell_selection_criteria(rrc_ptr->serving_cell->get_rsrp())) {
Info("During cell selection criteria, T311 expired. Aborting.\n");
state = state_t::success;
} else if (rrc_ptr->cell_selection_criteria(rrc_ptr->serving_cell->get_rsrp())) {
// Actions following cell reselection while T311 is running 5.3.7.3 // Actions following cell reselection while T311 is running 5.3.7.3
// Upon selecting a suitable E-UTRA cell, the UE shall: // Upon selecting a suitable E-UTRA cell, the UE shall:
Info("Cell Selection criteria passed after %dms. Sending RRC Connection Reestablishment Request\n", Info("Cell Selection criteria passed after %dms. Sending RRC Connection Reestablishment Request\n",
@ -1025,55 +1017,38 @@ void rrc::connection_reest_proc::step_cell_criteria()
rrc_ptr->t301.run(); rrc_ptr->t301.run();
// apply the timeAlignmentTimerCommon included in SystemInformationBlockType2; // apply the timeAlignmentTimerCommon included in SystemInformationBlockType2;
// TODO // Not implemented yet.
// initiate transmission of the RRCConnectionReestablishmentRequest message in accordance with 5.3.7.4; // initiate transmission of the RRCConnectionReestablishmentRequest message in accordance with 5.3.7.4;
rrc_ptr->send_con_restablish_request(reest_cause, reest_rnti, reest_source_pci); rrc_ptr->send_con_restablish_request(reest_cause, reest_rnti, reest_source_pci);
} else { } else {
// Upon selecting an inter-RAT cell // Upon selecting an inter-RAT cell
Warning("Reestablishment Cell Selection criteria failed.\n"); Info("Reestablishment Cell Selection criteria failed.\n");
rrc_ptr->leave_connected(); rrc_ptr->leave_connected();
} }
state = state_t::success; return proc_outcome_t::success;
} }
proc_outcome_t rrc::connection_reest_proc::step() proc_outcome_t rrc::connection_reest_proc::step()
{ {
proc_outcome_t proc_outcome = srslte::proc_outcome_t::yield; // Abort procedure if T311 expires
if (!rrc_ptr->t311.is_running()) {
Info("T311 expired. Aborting.\n");
return proc_outcome_t::success;
}
/* /*
* Implementation of procedure in 3GPP 36.331 Section 5.3.7.3: Actions following cell selection while T311 is running * Implementation of procedure in 3GPP 36.331 Section 5.3.7.3: Actions following cell selection while T311 is running
*/ */
switch (state) { switch (state) {
case state_t::init:
step_init();
break;
case state_t::cell_reselection: case state_t::cell_reselection:
step_cell_reselection(); return step_cell_reselection();
break;
case state_t::cell_configuration: case state_t::cell_configuration:
step_cell_configuration(); return step_cell_configuration();
break;
case state_t::cell_criteria:
step_cell_criteria();
break;
case state_t::success:
Info("Finished successfully\n");
proc_outcome = srslte::proc_outcome_t::success;
break;
case state_t::error:
Info("Finished with error\n");
proc_outcome = srslte::proc_outcome_t::error;
break;
} }
return proc_outcome; return proc_outcome_t::error;
} }
} // namespace srsue } // namespace srsue

Loading…
Cancel
Save