diff --git a/srsenb/enb.conf.example b/srsenb/enb.conf.example index e34503e16..985e0fab5 100644 --- a/srsenb/enb.conf.example +++ b/srsenb/enb.conf.example @@ -371,7 +371,7 @@ enable = false #ema_alpha = 0.0143 ##################################################################### -[ric_client] +[e2_agent] enable = true #ric_ip = 127.0.0.1 #ric_port = 36421 diff --git a/srsenb/hdr/enb.h b/srsenb/hdr/enb.h index 5c30752db..bfe0bad07 100644 --- a/srsenb/hdr/enb.h +++ b/srsenb/hdr/enb.h @@ -114,7 +114,7 @@ struct all_args_t { general_args_t general; phy_args_t phy; stack_args_t stack; - ric_args_t ric_client; + e2_agent_args_t e2_agent; gnb_stack_args_t nr_stack; }; @@ -139,7 +139,7 @@ public: void print_pool(); - bool enable_ric_client(srsenb::e2_interface_metrics* e2_metrics); + bool enable_e2_agent(srsenb::e2_interface_metrics* e2_metrics); // eNodeB metrics interface bool get_metrics(enb_metrics_t* m) override; @@ -174,7 +174,7 @@ private: std::unique_ptr nr_stack = nullptr; std::unique_ptr radio = nullptr; std::unique_ptr phy = nullptr; - std::unique_ptr ric = nullptr; + std::unique_ptr _e2_agent = nullptr; // System metrics processor. srsran::sys_metrics_processor sys_proc; diff --git a/srsenb/src/enb.cc b/srsenb/src/enb.cc index 51b727f3a..2c5299db7 100644 --- a/srsenb/src/enb.cc +++ b/srsenb/src/enb.cc @@ -190,19 +190,19 @@ void enb::start_plot() phy->start_plot(); } -bool enb::enable_ric_client(srsenb::e2_interface_metrics* e2_metrics) +bool enb::enable_e2_agent(srsenb::e2_interface_metrics* e2_metrics) { - std::unique_ptr tmp_ric_client = std::unique_ptr( - new srsenb::ric_client(srslog::fetch_basic_logger("RIC", log_sink, false), e2_metrics)); - if (tmp_ric_client == nullptr) { - srsran::console("Error creating RIC client instance.\n"); + std::unique_ptr tmp_e2_agent = std::unique_ptr( + new srsenb::e2_agent(srslog::fetch_basic_logger("E2_AGENT", log_sink, false), e2_metrics)); + if (tmp_e2_agent == nullptr) { + srsran::console("Error creating e2_agent instance.\n"); return SRSRAN_ERROR; } - if (tmp_ric_client->init(args.ric_client)) { - srsran::console("Error initializing RIC client.\n"); + if (tmp_e2_agent->init(args.e2_agent)) { + srsran::console("Error initializing e2_agent client.\n"); return SRSRAN_ERROR; } - ric = std::move(tmp_ric_client); + _e2_agent = std::move(tmp_e2_agent); return SRSRAN_SUCCESS; } @@ -275,8 +275,8 @@ void enb::tti_clock() return; } - if (ric) { - ric->tic(); + if (_e2_agent) { + _e2_agent->tic(); } if (eutra_stack) { diff --git a/srsenb/src/main.cc b/srsenb/src/main.cc index 019a8ab96..58ac1c9a1 100644 --- a/srsenb/src/main.cc +++ b/srsenb/src/main.cc @@ -229,9 +229,9 @@ void parse_args(all_args_t* args, int argc, char* argv[]) ("cfr.ema_alpha", bpo::value(&args->phy.cfr_args.ema_alpha)->default_value(args->phy.cfr_args.ema_alpha), "Alpha coefficient for the power average in auto_ema mode (0 to 1)") /* RIC section */ - ("ric_client.enable", bpo::value(&args->ric_client.enable)->default_value(false), "Enables the RIC client") - ("ric_client.ric_ip", bpo::value(&args->ric_client.ric_ip)->default_value("127.0.0.1"), "RIC IP address") - ("ric_client.ric_port", bpo::value(&args->ric_client.ric_port)->default_value(36421), "RIC port") + ("e2_agent.enable", bpo::value(&args->e2_agent.enable)->default_value(false), "Enables the E2 agent") + ("e2_agent.ric_ip", bpo::value(&args->e2_agent.ric_ip)->default_value("127.0.0.1"), "RIC IP address") + ("e2_agent.ric_port", bpo::value(&args->e2_agent.ric_port)->default_value(36421), "RIC port") /* Expert section */ ("expert.metrics_period_secs", bpo::value(&args->general.metrics_period_secs)->default_value(1.0), "Periodicity for metrics in seconds.") @@ -684,7 +684,7 @@ int main(int argc, char* argv[]) metricshub.add_listener(&json_metrics); } srsenb::metrics_e2 e2_metrics(enb.get()); - if (args.ric_client.enable) { + if (args.e2_agent.enable) { metricshub.add_listener(&e2_metrics); } @@ -695,9 +695,9 @@ int main(int argc, char* argv[]) if (args.gui.enable) { enb->start_plot(); } - if (args.ric_client.enable) { - if (enb->enable_ric_client(&e2_metrics)) { - srslog::fetch_basic_logger("RIC").error("Failed to enable RIC client"); + if (args.e2_agent.enable) { + if (enb->enable_e2_agent(&e2_metrics)) { + srslog::fetch_basic_logger("E2_AGENT").error("Failed to enable E2 Agent"); } } } diff --git a/srsgnb/hdr/stack/ric/e2ap.h b/srsgnb/hdr/stack/ric/e2ap.h index e32076259..dc909533a 100644 --- a/srsgnb/hdr/stack/ric/e2ap.h +++ b/srsgnb/hdr/stack/ric/e2ap.h @@ -46,13 +46,13 @@ typedef struct { std::vector not_admitted_actions; } ric_subscription_reponse_t; -class ric_client; +class e2_agent; class e2ap { public: e2ap(srslog::basic_logger& logger, - ric_client* _ric_client, + e2_agent* _e2_agent, srsenb::e2_interface_metrics* _gnb_metrics, srsran::task_scheduler* _task_sched_ptr); ~e2ap(); @@ -95,7 +95,7 @@ public: private: srslog::basic_logger& logger; - ric_client* _ric_client; + e2_agent* _e2_agent; e2sm_kpm e2sm_; bool e2_established = false; srsran::unique_timer e2_procedure_timeout; diff --git a/srsgnb/hdr/stack/ric/ric_client.h b/srsgnb/hdr/stack/ric/ric_client.h index ee8596281..b9a03c408 100644 --- a/srsgnb/hdr/stack/ric/ric_client.h +++ b/srsgnb/hdr/stack/ric/ric_client.h @@ -32,21 +32,21 @@ enum e2_msg_type_t { E2_RESET_RESPONSE }; -struct ric_args_t { +struct e2_agent_args_t { bool enable; std::string ric_ip; uint32_t ric_port; }; namespace srsenb { -class ric_client : public srsran::thread +class e2_agent : public srsran::thread { public: - ric_client(srslog::basic_logger& logger, srsenb::e2_interface_metrics* _gnb_metrics); - ~ric_client() = default; + e2_agent(srslog::basic_logger& logger, srsenb::e2_interface_metrics* _gnb_metrics); + ~e2_agent() = default; // Initiate and Stop - bool init(ric_args_t args); + bool init(e2_agent_args_t args); void stop(); void run_thread(); void tic(); diff --git a/srsgnb/src/stack/ric/e2ap.cc b/srsgnb/src/stack/ric/e2ap.cc index ac6b9d9a9..8aafcf3cc 100644 --- a/srsgnb/src/stack/ric/e2ap.cc +++ b/srsgnb/src/stack/ric/e2ap.cc @@ -15,10 +15,10 @@ #include "srsgnb/hdr/stack/ric/ric_client.h" e2ap::e2ap(srslog::basic_logger& logger, - ric_client* _ric_client, + e2_agent* _e2_agent, srsenb::e2_interface_metrics* _gnb_metrics, srsran::task_scheduler* _task_sched_ptr) : - logger(logger), _ric_client(_ric_client), e2sm_(logger, _task_sched_ptr), task_sched_ptr(_task_sched_ptr) + logger(logger), _e2_agent(_e2_agent), e2sm_(logger, _task_sched_ptr), task_sched_ptr(_task_sched_ptr) { gnb_metrics = _gnb_metrics; e2_procedure_timeout = task_sched_ptr->get_unique_timer(); @@ -47,8 +47,8 @@ bool e2ap::get_func_desc(uint32_t ran_func_id, RANfunction_description& fdesc) bool e2ap::queue_send_e2ap_pdu(e2_ap_pdu_c e2ap_pdu) { - if (_ric_client) { - _ric_client->queue_send_e2ap_pdu(e2ap_pdu); + if (_e2_agent) { + _e2_agent->queue_send_e2ap_pdu(e2ap_pdu); } return true; } @@ -382,7 +382,7 @@ int e2ap::process_reset_request(reset_request_s reset_request) { reset_id = reset_request->transaction_id.value; - // TO DO: Parse and store the cause for future extension of the ric client + // TODO: Parse and store the cause for future extension of the e2_agent return SRSRAN_SUCCESS; } diff --git a/srsgnb/src/stack/ric/ric_client.cc b/srsgnb/src/stack/ric/ric_client.cc index f9bdf0444..61db28922 100644 --- a/srsgnb/src/stack/ric/ric_client.cc +++ b/srsgnb/src/stack/ric/ric_client.cc @@ -14,19 +14,15 @@ #include "srsran/asn1/e2ap.h" using namespace srsenb; -ric_client::ric_client(srslog::basic_logger& logger, e2_interface_metrics* _gnb_metrics) : - task_sched(), - logger(logger), - rx_sockets(), - thread("RIC_CLIENT_THREAD"), - e2ap_(logger, this, _gnb_metrics, &task_sched) +e2_agent::e2_agent(srslog::basic_logger& logger, e2_interface_metrics* _gnb_metrics) : + task_sched(), logger(logger), rx_sockets(), thread("E2_AGENT_THREAD"), e2ap_(logger, this, _gnb_metrics, &task_sched) { gnb_metrics = _gnb_metrics; } -bool ric_client::init(ric_args_t args) +bool e2_agent::init(e2_agent_args_t args) { - printf("RIC_CLIENT: Init\n"); + printf("E2_AGENT: Init\n"); using namespace srsran::net_utils; // Open SCTP socket if (not ric_socket.open_socket(addr_family::ipv4, socket_type::seqpacket, protocol_type::SCTP)) { @@ -63,19 +59,19 @@ bool ric_client::init(ric_args_t args) return SRSRAN_SUCCESS; } -void ric_client::stop() +void e2_agent::stop() { running = false; wait_thread_finish(); } -void ric_client::tic() +void e2_agent::tic() { // get tick every 1ms to advance timers task_sched.tic(); } -void ric_client::run_thread() +void e2_agent::run_thread() { using namespace asn1::e2ap; @@ -88,7 +84,7 @@ void ric_client::run_thread() } } -bool ric_client::send_sctp(srsran::unique_byte_buffer_t& buf) +bool e2_agent::send_sctp(srsran::unique_byte_buffer_t& buf) { ssize_t ret; ret = sctp_sendmsg(ric_socket.fd(), @@ -108,7 +104,7 @@ bool ric_client::send_sctp(srsran::unique_byte_buffer_t& buf) return true; } -bool ric_client::send_e2_msg(e2_msg_type_t msg_type) +bool e2_agent::send_e2_msg(e2_msg_type_t msg_type) { std::string message_name; e2_ap_pdu_c send_pdu; @@ -134,14 +130,14 @@ bool ric_client::send_e2_msg(e2_msg_type_t msg_type) return send_e2ap_pdu(send_pdu); } -bool ric_client::queue_send_e2ap_pdu(e2_ap_pdu_c e2ap_pdu) +bool e2_agent::queue_send_e2ap_pdu(e2_ap_pdu_c e2ap_pdu) { auto send_e2ap_pdu_task = [this, e2ap_pdu]() { send_e2ap_pdu(e2ap_pdu); }; ric_rece_task_queue.push(send_e2ap_pdu_task); return true; } -bool ric_client::send_e2ap_pdu(e2_ap_pdu_c send_pdu) +bool e2_agent::send_e2ap_pdu(e2_ap_pdu_c send_pdu) { srsran::unique_byte_buffer_t buf = srsran::make_byte_buffer(); if (buf == nullptr) { @@ -162,12 +158,12 @@ bool ric_client::send_e2ap_pdu(e2_ap_pdu_c send_pdu) return true; } -bool ric_client::handle_e2_rx_msg(srsran::unique_byte_buffer_t pdu, - const sockaddr_in& from, - const sctp_sndrcvinfo& sri, - int flags) +bool e2_agent::handle_e2_rx_msg(srsran::unique_byte_buffer_t pdu, + const sockaddr_in& from, + const sctp_sndrcvinfo& sri, + int flags) { - printf("RIC_CLIENT: Received %d bytes from %s\n", pdu->N_bytes, inet_ntoa(from.sin_addr)); + printf("E2_AGENT: Received %d bytes from %s\n", pdu->N_bytes, inet_ntoa(from.sin_addr)); e2_ap_pdu_c pdu_c; asn1::cbit_ref bref(pdu->msg, pdu->N_bytes); if (pdu_c.unpack(bref) != asn1::SRSASN_SUCCESS) { @@ -189,7 +185,7 @@ bool ric_client::handle_e2_rx_msg(srsran::unique_byte_buffer_t pdu, return true; } -bool ric_client::handle_e2_init_msg(asn1::e2ap::init_msg_s& init_msg) +bool e2_agent::handle_e2_init_msg(asn1::e2ap::init_msg_s& init_msg) { using namespace asn1::e2ap; if (init_msg.value.type() == e2_ap_elem_procs_o::init_msg_c::types_opts::ricsubscription_request) { @@ -218,7 +214,7 @@ bool ric_client::handle_e2_init_msg(asn1::e2ap::init_msg_s& init_msg) return true; } -bool ric_client::handle_e2_successful_outcome(asn1::e2ap::successful_outcome_s& successful_outcome) +bool e2_agent::handle_e2_successful_outcome(asn1::e2ap::successful_outcome_s& successful_outcome) { using namespace asn1::e2ap; if (successful_outcome.value.type() == e2_ap_elem_procs_o::successful_outcome_c::types_opts::e2setup_resp) { @@ -248,7 +244,7 @@ bool ric_client::handle_e2_successful_outcome(asn1::e2ap::successful_outcome_s& return true; } -bool ric_client::handle_e2_setup_response(e2setup_resp_s setup_response) +bool e2_agent::handle_e2_setup_response(e2setup_resp_s setup_response) { if (e2ap_.process_setup_response(setup_response)) { logger.error("Failed to process E2 Setup Response \n"); @@ -257,7 +253,7 @@ bool ric_client::handle_e2_setup_response(e2setup_resp_s setup_response) return true; } -bool ric_client::handle_e2_unsuccessful_outcome(asn1::e2ap::unsuccessful_outcome_s& unsuccessful_outcome) +bool e2_agent::handle_e2_unsuccessful_outcome(asn1::e2ap::unsuccessful_outcome_s& unsuccessful_outcome) { using namespace asn1::e2ap; if (unsuccessful_outcome.value.type() == e2_ap_elem_procs_o::unsuccessful_outcome_c::types_opts::e2setup_fail) { @@ -294,7 +290,7 @@ bool ric_client::handle_e2_unsuccessful_outcome(asn1::e2ap::unsuccessful_outcome return true; } -bool ric_client::handle_ric_subscription_request(ricsubscription_request_s ric_subscription_request) +bool e2_agent::handle_ric_subscription_request(ricsubscription_request_s ric_subscription_request) { logger.info("Received RIC Subscription Request from RIC ID: %i (instance id %i) to RAN Function ID: %i", ric_subscription_request->ri_crequest_id->ric_requestor_id, @@ -309,7 +305,7 @@ bool ric_client::handle_ric_subscription_request(ricsubscription_request_s ric_s return true; } -bool ric_client::handle_ric_subscription_delete_request(ricsubscription_delete_request_s ricsubscription_delete_request) +bool e2_agent::handle_ric_subscription_delete_request(ricsubscription_delete_request_s ricsubscription_delete_request) { logger.info("Received RIC Subscription Delete request from RIC ID: %i (instance id %i) to RAN Function ID: %i", ricsubscription_delete_request->ri_crequest_id->ric_requestor_id, @@ -324,7 +320,7 @@ bool ric_client::handle_ric_subscription_delete_request(ricsubscription_delete_r return true; } -bool ric_client::handle_subscription_modification_request(uint32_t ric_subscription_modification_request) +bool e2_agent::handle_subscription_modification_request(uint32_t ric_subscription_modification_request) { if (e2ap_.process_subscription_modification_request(ric_subscription_modification_request)) { logger.error("Failed to process RIC subscription delete request \n"); @@ -332,7 +328,7 @@ bool ric_client::handle_subscription_modification_request(uint32_t ric_subscript } return true; } -bool ric_client::handle_subscription_modification_confirm(uint32_t ric_subscription_modification_confirm) +bool e2_agent::handle_subscription_modification_confirm(uint32_t ric_subscription_modification_confirm) { if (e2ap_.process_subscription_modification_confirm(ric_subscription_modification_confirm)) { logger.error("Failed to process RIC subscription delete request \n"); @@ -340,7 +336,7 @@ bool ric_client::handle_subscription_modification_confirm(uint32_t ric_subscript } return true; } -bool ric_client::handle_subscription_modification_refuse(uint32_t ric_subscription_modification_refuse) +bool e2_agent::handle_subscription_modification_refuse(uint32_t ric_subscription_modification_refuse) { if (e2ap_.process_subscription_modification_refuse(ric_subscription_modification_refuse)) { logger.error("Failed to process RIC subscription delete request \n"); @@ -349,7 +345,7 @@ bool ric_client::handle_subscription_modification_refuse(uint32_t ric_subscripti return true; } -bool ric_client::handle_reset_request(reset_request_s& reset_request) +bool e2_agent::handle_reset_request(reset_request_s& reset_request) { printf("Received E2AP E2 Reset Request \n"); // call process to handle reset request, if it fails log error and return false, else return true - success @@ -367,7 +363,7 @@ bool ric_client::handle_reset_request(reset_request_s& reset_request) return true; } -bool ric_client::handle_reset_response(reset_resp_s& reset_response) +bool e2_agent::handle_reset_response(reset_resp_s& reset_response) { printf("Received E2AP E2 Reset Response \n"); // call process to handle reset reponse, if it fails log error, else return true - success