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

Update UE-statistic

parent 3a34f4d2
......@@ -479,28 +479,6 @@ void amf_n1::service_request_handle(bool isNasSig, std::shared_ptr<nas_context>
}
}
//------------------------------------------------------------------------------
void amf_n1::update_ue_information_statics(ue_infos &ueItem, const string connStatus, const string registerStatus, uint32_t ranid, uint32_t amfid, string imsi, string guti, string mcc, string mnc, uint32_t cellId) {
if (connStatus != "")
ueItem.connStatus = connStatus;
if (registerStatus != "")
ueItem.registerStatus = registerStatus;
if (ranid != 0)
ueItem.ranid = ranid;
if (amfid != 0)
ueItem.amfid = amfid;
if (imsi != "")
ueItem.imsi = imsi;
if (guti != "")
ueItem.guti = guti;
if (mcc != "")
ueItem.mcc = mcc;
if (mnc != "")
ueItem.mnc = mnc;
if (cellId != 0)
ueItem.cellId = cellId;
}
//------------------------------------------------------------------------------
void amf_n1::registration_request_handle(bool isNasSig, std::shared_ptr<nas_context> nc, uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, std::string snn, bstring reg) {
//Decode registration request message
......@@ -527,10 +505,19 @@ void amf_n1::registration_request_handle(bool isNasSig, std::shared_ptr<nas_cont
std::shared_ptr<ue_context> uc;
Logger::amf_n1().info("Try to find ue_context in amf_app using ran_amf_id %s", ue_context_key.c_str());
uc = amf_app_inst->ran_amf_id_2_ue_context(ue_context_key);
ue_infos 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);
nc.get()->is_stacs_available = true;
stacs.ues.push_back(ueItem);
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.ranid = ran_ue_ngap_id;
ueItem.amfid = 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);
nc.get()->is_stacs_available = true;
}
//nc.get()->imsi = //need interface to transfer SUCI_imsi_t to string
}
......@@ -1322,14 +1309,15 @@ 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) {
int index = 0;
for (int i = 0; i < stacs.ues.size(); i++) {
if (!(nc.get()->imsi).compare(stacs.ues[i].imsi)) {
index = i;
break;
}
}
update_ue_information_statics(stacs.ues[index], "", "RM-REGISTRED", ran_ue_ngap_id, amf_ue_ngap_id, "", guti, "", "", 0);
ue_info_t ueItem;
ueItem.connStatus = "";
ueItem.registerStatus = "RM-REGISTRED";
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);
}
set_guti_2_nas_context(guti, nc);
......
......@@ -121,9 +121,8 @@ class amf_n1 {
void ue_authentication_simulator(uint8_t *rand, uint8_t *autn);
void annex_a_4_33501(uint8_t ck[16], uint8_t ik[16], uint8_t *input, uint8_t rand[16], std::string serving_network, uint8_t *output);
void send_itti_to_smf_services_consumer(uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, uint8_t request_type, uint8_t pdu_session_id, bstring dnn, bstring sm_msg);
void update_ue_information_statics(ue_infos &ueItem, const std::string connStatus, const std::string registerStatus, uint32_t ranid, uint32_t amfid, std::string imsi, std::string guti, std::string mcc, std::string mnc, uint32_t cellId);
private: //nas message handlers
private: //nas message handlers
void ue_initiate_de_registration_handle(uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, bstring nas);
void registration_request_handle(bool isNasSig, std::shared_ptr<nas_context> nc, uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, std::string snn, bstring reg);
void authentication_response_handle(uint32_t ran_ue_ngap_id, long amf_ue_ngap_id, bstring plain_msg);
......
......@@ -57,11 +57,14 @@ 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 |");
for (int i = 0; i < ues.size(); i++) {
Logger::amf_app().info("| %d | %s | %s | %s | %s | %d | %d | ", i + 1, ues[i].connStatus.c_str(), ues[i].registerStatus.c_str(), ues[i].imsi.c_str(), ues[i].guti.c_str(), ues[i].ranid, ues[i].amfid);
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)]", (ues[i].mcc + ues[i].mnc).c_str(), ues[i].cellId);
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("");
i++;
}
Logger::amf_app().info("|----------------------------------------------------------------------------------------------------------------|");
Logger::amf_app().info("");
......@@ -74,6 +77,22 @@ statistics::statistics() {
UE_registred = 0;
}
//------------------------------------------------------------------------------
void statistics::update_ue_info(const ue_info_t& ue_info) {
if (!(ue_info.imsi.size() > 0)) {
Logger::amf_app().warn("Update UE Info with invalid IMSI");
}
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);
} 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);
}
}
//------------------------------------------------------------------------------
statistics::~statistics() {
}
......@@ -49,7 +49,7 @@ typedef struct {
//long nrCellId;
} gnb_infos;
typedef struct {
typedef struct ue_info_s {
std::string connStatus;
std::string registerStatus;
uint32_t ranid;
......@@ -59,20 +59,21 @@ typedef struct {
std::string mcc;
std::string mnc;
uint32_t cellId;
} ue_infos;
} ue_info_t;
class statistics {
public:
void display();
statistics();
~statistics();
void update_ue_info(const ue_info_t& ue_info);
public:
uint32_t gNB_connected;
uint32_t UE_connected;
uint32_t UE_registred;
//uint32_t system_pdu_sessions;
std::vector<gnb_infos> gnbs;
std::vector<ue_infos> ues;
std::map<std::string, ue_info_t> ue_infos;
};
......
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