Jimmy
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    [TOC] :::info * Add the reminder in the modified code place. ::: # AUSF improvement 2 * Before ![image](https://hackmd.io/_uploads/SkJZl0tX0.png) * After ![image](https://hackmd.io/_uploads/rkf07zsm0.png) ## Reason ![image](https://hackmd.io/_uploads/rJXFpu91C.png) ![image](https://hackmd.io/_uploads/rkZIT_5J0.png) ## 1st req & resp ### Method * Use the function call in AMF, instead of call AUSF's API. ![image](https://hackmd.io/_uploads/H1RS0rQQA.png) * In **ue_authentication.go**(AMF) * Call by **func SendUEAuthenticationAuthenticateRequest** - [x] Need to check whether creating another new file for function calling is needed or not. * **No, all modification is done in ue_authentication.go** :::warning * Reserve parts : * RAND, AUTN pass in AUSF ![image](https://hackmd.io/_uploads/ByyARSmQ0.png) * In **ue_authentication.go**(AUSF) * Call by **func UeAuthPostRequestProcedure** * RAND, AUTN gen in UDM ![image](https://hackmd.io/_uploads/H1QY1LQmR.png) * In **generate_auth_data.go**(UDM) * **func GenerateAuthDataProcedure** * **func strictHex** * **func aucSQN** * MongoDB API in UDR * In **data_repository.go**(UDR) * **func QueryAuthSubsDataProcedure** * **func getDataFromDB** * **func ModifyAuthenticationProcedure** * **func patchDataToDBAndNotify** * Reduction * API -> function calling (Some functions, URI creating, parameters passing, http interaction) * AUSF selection * AUSF context create. * EAP-AKA' * Service network authorization * Simplfy resyncronization, SUCI checking * SUCI to SUPI ::: ### Modification #### Prerequisite * Move the file from the VM in server room to computer in lab because of storage problem. * OS changed from **ubuntu 20.04 to 18.04**, and kernel version is still on **5.4.0**, so it is OK for **gtp module**. * Move the **reserved parts** to AMF, and put them **above func SendUEAuthenticationAuthenticateRequest**. #### Implementation :::warning **The parts need to check after modification :** (They are in the folded area below, here just for **final confirmation** and not for check list) - [ ] func SendUEAuthenticationAuthenticateRequest - [ ] func UeAuthPostRequestProcedure - [ ] func GenerateAuthDataProcedure ::: :::spoiler **func SendUEAuthenticationAuthenticateRequest** ![image](https://hackmd.io/_uploads/HyCkjqNmA.png) 1. Why I dont call func UeAuthPostRequestProcedure of AUSF directly from func AuthenticationProcedure of AMF. * In modification before, it has a transformation of the format **authInfo**. ![image](https://hackmd.io/_uploads/ByI5atEXR.png) * The parameters passed from AuthenticationProcedure are ![image](https://hackmd.io/_uploads/Sk_CCKNX0.png) * The received side is ![image](https://hackmd.io/_uploads/S1O11547R.png) * And it use them to make the parameters will be passed to AUSF. ![image](https://hackmd.io/_uploads/BJ3US9VXR.png) - [ ] So I reserved them first and to see if I need to move them to AuthenticationProcedure or remove them. 2. Change the receive parameters to ignore the API part and match the return. ![image](https://hackmd.io/_uploads/H1O-zcVm0.png) ![image](https://hackmd.io/_uploads/BkFuH5E7R.png) * The locationURI in UeAuthPostRequestProcedure also needs to modify. - [ ] The return parameters remain three to match AuthenticationProcedure's calling, or modify to another err reporting format. - [ ] Not sure if the format of ueAuthenticationCtx is matched or not. ![image](https://hackmd.io/_uploads/BkrFEXs70.png) ![image](https://hackmd.io/_uploads/rJln4Qi70.png) ![image](https://hackmd.io/_uploads/BkTnNms7R.png) 3. Remove part ![image](https://hackmd.io/_uploads/rylX8cN7C.png) ::: :::spoiler **func UeAuthPostRequestProcedure** ![image](https://hackmd.io/_uploads/HkP0q5EmR.png) 1. Comment out the service network authorization. ![image](https://hackmd.io/_uploads/rkflJn4QA.png) 2. Reduce EAP-AKA' ![image](https://hackmd.io/_uploads/BJFmoqN7R.png) 3. Reduce the return parameters to two(rep & err). ![image](https://hackmd.io/_uploads/B123YiV7R.png) ![image](https://hackmd.io/_uploads/HJUaFoE7A.png) - [ ] Need to check the pointer format when test. 4. Comment out the locationURI processing. ![image](https://hackmd.io/_uploads/Hy2Blh4QC.png) - [ ] Because it is used in one of the return parameter(responseBody), so reserve it first, and see if I can remove it latter.([Code explanation](https://hackmd.io/DETj57LjQFimKBIOaD6csQ?both#API-link)) ![image](https://hackmd.io/_uploads/ry12ghVQR.png) 5. Resynchronization ![image](https://hackmd.io/_uploads/By4Zhs4QR.png) * Originally it will not be used at UE's first attach in func AuthenticationProcedure, it passes a nil to func SendUEAuthenticationAuthenticateRequest. ![image](https://hackmd.io/_uploads/H1F_asNXA.png) ![image](https://hackmd.io/_uploads/H1oCTiV7A.png) * In func HandleAuthenticationFailure, it will call again and give it resynchronizationInfo. ![image](https://hackmd.io/_uploads/r1Ek6iEQR.png) - [ ] Comment out here and need to prepare how to deal with resyncronization. ![image](https://hackmd.io/_uploads/SJDmJnE7R.png) 6. Call UDM -> Call function * Original API server parameters passing to UDM is like this. ![image](https://hackmd.io/_uploads/Hk8rEgsm0.png) * Ignore the original API calling, and modify the parameters to call function. ![image](https://hackmd.io/_uploads/HJlrDriQA.png) * The UDM function side. ![image](https://hackmd.io/_uploads/H126mgjXC.png) * The return parameters in UDM function are matched with original API. ![image](https://hackmd.io/_uploads/SyPKBeomR.png) * Format in UDM function ![image](https://hackmd.io/_uploads/HkbxISsQA.png) ![image](https://hackmd.io/_uploads/ByqAHro70.png) ![image](https://hackmd.io/_uploads/ByFkIHsmC.png) - [ ] So remove the API parameter rsp, and Im not sure if the format of err is matched with problemDetails, because it's originally passed to API function. ![image](https://hackmd.io/_uploads/Sk9ZPgjQR.png) 7. Reduce the ausf context process part, and reserve ueid access, print it to add a pause and see the result. * I dont know which one can print on terminal so I use two of them. ![image](https://hackmd.io/_uploads/BJ1SYlsXR.png) * The other part below. ![image](https://hackmd.io/_uploads/H1fKFlo7A.png) 8. Kseaf & Kausf - [ ] I reserved the Kseaf derive part first, although, because Kseaf will be used in 2nd req & rep to generate Kamf, I dont know if that will be reduced or not. ![image](https://hackmd.io/_uploads/rkeb2zi70.png) * Kausf will be gen in UDM function, and it is included in AV , so it will beb reserved. :::warning * **Modules need to be added** * "encoding/hex" ![image](https://hackmd.io/_uploads/BJEvUMiXR.png) ![image](https://hackmd.io/_uploads/BJJaLzimC.png) * "crypto/sha256" ![image](https://hackmd.io/_uploads/HyHwKGjm0.png) * "net/http" ![image](https://hackmd.io/_uploads/HJ_c3zs7R.png) * Upper part also has the same place need it. * "github.com/free5gc/util/ueauth" ![image](https://hackmd.io/_uploads/Hy3BlQsm0.png) * **logger function** * Original in AMF ![image](https://hackmd.io/_uploads/SkHXKMoXC.png) - [x] The logger file may not has the function of AUSF print function, need to add or change to AMF print function. ::: :::spoiler **func GenerateAuthDataProcedure** 1. Reduce EAP-AKA' ![image](https://hackmd.io/_uploads/SkcwNHj7C.png) 2. Call ToSupi -> Call function - [x] Need to check whether to pass supi directly. 1. Original source in UDM ![image](https://hackmd.io/_uploads/S1shQBimA.png) ![image](https://hackmd.io/_uploads/BynPXBjQ0.png) ![image](https://hackmd.io/_uploads/H1xALoTQC.png) * ToSupi function is in suci.go, and it calls other key transform functions above it, so if I move all of them, I need to modify a lot, then I take a see of Terry's method. 2. [Terry's solution](https://hackmd.io/AMzUH2F7TzOxIo5o3H3CyA?both#SUCI-to-SUPI) * [Example test link](https://hackmd.io/DETj57LjQFimKBIOaD6csQ?view#Run-go-in-VScode) * Im not sure if it can transform or not, so I print the SUCI in AMF and SUPI in UDM. ![image](https://hackmd.io/_uploads/H1HKSsaX0.png) ![image](https://hackmd.io/_uploads/BJHcBs6QR.png) ![image](https://hackmd.io/_uploads/SJDlHsTmC.png) * This solu **assumes that the UE use IMSI SUPI type**, and **mcc/mnc parts are fixed**, so if the mcc/mnc are changed, it turns out error. 3. So here I'm concerning to move suci.go. * Move to here and change the packge name. ![image](https://hackmd.io/_uploads/ryQBio67C.png) * The logger imported print function should be modified. * Here I found a problem is that it has a passing parameter called **suciProfiles**, which is **used in home nework key & SUCI to SUPI transfrom**, like the below description. ![image](https://hackmd.io/_uploads/Syj36ia70.png) * And **the several functions above ToSupi are all for the profileA & profileB**. 4. So here I decide to combine the [mcc/mnc extract method](https://hackmd.io/DETj57LjQFimKBIOaD6csQ?both#const) in ToSupi and Terry's method. * Create the const ![image](https://hackmd.io/_uploads/S1G7n2670.png) * Original other guys' method * Terry ![image](https://hackmd.io/_uploads/B1j2jh6QR.png) * ToSupi ![image](https://hackmd.io/_uploads/r1U1h367C.png) * My final method ![image](https://hackmd.io/_uploads/rJXO2hpXC.png) * Remove the supi.go which I wanted to move to here, and this part. ![image](https://hackmd.io/_uploads/Hkat2hamC.png) 3. Call UDR -> Call function * The API part from UDM side to UDR side, maybe I have to **put the selected part into the UDM's calling side(it's moved now)**. ![image](https://hackmd.io/_uploads/Hkx2eHVN0.png) * In the main part, UDR side passes two parameters to get UE data from mongoDB, and in the getDataFromDB, it imports something. * ![image](https://hackmd.io/_uploads/Bkr5LrE4A.png) * ![image](https://hackmd.io/_uploads/BkhzvHNVC.png) * **About how it imports, go [here](https://hackmd.io/DETj57LjQFimKBIOaD6csQ?both#import-githubcom%E2%80%A6-) for more info**. * When I was checking Terry's approach of here(connect and get data from mongoDB), I have more problem about the difference with my past import methods, **go [here](https://hackmd.io/DETj57LjQFimKBIOaD6csQ?both#Go-module) for more info about what I has discovered**. * Pint the ueId which will be use in the API process of UDM-UDR, so it is SUPI. ![image](https://hackmd.io/_uploads/BkuS1PEEA.png) ![image](https://hackmd.io/_uploads/rkv7lw4VC.png) * Remove UDR client creating, and move the parameters creating from UDR. ![image](https://hackmd.io/_uploads/HJugZvVVC.png) * Pint the return value of API and the function I want to move. ![image](https://hackmd.io/_uploads/Sk0nfPNVR.png) ![image](https://hackmd.io/_uploads/HJNjZONVR.png) * Im not sure if authSubs can directly receive the return of this format(map[string]interface{}), without the trasformation of API(response->authSubs), the usage of authSubs below are all **in the content of the return** from func QueryAuthSubsDataProcedure in UDR. ![image](https://hackmd.io/_uploads/r1HqVuENR.png) ![image](https://hackmd.io/_uploads/S1H9rdVE0.png) ![image](https://hackmd.io/_uploads/SJT5SuN40.png) ![image](https://hackmd.io/_uploads/S1LoHOVVC.png) ![image](https://hackmd.io/_uploads/HkgnHdV40.png) ![image](https://hackmd.io/_uploads/rymTSd4VR.png) * Sort up the **output of return map** of func QueryAuthSubsDataProcedure, so **they are matched** and can indeed call the parameters. ![image](https://hackmd.io/_uploads/rkxIBONVC.png) * Reduce the receive parameters to two, an comment out the API process. ![image](https://hackmd.io/_uploads/rkidDd4VR.png) * Delete the redundent of API part, because it has directly calls the **func QueryAuthSubsDataProcedure**. ![image](https://hackmd.io/_uploads/Sypr51PB0.png) * But keep the printing line in ![image](https://hackmd.io/_uploads/r11-ikDrC.png) 4. strictHex ![image](https://hackmd.io/_uploads/HJXbItEVA.png) ![image](https://hackmd.io/_uploads/B1HNU6IBA.png) ![image](https://hackmd.io/_uploads/BJ5ihTIBR.png) ![image](https://hackmd.io/_uploads/ByJj3T8rC.png) * Add one more function from UDM, [here](https://hackmd.io/DETj57LjQFimKBIOaD6csQ?view#strictHex) is what it does. ![image](https://hackmd.io/_uploads/SyVE8YEVR.png) 5. make -> [Link](https://hackmd.io/DETj57LjQFimKBIOaD6csQ?view#API-link) ![image](https://hackmd.io/_uploads/rJxyvpIH0.png) 6. Resynchronization Here I just checked the modification before : * So in **func AuthenticationProcedure**, the resync info passed to **func SendUEAuthenticationAuthenticateRequest** will be set to nil. ![image](https://hackmd.io/_uploads/BJXjTaUS0.png) But it will be set in **func HandleAuthenticationFailure** if there is a sync failure happened. ![image](https://hackmd.io/_uploads/Sy2zCpIH0.png) ![image](https://hackmd.io/_uploads/HyDeC6LSC.png) * In **func SendUEAuthenticationAuthenticateRequest**, it just passes the parameter if it receives it, and doesn't do more process. ![image](https://hackmd.io/_uploads/S1_gyRIr0.png) * In past modification, I commented out the resync process in **func UeAuthPostRequestProcedure** because it includes ausf context edit, but I want to keep the resync info passing, so I do this modificaiton. ![image](https://hackmd.io/_uploads/HyPulCUSA.png) * Then if the resync info exists, the info will not be lost, and will be received by **func GenerateAuthDataProcedure**. - [ ] But here I'm not sure commenting out this Rand parameter filling will affect or not (There will not have Rand parameter ?). ![image](https://hackmd.io/_uploads/Sypl-08BR.png) * In **func GenerateAuthDataProcedure**. * It **decodes Auts/Rand** from ResynchronizationInfo, and use aucSQN to **generate SQN & mac**. * **aucSQN** ![image](https://hackmd.io/_uploads/S1o4nRUBC.png) * It is a function in original UDM, so copy it to AMF. ![image](https://hackmd.io/_uploads/SJAll1Pr0.png) * Then it uses some imported function to do computation in if/else -> [Link](https://hackmd.io/DETj57LjQFimKBIOaD6csQ?both#Some-computation) * In else part, comment out the suci checking, only keep the logger printing and return. ![image](https://hackmd.io/_uploads/rkqsXJwB0.png) 7. increment sqn(**call UDR -> call function**) * Do some computation for SQN. -> [Link](https://hackmd.io/DETj57LjQFimKBIOaD6csQ?view#Some-computation) ![image](https://hackmd.io/_uploads/B1CZKyDSC.png) * Save the computaion results into DB ![image](https://hackmd.io/_uploads/Hy8QY1vr0.png) * Here is the API operation in UDR, need to combine it into AMF. ![image](https://hackmd.io/_uploads/SJtzTyPr0.png) ![image](https://hackmd.io/_uploads/Sy6q0yPBA.png) * **Modification 1** : Move the API calling/parameter passing to here. ![image](https://hackmd.io/_uploads/BkWv1evSC.png) * Modify the error process. ![image](https://hackmd.io/_uploads/rJpK1gDrC.png) * **Modification 2** : Attach the parts (1&2) forgot in the UDR function calling last time (get data from DB), the http calling has been imported when doing AUSF funciton moving. ![image](https://hackmd.io/_uploads/H1DAMgvHR.png) And the **util calling** need to be modified because it is originally from UDR. ![image](https://hackmd.io/_uploads/rktKHlDS0.png) * **Modification 3** : util function * Originally, UDR import this folder "github.com/free5gc/udr/internal/util" and call the function in this file. ![image](https://hackmd.io/_uploads/rJnG-zurA.png) * But only these two functions(get, modify) I import from UDR call that file, so I decide to move the called functions directly. ![image](https://hackmd.io/_uploads/HJDXfMuSA.png) ![image](https://hackmd.io/_uploads/ryXNff_rR.png) ![image](https://hackmd.io/_uploads/SkkBzzdHR.png) * The http and model need to add have been imported in my files, so just move and modify. ![image](https://hackmd.io/_uploads/Bkl3XzdS0.png) ![image](https://hackmd.io/_uploads/SJCj4MOS0.png) * About the variable declaration -> [Link](https://hackmd.io/DETj57LjQFimKBIOaD6csQ?view#Declaration-amp---) * **Modification 4** : func patchDataToDBAndNotify * Add one import ("encoding/json"). - [ ] Comment out the notify function calling, because it is not nessesiry to send a notification from UDR in future, just modify the DB. But Im not sure whether this notification will affect other module or not. ![image](https://hackmd.io/_uploads/rkJzCf_SC.png) ![image](https://hackmd.io/_uploads/HJJlAfOHR.png) ![image](https://hackmd.io/_uploads/SJ20af_S0.png) * About the recover() function -> [Link](https://hackmd.io/DETj57LjQFimKBIOaD6csQ?view#recover) :::warning * **Modules need to be added** * "math/rand" "time" ![image](https://hackmd.io/_uploads/ByBTzSi7A.png) * "github.com/free5gc/util/milenage" ![image](https://hackmd.io/_uploads/ryvzBKVEA.png) * "strings" ![image](https://hackmd.io/_uploads/ryHFUt4VC.png) * "cryptoRand "crypto/rand" ![image](https://hackmd.io/_uploads/SyDdwYE40.png) * "reflect" ![image](https://hackmd.io/_uploads/SkOtgyDrR.png) * "math/big" ![image](https://hackmd.io/_uploads/ryFSZyDSC.png) * "github.com/free5gc/util/mongoapi" ![image](https://hackmd.io/_uploads/S1vJmxwB0.png) * "go.mongodb.org/mongo-driver/bson" ![image](https://hackmd.io/_uploads/HJXl7gPHR.png) * "encoding/json" ![image](https://hackmd.io/_uploads/ByUu_z_BR.png) * **logger function** * ![image](https://hackmd.io/_uploads/r1lhQp3TXA.png) * ![image](https://hackmd.io/_uploads/rkZQT267R.png) * ![image](https://hackmd.io/_uploads/HkzO_dE4C.png) * ![image](https://hackmd.io/_uploads/HkxYudNER.png) * ![image](https://hackmd.io/_uploads/rJjKudNE0.png) * ![image](https://hackmd.io/_uploads/rya5OdENA.png) * ![image](https://hackmd.io/_uploads/B1AnuuEEA.png) * ![image](https://hackmd.io/_uploads/Sk2VSKVNR.png) * ![image](https://hackmd.io/_uploads/Sya5D6LB0.png) * ![image](https://hackmd.io/_uploads/HkQPrY4VC.png) * ![image](https://hackmd.io/_uploads/SJURDTLSC.png) * ![image](https://hackmd.io/_uploads/BJ7yOTLHA.png) * ![image](https://hackmd.io/_uploads/rJegO68rA.png) * ![image](https://hackmd.io/_uploads/H14rXR8BA.png) * ![image](https://hackmd.io/_uploads/HkCrX0IrR.png) * ![image](https://hackmd.io/_uploads/SJ_8Q0IHR.png) * ![image](https://hackmd.io/_uploads/ryVBgkDBR.png) * ![image](https://hackmd.io/_uploads/B1ore1vS0.png) * ![image](https://hackmd.io/_uploads/rkBIl1DBR.png) * ![image](https://hackmd.io/_uploads/B1tzb1DSR.png) * ![image](https://hackmd.io/_uploads/ByJFb1vrR.png) * ![image](https://hackmd.io/_uploads/Sk-1XJDS0.png) * ![image](https://hackmd.io/_uploads/BJyVVJwBC.png) * ![image](https://hackmd.io/_uploads/HJnVVyvH0.png) * ![image](https://hackmd.io/_uploads/SJSUCM_S0.png) * ![image](https://hackmd.io/_uploads/SJbPRMdrA.png) * ![image](https://hackmd.io/_uploads/BkEO0zdSA.png) * ![image](https://hackmd.io/_uploads/H1rFAfdBR.png) * ![image](https://hackmd.io/_uploads/ByvGJ7uH0.png) * ![image](https://hackmd.io/_uploads/BkJLkmdSA.png) * ![image](https://hackmd.io/_uploads/S1UfN7_S0.png) * **logger function (UDR)** * ![image](https://hackmd.io/_uploads/SyXHokDHA.png) * ![image](https://hackmd.io/_uploads/rkQHAkPrA.png) * ![image](https://hackmd.io/_uploads/HyiD6kDHA.png) * ![image](https://hackmd.io/_uploads/HJWtCJwHC.png) ::: ### Compilation #### Problem 1 :::danger * Need to go get some imported module ![image](https://hackmd.io/_uploads/ryxh_7OrR.png) ::: :::success * About tha fatal lines info -> [Link](https://hackmd.io/DETj57LjQFimKBIOaD6csQ?view#make) * Type these commands : ```shell= cd NFs/amf go get github.com/free5gc/util/mongoapi@v1.0.5-0.20230306071612-a52909216bd2 go get github.com/free5gc/amf/internal/sbi/consumer ``` * I don't know if it is right to go get in the root folder. ![image](https://hackmd.io/_uploads/SJWz-4_BC.png) ::: :::danger ![image](https://hackmd.io/_uploads/B1KTeNuBC.png) ![image](https://hackmd.io/_uploads/HJUteVdrR.png) ::: :::success * Need to go get in the folder which has go.mod ![image](https://hackmd.io/_uploads/SJSVWEur0.png) ::: :::danger * I don't know why make command say that I need to go get amf/comsumer, maybe because I did the modification in comsumer folder. ![image](https://hackmd.io/_uploads/SJYanVOSC.png) * And if I ignore the errors above and make directly, I will get the same errors. ![image](https://hackmd.io/_uploads/rk6VaNdrC.png) ::: :::success * So I just ignore it and keep debugging. ::: #### Problem 2 :::danger ![image](https://hackmd.io/_uploads/Sy3TaVOSR.png) ::: :::success 1. ![image](https://hackmd.io/_uploads/S1_KmI_SA.png) -> ![image](https://hackmd.io/_uploads/r1FjmU_rA.png) 2. The logger problem : logger printing functions used in UDR/UDM/AUSF are not in AMF. * When you check the logger.go it imports in AMF and UDR, you will find they has very similar structure. ![image](https://hackmd.io/_uploads/SyEjvUdSR.png) ![image](https://hackmd.io/_uploads/rkLku8urA.png) * So I think we can just add the logger variable that AMF does not have, but UDR has. * ![image](https://hackmd.io/_uploads/SyAvuLdBR.png) * ![image](https://hackmd.io/_uploads/rkrwuUdSC.png) 3. This variable is definded in orignal file, by a const function, so add it. ![image](https://hackmd.io/_uploads/SJVRuLOHC.png) V![image](https://hackmd.io/_uploads/BJ25QDYSC.png) 4. Add variables * ![image](https://hackmd.io/_uploads/HkhdcU_BA.png) * ![image](https://hackmd.io/_uploads/H1KI5IuHC.png) 5. Plus M to prevent the repeat error. * ![image](https://hackmd.io/_uploads/HJWCGwYHA.png) ::: #### Problem 3 :::danger ![image](https://hackmd.io/_uploads/SygYWLr6HR.png) ::: :::success 1. This error is that I didnt deal with the parameters in the function calling which I have commented out. ![image](https://hackmd.io/_uploads/ryF08DtrC.png) * For checking whther this action will affect the DB modifiction or not, I print out these two variables in original free5gc, so the modification is the SQN number, and we can make sure that the modification is made between these two **RestfulAPIGetOne**. ![image](https://hackmd.io/_uploads/HJWYLvYBR.png) * And if you check the content of the notify functions, you can find that they only use these got values for sending http message, not for computing or something, so we can peacefully ignore them. ![image](https://hackmd.io/_uploads/ByvdFDtB0.png) ![image](https://hackmd.io/_uploads/BJ2BtDFB0.png) * So this check item is finished. ![image](https://hackmd.io/_uploads/SJWaPPKSA.png) * And the method is adding two print line so the variables will be used. ![image](https://hackmd.io/_uploads/rJ7dqwFHC.png) ![image](https://hackmd.io/_uploads/H13zJnYHR.png) 2. Need to difine it using :=, or the compiler can not verify it in return line. ![image](https://hackmd.io/_uploads/BJM0qwtB0.png) -> ![image](https://hackmd.io/_uploads/B1ZJovFHC.png) 3. ![image](https://hackmd.io/_uploads/rJltTvKBC.png) * In error place, it use the received err to give to Detail. ![image](https://hackmd.io/_uploads/rk34RwFBR.png) * In the called function, the pd is returned as err. ![image](https://hackmd.io/_uploads/S1KO0PYrA.png) * As you can see, the pd is also created from problemDetails. ![image](https://hackmd.io/_uploads/rJ3a0vYHR.png) * So there is no one item called err.Error() for us to use, I think it is because it is originally call API, not function, there will has some funciton we can call. * Here I change it to one of the item in the **models.ProblemDetails** that can be called, and to represent the Detail(DATA NOT FOUND). ![image](https://hackmd.io/_uploads/BJ50JOYBC.png) * Change the function name. ![image](https://hackmd.io/_uploads/B1MdbFtrR.png) -> ![image](https://hackmd.io/_uploads/HkfqbKtrA.png) 4. ![image](https://hackmd.io/_uploads/SkaLfKKH0.png) * The compiler can not find the PermanentKey item, I guess it is because the passing format problem or naming problem. ![image](https://hackmd.io/_uploads/HJJk-uFBC.png) ![image](https://hackmd.io/_uploads/SkMCxOFr0.png) * I print the passing value in three places * ![image](https://hackmd.io/_uploads/ryK9EdKBR.png) * ![image](https://hackmd.io/_uploads/HJk5EutBR.png) * ![image](https://hackmd.io/_uploads/BJmDNdKSA.png) * The results are like below, we can see that the value turn to memory address after API process. ![image](https://hackmd.io/_uploads/SJIyBdtS0.png) * So based on the error message, we need to transform the map[string]interface format. * About the explanation, disadvantage and reason of this format -> [Link](https://hackmd.io/DETj57LjQFimKBIOaD6csQ?view#mapstringinterface-) . * The other reason that I don't use this fromat directly as below, is that there are too many palce need to modify, so it's more efficient by creating a structure. * First do the definition. ![image](https://hackmd.io/_uploads/rkKlujYS0.png) * Compared to the content of map format. ![image](https://hackmd.io/_uploads/BJHrwoYBR.png) * Then do the transformation of the data received from MongoDB in this function. ![image](https://hackmd.io/_uploads/r19KuoFBA.png) * The original calling of authSubs should be done successfully, notice that the return format defining should be changed correctlly, or the compiler will report the same error. ![image](https://hackmd.io/_uploads/ryn9csFrR.png) V ![image](https://hackmd.io/_uploads/B1mRcjYBC.png) * Compared to Terry's MongoDB client -> [Link](https://hackmd.io/AMzUH2F7TzOxIo5o3H3CyA?view#MongoDB) . 5. ![image](https://hackmd.io/_uploads/BkC4ssYHR.png) ![image](https://hackmd.io/_uploads/B1z8ijFSC.png) * This is also defined as const in original funciton, so add it. ![image](https://hackmd.io/_uploads/B1CKsoKHR.png) ::: :::danger ![image](https://hackmd.io/_uploads/Hk5v3sYHR.png) ::: :::success 1. The AuthSubs declaration is in the same file with calling function, so don't need to add model. to import. ![image](https://hackmd.io/_uploads/rJUJ6sYSC.png) V ![image](https://hackmd.io/_uploads/rkgMpoKrC.png) 2. Just delete the redundent returned variable, I forgot why I put one more variable here. ![image](https://hackmd.io/_uploads/ryW2CsKrR.png) V ![image](https://hackmd.io/_uploads/r1YaRsYSA.png) ::: #### Problem 4 :::danger ![image](https://hackmd.io/_uploads/H1duXBpSC.png) ::: :::success 1. ![image](https://hackmd.io/_uploads/B1tZwBTr0.png) * I think the problem here is the previous declaration assign err as ***model.ProblemDetails**, because the called function is from UDR, the return format is not the same as here(**hex.DecodeString** originally from UDM). ![image](https://hackmd.io/_uploads/Bk5PDHaH0.png) * So I change the parameter name which will be used only for hex function, ![image](https://hackmd.io/_uploads/ByHE_SpHR.png) 2. ![image](https://hackmd.io/_uploads/HkVY_HpSC.png) * The problem is the checking action here can not match the structure(Milenage.Op) with nil. ![image](https://hackmd.io/_uploads/rym6jHTSC.png) * Here we can reserver the OpValue only, because the error report here is just to know whther the OpValue exists or not. ![image](https://hackmd.io/_uploads/rJyhoSpH0.png) 3. The remaining errors are all the same with 1. ![image](https://hackmd.io/_uploads/H15Lnr6r0.png) * So I just change their names. ![image](https://hackmd.io/_uploads/BkhqnBTH0.png) ![image](https://hackmd.io/_uploads/Hyra3BpBC.png) * Here is another function calling(milenage), so I change to another nameing. ![image](https://hackmd.io/_uploads/BJXGCB6B0.png) * The 411 line is still hex function. ![image](https://hackmd.io/_uploads/rJKdpBpB0.png) * Need to change to :=, or there will have this problem ![image](https://hackmd.io/_uploads/B1aTAS6HA.png) ![image](https://hackmd.io/_uploads/B1RARSTSC.png) ![image](https://hackmd.io/_uploads/H1kby8TS0.png) ![image](https://hackmd.io/_uploads/BJlfk8pHA.png) * Or like this. ![image](https://hackmd.io/_uploads/Syu_1ITSA.png) ![image](https://hackmd.io/_uploads/H1jwyU6rR.png) ::: #### Problem 5 :::danger ![image](https://hackmd.io/_uploads/BkHjJU6HR.png) ::: :::success * The same so keep changing. ![image](https://hackmd.io/_uploads/BJIFl8aS0.png) ![image](https://hackmd.io/_uploads/rJXHgU6rR.png) ![image](https://hackmd.io/_uploads/S1l1ZIaH0.png) ![image](https://hackmd.io/_uploads/rJZWZIpSC.png) ::: #### Problem 6 :::danger ![image](https://hackmd.io/_uploads/HJk0WDaSA.png) ::: :::success 1. ![image](https://hackmd.io/_uploads/B1CMG86BR.png) * It is continued from problem 2-5, and is same as problem 3-3. * In **func ModifyAuthenticationProcedure**, the returned structure include Cause and Detail, but Detail is assigned as "", so we can only use Cause to print out what happened("MODIFY_NOT_ALLOWED"). ![image](https://hackmd.io/_uploads/Sy5MQUaHC.png) ![image](https://hackmd.io/_uploads/S1flNLTr0.png) 2. At line 602. ![image](https://hackmd.io/_uploads/B1tedUTBA.png) V ![image](https://hackmd.io/_uploads/rkA8_ITHA.png) 3. At line 609. ![image](https://hackmd.io/_uploads/r1-UdLTrA.png) V ![image](https://hackmd.io/_uploads/By73uITHC.png) * I dont know why it doesnt need := here, the error pops up when I add :=. ![image](https://hackmd.io/_uploads/BkSWtUar0.png) 4. ![image](https://hackmd.io/_uploads/SkNZ98prA.png) * From the model it imports, the type is not string. ![image](https://hackmd.io/_uploads/BynmcI6HR.png) * One solution is that transfer the string format to model.AuthMethod. ![image](https://hackmd.io/_uploads/S1lAi8Tr0.png) * ~~But we need to define this model like the github import.~~ ![image](https://hackmd.io/_uploads/SkNf38aHR.png) * Another solution is that change the declaration in AuthSub. ![image](https://hackmd.io/_uploads/SJVB2UarR.png) * Originally I dont want to use model.AuthMethod, but use "5G_AKA" to compare directly. ![image](https://hackmd.io/_uploads/r1X9TI6BA.png) * But there are some flaws. ![image](https://hackmd.io/_uploads/ByA_TIpS0.png) * Also below has some other palce using this model format, to compare with the reutrn value from this UDM function. ![image](https://hackmd.io/_uploads/H1IXC8aSC.png) ![image](https://hackmd.io/_uploads/BygeRU6BA.png) * So I decide to change the format in AuthSubs, then I don't need to do some change if the model is used in the part after. ![image](https://hackmd.io/_uploads/rk4jZParR.png) ::: #### Problem 7 :::danger ![image](https://hackmd.io/_uploads/SJXmMDpHA.png) ::: :::success 1. After the resync part is OK, compiler say that we didnt use the parameters k, op, opc. ![image](https://hackmd.io/_uploads/ry-qmDarC.png) ![image](https://hackmd.io/_uploads/BybsXwTrR.png) ![image](https://hackmd.io/_uploads/rkU2QDaBC.png) * So comment out them at here. ![image](https://hackmd.io/_uploads/r1xcDPaBA.png) V ![image](https://hackmd.io/_uploads/B11oPv6BR.png) * But it will be another problem, because the k declared in if/else will only be seen recognized in if/else. ![image](https://hackmd.io/_uploads/SJS6KvarC.png) ![image](https://hackmd.io/_uploads/rJ9RYPpH0.png) * So we still need to define them at begining, and need to change := to =, then the errHex and errMil need to be defined too. * Like here, after uncomment out the parameters defining and change := to =. ![image](https://hackmd.io/_uploads/r1soqPpHR.png) * Comfirm te return formats of these function. ![image](https://hackmd.io/_uploads/SyyV2P6BA.png) ![image](https://hackmd.io/_uploads/rJ80sPTrC.png) * We can see the err returned by them are **type error**. ![image](https://hackmd.io/_uploads/B1OFhP6BC.png) * So the declaration is like this. ![image](https://hackmd.io/_uploads/Byn7pPprA.png) ![image](https://hackmd.io/_uploads/S1APpvTr0.png) ![image](https://hackmd.io/_uploads/rkQPpwTrA.png) ![image](https://hackmd.io/_uploads/S1Diav6B0.png) ::: * Until here, we finish the successful compiling of func GenerateAuthDataProcedure of UDM, so next is to keep debug in below part(AUSF, AMF). #### Problem 8 :::danger ![image](https://hackmd.io/_uploads/H1qZCwTHC.png) ::: :::success 1. Add variables. ![image](https://hackmd.io/_uploads/HJGISd6SC.png) ![image](https://hackmd.io/_uploads/HJ1wSu6r0.png) 2. ![image](https://hackmd.io/_uploads/rJX9r_TrR.png) V ![image](https://hackmd.io/_uploads/rkzzLd6rA.png) 3. ![image](https://hackmd.io/_uploads/HkiVUuTr0.png) * The same as previous problem. * There are some return inlcuding Detail, some doesnt include, so I print out both cause and detail. ![image](https://hackmd.io/_uploads/Syl1ku_aB0.png) 4. ![image](https://hackmd.io/_uploads/HyUc_d6BA.png) * It assign status code but parameter rep has been commented out. ![image](https://hackmd.io/_uploads/BJUAOuTHR.png) * The rep is declared as **http.Response** ![image](https://hackmd.io/_uploads/HJ5xtdTHA.png) * So I go to see the format of status code in this package(net/http). ![image](https://hackmd.io/_uploads/HkMHquTH0.png) * About the int32 function : [Link](https://hackmd.io/DETj57LjQFimKBIOaD6csQ?view#int32) * Then I want to know the status code value when error happens, so I change the K in webconsole, and add printing lines in original free5gc. ![image](https://hackmd.io/_uploads/SksQpO6HC.png) V ![image](https://hackmd.io/_uploads/r1cEpuaSC.png) ![image](https://hackmd.io/_uploads/HyKSpuTHC.png) * Here you can see the Forbidden status code is 403. ![image](https://hackmd.io/_uploads/HJtfAOpSR.png) * And if you check all error return, you can find that their status are all http.StatusForbidden, so change the parameter to 403(int) directly. * Confirm that the format of problemDetails.Status is int32, so that the value 403 can be assigned directly. ![image](https://hackmd.io/_uploads/H1qeeYprA.png) ![image](https://hackmd.io/_uploads/HyKrlYpB0.png) 5. ![image](https://hackmd.io/_uploads/r1hFxKpB0.png) * In the function definition, the returned variable number need to change. ![image](https://hackmd.io/_uploads/H1-U-FarC.png) V ![image](https://hackmd.io/_uploads/ryW0-t6S0.png) 6. ![image](https://hackmd.io/_uploads/ByzuptpBC.png) ![image](https://hackmd.io/_uploads/SJfFaFaH0.png) * Add variables. ![image](https://hackmd.io/_uploads/BkgRpKprC.png) ![image](https://hackmd.io/_uploads/Byu0atpS0.png) ::: #### Problem 9 :::danger ![image](https://hackmd.io/_uploads/S1VW0Ypr0.png) ::: :::success 1. ![image](https://hackmd.io/_uploads/rkrj4qpSR.png) V ![image](https://hackmd.io/_uploads/rkk5E9TBR.png) 2. ![image](https://hackmd.io/_uploads/B1o0456r0.png) * Because I commented out here before. ![image](https://hackmd.io/_uploads/rJw3rcTHA.png) * But now I think it can be reserved before, because **updateAuthenticationInfo.ServingNetworkName** is received from **func SendUEAuthenticationAuthenticateRequest** and it write the SN name here. ![image](https://hackmd.io/_uploads/rytrIq6HC.png) * Because it has value, I think we can just store it but not do any authorization. * So uncomment out it, and assign it to **responseBody** and **authInfoReq**. ![image](https://hackmd.io/_uploads/rJSeDcTrC.png) 3. ![image](https://hackmd.io/_uploads/BJkn5cpBR.png) * No need to add &. ![image](https://hackmd.io/_uploads/rkxi996SC.png) V ![image](https://hackmd.io/_uploads/BktMi9pSA.png) 4. ![image](https://hackmd.io/_uploads/rJRHicpHA.png) * It is also resulted from the format of err, because of the changing from API to function calling. ![image](https://hackmd.io/_uploads/HJfG2qTBA.png) * Because there is no API passing between **func SendUEAuthenticationAuthenticateRequest** and **func UeAuthPostRequestProcedure**, the received err has already been **&models.ProblemDetails**, we don't need to extract the problem from err, use err directly(err is address so don't add & before it). ![image](https://hackmd.io/_uploads/H1eT69pBR.png) ::: :::danger ![image](https://hackmd.io/_uploads/SyA4P5aBA.png) ::: :::success * Derive Kseaf but not used. ![image](https://hackmd.io/_uploads/HkMPF96S0.png) * I think it will not be used so just comment out this part. ![image](https://hackmd.io/_uploads/B1v85caHA.png) ::: ### Test #### Problem 1 :::danger ![image](https://hackmd.io/_uploads/SJZD9C0BC.png) ::: :::success * The explanation of ChatGPT. ![image](https://hackmd.io/_uploads/HJ4cqCRHR.png) ```go= var client *mongo.Client var err error client, err = mongo.Connect(context.TODO(), options.Client().ApplyURI("mongodb://localhost:27017")) if err != nil { log.Fatal(err) } // 檢查連接 err = client.Ping(context.TODO(), nil) if err != nil { log.Fatal(err) } ``` * It seems that I didn't set a client for MongoDB connection, go to see the line that error tells to me. ![image](https://hackmd.io/_uploads/Bkjt0Jx8C.png) V ![image](https://hackmd.io/_uploads/SJxa0keLC.png) V ![image](https://hackmd.io/_uploads/Sy0e1geUC.png) * As you can see, the client is also created in the same file which is called by UDR function, and in this **func SetMongoDB** it will build the connection with DB. * Terry build the connection by himself, you can see the process -> [Link](https://hackmd.io/AMzUH2F7TzOxIo5o3H3CyA?both#Connection-building) * And then I'm wondering where the original Free5GC do thhis action -> [Link](https://hackmd.io/DETj57LjQFimKBIOaD6csQ?both#MongoDB) * So I copy the connection building process from UDR to AMF in init.go. * The passing parameters in called function can be find in factory. ![image](https://hackmd.io/_uploads/HkwSFWlUR.png) ![image](https://hackmd.io/_uploads/rkGotWe80.png) * And the parameters creating sequence is like below. * ![image](https://hackmd.io/_uploads/BkxcqbeLA.png) V ![image](https://hackmd.io/_uploads/Byww9ZeUR.png) V ![image](https://hackmd.io/_uploads/rkfzc-lIC.png) V ![image](https://hackmd.io/_uploads/SkX0cWxIA.png) V ![image](https://hackmd.io/_uploads/rko1iZxIR.png) V ![image](https://hackmd.io/_uploads/SJNMsbgIC.png) * I don't know how it fill the mongo name and url from config.yaml to here, but it is confirmed that this two parameters are set in yaml file. ![image](https://hackmd.io/_uploads/H1z-3Wl8R.png) ![image](https://hackmd.io/_uploads/r1L3_-lIA.png) * So we can direcly input these value to set the connection. ![image](https://hackmd.io/_uploads/ryDa3Zl8R.png) ![image](https://hackmd.io/_uploads/Hyc5Cbl80.png) ![image](https://hackmd.io/_uploads/SkL0pWg8R.png) ::: #### Problem 2 :::danger ![image](https://hackmd.io/_uploads/r1l9xze80.png) ::: :::success * For logs' sources. ![image](https://hackmd.io/_uploads/SJIaxzgIA.png) ![image](https://hackmd.io/_uploads/rJmkWzgIR.png) * I have comfirmed that the setting in free5gc-ue.yaml and webconsole are no problem. * Then I think maybe the searching keywords have problem, so I printing out supi. ![image](https://hackmd.io/_uploads/BkAMmfeLA.png) ![image](https://hackmd.io/_uploads/BJ8-XGlL0.png) * As you can see, the collname is matched with the display on mongodb-compass, one hyphen(-, or you can say dash) is missing in ueId. ![image](https://hackmd.io/_uploads/SkYdXMgIA.png) * So modify here. ![image](https://hackmd.io/_uploads/BJH4NMl80.png) V ![image](https://hackmd.io/_uploads/B18H4Gx8R.png) ::: #### Problem 3 :::danger ![image](https://hackmd.io/_uploads/rym34MeIC.png) ::: :::success * For logs' sources, it is right after the getDataFromDB, so data is got, but the transfer is not successful. ![image](https://hackmd.io/_uploads/HJAOHGxUR.png) * The explanation from ChatGPT. ![image](https://hackmd.io/_uploads/r1q2dGg8A.png) ![image](https://hackmd.io/_uploads/SJNpdMgLA.png) ![image](https://hackmd.io/_uploads/Bk5COGgIC.png) ![image](https://hackmd.io/_uploads/H1fzYGg80.png) * So I think we can change the format of which will recieve number into float64 directly. ![image](https://hackmd.io/_uploads/S1r9Kfg8R.png) ![image](https://hackmd.io/_uploads/B1Hy9fxU0.png) * And this is also why Terry has some float64 in his structure. ![image](https://hackmd.io/_uploads/B18x9feI0.png) * I also check that these EncryptionAlgorithm and EncryptionKey will not be used in parts after, so this change will not cause error. ::: ### Result #### Result 1 * CN side ![image](https://hackmd.io/_uploads/rJWBeQeIC.png) * It has a successful req. generating, but stucks in handling resp. and then keeps receiving the initial messages from UE. ![image](https://hackmd.io/_uploads/Bkt4MmeIA.png) * gnb side ![image](https://hackmd.io/_uploads/Bk3PxQlIR.png) * UE side ![image](https://hackmd.io/_uploads/BkG5xQg80.png) * The timer will expired when waiting the ACK, after UE receives the req. and send the resp., so UE stucks on here and then keeps retrying registration. ![image](https://hackmd.io/_uploads/HykvW7x8A.png) #### Trace the result 1. ![image](https://hackmd.io/_uploads/rySmsmxLC.png) V ![image](https://hackmd.io/_uploads/HyMUi7l8R.png) V ![image](https://hackmd.io/_uploads/HJ8Kj7lL0.png) V ![image](https://hackmd.io/_uploads/SJDApNZU0.png) ![image](https://hackmd.io/_uploads/rkO6sQe8C.png) ![image](https://hackmd.io/_uploads/SJTCj7g8C.png) V ![image](https://hackmd.io/_uploads/BkFWxNe8A.png) V ![image](https://hackmd.io/_uploads/rkOCyEeU0.png) :::danger #### Problem 1 * Normally, if the modification on auth req. is successful, CN should properly process the rep., and have a successful 5G-AKA, so I go to find the source of the **server no response** error, to see which part cause this. * First I print out the passing variable and received variables, I want to check the content or **resStar** and the **err** which causes the error report. ![image](https://hackmd.io/_uploads/Hy48pN-U0.png) * The result. ![image](https://hackmd.io/_uploads/r1fOTNWLR.png) * Then keep tracing where is the final stop point, so I go into **func HandleAuth5gAkaComfirmRequest**, which is call by **client.DefaultApi.UeAuthenticationsAuthCtxId5gAkaConfirmationPut**. * After the API routing and the function of comparing res* and xres*, print out something to check whether the received values from the called **func Auth5gAkaComfirmRequestProcedure** are matched with previous part. ![image](https://hackmd.io/_uploads/B1Vz1BZLR.png) * The strange thing is that it didnt print out anything, still the same after compiling. * So I go back to the API routing place who forward the message to **func HandleAuth5gAkaComfirmRequest**. * Print out some text before and after forwarding, to see where is the stop point. ![image](https://hackmd.io/_uploads/SkeKkgrb8C.png) * The result is still the same, nothing printed out, which means the error happens before the message reaching the **router.go & api_defaut.go** of AUSF. * I go back to see the printed **err**, it says **missing protocol scheme**, and no return & http response. ![image](https://hackmd.io/_uploads/SJvlQHbUR.png) * I go to see the format **confirmData** is declared. ![image](https://hackmd.io/_uploads/SJ2QNSWUR.png) V ![image](https://hackmd.io/_uploads/rJiEVH-UA.png) V ![image](https://hackmd.io/_uploads/HJs8NBbUR.png) V but I can only find the function about **configuration**. ![image](https://hackmd.io/_uploads/B1vtNrW8A.png) * Then I notice that the scheme is used in here, and **confirmUri** is declared from parsing **ue.AuthenticationCtx.Links["5g-aka"].Href**, which is matched with the printed **err**. ![image](https://hackmd.io/_uploads/Skq9SS-UA.png) * So I go to see the content of **ue**. ![image](https://hackmd.io/_uploads/SkUB8rZIC.png) V ![image](https://hackmd.io/_uploads/Hyr88r-LR.png) V ![image](https://hackmd.io/_uploads/BJUKUB-LA.png) V then find that the format of **ue.AuthenticationCtx** is imported here. ![image](https://hackmd.io/_uploads/BJN58rW8A.png) * Find on github. ![image](https://hackmd.io/_uploads/HkggGvHbU0.png) V we can see the **Links** definition ![image](https://hackmd.io/_uploads/HJRVvrZLC.png) V see back to code, you can see it use **Links.Herf** ![image](https://hackmd.io/_uploads/SySqPr-UC.png) V if you check here, you can see the source of **Herf** ![image](https://hackmd.io/_uploads/BkfRvSb8C.png) ![image](https://hackmd.io/_uploads/ByyzurWL0.png) * Finally, if you search **Links or Herf** in the file, you can confirm that real reason is that I modify the **putLink** generating process, so there are some missed item. ![image](https://hackmd.io/_uploads/Hk-FnHb8A.png) ![image](https://hackmd.io/_uploads/Bym0nSWL0.png) * Then it is wrapped in **responseBody**, returned to **handler.go** as **ueAuthenticationCtx**, and wrapped into **ue**, so that is why there is an error when parsing **ue.AuthenticationCtx**, causing that **ausfUri** is not complete. ![image](https://hackmd.io/_uploads/HylxyL-8C.png) V ![image](https://hackmd.io/_uploads/S1rrkUZ8A.png) * You can also confirm by see that the first %s doesnt print out. ![image](https://hackmd.io/_uploads/r10paB-LR.png) ![image](https://hackmd.io/_uploads/BkjJCHZLC.png) ::: :::success * I need to reconstruct the URI if I want to have a successful call to AUSF, but it is useless for the 2nd modification, because the client including ausfUri will be commented out after changing to function calling. * But I want to test whether my change on 1st is OK for UE access, so I will just **assign the locationURI manually** even if it will be commented out. ![image](https://hackmd.io/_uploads/rJxjfIbU0.png) * **self** is declared here. ![image](https://hackmd.io/_uploads/ByxAzLW80.png) V find in original ausf file ![image](https://hackmd.io/_uploads/BJg4mUbI0.png) V ![image](https://hackmd.io/_uploads/r1Br7IZLC.png) V ![image](https://hackmd.io/_uploads/rk1wQLWUR.png) V ![image](https://hackmd.io/_uploads/HyK5QUbU0.png) * And **factory.AusfAuthResUriPrefix** is here. ![image](https://hackmd.io/_uploads/HJfkII-8R.png) * It seems that printing out them in original free5gc is faster * ![image](https://hackmd.io/_uploads/rkMoN8ZLA.png) ![image](https://hackmd.io/_uploads/SJGbHUZIR.png) * ![image](https://hackmd.io/_uploads/rJj4SUZIC.png) ![image](https://hackmd.io/_uploads/S1-PrUb8A.png) * So they are all string format, can direcly add them together. ![image](https://hackmd.io/_uploads/SJRgPIZLA.png) ::: #### Result 2 * CN side ![image](https://hackmd.io/_uploads/H1VMTI-LR.png) * gnb side & UE side * The same. :::danger #### Problem 2 * I comment out here and assign the value manually. ![image](https://hackmd.io/_uploads/Hy9Ca8-L0.png) ![image](https://hackmd.io/_uploads/BJgGR8WIC.png) * It will turn out these error in process. ![image](https://hackmd.io/_uploads/r1Y4CUbLR.png) ![image](https://hackmd.io/_uploads/SJKIAUbIR.png) ::: :::success * After compiling OK, it turns out other errors related to AUSF context. ![image](https://hackmd.io/_uploads/rJth0LZUC.png) ![image](https://hackmd.io/_uploads/HkUgkw-LC.png) * It will be too much if I keep modify the AUSF context, so I decide to do 2nd modification directly, and ignore AUSF related part. ::: #### Github upload version before problem 1 ![image](https://hackmd.io/_uploads/SkG5I7lL0.png) #### Github upload version after problem 2 ![image](https://hackmd.io/_uploads/SkhLlPbUC.png) ## 2nd req & resp ### Method * Same as 1st, use the function call in AMF. ![image](https://hackmd.io/_uploads/BkK3KXe8R.png) * In **ue_authentication.go**(AMF) * Call by **func SendAuth5gAkaConfirmRequest** :::warning * Reserve parts : * RES* & XRES* comparison in AUSF * In ue_authentication.go * **func HandleAuth5gAkaComfirmRequestProcedure** * In **function.go** * **func logConfirmFailureAndInformUDM** * **func sendAuthResultToUDM** * Change format and call UDR in UDM * In generate_auth_data.go * **func ConfirmAuthDataProcedure** * In converter.go * **func ToBsonM** * MongoDB API in UDR * In data_repository.go * **func CreateAuthenticationStatusProcedure** * Reduction * API -> function calling (Some functions, URI setting, parameters passing, http interaction) * Get data from AUSF context. * EAP-AKA' * Simplfy SUCI checking ::: ### Modification #### Prerequisite * Move the **reserved parts** to AMF, and put them **above func SendAuth5gAkaConfirmRequest**. #### Implementation :::warning **The parts need to check after modification :** (They are in the folded area below, here just for **final confirmation** and not for check list) - [ ] func SendAuth5gAkaConfirmRequest - [ ] func HandleAuth5gAkaComfirmRequestProcedure - [ ] func logConfirmFailureAndInformUDM - [ ] func sendAuthResultToUDM - [ ] func ConfirmAuthDataProcedure - [ ] func CreateAuthenticationStatusProcedure ::: :::spoiler **func SendAuth5gAkaConfirmRequest** ![image](https://hackmd.io/_uploads/B1JNN_bLA.png) 1. Comment out the ausf part. ![image](https://hackmd.io/_uploads/Hkx9BuZUR.png) * I dont know whether it is necessory to use comfirmData's **optional.Interface** format or I can pass resStar directly. * But it seems like an API working on Nausf, so I think I can ignore it by just pass resStar **string** to function. ![image](https://hackmd.io/_uploads/HyWFdObI0.png) 2. I want to know the received value in the called function **func HandleAuth5gAkaComfirmRequest**, so I print out these variables. ![image](https://hackmd.io/_uploads/ryKALdWUC.png) * The result is restar and suci. ![image](https://hackmd.io/_uploads/BkVMwObIA.png) * So that I know I can modify like this. ![image](https://hackmd.io/_uploads/rkbVqdWIA.png) * Also change the name of called function. ![image](https://hackmd.io/_uploads/HJcLc_bUA.png) ::: :::spoiler **func HandleAuth5gAkaComfirmRequestProcedure** ![image](https://hackmd.io/_uploads/ByeqqdW8C.png) 1. About the API function between this and previous function, I just move the logger and comment out it. ![image](https://hackmd.io/_uploads/B10T9dW8R.png) ![image](https://hackmd.io/_uploads/HJSkjubLA.png) 2. Format * This variable will receive resStar, so change format to string. ![image](https://hackmd.io/_uploads/ryLhjdbLC.png) * This format is from model, and includes supi and Kseaf ![image](https://hackmd.io/_uploads/S13InO-UA.png) ![image](https://hackmd.io/_uploads/ByFa2dZ8A.png) * supi will be return back to handler.go and save to **ue**, so we can reserve this format. ![image](https://hackmd.io/_uploads/rkEz6OWU0.png) * There is another format in model for resStar, but here I just pass resStar directly. ![image](https://hackmd.io/_uploads/Skly8p_-LR.png) * Delete this redudent parameter, because I passed resStar to here directly. ![image](https://hackmd.io/_uploads/B1AbR_Z80.png) * I find that handler encode resStar before passing it, so I print out some value in original free5gc to confirm if I need to decode it. ![image](https://hackmd.io/_uploads/B1PdCFzUR.png) * In handler, **resStar, resStar[:]** are the same, so the point is tha value after encoding. ![image](https://hackmd.io/_uploads/BytcCtGUC.png) Use text book for conveniently wathing. ![image](https://hackmd.io/_uploads/SyZxy9MU0.png) * In AMF, the value stay same after the wrap of confirmData. ![image](https://hackmd.io/_uploads/SkiSy5zI0.png) ![image](https://hackmd.io/_uploads/S1b2yczLR.png) * In AUSF, there has already a printing function existedd to compare the res* and xres*, but the printing format is Hexadecimal(%x), so I just print out the %+v format to ensure that they are compared in encoded status. ![image](https://hackmd.io/_uploads/BJ9-x5zU0.png) ![image](https://hackmd.io/_uploads/SyBqlczL0.png) * About the explanation of %x -> [Link](https://hackmd.io/DETj57LjQFimKBIOaD6csQ?view#x) * So if two sides are all encoded and then compared, I dont need to do decoding. 3. ausf context * Comment out the process of checking SUCI and get the SUPI from ausf context, because all ausf context related parts are commented out, and we need to get the SUPI from **ConfirmationDataResponseID**(SUCI). ![image](https://hackmd.io/_uploads/SJs-PcMLR.png) * Use this transfer again, and change variable name. ![image](https://hackmd.io/_uploads/SJ8bsjMIR.png) ![image](https://hackmd.io/_uploads/SJIOf3zIR.png) * Then manually set the SNname by print out the string in original free5gc ![image](https://hackmd.io/_uploads/SJsu3cMI0.png) ![image](https://hackmd.io/_uploads/ryc83cGLA.png) ![image](https://hackmd.io/_uploads/BJ3fiiMUC.png) * Because Xres* store in AUSF context originally, and previous modification comments out it and didnt store it in other parameter, so we need to add one to store Xres*. ![image](https://hackmd.io/_uploads/H1dC35z8C.png) ![image](https://hackmd.io/_uploads/r15cXAGIR.png) ![image](https://hackmd.io/_uploads/SkgaXRMI0.png) * Xres* is encoded in **func GenerateAuthDataProcedure**. ![image](https://hackmd.io/_uploads/BkBCSsM80.png) * And is stored in ausf context in **func UeAuthPostRequestProcedure**. ![image](https://hackmd.io/_uploads/SJw_Lsf80.png) ![image](https://hackmd.io/_uploads/SJtr8jGLR.png) * Add a global variable to store it. ![image](https://hackmd.io/_uploads/S1IiOoMLR.png) ![image](https://hackmd.io/_uploads/SJCquoGU0.png) * Change the variable. ![image](https://hackmd.io/_uploads/B1BetoG80.png) * HRES* & HXRES* comparison is here, above the calling of **func SendAuth5gAkaConfirmRequest**. ![image](https://hackmd.io/_uploads/S11hQiGIC.png) ![image](https://hackmd.io/_uploads/B1p_VsGIC.png) * And **HxresStar** is got from ue.AuthenticationCtx.Var5gAuthData, which receives the hxres* from AUSF function direcly. ![image](https://hackmd.io/_uploads/H1omBiGLA.png) ![image](https://hackmd.io/_uploads/BkfZBoGLA.png) * So it will not be affected by ausf context. * Kseaf process is commented out before, so here just give it zero string for storing in ue context. ![image](https://hackmd.io/_uploads/HJrK2sM8R.png) * Comment out these two. ![image](https://hackmd.io/_uploads/BkU6njMUR.png) * UdmUeauUrl doesnt exist without ausf context, so comment them out too. ![image](https://hackmd.io/_uploads/B139Tsz8R.png) ![image](https://hackmd.io/_uploads/H13JVaMUC.png) :::warning * **logger function** * ![image](https://hackmd.io/_uploads/r1tU9jMIA.png) * ![image](https://hackmd.io/_uploads/ryRO5sz8A.png) * ![image](https://hackmd.io/_uploads/H1x99jMIC.png) * ![image](https://hackmd.io/_uploads/BJb1pozLC.png) ::: :::spoiler **func logConfirmFailureAndInformUDM** * Before ![image](https://hackmd.io/_uploads/Byx0aiML0.png) * After ![image](https://hackmd.io/_uploads/B1WMy3G8R.png) :::warning * **logger function** * ![image](https://hackmd.io/_uploads/BJolAoGIC.png) * ![image](https://hackmd.io/_uploads/S1Ur0oGIC.png) * ![image](https://hackmd.io/_uploads/SkFiCjfIR.png) ::: :::spoiler **func sendAuthResultToUDM** * Before ![image](https://hackmd.io/_uploads/H18N13fLA.png) * After ![image](https://hackmd.io/_uploads/rJAof2fUA.png) * self.GetSelfID() get the Nfid which is string. ![image](https://hackmd.io/_uploads/rkxegnz8C.png) * Here change to get the AMF Nfid, but AMF doesnt have **func GetSelfID()**, so directly retrieve it, I dont know it is right or not using pointer to do it. ![image](https://hackmd.io/_uploads/S1g2bhG8A.png) ::: :::spoiler **func ConfirmAuthDataProcedure** * Move the logger and comment out UDM API process. ![image](https://hackmd.io/_uploads/rkqCQhz8R.png) * Before ![image](https://hackmd.io/_uploads/B1blN3fUC.png) * After * Move the DB parameters setting and function calling and then comment out the UDR API process ![image](https://hackmd.io/_uploads/S1QtVhz8R.png) * The original authEvent wrapping uses **optional.Interface** format , which I think is for API process, so I comment out them, and to see how to pass authEvent to DB. ![image](https://hackmd.io/_uploads/H10cjhzU0.png) ![image](https://hackmd.io/_uploads/Byx5Td2M8C.png) * Here is the modification of moved parameters setting and function calling in UDR API process. ![image](https://hackmd.io/_uploads/rJY4yazIA.png) * The function changing the **authEvent** to Bson is from UDR, so we need to move it to here, make sure if there is any new import mod or not. ![image](https://hackmd.io/_uploads/r1v3JTMLA.png) V ![image](https://hackmd.io/_uploads/B1g8xazLA.png) * Delete the util. ![image](https://hackmd.io/_uploads/H17YgazI0.png) -> ![image](https://hackmd.io/_uploads/SJb5gpzL0.png) * Because **func CreateAuthenticationStatusProcedure** doesnt have return, so we can comment the http API error report, and also API calling. ![image](https://hackmd.io/_uploads/rJxGf6MI0.png) * But this function need to return one err, so just keep it nil. :::warning * **logger function** * ![image](https://hackmd.io/_uploads/HJIwu3GIR.png) ::: :::spoiler **func CreateAuthenticationStatusProcedure** * No need to change. ![image](https://hackmd.io/_uploads/H1P_GTMLR.png) * About the ueId adding, because originally authEvent doesnt have this item, and the chatGPT explanation. ![image](https://hackmd.io/_uploads/ByvXmAf8R.png) ![image](https://hackmd.io/_uploads/HkM47AM80.png) ::: ### Comilation #### Problem 1 :::danger ![image](https://hackmd.io/_uploads/Syx5G0G8C.png) ::: :::success * ![image](https://hackmd.io/_uploads/SkLFMCz80.png) ![image](https://hackmd.io/_uploads/Hk0iM0M80.png) * This problem is that originally the variables in string format are declared together, about the explanation -> [Link](https://hackmd.io/DETj57LjQFimKBIOaD6csQ?both#Function-declaration). ![image](https://hackmd.io/_uploads/Bks4I0fUA.png) ![image](https://hackmd.io/_uploads/B1mH8Rz8A.png) * So just give them the format. ![image](https://hackmd.io/_uploads/SkehuIAzUC.png) ![image](https://hackmd.io/_uploads/rkyOU0z8C.png) ::: #### Problem 2 :::danger ![image](https://hackmd.io/_uploads/H1dCFAMLR.png) ::: :::success 1. I think that is becaues **logger.DataRepoLog.Errorf** needs string to print, but the format of err is error, original print function use **logger.DataRepoLog.Error**. ![image](https://hackmd.io/_uploads/HkG0PkQLR.png) V ![image](https://hackmd.io/_uploads/HJfgOJQUA.png) 2. ![image](https://hackmd.io/_uploads/Bk_5uJXLR.png) ![image](https://hackmd.io/_uploads/rygj_ymUC.png) ![image](https://hackmd.io/_uploads/r1zIuy78R.png) * Change the return format declaration. ![image](https://hackmd.io/_uploads/BJuud17L0.png) V ![image](https://hackmd.io/_uploads/Hyn-KkX8A.png) * It causes other problem. ![image](https://hackmd.io/_uploads/rJHst1QLC.png) * Just print problemDetails itself. ![image](https://hackmd.io/_uploads/ryveq17LC.png) ![image](https://hackmd.io/_uploads/HJFG9J78R.png) V ![image](https://hackmd.io/_uploads/Sk_-ckQIC.png) ![image](https://hackmd.io/_uploads/Syy49k7UC.png) 3. ![image](https://hackmd.io/_uploads/Hyl3vqk7IC.png) ![image](https://hackmd.io/_uploads/BkG_qk7UC.png) * Remove the redudent &. ![image](https://hackmd.io/_uploads/BJzh51XL0.png) V ![image](https://hackmd.io/_uploads/r1Jaq1XUA.png) ::: ### Test #### No problem ### Result * CN side ![image](https://hackmd.io/_uploads/BJMZAkQIR.png) ![image](https://hackmd.io/_uploads/B1tGAJQU0.png) * 5G-AKA is successful but security mode has some problem. * gnb side ![image](https://hackmd.io/_uploads/rkr1yx78A.png) * UE side ![image](https://hackmd.io/_uploads/BJF30JX8R.png) :::danger * The original log is like this. ![image](https://hackmd.io/_uploads/HJI6AFLU0.png) * The SMC explanation -> [Link](https://hackmd.io/DETj57LjQFimKBIOaD6csQ?both#Security-mode) * Wireshark (Test with UERANSIM in other VM) * From UE's reject message, it has a cause. ![image](https://hackmd.io/_uploads/rJId-JuUR.png) * And **security mode rejected, unspecified (24)** is a keyword to search. * It is a LTE note about SMC in [here](https://www.sharetechnote.com/html/Handbook_LTE_NasSecurityModeControlProcedure.html) * From 5GC's DownlinkNAS SMC, we can see the contens of the packet is the same as normal 5GC (Except for message authentication code). * Modified. ![image](https://hackmd.io/_uploads/ByjCQ1uIR.png) * Normal. ![image](https://hackmd.io/_uploads/SyXeVJ_8A.png) * In logs. * It is hard to find where is the problem source by tracing the 5GC error message (**wrong security header type : 0x0, message type 95**) in code or googleing the UE error message (**Rejecting Security Mode Command with cause [SEC_MODE_REJECTED_UNSPECIFIED]**). * Will only find the header of UE's uplinkNAS is wrong, and print the error by call the printing function, and the parameters is from free5gc/nas. ![image](https://hackmd.io/_uploads/HJTBL1uIC.png) ![image](https://hackmd.io/_uploads/BkhEHJu8C.png) ![image](https://hackmd.io/_uploads/r1LDHJdLC.png) * Or find some [problem discussion](![image](https://hackmd.io/_uploads/S1ztryuLC.png)). ::: :::success * In the process above, I was doubting that maybe the cause is from the modification in ue_authentication.go, the missing in some parameter resulit in the rejection of UE. * And I ask Terry that whether the commenting out of **Kseaf generating** affects it or not, the answar is YES. * But I didnt know which part in security mode will use Kseaf, because I need to know where to put Kseaf value instead of AUSF context if I recover the generating process. * And Terry say that I can put into **AMF context**, becausee the security mode is working in AMF, and will access the parameter in AMF context. ::: #### Github upload version ![image](https://hackmd.io/_uploads/r19mll7IA.png) ## Security mode ### Method :::warning * Uncomment out the **Derive Kseaf from Kausf** in AUSF function (**func UeAuthPostRequestProcedure**) and try to put the value in UE context of AMF : **type AmfUe struct**. ![image](https://hackmd.io/_uploads/Skfy1VuL0.png) * ![image](https://hackmd.io/_uploads/BkYzQ4uUR.png) ::: ### Modification & Compilation & Test #### Problem 1 (Preparation) * The point is that the mutual context of UE is passing in handler.go and **func SendUEAuthenticationAuthenticateRequest** in ue_authentication.go, so we can not direcly put the value in **func UeAuthPostRequestProcedure** because ue.context is not passed to this function (Or we add a new variable, but we need to modify more place). 1. Like this error is that I want to call AmfUe in context folder. ![image](https://hackmd.io/_uploads/BJN-gV_80.png) 2. Even I change to the right name of import, and compile successfully, the test has error. ![image](https://hackmd.io/_uploads/H1q6lNOLC.png) ![image](https://hackmd.io/_uploads/BkTJZ4dIR.png) 3. Or I want to use **GetSelf** in context, but it is wrong, Kseaf is in context for UE, not in the AMFcontext ![image](https://hackmd.io/_uploads/S1vDWNOLR.png) ![image](https://hackmd.io/_uploads/SJs9b4uIR.png) * The error for this ![image](https://hackmd.io/_uploads/H1Tib4uIA.png) #### Problem 2 (Preparation) :::danger ![image](https://hackmd.io/_uploads/BJKVgVd8C.png) ::: :::success * We need to use **hex.EncodeToString()**. ::: #### Problem 3 (1st req & resp : func UeAuthPostRequestProcedure) :::danger ![image](https://hackmd.io/_uploads/S145zNd8C.png) * Because this function doesnt have the ue context variable, so I decide to put Kseaf into return variable. ![image](https://hackmd.io/_uploads/SJkgNNOL0.png) * Then receive and put Kseaf into ue context in this function. ![image](https://hackmd.io/_uploads/Ska4EVuIR.png) * In **handler.go**, it will receive **ue** and the ue variable is the same one (**amfUe**) passed from **func Authentication in sm.go**. ![image](https://hackmd.io/_uploads/HJ5yUEdL0.png) V ![image](https://hackmd.io/_uploads/S1Ix84_80.png) V ![image](https://hackmd.io/_uploads/rJwf8E_IA.png) * In **func Authentication**, it uses the same variable **amfUe** to call this function. ![image](https://hackmd.io/_uploads/rya_INOLA.png) * So if I load Kseaf into **ue**, it will be saved into **amfUe** by pointer passing. ::: :::success * My method is put Kseaf into **responseBody**, so we need to change its format. * Check the format on model repo. ![image](https://hackmd.io/_uploads/rJjOD7tUA.png) ![image](https://hackmd.io/_uploads/ryVwvQF8A.png) * Then put it above this function, change the **responseBody** declaration, and add Kseaf declaration in structure. ![image](https://hackmd.io/_uploads/S1zbdXY8C.png) * And assign Kseaf to it after generating. ![image](https://hackmd.io/_uploads/SkILu7KIC.png) * And the error in above screenshot is about the format of variables in structure. * For first one you can find the difined source on repo ![image](https://hackmd.io/_uploads/H1e-9XKLA.png) V ![image](https://hackmd.io/_uploads/ryKD9mtIC.png) V ![image](https://hackmd.io/_uploads/rJ_j5QKUR.png) V ![image](https://hackmd.io/_uploads/HklCqmK8R.png) * For second one. ![image](https://hackmd.io/_uploads/BJWejmFIA.png) V ![image](https://hackmd.io/_uploads/SJtcsQF8R.png) V ![image](https://hackmd.io/_uploads/B10so7YIR.png) V ![image](https://hackmd.io/_uploads/Skgk3mYUC.png) ::: #### Problem 3-1 :::danger * ![image](https://hackmd.io/_uploads/rJYvhXKUR.png) V ![image](https://hackmd.io/_uploads/HkOY2QYI0.png) * ![image](https://hackmd.io/_uploads/rkv5n7YUC.png) V ![image](https://hackmd.io/_uploads/BkDnn7YIA.png) ::: :::success * The problem is caused by the format in structure, which is not matched with the use below. * Here I can change two places, in struc or in the use below, I choose to modify in struc directly, it is successful so I didnt try to change the second place. * ![image](https://hackmd.io/_uploads/H1CwyEKLA.png) * The original variables are set as remarks commented out behind the sentence. ::: #### Problem 3-2 :::danger 1. ![image](https://hackmd.io/_uploads/S1QypXt8A.png) 2. ![image](https://hackmd.io/_uploads/B19f67FIA.png) ::: :::success * This form is correct one. ![image](https://hackmd.io/_uploads/BypZeVF80.png) ::: #### Problem 4 (Functions calling & func SendUEAuthenticationAuthenticateRequest) :::danger ![image](https://hackmd.io/_uploads/BkxHa7tI0.png) ::: :::success 1. ![image](https://hackmd.io/_uploads/By5KeNKUA.png) * It is caused by the return variable declaration. ![image](https://hackmd.io/_uploads/HJzXb4YIR.png) 2. ![image](https://hackmd.io/_uploads/rymE2NKIC.png) * It is in **func SendUEAuthenticationAuthenticateRequest**, to put the received Kseaf into ue context which is passed from **func AuthenticaionProcedure** to here. * Dont need to add models. ![image](https://hackmd.io/_uploads/HymPbNtU0.png) * After Kseaf is assigned, we need to put the other value into the original passing format, so declar a new variable using model's format and assign the value one by one. 3. ![image](https://hackmd.io/_uploads/SkZeG4tIR.png) ::: #### Problem 5 (2nd req & resp : func HandleAuthenticationResponse & func SendAuth5gAkaConfirmRequest & func HandleAuth5gAkaComfirmRequestProcedure) :::danger * The compilation is successful but the test is still tha same problem. ![image](https://hackmd.io/_uploads/SyS3MEFL0.png) ::: :::success * So I find another place where call Kseaf in UE context for using, and add logger in three places to see whether the Kseaf exists or not. * In func SendUEAuthenticationAuthenticateRequest. ![image](https://hackmd.io/_uploads/ryUg4NtI0.png) * In func AuthenticationProcedure ![image](https://hackmd.io/_uploads/B1nGEEFLC.png) * The results of these two all have the value of Kseaf. * ![image](https://hackmd.io/_uploads/HkaMHVtIA.png) * ![image](https://hackmd.io/_uploads/S17IBVtUC.png) * In func HandleAuthenticationResponse ![image](https://hackmd.io/_uploads/H1lQZKNKUA.png) * But the third place doesnt have. * ![image](https://hackmd.io/_uploads/Bk5JLEt8R.png) * Then when you go to : ![image](https://hackmd.io/_uploads/H123FVYLA.png) V **func SendAuth5gAkaConfirmRequest** ![image](https://hackmd.io/_uploads/B1XAYEYUA.png) V **func HandleAuth5gAkaComfirmRequestProcedure** ![image](https://hackmd.io/_uploads/rkBQ9EtUC.png) * You can see if the authentication confirm is successful, it will get Kseaf from susf context, but I have commented out it and give it null value, because I thought Kseaf would not ne used. * So I comment out here to prevent the null value cover the original value. ![image](https://hackmd.io/_uploads/HJOCsNYUR.png) ::: ### Result * CN side ![image](https://hackmd.io/_uploads/HkNUWrF8R.png) * The SMC is successful, and UE get the IP ![image](https://hackmd.io/_uploads/ryNcWHFUC.png) * PFCP is also builded. ![image](https://hackmd.io/_uploads/SJrn-HK8R.png) * gnb side ![image](https://hackmd.io/_uploads/SymAZrYLR.png) * UE side ![image](https://hackmd.io/_uploads/SyJkfBYLR.png) :::warning * Remember to comment out the logger which is used for test. ::: #### Github upload version ![image](https://hackmd.io/_uploads/BkRSrBYUC.png) ## Removal process ### Prerequisite * Because the result is successful, meaning that we don't need AUSF for 5G-AKA, now we can remove it to test again. * In Makefile ![image](https://hackmd.io/_uploads/BJxpBHYL0.png) * In run.sh ![image](https://hackmd.io/_uploads/SyUfUrKLC.png) * After that, you can see there is no AUSF initialization when running. ![image](https://hackmd.io/_uploads/S1S-DSYLC.png) ![image](https://hackmd.io/_uploads/HJpMPHFI0.png) ![image](https://hackmd.io/_uploads/r1NEDHYUR.png) ![image](https://hackmd.io/_uploads/HJwLwrYIC.png) ### Modification & Compilation & Test #### Problem 1 :::danger ![image](https://hackmd.io/_uploads/Hyk2wrKUR.png) ![image](https://hackmd.io/_uploads/S1SZpUY8A.png) ![image](https://hackmd.io/_uploads/HksG68KUA.png) ::: :::success * Comment out AUSF selecting part. ![image](https://hackmd.io/_uploads/H1HopIK80.png) ::: ### Result * After the error is solved, it is successful, then it is the same as above. #### Github upload version ![image](https://hackmd.io/_uploads/SkvybPYUA.png) ## Test with muiltiple UE ### Method :::warning * Use the commands on the wiki of UERANSIM github -> [Link](https://github.com/aligungr/UERANSIM/wiki/Usage) * Pre-register the UE in webconsole. ![image](https://hackmd.io/_uploads/SyOHv2c80.png) ::: ### Problems encountered * Use 5 UEs to test. #### Problem 1 :::danger * CN side ![image](https://hackmd.io/_uploads/ryt-d35LA.png) * gnb side ![image](https://hackmd.io/_uploads/BkVlOnqUC.png) * UE side ![image](https://hackmd.io/_uploads/rk37On58C.png) ::: :::success * There is no UE data in 5GC, so add them on webconsole, the SUCI will be from imsi-...3~7. ::: #### Problem 2 :::danger ![image](https://hackmd.io/_uploads/SJtnK2cL0.png) ![image](https://hackmd.io/_uploads/rkZ7Fhc8A.png) ::: :::success * Only one UE will successfully build the PDU session. * And you can see some Synch failure for 4 UEs ![image](https://hackmd.io/_uploads/HksqdR9IA.png) ![image](https://hackmd.io/_uploads/ryS_d0q8R.png) ![image](https://hackmd.io/_uploads/ByIw_R98C.png) ![image](https://hackmd.io/_uploads/SyKG_A9IA.png) * Other four will have a confirmation failed ![image](https://hackmd.io/_uploads/HkACvCqIC.png) ![image](https://hackmd.io/_uploads/HkfYwAc8R.png) * Find that the **XresStar comparison is not successful**, not the same with res*. ::: * But if I use original free5gc, it will be successful for muiltiple UE. * CN side ![image](https://hackmd.io/_uploads/SyqUt05IA.png) ![image](https://hackmd.io/_uploads/HJm_FR5LC.png) ![image](https://hackmd.io/_uploads/H1Z5YA980.png) ![image](https://hackmd.io/_uploads/SJz3tA9UR.png) * gnb side ![image](https://hackmd.io/_uploads/rySX9C9UC.png) * UE side ![image](https://hackmd.io/_uploads/BJTP5R98C.png) ![image](https://hackmd.io/_uploads/S1adc05IC.png) ![image](https://hackmd.io/_uploads/HJxsK5RqIA.png) ![image](https://hackmd.io/_uploads/ryv95AqL0.png) :::success * So I think the problem is that I use global variable for setting Xres*, then every UE's Xres* will be the same. * Here you can check the result that tests with 2 UEs. ![image](https://hackmd.io/_uploads/r1z9RAqLC.png) * And if you scroll up, you can see the final XresStar stored in the global variable is from imsi-...0003, so the imsi-...0004 will not pass the 5G-AKA confirmation. ![image](https://hackmd.io/_uploads/H1gk8kjL0.png) ::: ### Modification & Compilation #### Pre * Some differences between the original storing method and global method. ![image](https://hackmd.io/_uploads/SyliDkjL0.png) ![image](https://hackmd.io/_uploads/rk3iP1o80.png) * eed to ensure Xres* is stored independently for each UE. Using global variables in a concurrent environment can lead to race conditions and data corruption.So I need to use **context or mapping** to process it. * First import "sync", and change the delclaration. ![image](https://hackmd.io/_uploads/B1cd6kiUR.png) ![image](https://hackmd.io/_uploads/BJ165kiUA.png) * Then before comparison, get the value using supi from map, and do the error report. ![image](https://hackmd.io/_uploads/HJwGaysLR.png) #### Problem 1 :::danger ![image](https://hackmd.io/_uploads/Bkz14eiL0.png) ::: :::success * hex.DecodeString() has two return, but encode only one, so dont mess up them. ::: #### Problem 2 :::danger ![image](https://hackmd.io/_uploads/ByRrXljIC.png) ::: :::success ![image](https://hackmd.io/_uploads/SJ15mxsIA.png) V ![image](https://hackmd.io/_uploads/rJXKQlsI0.png) ::: #### Problem 3 :::danger ![image](https://hackmd.io/_uploads/HkLeMlsLA.png) ::: :::success ![image](https://hackmd.io/_uploads/HyU2NloLC.png) * Instead of hex.encodestring() ![image](https://hackmd.io/_uploads/B1BANgiLR.png) ::: #### Problem 4 :::danger ![image](https://hackmd.io/_uploads/ByVUMxjIC.png) * The Xres* is in if/else, so outside there can not be used. ::: :::success * Put the if/else of map in the most ouside place. ![image](https://hackmd.io/_uploads/Hyk-7ei8C.png) ::: ### Test #### Problem 1 :::danger ![image](https://hackmd.io/_uploads/HySHSgjLA.png) ::: :::success * Because there is no supi transformation in **func UeAuthPostRequestProcedure** ![image](https://hackmd.io/_uploads/r1qsrlsL0.png) * So here change supi to ConfirmationDataResponseID which is suci, use supci to find in map. ![image](https://hackmd.io/_uploads/HkOxIloLR.png) V ![image](https://hackmd.io/_uploads/Bycz8esL0.png) ::: ### Result #### 2 UEs * CN side (Can accept 2 UEs.) ![image](https://hackmd.io/_uploads/By9cUesUA.png) * gnb side ![image](https://hackmd.io/_uploads/BJgaIgiU0.png) * UE side ![image](https://hackmd.io/_uploads/BJmJvgjU0.png) ![image](https://hackmd.io/_uploads/HyWRIeiUC.png) #### 5 UEs * UE side ![image](https://hackmd.io/_uploads/r1DLPxoU0.png) * Ping internet test * You can see there are 5 tunnels builded in UE's VM. ![image](https://hackmd.io/_uploads/B1w9WJ3IC.png) ![image](https://hackmd.io/_uploads/Symhbk2L0.png) * Ping from these tunnels. ![image](https://hackmd.io/_uploads/SkAh71hLR.png) ![image](https://hackmd.io/_uploads/B1qy4k2LA.png) :::danger * Ping from uesimtun0 not successful but ping directly successful. ![image](https://hackmd.io/_uploads/rkDJ7k2LA.png) ::: :::success * In the VM of free5gc, need to set these network rules. ```shell= sudo sysctl -w net.ipv4.ip_forward=1 sudo iptables -t nat -A POSTROUTING -o ens18 -j MASQUERADE sudo iptables -A FORWARD -p tcp -m tcp --tcp-flags SYN,RST SYN -j TCPMSS --set-mss 1400 sudo systemctl stop ufw sudo iptables -I FORWARD 1 -j ACCEPT ``` ::: #### Github upload version ![image](https://hackmd.io/_uploads/B16xtRs8R.png)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully