void S1mmeSession::CuOutputNode(S1APNode* p_node, uint8_t worker_id,bool timeout) { bool output_ue_release = true, out_put_pdn_connect = true; time_t last_kqi_sec = 0; for (std::vector<CuKqiInfo_T>::iterator it = p_node->cu_kqi_.begin(); it != p_node->cu_kqi_.end();) { CuOutputKqi(p_node, it->msg_type, it->ebi, last_kqi_sec, output_ue_release,worker_id); it = p_node->cu_kqi_.erase(it); } S1MMEKQI* kqi_main = p_node->FindKqi(kS1mmeProcTypeERABModification); if(kqi_main){ CuEncodeErabModification(kqi_main, p_node->GetCommonInfo(), p_node->GetUserInfo(), current_time_.tv_sec,worker_id); } kqi_main = p_node->FindKqi(kS1mmeProcTypeSecondaryRatDataUsage); if(kqi_main){ CuEncodeSecondaryRatDataUsageReport(kqi_main, p_node->GetCommonInfo(), p_node->GetUserInfo(), current_time_.tv_sec,worker_id); } kqi_main = p_node->FindKqi(kS1mmeProcTypeAttach); if (kqi_main && ((timeout && nas_default_encrypt_alg_) || (!timeout))) { S1MMEKQI* kqi_ue_release = p_node->FindKqi(kS1mmeProcTypeUEContextRelease); S1MMEKQI* kqi_pdn_connect = p_node->FindKqi(kS1mmeProcTypePdnConnect, 5); if (1) { for (uint8_t i=0; i<1; i++) { //KQIBearer* p_bearer = kqi_initial_context->GetBearer(i); //if (p_bearer == NULL) break; //p_node->GetUserInfo()->FillKQIBearer(p_bearer->ebi, p_bearer); } } CuEncodeAttach(kqi_main, p_node->GetCommonInfo(), p_node->GetUserInfo(), current_time_.tv_sec,worker_id,kqi_ue_release,kqi_pdn_connect); //output attach if (output_ue_release && kqi_ue_release && kqi_ue_release->complete_time_.tv_sec - kqi_main->complete_time_.tv_sec > 15) { //output UEContextRelease; CuEncodeUEContextRelease(kqi_ue_release,p_node->GetCommonInfo(),p_node->GetUserInfo(),current_time_.tv_sec,worker_id); output_ue_release = false; } out_put_pdn_connect = false; }什么意思
时间: 2024-03-30 13:35:17 浏览: 103
这段代码主要是将S1APNode的信息输出到CU(Control Unit)中。首先,它会遍历p_node->cu_kqi_中的每个CuKqiInfo_T对象,并调用CuOutputKqi()函数将KQI信息编码并输出到CU中。接着,它会查找S1MMEKQI对象,并调用CuEncodeErabModification()、CuEncodeSecondaryRatDataUsageReport()和CuEncodeAttach()函数将ERAB Modification、Secondary RAT Data Usage Report和Attach信息编码并输出到CU中。如果timeout为true且nas_default_encrypt_alg_不为空,还会调用CuEncodeUEContextRelease()函数将UE Context Release信息编码并输出到CU中。在输出Attach信息时,如果output_ue_release为true且kqi_ue_release不为空,且kqi_ue_release已完成的时间与kqi_main已完成的时间相差大于15秒,则会调用CuEncodeUEContextRelease()函数将UE Context Release信息编码并输出到CU中。最后,将out_put_pdn_connect设置为false。
相关问题
void S1mmeSession::CheckTimeout(uint64_t second, uint8_t worker_id) { //主map 超时, 同时伴随 辅助map 超时 bool dead_loop_major,dead_loop_hoc,dead_loop_stmsi; { S1APNode* p_cur = (S1APNode*)(p_major_map_->GetHead()); S1APKey_T* p_cur_key = p_major_map_->GetCursorKey(); S1APNode* p_next = (S1APNode*)(p_major_map_->Next()); S1APKey_T* p_next_key = p_major_map_->GetCursorKey(); while (p_next != NULL) { if (current_time_.tv_sec - p_cur->GetLastTime().tv_sec > timeout_major_) { if (handle_session_version_ == S1MME_SESSION_VERSION_CHINA_TELECOM) { CtOutputNode(p_cur,true); } else { CuOutputNode(p_cur,s1mme_worker_id_,true); } p_path_switch_map_->DeleteData(p_cur->GetMMEKey(), p_s1ap_node_allocator_); p_handover_container_map_->DeleteData(p_cur->GetContainerKey(), p_s1ap_node_allocator_); SPUserInfo& sp_user_info = p_cur->GetUserInfo(); //Todo@ydzy:超时stmsi _map p_major_map_->DeleteData(*p_cur_key, p_s1ap_node_allocator_); p_cur = p_next; p_next = (S1APNode*)(p_major_map_->Next()); p_cur_key = p_next_key; p_next_key = p_major_map_->GetCursorKey(); } else { break; } } dead_loop_major = p_major_map_->CheckDeadLoop(); }什么意思
这是一个函数定义,函数名为CheckTimeout,参数列表包括一个uint64_t类型的second和一个uint8_t类型的worker_id。函数的主要作用是检查主map和辅助map是否超时,如果超时则进行相应的操作。其中,p_major_map_是主map,p_path_switch_map_和p_handover_container_map_是辅助map。函数实现的主要逻辑是:遍历主map中的节点,如果某个节点超时,则调用相应的函数进行处理,然后将该节点从所有map中删除。最后,检查主map是否出现死循环。具体的实现细节需要参考其他代码部分。
在S1mmeSession::CheckTimeout函数中增加一个超时处理函数,超时处理函数遍历新增加的hash节点,当current_time_.tv_sec-节点的last_time时,使用LogInfo函数将节点所有字段以及current_time_.tv_sec字段进行输出
可以在S1mmeSession类中增加一个私有成员函数TimeoutHandler,该函数的实现如下:
```
void S1mmeSession::TimeoutHandler() {
for (auto it = p_stmsi_map_->begin(); it != p_stmsi_map_->end(); ) {
if (current_time_.tv_sec - it->second->GetLastTime().tv_sec > timeout_stmsi_) {
// 使用LogInfo函数输出节点信息
LogInfo("TimeoutHandler: STMSI timeout, current_time=%ld, node_info=%s", current_time_.tv_sec, it->second->ToString().c_str());
// 删除节点
p_stmsi_map_->erase(it++);
} else {
++it;
}
}
}
```
在CheckTimeout函数中增加调用TimeoutHandler函数的代码:
```
void S1mmeSession::CheckTimeout(uint64_t second, uint8_t worker_id) {
bool dead_loop_major, dead_loop_hoc, dead_loop_stmsi;
{
// 遍历主map
// ...
}
dead_loop_major = p_major_map_->CheckDeadLoop();
{
// 遍历STMSI map
TimeoutHandler();
}
// ...
}
```
当STMSI map中的某个节点超时时,TimeoutHandler函数会使用LogInfo函数将节点信息输出,同时删除该节点。
阅读全文