Commit c2f91a23 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Add new function to update ue-statistic

parent fba70129
......@@ -507,8 +507,8 @@ void amf_n1::registration_request_handle(bool isNasSig, std::shared_ptr<nas_cont
uc = amf_app_inst->ran_amf_id_2_ue_context(ue_context_key);
ue_info_t ueItem;
//update_ue_information_statics(ueItem, "CM-CONNECTED", "REGISTRATION-INITIATING", ran_ue_ngap_id, amf_ue_ngap_id, nc.get()->imsi, "", uc.get()->cgi.mcc, uc.get()->cgi.mnc, uc.get()->cgi.nrCellID);
ueItem.connStatus = "CM-CONNECTED";
ueItem.registerStatus = "REGISTRATION-INITIATING";
ueItem.connStatus = "5GMM-CONNECTED";//"CM-CONNECTED";
ueItem.registerStatus = "5GMM-REGISTRATION-INITIATED"; //5GMM-COMMON-PROCEDURE-INITIATED
ueItem.ranid = ran_ue_ngap_id;
ueItem.amfid = amf_ue_ngap_id;
ueItem.imsi = nc.get()->imsi;
......@@ -1309,15 +1309,18 @@ void amf_n1::security_mode_complete_handle(uint32_t ran_ue_ngap_id, long amf_ue_
nc = amf_ue_id_2_nas_context(amf_ue_ngap_id);
Logger::amf_n1().info("UE (IMSI %s, GUTI %s, current RAN ID %d, current AMF ID %d) has been registered to the network", nc.get()->imsi.c_str(), guti.c_str(), ran_ue_ngap_id, amf_ue_ngap_id);
if (nc.get()->is_stacs_available) {
/*
ue_info_t ueItem;
ueItem.connStatus = "";
ueItem.registerStatus = "RM-REGISTRED";
ueItem.connStatus = "5GMM-CONNECTED";
ueItem.registerStatus = "5GMM-REGISTERED";
ueItem.ranid = ran_ue_ngap_id;
ueItem.amfid = amf_ue_ngap_id;
ueItem.guti = guti;
ueItem.imsi = nc.get()->imsi;
ueItem.cellId = 0;
stacs.update_ue_info(ueItem);
*/
stacs.update_5gmm_state(nc.get()->imsi,"5GMM-REGISTERED");
}
set_guti_2_nas_context(guti, nc);
......@@ -1537,7 +1540,23 @@ void amf_n1::ue_initiate_de_registration_handle(uint32_t ran_ue_ngap_id, long am
itti_send_dl_nas_buffer_to_task_n2(b, ran_ue_ngap_id, amf_ue_ngap_id);
//TODO: Update FSM
//TODO: Update statistic
nc.get()->is_stacs_available = false;
if (nc.get()->is_stacs_available) {
/* ue_info_t ueItem;
ueItem.connStatus = "";
ueItem.registerStatus = "5GMM-DEREGISTERED";
ueItem.ranid = nc.get()->ran_ue_ngap_id;
ueItem.amfid = nc.get()->amf_ue_ngap_id;
ueItem.imsi = nc.get()->imsi;
ueItem.mcc = uc.get()->cgi.mcc;
ueItem.mnc = uc.get()->cgi.mnc;
ueItem.cellId = uc.get()->cgi.nrCellID;
stacs.update_ue_info(ueItem);
*/
stacs.update_5gmm_state(nc.get()->imsi,"5GMM-DEREGISTERED");
}
}
//------------------------------------------------------------------------------
......
......@@ -56,14 +56,11 @@ void statistics::display() {
Logger::amf_app().info("|----------------------------------------------------------------------------------------------------------------|");
Logger::amf_app().info("|----------------------------------------------------UEs' information--------------------------------------------|");
Logger::amf_app().info("| Index | Connection state | Registration state | IMSI | GUTI | RAN UE NGAP ID | AMF UE ID |");
Logger::amf_app().info("| Index | 5GMM state | IMSI | GUTI | RAN UE NGAP ID | AMF UE ID | PLMN |Cell ID|");
int i = 0;
for (auto const &ue : ue_infos) {
Logger::amf_app().info("| %d | %s | %s | %s | %s | %d | %d | ", i + 1, ue.second.connStatus.c_str(), ue.second.registerStatus.c_str(), ue.second.imsi.c_str(), ue.second.guti.c_str(), ue.second.ranid, ue.second.amfid);
//Logger::amf_app().info("Current ran_ue_ngap_id[%d]; Current amf_ue_ngap_id[%d]", ues[i].ranid, ues[i].amfid);
Logger::amf_app().info("Location [NrCgi][PLMN(%s), cellID(%d)]", (ue.second.mcc + ue.second.mnc).c_str(), ue.second.cellId);
Logger::amf_app().info("");
Logger::amf_app().info("|%7d|%22s|19%s|%15s|%16d|%11d|%9s|%7d|", i + 1, ue.second.registerStatus.c_str(), ue.second.imsi.c_str(), ue.second.guti.c_str(), ue.second.ranid, ue.second.amfid, (ue.second.mcc + ue.second.mnc).c_str(), ue.second.cellId);
i++;
}
Logger::amf_app().info("|----------------------------------------------------------------------------------------------------------------|");
......@@ -86,10 +83,22 @@ void statistics::update_ue_info(const ue_info_t& ue_info) {
if (ue_infos.count(ue_info.imsi) > 0) {
ue_infos.erase(ue_info.imsi);
ue_infos.insert(std::pair<std::string, ue_info_t>(ue_info.imsi, ue_info));
Logger::amf_app().debug("Update UE Info (IMSI %s) success", ue_info.imsi);
Logger::amf_app().debug("Update UE Info (IMSI %s) success", ue_info.imsi.c_str());
} else {
ue_infos.insert(std::pair<std::string, ue_info_t>(ue_info.imsi, ue_info));
Logger::amf_app().debug("Add UE Info (IMSI %s) success", ue_info.imsi);
Logger::amf_app().debug("Add UE Info (IMSI %s) success", ue_info.imsi.c_str());
}
}
//------------------------------------------------------------------------------
void statistics::update_5gmm_state(const std::string& imsi, const std::string& state) {
if (ue_infos.count(imsi) > 0) {
ue_info_t ue_info = ue_infos.at(imsi);
ue_info.registerStatus = state;
ue_infos.insert(std::pair<std::string, ue_info_t>(imsi, ue_info));
Logger::amf_app().debug("Update UE State (IMSI %s, State %s) success", imsi.c_str(), state.c_str());
} else {
Logger::amf_app().warn("Update UE State (IMSI %s), UE does not exist!", imsi.c_str());
}
}
......
......@@ -67,6 +67,7 @@ class statistics {
statistics();
~statistics();
void update_ue_info(const ue_info_t& ue_info);
void update_5gmm_state(const std::string& imsi, const std::string& state);
public:
uint32_t gNB_connected;
uint32_t UE_connected;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment