Commit 977790c3 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Clean up N2 Handover procedure

parent 96e00243
...@@ -186,11 +186,11 @@ void amf_n2_task(void* args_p) { ...@@ -186,11 +186,11 @@ void amf_n2_task(void* args_p) {
itti_handover_notify* m = dynamic_cast<itti_handover_notify*>(msg); itti_handover_notify* m = dynamic_cast<itti_handover_notify*>(msg);
amf_n2_inst->handle_itti_message(ref(*m)); amf_n2_inst->handle_itti_message(ref(*m));
} break; } break;
case UPLINKRANSTATUSTRANSFER: { case UPLINK_RAN_STATUS_TRANSFER: {
Logger::amf_n2().info( Logger::amf_n2().info(
"Received UPLINKRANSTATUSTRANSFER message,handling"); "Received UPLINK_RAN_STATUS_TRANSFER message,handling");
itti_uplinkranstatsutransfer* m = itti_uplink_ran_status_transfer* m =
dynamic_cast<itti_uplinkranstatsutransfer*>(msg); dynamic_cast<itti_uplink_ran_status_transfer*>(msg);
amf_n2_inst->handle_itti_message(ref(*m)); amf_n2_inst->handle_itti_message(ref(*m));
} break; } break;
default: default:
...@@ -1113,7 +1113,7 @@ bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) { ...@@ -1113,7 +1113,7 @@ bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) {
plmn->getMnc(mnc); plmn->getMnc(mnc);
Logger::amf_n2().debug( Logger::amf_n2().debug(
"Handover required: Target ID GlobalRanNodeID PLmn (mcc: %s, mnc: %s, " "Handover Required: Target ID GlobalRanNodeID PLmn (mcc: %s, mnc: %s, "
"gnbid: %ld)", "gnbid: %ld)",
mcc.c_str(), mnc.c_str(), gnbid->getValue()); mcc.c_str(), mnc.c_str(), gnbid->getValue());
...@@ -1126,7 +1126,7 @@ bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) { ...@@ -1126,7 +1126,7 @@ bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) {
plmn->getMcc(mccOfselectTAI); plmn->getMcc(mccOfselectTAI);
plmn->getMnc(mncOfselectTAI); plmn->getMnc(mncOfselectTAI);
Logger::amf_n2().debug( Logger::amf_n2().debug(
"Handover required:Target ID selectedTAI PLmn=mcc%s mnc%s tac=%x", "Handover required:Target ID selectedTAI PLmn (mcc %s, mnc %s, tac %x)",
mccOfselectTAI.c_str(), mncOfselectTAI.c_str(), tac->getTac()); mccOfselectTAI.c_str(), mncOfselectTAI.c_str(), tac->getTac());
std::vector<PDUSessionResourceItem_t> List_HORqd; std::vector<PDUSessionResourceItem_t> List_HORqd;
...@@ -1140,26 +1140,36 @@ bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) { ...@@ -1140,26 +1140,36 @@ bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) {
sourceTotarget = sourceTotarget =
itti_msg.handoverReq->getSourceToTarget_TransparentContainer(); itti_msg.handoverReq->getSourceToTarget_TransparentContainer();
// TODO: T-AMF selection, for now use the same AMF
// TODO: Send PDU Session Update SM Context Request to SMF
// Create HandoverRequest message to be sent to target gNB // Create HandoverRequest message to be sent to target gNB
std::unique_ptr<HandoverRequest> handoverrequest = std::unique_ptr<HandoverRequest> handover_request =
std::make_unique<HandoverRequest>(); std::make_unique<HandoverRequest>();
handoverrequest->setMessageType(); handover_request->setMessageType();
handoverrequest->setAmfUeNgapId(amf_ue_ngap_id); handover_request->setAmfUeNgapId(amf_ue_ngap_id);
handoverrequest->setHandoverType(0); handover_request->setHandoverType(0);
handoverrequest->setCause( handover_request->setCause(
Ngap_Cause_PR_radioNetwork, Ngap_Cause_PR_radioNetwork,
Ngap_CauseRadioNetwork_handover_desirable_for_radio_reason); Ngap_CauseRadioNetwork_handover_desirable_for_radio_reason);
handoverrequest->setUEAggregateMaximumBitRate( handover_request->setUEAggregateMaximumBitRate(
300000000, 100000000); // TODO: remove hardcoded values 300000000, 100000000); // TODO: remove hardcoded values
handoverrequest->setUESecurityCapabilities( handover_request->setUESecurityCapabilities(
0xe000, 0xe000, 0xe000, 0xe000); // TODO: remove hardcoded values 0xe000, 0xe000, 0xe000, 0xe000); // TODO: remove hardcoded values
S_NSSAI s_nssai = {}; // Allowed NSSAI
s_nssai.setSst("01"); // TODO: remove hardcoded values
std::vector<S_NSSAI> Allowed_Nssai; std::vector<S_NSSAI> Allowed_Nssai;
for (int i = 0; i < amf_cfg.plmn_list.size(); i++) {
for (int j = 0; j < amf_cfg.plmn_list[i].slice_list.size(); j++) {
SliceSupportItem_t s_tmp;
S_NSSAI s_nssai = {};
s_nssai.setSst(amf_cfg.plmn_list[i].slice_list[j].sST);
s_nssai.setSd(amf_cfg.plmn_list[i].slice_list[j].sD);
Allowed_Nssai.push_back(s_nssai); Allowed_Nssai.push_back(s_nssai);
}
}
Guami_t guami; Guami_t guami = {};
guami.mcc = amf_cfg.guami.mcc; guami.mcc = amf_cfg.guami.mcc;
guami.mnc = amf_cfg.guami.mnc; guami.mnc = amf_cfg.guami.mnc;
guami.regionID = amf_cfg.guami.regionID; guami.regionID = amf_cfg.guami.regionID;
...@@ -1180,12 +1190,12 @@ bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) { ...@@ -1180,12 +1190,12 @@ bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) {
uint8_t* kamf = nc.get()->kamf[secu->vector_pointer]; uint8_t* kamf = nc.get()->kamf[secu->vector_pointer];
uint8_t kgnb[32]; uint8_t kgnb[32];
uint32_t ulcount = secu->ul_count.seq_num | (secu->ul_count.overflow << 8); uint32_t ulcount = secu->ul_count.seq_num | (secu->ul_count.overflow << 8);
Logger::amf_n1().debug("uplink count(%d)", secu->ul_count.seq_num); Logger::amf_n1().debug("Uplink count (%d)", secu->ul_count.seq_num);
uint8_t knh[32]; uint8_t knh[32];
Authentication_5gaka::handover_ncc_derive_knh( Authentication_5gaka::handover_ncc_derive_knh(
ulcount, 0x01, kamf, kgnb, knh, unc.get()->ncc); ulcount, 0x01, kamf, kgnb, knh, unc.get()->ncc);
bstring knh_bs = blk2bstr(knh, 32); bstring knh_bs = blk2bstr(knh, 32);
handoverrequest->setSecurityContext( handover_request->setSecurityContext(
unc.get()->ncc /*NCC count*/, (uint8_t*) bdata(knh_bs)); unc.get()->ncc /*NCC count*/, (uint8_t*) bdata(knh_bs));
string supi = "imsi-" + nc.get()->imsi; string supi = "imsi-" + nc.get()->imsi;
...@@ -1220,13 +1230,13 @@ bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) { ...@@ -1220,13 +1230,13 @@ bool amf_n2::handle_itti_message(itti_handover_required& itti_msg) {
} }
} }
handoverrequest->setPduSessionResourceSetupList(list); handover_request->setPduSessionResourceSetupList(list);
handoverrequest->setAllowedNSSAI(Allowed_Nssai); handover_request->setAllowedNSSAI(Allowed_Nssai);
handoverrequest->setSourceToTarget_TransparentContainer(sourceTotarget); handover_request->setSourceToTarget_TransparentContainer(sourceTotarget);
handoverrequest->setMobilityRestrictionList(m_plmnId); handover_request->setMobilityRestrictionList(m_plmnId);
handoverrequest->setGUAMI(m_plmnId, m_aMFRegionID, m_aMFSetID, m_aMFPointer); handover_request->setGUAMI(m_plmnId, m_aMFRegionID, m_aMFSetID, m_aMFPointer);
uint8_t buffer[20240]; uint8_t buffer[20240];
int encoded_size = handoverrequest->encode2buffer(buffer, 20240); int encoded_size = handover_request->encode2buffer(buffer, 20240);
bstring b = blk2bstr(buffer, encoded_size); bstring b = blk2bstr(buffer, encoded_size);
std::shared_ptr<gnb_context> gc_target = {}; std::shared_ptr<gnb_context> gc_target = {};
gc_target = gnb_id_2_gnb_context(gnbid->getValue()); gc_target = gnb_id_2_gnb_context(gnbid->getValue());
...@@ -1247,7 +1257,7 @@ void amf_n2::handle_itti_message(itti_handover_request_Ack& itti_msg) { ...@@ -1247,7 +1257,7 @@ void amf_n2::handle_itti_message(itti_handover_request_Ack& itti_msg) {
std::shared_ptr<gnb_context> gc = {}; std::shared_ptr<gnb_context> gc = {};
if (!is_assoc_id_2_gnb_context(itti_msg.assoc_id)) { if (!is_assoc_id_2_gnb_context(itti_msg.assoc_id)) {
Logger::amf_n2().error( Logger::amf_n2().error(
"gNB with assoc_id(%d) is illegal", itti_msg.assoc_id); "gNB with assoc_id (%d) is illegal", itti_msg.assoc_id);
return; return;
} }
gc = assoc_id_2_gnb_context(itti_msg.assoc_id); gc = assoc_id_2_gnb_context(itti_msg.assoc_id);
...@@ -1274,14 +1284,14 @@ void amf_n2::handle_itti_message(itti_handover_request_Ack& itti_msg) { ...@@ -1274,14 +1284,14 @@ void amf_n2::handle_itti_message(itti_handover_request_Ack& itti_msg) {
PDUSessionResourceHandoverRequestAckTransfer* PDUHandoverRequestAckTransfer = PDUSessionResourceHandoverRequestAckTransfer* PDUHandoverRequestAckTransfer =
new PDUSessionResourceHandoverRequestAckTransfer(); new PDUSessionResourceHandoverRequestAckTransfer();
uint8_t buf[1024]; uint8_t buf[BUFFER_SIZE_1024];
memcpy( memcpy(
buf, list[0].handoverRequestAcknowledgeTransfer.buf, buf, list[0].handoverRequestAcknowledgeTransfer.buf,
list[0].handoverRequestAcknowledgeTransfer.size); list[0].handoverRequestAcknowledgeTransfer.size);
if (!PDUHandoverRequestAckTransfer->decodefromHandoverRequestAckTransfer( if (!PDUHandoverRequestAckTransfer->decodefromHandoverRequestAckTransfer(
buf, list[0].handoverRequestAcknowledgeTransfer.size)) { buf, list[0].handoverRequestAcknowledgeTransfer.size)) {
Logger::ngap().error("Decode handoverrequestacktransfer error"); Logger::ngap().error("Decode Handover Request Acknowledge Transfer error");
return; return;
} }
...@@ -1314,12 +1324,10 @@ void amf_n2::handle_itti_message(itti_handover_request_Ack& itti_msg) { ...@@ -1314,12 +1324,10 @@ void amf_n2::handle_itti_message(itti_handover_request_Ack& itti_msg) {
std::shared_ptr<nas_context> nc = std::shared_ptr<nas_context> nc =
amf_n1_inst->amf_ue_id_2_nas_context(amf_ue_ngap_id); amf_n1_inst->amf_ue_id_2_nas_context(amf_ue_ngap_id);
// setPduSessionResourceHandoverList_PDYSessionID_handovercommandtransfer
std::vector<PDUSessionResourceHandoverItem_t> handover_list; std::vector<PDUSessionResourceHandoverItem_t> handover_list;
PDUSessionResourceHandoverItem_t item = {}; PDUSessionResourceHandoverItem_t item = {};
// set pdu id
item.pduSessionId = list[0].pduSessionId; item.pduSessionId = list[0].pduSessionId;
// set qosFLowtobeforwardedlist // qosFLowtobeforwardedlist
std::vector<QosFlowToBeForwardedItem_t> forward_list; std::vector<QosFlowToBeForwardedItem_t> forward_list;
QosFlowToBeForwardedItem_t forward_item; QosFlowToBeForwardedItem_t forward_item;
forward_item.QFI = qosflowidentifiervalue; forward_item.QFI = qosflowidentifiervalue;
...@@ -1336,7 +1344,6 @@ void amf_n2::handle_itti_message(itti_handover_request_Ack& itti_msg) { ...@@ -1336,7 +1344,6 @@ void amf_n2::handle_itti_message(itti_handover_request_Ack& itti_msg) {
uptlinfo.gtp_teid = teid; uptlinfo.gtp_teid = teid;
uptlinfo.ip_address = n3_ip_address; uptlinfo.ip_address = n3_ip_address;
handovercommandtransfer->setUPTransportLayerInformation(uptlinfo); handovercommandtransfer->setUPTransportLayerInformation(uptlinfo);
// handovercommand->setTargetToSource_TransparentContainer(targetTosource);
uint8_t buffer2[500]; uint8_t buffer2[500];
int encoded_size2 = int encoded_size2 =
handovercommandtransfer->encodePDUSessionResourceHandoverCommandTransfer( handovercommandtransfer->encodePDUSessionResourceHandoverCommandTransfer(
...@@ -1349,8 +1356,8 @@ void amf_n2::handle_itti_message(itti_handover_request_Ack& itti_msg) { ...@@ -1349,8 +1356,8 @@ void amf_n2::handle_itti_message(itti_handover_request_Ack& itti_msg) {
handovercommand->setPduSessionResourceHandoverList(handover_list); handovercommand->setPduSessionResourceHandoverList(handover_list);
handovercommand->setTargetToSource_TransparentContainer(targetTosource); handovercommand->setTargetToSource_TransparentContainer(targetTosource);
// setPduSessionResourceHandoverList_PDYSessionID_handovercommandtransfer-end // setPduSessionResourceHandoverList_PDYSessionID_handovercommandtransfer-end
uint8_t buffer[10240]; uint8_t buffer[BUFFER_SIZE_1024];
int encoded_size = handovercommand->encode2buffer(buffer, 10240); int encoded_size = handovercommand->encode2buffer(buffer, BUFFER_SIZE_1024);
bstring b = blk2bstr(buffer, encoded_size); bstring b = blk2bstr(buffer, encoded_size);
/* /*
...@@ -1416,13 +1423,12 @@ void amf_n2::handle_itti_message(itti_handover_notify& itti_msg) { ...@@ -1416,13 +1423,12 @@ void amf_n2::handle_itti_message(itti_handover_notify& itti_msg) {
ueContextReleaseCommand->setCauseRadioNetwork( ueContextReleaseCommand->setCauseRadioNetwork(
Ngap_CauseRadioNetwork_successful_handover); Ngap_CauseRadioNetwork_successful_handover);
uint8_t buffer[10240]; // TODO: remove hardcoded value uint8_t buffer[BUFFER_SIZE_1024];
int encoded_size = ueContextReleaseCommand->encode2buffer(buffer, 10240); int encoded_size =
ueContextReleaseCommand->encode2buffer(buffer, BUFFER_SIZE_1024);
bstring b = blk2bstr(buffer, encoded_size); bstring b = blk2bstr(buffer, encoded_size);
std::shared_ptr<nas_context> nc = std::shared_ptr<nas_context> nc =
amf_n1_inst->amf_ue_id_2_nas_context(amf_ue_ngap_id); amf_n1_inst->amf_ue_id_2_nas_context(amf_ue_ngap_id);
// std::shared_ptr<ue_ngap_context> ngc =
// ran_ue_id_2_ue_ngap_context(nc.get()->ran_ue_ngap_id);
sctp_s_38412.sctp_send_msg(unc.get()->gnb_assoc_id, 0, &b); sctp_s_38412.sctp_send_msg(unc.get()->gnb_assoc_id, 0, &b);
/*std::shared_ptr<nas_context> nc = /*std::shared_ptr<nas_context> nc =
...@@ -1450,10 +1456,10 @@ void amf_n2::handle_itti_message(itti_handover_notify& itti_msg) { ...@@ -1450,10 +1456,10 @@ void amf_n2::handle_itti_message(itti_handover_notify& itti_msg) {
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void amf_n2::handle_itti_message(itti_uplinkranstatsutransfer& itti_msg) { void amf_n2::handle_itti_message(itti_uplink_ran_status_transfer& itti_msg) {
unsigned long amf_ue_ngap_id = itti_msg.uplinkrantransfer->getAmfUeNgapId(); unsigned long amf_ue_ngap_id = itti_msg.uplinkrantransfer->getAmfUeNgapId();
Logger::amf_n2().error( Logger::amf_n2().error(
"uplinkranstatustransfer amf_ue_ngap_id(%d)", amf_ue_ngap_id); "Uplink RAN Status Transfer amf_ue_ngap_id (%d)", amf_ue_ngap_id);
if (!is_assoc_id_2_gnb_context(itti_msg.assoc_id)) { if (!is_assoc_id_2_gnb_context(itti_msg.assoc_id)) {
Logger::amf_n2().error( Logger::amf_n2().error(
"gNB with assoc_id (%d) is illegal", itti_msg.assoc_id); "gNB with assoc_id (%d) is illegal", itti_msg.assoc_id);
...@@ -1513,8 +1519,6 @@ void amf_n2::handle_itti_message(itti_uplinkranstatsutransfer& itti_msg) { ...@@ -1513,8 +1519,6 @@ void amf_n2::handle_itti_message(itti_uplinkranstatsutransfer& itti_msg) {
uint8_t buffer[1024]; uint8_t buffer[1024];
int encode_size = downLinkranstatustransfer->encodetobuffer(buffer, 1024); int encode_size = downLinkranstatustransfer->encodetobuffer(buffer, 1024);
bstring b = blk2bstr(buffer, encode_size); bstring b = blk2bstr(buffer, encode_size);
// std::shared_ptr<ue_ngap_context> ngc =
// ran_ue_id_2_ue_ngap_context(unc.get()->target_ran_ue_ngap_id );
sctp_s_38412.sctp_send_msg(unc.get()->target_gnb_assoc_id, 0, &b); sctp_s_38412.sctp_send_msg(unc.get()->target_gnb_assoc_id, 0, &b);
} }
......
...@@ -61,7 +61,7 @@ class amf_n2 : public ngap::ngap_app { ...@@ -61,7 +61,7 @@ class amf_n2 : public ngap::ngap_app {
bool handle_itti_message(itti_handover_required& itti_msg); bool handle_itti_message(itti_handover_required& itti_msg);
void handle_itti_message(itti_handover_request_Ack& itti_msg); void handle_itti_message(itti_handover_request_Ack& itti_msg);
void handle_itti_message(itti_handover_notify& itti_msg); void handle_itti_message(itti_handover_notify& itti_msg);
void handle_itti_message(itti_uplinkranstatsutransfer& itti_msg); void handle_itti_message(itti_uplink_ran_status_transfer& itti_msg);
void send_handover_preparation_failure( void send_handover_preparation_failure(
const unsigned long amf_ue_ngap_id, const uint32_t ran_ue_ngap_id, const unsigned long amf_ue_ngap_id, const uint32_t ran_ue_ngap_id,
const sctp_assoc_id_t& gnb_assoc_id); const sctp_assoc_id_t& gnb_assoc_id);
......
...@@ -89,7 +89,7 @@ typedef enum { ...@@ -89,7 +89,7 @@ typedef enum {
HANDOVER_REQUIRED, HANDOVER_REQUIRED,
HANDOVER_REQUEST_ACK, HANDOVER_REQUEST_ACK,
HANDOVER_NOTIFY, HANDOVER_NOTIFY,
UPLINKRANSTATUSTRANSFER, UPLINK_RAN_STATUS_TRANSFER,
PDU_SESS_RES_SET_RESP, PDU_SESS_RES_SET_RESP,
TIME_OUT, TIME_OUT,
HEALTH_PING, HEALTH_PING,
......
...@@ -238,12 +238,12 @@ class itti_handover_notify : public itti_msg_n2 { ...@@ -238,12 +238,12 @@ class itti_handover_notify : public itti_msg_n2 {
HandoverNotifyMsg* handovernotify; HandoverNotifyMsg* handovernotify;
}; };
class itti_uplinkranstatsutransfer : public itti_msg_n2 { class itti_uplink_ran_status_transfer : public itti_msg_n2 {
public: public:
itti_uplinkranstatsutransfer( itti_uplink_ran_status_transfer(
const task_id_t origin, const task_id_t destination) const task_id_t origin, const task_id_t destination)
: itti_msg_n2(UPLINKRANSTATUSTRANSFER, origin, destination) {} : itti_msg_n2(UPLINK_RAN_STATUS_TRANSFER, origin, destination) {}
itti_uplinkranstatsutransfer(const itti_uplinkranstatsutransfer& i) itti_uplink_ran_status_transfer(const itti_uplink_ran_status_transfer& i)
: itti_msg_n2(i) {} : itti_msg_n2(i) {}
UplinkRANStatusTransfer* uplinkrantransfer; UplinkRANStatusTransfer* uplinkrantransfer;
}; };
......
...@@ -872,22 +872,22 @@ int uplink_ran_status_transfer( ...@@ -872,22 +872,22 @@ int uplink_ran_status_transfer(
const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream, const sctp_assoc_id_t assoc_id, const sctp_stream_id_t stream,
struct Ngap_NGAP_PDU* message_p) { struct Ngap_NGAP_PDU* message_p) {
Logger::ngap().debug( Logger::ngap().debug(
"Sending itti uplink ran status transfer to TASK_AMF_N2"); "Sending ITTI Uplink RAN Status Transfer to TASK_AMF_N2");
/*receive uplinkranstatustransfer*/
asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, message_p); asn_fprint(stderr, &asn_DEF_Ngap_NGAP_PDU, message_p);
UplinkRANStatusTransfer* Uplinkranstatustransfer = UplinkRANStatusTransfer* Uplinkranstatustransfer =
new UplinkRANStatusTransfer(); new UplinkRANStatusTransfer();
if (!Uplinkranstatustransfer->defromPDU(message_p)) { if (!Uplinkranstatustransfer->defromPDU(message_p)) {
Logger::ngap().error("Decoding Uplinkranstatustransfer message error"); Logger::ngap().error("Decoding Uplink RAN Status Transfer message error");
return -1; return -1;
} }
itti_uplinkranstatsutransfer* itti_uplinkran_sta_tran = itti_uplink_ran_status_transfer* itti_uplinkran_sta_tran =
new itti_uplinkranstatsutransfer(TASK_NGAP, TASK_AMF_N2); new itti_uplink_ran_status_transfer(TASK_NGAP, TASK_AMF_N2);
itti_uplinkran_sta_tran->assoc_id = assoc_id; itti_uplinkran_sta_tran->assoc_id = assoc_id;
itti_uplinkran_sta_tran->stream = stream; itti_uplinkran_sta_tran->stream = stream;
itti_uplinkran_sta_tran->uplinkrantransfer = Uplinkranstatustransfer; itti_uplinkran_sta_tran->uplinkrantransfer = Uplinkranstatustransfer;
std::shared_ptr<itti_uplinkranstatsutransfer> i = std::shared_ptr<itti_uplink_ran_status_transfer> i =
std::shared_ptr<itti_uplinkranstatsutransfer>(itti_uplinkran_sta_tran); std::shared_ptr<itti_uplink_ran_status_transfer>(itti_uplinkran_sta_tran);
int ret = itti_inst->send_msg(i); int ret = itti_inst->send_msg(i);
if (0 != ret) { if (0 != ret) {
Logger::ngap().error( Logger::ngap().error(
......
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