-
Notifications
You must be signed in to change notification settings - Fork 129
test: HandleCreateUEContext #165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 22 commits
1d289f3
bcc313b
5c7f97a
4debe76
2033aaa
142491e
4c06b72
cc20ecb
8b127d5
9afeac2
e5ebd17
c66ad32
b180fa2
f1728f7
a3ab9aa
042a19a
116dd38
003b729
fb23ab1
b3b2037
432b090
44e3d6e
544d77b
b305859
954cbfb
166ec15
9f16b7a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1490,7 +1490,82 @@ func handleHandoverRequestAcknowledgeMain(ran *context.AmfRan, | |
| if sourceUe == nil { | ||
| // TODO: Send Namf_Communication_CreateUEContext Response to S-AMF | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After implementation, this TODO line can be removed. |
||
| ran.Log.Error("handover between different Ue has not been implement yet") | ||
| var ueContextCreatedData models.UeContextCreatedData | ||
|
||
|
|
||
| ueContextCreatedData.UeContext = new(models.UeContext) | ||
| ueContextCreatedData.UeContext.Supi = amfUe.Supi | ||
| ueContextCreatedData.UeContext.SupiUnauthInd = amfUe.UnauthenticatedSupi | ||
| if amfUe.Gpsi != "" { | ||
| ueContextCreatedData.UeContext.GpsiList = append(ueContextCreatedData.UeContext.GpsiList, amfUe.Gpsi) | ||
| } | ||
| if amfUe.Pei != "" { | ||
| ueContextCreatedData.UeContext.Pei = amfUe.Pei | ||
| } | ||
| if amfUe.UdmGroupId != "" { | ||
| ueContextCreatedData.UeContext.UdmGroupId = amfUe.UdmGroupId | ||
| } | ||
| if amfUe.AusfGroupId != "" { | ||
| ueContextCreatedData.UeContext.AusfGroupId = amfUe.AusfGroupId | ||
| } | ||
| if amfUe.AccessAndMobilitySubscriptionData != nil { | ||
| if amfUe.AccessAndMobilitySubscriptionData.SubscribedUeAmbr != nil { | ||
| ueContextCreatedData.UeContext.SubUeAmbr = &models.Ambr{ | ||
| Uplink: amfUe.AccessAndMobilitySubscriptionData.SubscribedUeAmbr.Uplink, | ||
| Downlink: amfUe.AccessAndMobilitySubscriptionData.SubscribedUeAmbr.Downlink, | ||
| } | ||
| } | ||
| if amfUe.AccessAndMobilitySubscriptionData.RfspIndex != 0 { | ||
| ueContextCreatedData.UeContext.SubRfsp = amfUe.AccessAndMobilitySubscriptionData.RfspIndex | ||
| } | ||
| } | ||
| if amfUe.PcfId != "" { | ||
| ueContextCreatedData.UeContext.PcfId = amfUe.PcfId | ||
| } | ||
| if amfUe.AmPolicyUri != "" { | ||
| ueContextCreatedData.UeContext.PcfAmPolicyUri = amfUe.AmPolicyUri | ||
| } | ||
| for _, eventSub := range amfUe.EventSubscriptionsInfo { | ||
| if eventSub.EventSubscription != nil { | ||
| ueContextCreatedData.UeContext.EventSubscriptionList = append( | ||
| ueContextCreatedData.UeContext.EventSubscriptionList, *eventSub.EventSubscription) | ||
| } | ||
| } | ||
| if amfUe.TraceData != nil { | ||
| ueContextCreatedData.UeContext.TraceData = amfUe.TraceData | ||
| } | ||
|
|
||
| ueContextCreatedData.TargetToSourceData = new(models.N2InfoContent) | ||
| ueContextCreatedData.TargetToSourceData.NgapIeType = models.AmfCommunicationNgapIeType_TAR_TO_SRC_CONTAINER | ||
|
|
||
| ueContextCreatedData.TargetToSourceData.NgapData = new(models.RefToBinaryData) | ||
| ueContextCreatedData.TargetToSourceData.NgapData.ContentId = "N2InfoContent" | ||
|
|
||
| for _, pduSessionResourceHandoverItem := range pduSessionResourceHandoverList.List { | ||
| ueContextCreatedData.PduSessionList = append(ueContextCreatedData.PduSessionList, models.N2SmInformation{ | ||
| PduSessionId: int32(pduSessionResourceHandoverItem.PDUSessionID.Value), | ||
| }) | ||
| } | ||
|
|
||
| resp201 := models.CreateUeContextResponse201{ | ||
| JsonData: &ueContextCreatedData, | ||
| BinaryDataN2Information: targetToSourceTransparentContainer.Value, | ||
| } | ||
|
|
||
| amfSelf := amfUe.ServingAMF() | ||
|
|
||
| // Create channel if not exist | ||
| pendingHOResponseChan := make(chan context.PendingHandoverResponse) | ||
|
||
| value, loaded := amfSelf.PendingHandovers.LoadOrStore(amfUe.Supi, pendingHOResponseChan) | ||
| if loaded { | ||
| pendingHOResponseChan = value.(chan context.PendingHandoverResponse) | ||
| } | ||
|
|
||
| // Send the Response to CreateUEContextProcedure() | ||
| pendingHOResponseChan <- context.PendingHandoverResponse{ | ||
| Response201: &resp201, | ||
| } | ||
| } else { | ||
| // Handover in the same AMF | ||
| ran.Log.Tracef("Source: RanUeNgapID[%d] AmfUeNgapID[%d]", sourceUe.RanUeNgapId, sourceUe.AmfUeNgapId) | ||
| ran.Log.Tracef("Target: RanUeNgapID[%d] AmfUeNgapID[%d]", targetUe.RanUeNgapId, targetUe.AmfUeNgapId) | ||
| if len(pduSessionResourceHandoverList.List) == 0 { | ||
|
|
@@ -1633,10 +1708,161 @@ func handleHandoverRequiredMain(ran *context.AmfRan, | |
| // handover between different AMF | ||
| sourceUe.Log.Warnf("Handover required : cannot find target Ran Node Id[%+v] in this AMF", targetRanNodeId) | ||
| sourceUe.Log.Error("Handover between different AMF has not been implemented yet") | ||
|
|
||
| hoFailCause = business_metrics.HANDOVER_BETWEEN_DIFFERENT_AMF_NOT_SUPPORTED | ||
| return | ||
| // TODO: Send to T-AMF | ||
| // Described in (23.502 4.9.1.3.2) step 3.Namf_Communication_CreateUEContext Request | ||
| /* | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did this section remain in comment condition? If it doesn't need now, please remove it or leave the comment with why you make it as comment. |
||
| var ueContextCreateData models.UeContextCreateData | ||
| ueContextCreateData.UeContext.Supi = amfUe.Supi | ||
| ueContextCreateData.UeContext.SupiUnauthInd = amfUe.UnauthenticatedSupi | ||
| ueContextCreateData.UeContext.UdmGroupId = amfUe.UdmGroupId | ||
| ueContextCreateData.UeContext.AusfGroupId = amfUe.AusfGroupId | ||
| ueContextCreateData.UeContext.RestrictedPrimaryRatList[0] = amfUe.RatType | ||
|
|
||
| ueContextCreateData.TargetId.RanNodeId = &targetRanNodeId | ||
| ueContextCreateData.TargetId.Tai = &amfUe.Tai | ||
|
|
||
| ueContextCreateData.PduSessionList = make([]models.N2SmInformation, 0) | ||
| for _, pDUSessionResourceHoItem := range pDUSessionResourceListHORqd.List { | ||
| pduSessionID := int32(pDUSessionResourceHoItem.PDUSessionID.Value) | ||
| smContext, okSmContextFindByPDUSessionID := amfUe.SmContextFindByPDUSessionID(pduSessionID) | ||
| if !okSmContextFindByPDUSessionID { | ||
| sourceUe.Log.Warnf("SmContext[PDU Session ID:%d] not found", pduSessionID) | ||
| // TODO: Check if doing error handling here | ||
| continue | ||
| } | ||
| snssai := smContext.Snssai() | ||
| ueContextCreateData.PduSessionList = append(ueContextCreateData.PduSessionList, models.N2SmInformation{ | ||
| PduSessionId: pduSessionID, | ||
| SNssai: &snssai, | ||
| }) | ||
| } | ||
|
|
||
| ueContextCreateData.SourceToTargetData.NgapIeType = models.AmfCommunicationNgapIeType_HANDOVER_REQUIRED | ||
| ueContextCreateData.SourceToTargetData.NgapData.ContentId = "N2SmInfo" | ||
|
|
||
| ueContextCreateData.N2NotifyUri = "" | ||
| ueContextCreatedData, targetToSourceTransparentContainer, | ||
| problemDetails, err := consumer.GetConsumer().CreateUEContextRequest(amfUe, ueContextCreateData) | ||
|
|
||
| if problemDetails != nil { | ||
| // get UeContextCreateError (HANDOVER FAILURE) from target AMF. | ||
| // Send Handover Preparation Failure to source RAN (described in TS 38.413 8.4.1.3). | ||
| sourceUe.Log.Info("Handle Handover Preparation Failure [HoFailure In Target5GC NgranNode Or TargetSystem]") | ||
| cause = &ngapType.Cause{ | ||
| Present: ngapType.CausePresentRadioNetwork, | ||
| RadioNetwork: &ngapType.CauseRadioNetwork{ | ||
| Value: ngapType.CauseRadioNetworkPresentHoFailureInTarget5GCNgranNodeOrTargetSystem, | ||
| }, | ||
| } | ||
| ngap_message.SendHandoverPreparationFailure(sourceUe, *cause, nil) | ||
| return | ||
| } else if err != nil { | ||
| // error occurred in S-AMF. | ||
| sourceUe.Log.Errorf("CreateUEContextRequest Error in source AMF: %s", err.Error()) | ||
| cause = &ngapType.Cause{ | ||
| Present: ngapType.CausePresentRadioNetwork, | ||
| RadioNetwork: &ngapType.CauseRadioNetwork{ | ||
| Value: ngapType.CauseRadioNetworkPresentUnspecified, | ||
| }, | ||
| } | ||
| ngap_message.SendHandoverPreparationFailure(sourceUe, *cause, nil) | ||
| } else { | ||
| // Get UeContextCreatedData from T-AMF. | ||
| // Send HandoverCommand to S-RAN. | ||
| var pduSessionResourceHandoverList ngapType.PDUSessionResourceHandoverList | ||
| var pduSessionResourceToReleaseList ngapType.PDUSessionResourceToReleaseListHOCmd | ||
|
|
||
| for _, N2SmInfo := range ueContextCreatedData.PduSessionList { | ||
| var item ngapType.PDUSessionResourceHandoverItem | ||
| item.PDUSessionID.Value = int64(N2SmInfo.PduSessionId) | ||
| } | ||
|
|
||
| ngap_message.SendHandoverCommand(sourceUe, pduSessionResourceHandoverList, pduSessionResourceToReleaseList, | ||
| *targetToSourceTransparentContainer, nil) | ||
| /* | ||
| // describe in 23.502 4.9.1.3.2 step11 | ||
| if pDUSessionResourceAdmittedList != nil { | ||
| targetUe.Log.Infof("Send HandoverRequestAcknowledgeTransfer to SMF") | ||
| for _, item := range pDUSessionResourceAdmittedList.List { /* | ||
| pduSessionID := int32(item.PDUSessionID.Value) | ||
| transfer := item.HandoverRequestAcknowledgeTransfer | ||
| smContext, ok := amfUe.SmContextFindByPDUSessionID(pduSessionID) | ||
| if !ok { | ||
| targetUe.Log.Warnf("SmContext[PDU Session ID:%d] not found", pduSessionID) | ||
| // TODO: Check if doing error handling here | ||
| continue | ||
| } | ||
| resp, errResponse, problemDetails, err := consumer.GetConsumer().SendUpdateSmContextN2HandoverPrepared(amfUe, | ||
| smContext, models.N2SmInfoType_HANDOVER_REQ_ACK, transfer) | ||
| if err != nil { | ||
| targetUe.Log.Errorf("Send HandoverRequestAcknowledgeTransfer error: %v", err) | ||
| } | ||
| if problemDetails != nil { | ||
| targetUe.Log.Warnf("ProblemDetails[status: %d, Cause: %s]", problemDetails.Status, problemDetails.Cause) | ||
| } | ||
| if resp != nil && resp.BinaryDataN2SmInformation != nil { | ||
| handoverItem := ngapType.PDUSessionResourceHandoverItem{} | ||
| handoverItem.PDUSessionID = item.PDUSessionID | ||
| handoverItem.HandoverCommandTransfer = resp.BinaryDataN2SmInformation | ||
| pduSessionResourceHandoverList.List = append(pduSessionResourceHandoverList.List, handoverItem) | ||
| targetUe.SuccessPduSessionId = append(targetUe.SuccessPduSessionId, pduSessionID) | ||
| } | ||
| if errResponse != nil && errResponse.BinaryDataN2SmInformation != nil { | ||
| releaseItem := ngapType.PDUSessionResourceToReleaseItemHOCmd{} | ||
| releaseItem.PDUSessionID = item.PDUSessionID | ||
| releaseItem.HandoverPreparationUnsuccessfulTransfer = errResponse.BinaryDataN2SmInformation | ||
| pduSessionResourceToReleaseList.List = append(pduSessionResourceToReleaseList.List, releaseItem) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if pDUSessionResourceFailedToSetupListHOAck != nil { | ||
| targetUe.Log.Infof("Send HandoverResourceAllocationUnsuccessfulTransfer to SMF") | ||
| for _, item := range pDUSessionResourceFailedToSetupListHOAck.List { | ||
| pduSessionID := int32(item.PDUSessionID.Value) | ||
| transfer := item.HandoverResourceAllocationUnsuccessfulTransfer | ||
| smContext, ok := amfUe.SmContextFindByPDUSessionID(pduSessionID) | ||
| if !ok { | ||
| targetUe.Log.Warnf("SmContext[PDU Session ID:%d] not found", pduSessionID) | ||
| // TODO: Check if doing error handling here | ||
| continue | ||
| } | ||
| _, _, problemDetails, err := consumer.GetConsumer().SendUpdateSmContextN2HandoverPrepared(amfUe, smContext, | ||
| models.N2SmInfoType_HANDOVER_RES_ALLOC_FAIL, transfer) | ||
| if err != nil { | ||
| targetUe.Log.Errorf("Send HandoverResourceAllocationUnsuccessfulTransfer error: %v", err) | ||
| } | ||
| if problemDetails != nil { | ||
| targetUe.Log.Warnf("ProblemDetails[status: %d, Cause: %s]", problemDetails.Status, problemDetails.Cause) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| sourceUe := targetUe.SourceUe | ||
| if sourceUe == nil { | ||
| // TODO: Send Namf_Communication_CreateUEContext Response to S-AMF | ||
| ran.Log.Error("handover between different Ue has not been implement yet") | ||
| } else { | ||
| ran.Log.Tracef("Source: RanUeNgapID[%d] AmfUeNgapID[%d]", sourceUe.RanUeNgapId, sourceUe.AmfUeNgapId) | ||
| ran.Log.Tracef("Target: RanUeNgapID[%d] AmfUeNgapID[%d]", targetUe.RanUeNgapId, targetUe.AmfUeNgapId) | ||
| if len(pduSessionResourceHandoverList.List) == 0 { | ||
| targetUe.Log.Info("Handle Handover Preparation Failure [HoFailure In Target5GC NgranNode Or TargetSystem]") | ||
| cause := &ngapType.Cause{ | ||
| Present: ngapType.CausePresentRadioNetwork, | ||
| RadioNetwork: &ngapType.CauseRadioNetwork{ | ||
| Value: ngapType.CauseRadioNetworkPresentHoFailureInTarget5GCNgranNodeOrTargetSystem, | ||
| }, | ||
| } | ||
| ngap_message.SendHandoverPreparationFailure(sourceUe, *cause, nil) | ||
| return | ||
| } | ||
| ngap_message.SendHandoverCommand(sourceUe, pduSessionResourceHandoverList, pduSessionResourceToReleaseList, | ||
| *targetToSourceTransparentContainer, nil) | ||
| } | ||
| } */ | ||
| } else { | ||
| // Handover in same AMF | ||
| sourceUe.HandOverType.Value = handoverType.Value | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use Warnln to instead