@ -117,27 +117,18 @@ void rrc::ue::activity_timer_expired(activity_timeout_type_t type)
if ( parent - > s1ap - > user_exists ( rnti ) ) {
if ( type = = UE_INACTIVITY_TIMEOUT ) {
parent - > s1ap - > user_release ( rnti , asn1 : : s1ap : : cause_radio_network_opts : : user_inactivity ) ;
event_logger : : get ( ) . log_rrc_disconnect ( ue_cell_list . get_ue_cc_idx ( UE_PCELL_CC_IDX ) - > cell_common - > enb_cc_idx ,
static_cast < unsigned > ( rrc_idle_transition_cause : : timeout ) ,
rnti ) ;
con_release_result = procedure_result_code : : activity_timeout ;
} else if ( type = = UE_REESTABLISH_TIMEOUT ) {
parent - > s1ap - > user_release ( rnti , asn1 : : s1ap : : cause_radio_network_opts : : radio_conn_with_ue_lost ) ;
event_logger : : get ( ) . log_rrc_disconnect (
ue_cell_list . get_ue_cc_idx ( UE_PCELL_CC_IDX ) - > cell_common - > enb_cc_idx ,
static_cast < unsigned > ( rrc_idle_transition_cause : : radio_conn_with_ue_lost ) ,
rnti ) ;
con_release_result = procedure_result_code : : radio_conn_with_ue_lost ;
} else if ( type = = MSG3_RX_TIMEOUT ) {
// MSG3 timeout, no need to notify S1AP, just remove UE
parent - > rem_user_thread ( rnti ) ;
event_logger : : get ( ) . log_rrc_disconnect ( ue_cell_list . get_ue_cc_idx ( UE_PCELL_CC_IDX ) - > cell_common - > enb_cc_idx ,
static_cast < unsigned > ( rrc_idle_transition_cause : : msg3_timeout ) ,
rnti ) ;
con_release_result = procedure_result_code : : msg3_timeout ;
} else {
// Unhandled activity timeout, just remove UE and log an error
parent - > rem_user_thread ( rnti ) ;
event_logger : : get ( ) . log_rrc_disconnect ( ue_cell_list . get_ue_cc_idx ( UE_PCELL_CC_IDX ) - > cell_common - > enb_cc_idx ,
static_cast < unsigned > ( rrc_idle_transition_cause : : msg3_timeout ) ,
rnti ) ;
con_release_result = procedure_result_code : : activity_timeout ;
parent - > logger . error (
" Unhandled reason for activity timer expiration. rnti=0x%x, cause %d " , rnti , static_cast < unsigned > ( type ) ) ;
}
@ -232,9 +223,11 @@ void rrc::ue::parse_ul_dcch(uint32_t lcid, srsran::unique_byte_buffer_t pdu)
switch ( ul_dcch_msg . msg . c1 ( ) . type ( ) ) {
case ul_dcch_msg_type_c : : c1_c_ : : types : : rrc_conn_setup_complete :
save_ul_message ( std : : move ( original_pdu ) ) ;
handle_rrc_con_setup_complete ( & ul_dcch_msg . msg . c1 ( ) . rrc_conn_setup_complete ( ) , std : : move ( pdu ) ) ;
break ;
case ul_dcch_msg_type_c : : c1_c_ : : types : : rrc_conn_reest_complete :
save_ul_message ( std : : move ( original_pdu ) ) ;
handle_rrc_con_reest_complete ( & ul_dcch_msg . msg . c1 ( ) . rrc_conn_reest_complete ( ) , std : : move ( pdu ) ) ;
break ;
case ul_dcch_msg_type_c : : c1_c_ : : types : : ul_info_transfer :
@ -255,6 +248,7 @@ void rrc::ue::parse_ul_dcch(uint32_t lcid, srsran::unique_byte_buffer_t pdu)
parent - > s1ap - > write_pdu ( rnti , std : : move ( pdu ) ) ;
break ;
case ul_dcch_msg_type_c : : c1_c_ : : types : : rrc_conn_recfg_complete :
save_ul_message ( std : : move ( original_pdu ) ) ;
handle_rrc_reconf_complete ( & ul_dcch_msg . msg . c1 ( ) . rrc_conn_recfg_complete ( ) , std : : move ( pdu ) ) ;
srsran : : console ( " User 0x%x connected \n " , rnti ) ;
state = RRC_STATE_REGISTERED ;
@ -274,7 +268,7 @@ void rrc::ue::parse_ul_dcch(uint32_t lcid, srsran::unique_byte_buffer_t pdu)
send_connection_reconf ( std : : move ( pdu ) ) ;
state = RRC_STATE_WAIT_FOR_CON_RECONF_COMPLETE ;
} else {
send_connection_reject ( ) ;
send_connection_reject ( procedure_result_code : : none ) ;
state = RRC_STATE_IDLE ;
}
break ;
@ -305,13 +299,16 @@ std::string rrc::ue::to_string(const activity_timeout_type_t& type)
*/
void rrc : : ue : : handle_rrc_con_req ( rrc_conn_request_s * msg )
{
if ( not parent - > s1ap - > is_mme_connected ( ) ) {
parent - > logger . error ( " MME isn't connected. Sending Connection Reject " ) ;
event_logger : : get ( ) . log_rrc_connected ( ue_cell_list . get_ue_cc_idx ( UE_PCELL_CC_IDX ) - > cell_common - > enb_cc_idx ,
// Log event.
event_logger : : get ( ) . log_rrc_event ( ue_cell_list . get_ue_cc_idx ( UE_PCELL_CC_IDX ) - > cell_common - > enb_cc_idx ,
asn1 : : octstring_to_string ( last_ul_msg - > msg , last_ul_msg - > N_bytes ) ,
static_cast < unsigned > ( conn_request_result_t : : error_mme_not_connected ) ,
static_cast < unsigned > ( rrc_event_type : : con_request ) ,
static_cast < unsigned > ( procedure_result_code : : none ) ,
rnti ) ;
send_connection_reject ( ) ;
if ( not parent - > s1ap - > is_mme_connected ( ) ) {
parent - > logger . error ( " MME isn't connected. Sending Connection Reject " ) ;
send_connection_reject ( procedure_result_code : : error_mme_not_connected ) ;
return ;
}
@ -365,13 +362,28 @@ void rrc::ue::send_connection_setup()
// Configure PHY layer
apply_setup_phy_config_dedicated ( rr_cfg . phys_cfg_ded ) ; // It assumes SCell has not been set before
send_dl_ccch ( & dl_ccch_msg ) ;
std : : string octet_str ;
send_dl_ccch ( & dl_ccch_msg , & octet_str ) ;
// Log event.
event_logger : : get ( ) . log_rrc_event ( ue_cell_list . get_ue_cc_idx ( UE_PCELL_CC_IDX ) - > cell_common - > enb_cc_idx ,
octet_str ,
static_cast < unsigned > ( rrc_event_type : : con_setup ) ,
static_cast < unsigned > ( procedure_result_code : : none ) ,
rnti ) ;
apply_rr_cfg_ded_diff ( current_ue_cfg . rr_cfg , rr_cfg ) ;
}
void rrc : : ue : : handle_rrc_con_setup_complete ( rrc_conn_setup_complete_s * msg , srsran : : unique_byte_buffer_t pdu )
{
// Log event.
event_logger : : get ( ) . log_rrc_event ( ue_cell_list . get_ue_cc_idx ( UE_PCELL_CC_IDX ) - > cell_common - > enb_cc_idx ,
asn1 : : octstring_to_string ( last_ul_msg - > msg , last_ul_msg - > N_bytes ) ,
static_cast < unsigned > ( rrc_event_type : : con_setup_complete ) ,
static_cast < unsigned > ( procedure_result_code : : none ) ,
rnti ) ;
// Inform PHY about the configuration completion
parent - > phy - > complete_config ( rnti ) ;
@ -398,12 +410,6 @@ void rrc::ue::handle_rrc_con_setup_complete(rrc_conn_setup_complete_s* msg, srsr
}
state = RRC_STATE_WAIT_FOR_CON_RECONF_COMPLETE ;
// Log event.
event_logger : : get ( ) . log_rrc_connected ( enb_cc_idx ,
asn1 : : octstring_to_string ( last_ul_msg - > msg , last_ul_msg - > N_bytes ) ,
static_cast < unsigned > ( conn_request_result_t : : success ) ,
rnti ) ;
// 2> if the UE has radio link failure or handover failure information available
if ( msg - > crit_exts . type ( ) . value = = c1_or_crit_ext_opts : : c1 and
msg - > crit_exts . c1 ( ) . type ( ) . value = =
@ -415,13 +421,22 @@ void rrc::ue::handle_rrc_con_setup_complete(rrc_conn_setup_complete_s* msg, srsr
}
}
void rrc : : ue : : send_connection_reject ( )
void rrc : : ue : : send_connection_reject ( procedure_result_code cause )
{
mac_ctrl . handle_con_reject ( ) ;
dl_ccch_msg_s dl_ccch_msg ;
dl_ccch_msg . msg . set_c1 ( ) . set_rrc_conn_reject ( ) . crit_exts . set_c1 ( ) . set_rrc_conn_reject_r8 ( ) . wait_time = 10 ;
send_dl_ccch ( & dl_ccch_msg ) ;
std : : string octet_str ;
send_dl_ccch ( & dl_ccch_msg , & octet_str ) ;
// Log event.
event_logger : : get ( ) . log_rrc_event ( ue_cell_list . get_ue_cc_idx ( UE_PCELL_CC_IDX ) - > cell_common - > enb_cc_idx ,
octet_str ,
static_cast < unsigned > ( rrc_event_type : : con_reject ) ,
static_cast < unsigned > ( cause ) ,
rnti ) ;
}
/*
@ -429,13 +444,16 @@ void rrc::ue::send_connection_reject()
*/
void rrc : : ue : : handle_rrc_con_reest_req ( rrc_conn_reest_request_s * msg )
{
if ( not parent - > s1ap - > is_mme_connected ( ) ) {
parent - > logger . error ( " MME isn't connected. Sending Connection Reject " ) ;
event_logger : : get ( ) . log_rrc_connected ( ue_cell_list . get_ue_cc_idx ( UE_PCELL_CC_IDX ) - > cell_common - > enb_cc_idx ,
// Log event.
event_logger : : get ( ) . log_rrc_event ( ue_cell_list . get_ue_cc_idx ( UE_PCELL_CC_IDX ) - > cell_common - > enb_cc_idx ,
asn1 : : octstring_to_string ( last_ul_msg - > msg , last_ul_msg - > N_bytes ) ,
static_cast < unsigned > ( conn_request_result_t : : error_mme_not_connected ) ,
static_cast < unsigned > ( rrc_event_type : : con_reest_req ) ,
static_cast < unsigned > ( procedure_result_code : : none ) ,
rnti ) ;
send_connection_reject ( ) ;
if ( not parent - > s1ap - > is_mme_connected ( ) ) {
parent - > logger . error ( " MME isn't connected. Sending Connection Reject " ) ;
send_connection_reject ( procedure_result_code : : error_mme_not_connected ) ;
return ;
}
parent - > logger . debug ( " rnti=0x%x, phyid=0x%x, smac=0x%x, cause=%s " ,
@ -496,11 +514,7 @@ void rrc::ue::handle_rrc_con_reest_req(rrc_conn_reest_request_s* msg)
set_activity_timeout ( UE_INACTIVITY_TIMEOUT ) ;
} else {
parent - > logger . error ( " Received ConnectionReestablishment for rnti=0x%x without context " , old_rnti ) ;
event_logger : : get ( ) . log_rrc_connected ( ue_cell_list . get_ue_cc_idx ( UE_PCELL_CC_IDX ) - > cell_common - > enb_cc_idx ,
asn1 : : octstring_to_string ( last_ul_msg - > msg , last_ul_msg - > N_bytes ) ,
static_cast < unsigned > ( conn_request_result_t : : error_unknown_rnti ) ,
rnti ) ;
send_connection_reest_rej ( ) ;
send_connection_reest_rej ( procedure_result_code : : error_unknown_rnti ) ;
}
} else {
parent - > logger . error ( " Received ReestablishmentRequest from an rnti=0x%x not in IDLE " , rnti ) ;
@ -532,13 +546,28 @@ void rrc::ue::send_connection_reest(uint8_t ncc)
// Configure PHY layer
apply_setup_phy_config_dedicated ( rr_cfg . phys_cfg_ded ) ; // It assumes SCell has not been set before
send_dl_ccch ( & dl_ccch_msg ) ;
std : : string octet_str ;
send_dl_ccch ( & dl_ccch_msg , & octet_str ) ;
apply_rr_cfg_ded_diff ( current_ue_cfg . rr_cfg , rr_cfg ) ;
// Log event.
event_logger : : get ( ) . log_rrc_event ( ue_cell_list . get_ue_cc_idx ( UE_PCELL_CC_IDX ) - > cell_common - > enb_cc_idx ,
octet_str ,
static_cast < unsigned > ( rrc_event_type : : con_reest ) ,
static_cast < unsigned > ( procedure_result_code : : none ) ,
rnti ) ;
}
void rrc : : ue : : handle_rrc_con_reest_complete ( rrc_conn_reest_complete_s * msg , srsran : : unique_byte_buffer_t pdu )
{
// Log event.
event_logger : : get ( ) . log_rrc_event ( ue_cell_list . get_ue_cc_idx ( UE_PCELL_CC_IDX ) - > cell_common - > enb_cc_idx ,
asn1 : : octstring_to_string ( last_ul_msg - > msg , last_ul_msg - > N_bytes ) ,
static_cast < unsigned > ( rrc_event_type : : con_reest_complete ) ,
static_cast < unsigned > ( procedure_result_code : : none ) ,
rnti ) ;
// Inform PHY about the configuration completion
parent - > phy - > complete_config ( rnti ) ;
@ -567,11 +596,6 @@ void rrc::ue::handle_rrc_con_reest_complete(rrc_conn_reest_complete_s* msg, srsr
state = RRC_STATE_REESTABLISHMENT_COMPLETE ;
event_logger : : get ( ) . log_rrc_connected ( ue_cell_list . get_ue_cc_idx ( UE_PCELL_CC_IDX ) - > cell_common - > enb_cc_idx ,
asn1 : : octstring_to_string ( last_ul_msg - > msg , last_ul_msg - > N_bytes ) ,
0 ,
rnti ) ;
// 2> if the UE has radio link failure or handover failure information available
if ( msg - > crit_exts . type ( ) . value = = rrc_conn_reest_complete_s : : crit_exts_c_ : : types_opts : : rrc_conn_reest_complete_r8 ) {
const auto & complete_r8 = msg - > crit_exts . rrc_conn_reest_complete_r8 ( ) ;
@ -583,13 +607,22 @@ void rrc::ue::handle_rrc_con_reest_complete(rrc_conn_reest_complete_s* msg, srsr
send_connection_reconf ( std : : move ( pdu ) ) ;
}
void rrc : : ue : : send_connection_reest_rej ( )
void rrc : : ue : : send_connection_reest_rej ( procedure_result_code cause )
{
mac_ctrl . handle_con_reject ( ) ;
dl_ccch_msg_s dl_ccch_msg ;
dl_ccch_msg . msg . set_c1 ( ) . set_rrc_conn_reest_reject ( ) . crit_exts . set_rrc_conn_reest_reject_r8 ( ) ;
send_dl_ccch ( & dl_ccch_msg ) ;
std : : string octet_str ;
send_dl_ccch ( & dl_ccch_msg , & octet_str ) ;
// Log event.
event_logger : : get ( ) . log_rrc_event ( ue_cell_list . get_ue_cc_idx ( UE_PCELL_CC_IDX ) - > cell_common - > enb_cc_idx ,
octet_str ,
static_cast < unsigned > ( rrc_event_type : : con_reest_reject ) ,
static_cast < unsigned > ( cause ) ,
rnti ) ;
}
/*
@ -653,7 +686,15 @@ void rrc::ue::send_connection_reconf(srsran::unique_byte_buffer_t pdu,
}
// send DL-DCCH message to lower layers
send_dl_dcch ( & dl_dcch_msg , std : : move ( pdu ) ) ;
std : : string octet_str ;
send_dl_dcch ( & dl_dcch_msg , std : : move ( pdu ) , & octet_str ) ;
// Log event.
event_logger : : get ( ) . log_rrc_event ( ue_cell_list . get_ue_cc_idx ( UE_PCELL_CC_IDX ) - > cell_common - > enb_cc_idx ,
octet_str ,
static_cast < unsigned > ( rrc_event_type : : con_reconf ) ,
static_cast < unsigned > ( procedure_result_code : : none ) ,
rnti ) ;
state = RRC_STATE_WAIT_FOR_CON_RECONF_COMPLETE ;
}
@ -669,6 +710,13 @@ void rrc::ue::handle_rrc_reconf_complete(rrc_conn_recfg_complete_s* msg, srsran:
return ;
}
// Log event.
event_logger : : get ( ) . log_rrc_event ( ue_cell_list . get_ue_cc_idx ( UE_PCELL_CC_IDX ) - > cell_common - > enb_cc_idx ,
asn1 : : octstring_to_string ( last_ul_msg - > msg , last_ul_msg - > N_bytes ) ,
static_cast < unsigned > ( rrc_event_type : : con_reconf_complete ) ,
static_cast < unsigned > ( procedure_result_code : : none ) ,
rnti ) ;
// Activate SCells and bearers in the MAC scheduler that were advertised in the RRC Reconf message
mac_ctrl . handle_con_reconf_complete ( ) ;
@ -825,11 +873,14 @@ void rrc::ue::send_connection_release()
}
}
send_dl_dcch ( & dl_dcch_msg ) ;
std : : string octet_str ;
send_dl_dcch ( & dl_dcch_msg , nullptr , & octet_str ) ;
// Log rrc release event.
event_logger : : get ( ) . log_rrc_disconnect ( ue_cell_list . get_ue_cc_idx ( UE_PCELL_CC_IDX ) - > cell_common - > enb_cc_idx ,
static_cast < unsigned > ( rrc_idle_transition_cause : : release ) ,
event_logger : : get ( ) . log_rrc_event ( ue_cell_list . get_ue_cc_idx ( UE_PCELL_CC_IDX ) - > cell_common - > enb_cc_idx ,
octet_str ,
static_cast < unsigned > ( rrc_event_type : : con_release ) ,
static_cast < unsigned > ( con_release_result ) ,
rnti ) ;
}
@ -1099,7 +1150,7 @@ void rrc::ue::update_scells()
/********************** HELPERS ***************************/
void rrc : : ue : : send_dl_ccch ( dl_ccch_msg_s * dl_ccch_msg )
void rrc : : ue : : send_dl_ccch ( dl_ccch_msg_s * dl_ccch_msg , std : : string * octet_str )
{
// Allocate a new PDU buffer, pack the message and send to PDCP
srsran : : unique_byte_buffer_t pdu = srsran : : make_byte_buffer ( ) ;
@ -1114,13 +1165,19 @@ void rrc::ue::send_dl_ccch(dl_ccch_msg_s* dl_ccch_msg)
char buf [ 32 ] = { } ;
sprintf ( buf , " SRB0 - rnti=0x%x " , rnti ) ;
parent - > log_rrc_message ( buf , Tx , pdu . get ( ) , * dl_ccch_msg , dl_ccch_msg - > msg . c1 ( ) . type ( ) . to_string ( ) ) ;
// Encode the pdu as an octet string if the user passed a valid pointer.
if ( octet_str ) {
* octet_str = asn1 : : octstring_to_string ( pdu - > msg , pdu - > N_bytes ) ;
}
parent - > rlc - > write_sdu ( rnti , RB_ID_SRB0 , std : : move ( pdu ) ) ;
} else {
parent - > logger . error ( " Allocating pdu " ) ;
}
}
bool rrc : : ue : : send_dl_dcch ( const dl_dcch_msg_s * dl_dcch_msg , srsran : : unique_byte_buffer_t pdu )
bool rrc : : ue : : send_dl_dcch ( const dl_dcch_msg_s * dl_dcch_msg , srsran : : unique_byte_buffer_t pdu , std : : string * octet_str )
{
if ( ! pdu ) {
pdu = srsran : : make_byte_buffer ( ) ;
@ -1143,6 +1200,11 @@ bool rrc::ue::send_dl_dcch(const dl_dcch_msg_s* dl_dcch_msg, srsran::unique_byte
sprintf ( buf , " SRB%d - rnti=0x%x " , lcid , rnti ) ;
parent - > log_rrc_message ( buf , Tx , pdu . get ( ) , * dl_dcch_msg , dl_dcch_msg - > msg . c1 ( ) . type ( ) . to_string ( ) ) ;
// Encode the pdu as an octet string if the user passed a valid pointer.
if ( octet_str ) {
* octet_str = asn1 : : octstring_to_string ( pdu - > msg , pdu - > N_bytes ) ;
}
parent - > pdcp - > write_sdu ( rnti , lcid , std : : move ( pdu ) ) ;
} else {
parent - > logger . error ( " Allocating pdu " ) ;