diff --git a/lib/include/srslte/common/enb_events.h b/lib/include/srslte/common/enb_events.h index 296ab3297..40cd4b037 100644 --- a/lib/include/srslte/common/enb_events.h +++ b/lib/include/srslte/common/enb_events.h @@ -41,11 +41,14 @@ public: /// Logs into the underlying log channel the S1 context delete event. virtual void log_s1_ctx_delete(uint32_t mme_id, uint32_t enb_id, uint16_t rnti) = 0; - /// Logs into the underlying log channel the when a sector has been started. + /// Logs into the underlying log channel when a sector has been started. virtual void log_sector_start(uint32_t cc_idx, uint32_t pci, uint32_t cell_id) = 0; - /// Logs into the underlying log channel the when a sector has been stopped. + /// Logs into the underlying log channel when a sector has been stopped. virtual void log_sector_stop(uint32_t cc_idx, uint32_t pci, uint32_t cell_id) = 0; + + /// Logs into the underlying log channel a RLF event. + virtual void log_rlf(uint32_t cc_idx, const std::string& asn1, uint16_t rnti) = 0; }; /// Singleton class to provide global access to the event_logger_interface interface. diff --git a/lib/src/common/enb_events.cc b/lib/src/common/enb_events.cc index d4398123b..1abc0f0b5 100644 --- a/lib/src/common/enb_events.cc +++ b/lib/src/common/enb_events.cc @@ -28,6 +28,7 @@ public: void log_s1_ctx_delete(uint32_t mme_id, uint32_t enb_id, uint16_t rnti) override {} void log_sector_start(uint32_t cc_idx, uint32_t pci, uint32_t cell_id) override {} void log_sector_stop(uint32_t cc_idx, uint32_t pci, uint32_t cell_id) override {} + void log_rlf(uint32_t cc_idx, const std::string& asn1, uint16_t rnti) override {} }; } // namespace @@ -38,10 +39,16 @@ namespace { DECLARE_METRIC("type", metric_type_tag, std::string, ""); DECLARE_METRIC("event_name", metric_event_name, std::string, ""); +DECLARE_METRIC("rnti", metric_rnti, uint16_t, ""); +DECLARE_METRIC("sector_id", metric_sector_id, uint32_t, ""); + +/// ASN1 message metrics. +DECLARE_METRIC("asn1_length", metric_asn1_length, uint32_t, ""); +DECLARE_METRIC("asn1_message", metric_asn1_message, std::string, ""); + /// Context for sector start/stop. DECLARE_METRIC("pci", metric_pci, uint32_t, ""); DECLARE_METRIC("cell_identity", metric_cell_identity, uint32_t, ""); -DECLARE_METRIC("sector_id", metric_sector_id, uint32_t, ""); DECLARE_METRIC_SET("event_data", mset_sector_event, metric_pci, metric_cell_identity, metric_sector_id); using sector_event_t = srslog::build_context_type; @@ -53,10 +60,13 @@ using rrc_event_t = srslog::build_context_type; +/// Context for the RLC event. +DECLARE_METRIC_SET("event_data", mset_rlfctx_event, metric_asn1_length, metric_asn1_message, metric_rnti); +using rlfctx_event_t = srslog::build_context_type; + /// Logs events into the configured log channel. class logging_event_logger : public event_logger_interface { @@ -131,6 +141,18 @@ public: event_channel(ctx); } + void log_rlf(uint32_t cc_idx, const std::string& asn1, uint16_t rnti) override + { + rlfctx_event_t ctx(""); + + ctx.write("event"); + ctx.write("radio_link_failure"); + ctx.get().write(asn1.size()); + ctx.get().write(asn1); + ctx.get().write(rnti); + event_channel(ctx); + } + private: srslog::log_channel& event_channel; }; diff --git a/srsenb/hdr/stack/rrc/rrc_ue.h b/srsenb/hdr/stack/rrc/rrc_ue.h index 026f17270..72230b256 100644 --- a/srsenb/hdr/stack/rrc/rrc_ue.h +++ b/srsenb/hdr/stack/rrc/rrc_ue.h @@ -66,7 +66,7 @@ public: bool handle_ue_cap_info(asn1::rrc::ue_cap_info_s* msg); void handle_ue_init_ctxt_setup_req(const asn1::s1ap::init_context_setup_request_s& msg); bool handle_ue_ctxt_mod_req(const asn1::s1ap::ue_context_mod_request_s& msg); - void handle_ue_info_resp(const asn1::rrc::ue_info_resp_r9_s& msg); + void handle_ue_info_resp(const asn1::rrc::ue_info_resp_r9_s& msg, srslte::unique_byte_buffer_t pdu); void set_bitrates(const asn1::s1ap::ue_aggregate_maximum_bitrate_s& rates); diff --git a/srsenb/src/stack/rrc/rrc_ue.cc b/srsenb/src/stack/rrc/rrc_ue.cc index 4bac96c07..883106477 100644 --- a/srsenb/src/stack/rrc/rrc_ue.cc +++ b/srsenb/src/stack/rrc/rrc_ue.cc @@ -167,8 +167,8 @@ void rrc::ue::parse_ul_dcch(uint32_t lcid, srslte::unique_byte_buffer_t pdu) parent->log_rrc_message( srsenb::to_string((rb_id_t)lcid), Rx, pdu.get(), ul_dcch_msg, ul_dcch_msg.msg.c1().type().to_string()); - // reuse PDU - pdu->clear(); // TODO: name collision with byte_buffer reset + srslte::unique_byte_buffer_t original_pdu = std::move(pdu); + pdu = srslte::allocate_unique_buffer(*pool); transaction_id = 0; @@ -228,7 +228,7 @@ void rrc::ue::parse_ul_dcch(uint32_t lcid, srslte::unique_byte_buffer_t pdu) } break; case ul_dcch_msg_type_c::c1_c_::types::ue_info_resp_r9: - handle_ue_info_resp(ul_dcch_msg.msg.c1().ue_info_resp_r9()); + handle_ue_info_resp(ul_dcch_msg.msg.c1().ue_info_resp_r9(), std::move(original_pdu)); break; default: parent->logger.error("Msg: %s not supported", ul_dcch_msg.msg.c1().type().to_string().c_str()); @@ -607,11 +607,12 @@ void rrc::ue::send_ue_info_req() send_dl_dcch(&msg); } -void rrc::ue::handle_ue_info_resp(const asn1::rrc::ue_info_resp_r9_s& msg) +void rrc::ue::handle_ue_info_resp(const asn1::rrc::ue_info_resp_r9_s& msg, srslte::unique_byte_buffer_t pdu) { auto& resp_r9 = msg.crit_exts.c1().ue_info_resp_r9(); if (resp_r9.rlf_report_r9_present) { - // TODO: Handle RLF-Report + std::string msg_str = asn1::octstring_to_string(pdu->msg, pdu->N_bytes); + event_logger::get().log_rlf(ue_cell_list.get_ue_cc_idx(UE_PCELL_CC_IDX)->cell_common->enb_cc_idx, msg_str, rnti); } if (resp_r9.rach_report_r9_present) { // TODO: Handle RACH-Report @@ -944,7 +945,7 @@ void rrc::ue::notify_s1ap_ue_erab_setup_response(const asn1::s1ap::erab_to_be_se } else { res.protocol_ies.erab_failed_to_setup_list_bearer_su_res_present = true; res.protocol_ies.erab_failed_to_setup_list_bearer_su_res.value.push_back({}); - auto& item = res.protocol_ies.erab_failed_to_setup_list_bearer_su_res.value.back(); + auto& item = res.protocol_ies.erab_failed_to_setup_list_bearer_su_res.value.back(); item.load_info_obj(ASN1_S1AP_ID_ERAB_ITEM); item.value.erab_item().erab_id = id; item.value.erab_item().cause.set_radio_network().value =