Skip to content
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

Aether Scaling #124

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions context/ausf_context_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func InitAusfContext(context *AUSFContext) {
if os.Getenv("MANAGED_BY_CONFIG_POD") != "true" {
context.PlmnList = append(context.PlmnList, configuration.PlmnSupportList...)
}
context.EnableScaling = configuration.EnableScaling
context.EnableNrfCaching = configuration.EnableNrfCaching
if configuration.EnableNrfCaching {
if configuration.NrfCacheEvictionInterval == 0 {
Expand Down
2 changes: 2 additions & 0 deletions context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ type AUSFContext struct {
SBIPort int
EnableNrfCaching bool
NrfCacheEvictionInterval time.Duration
EnableScaling bool
UeNfProfile sync.Map // map[Supi]models.UeNfProfile
}

type AusfUeContext struct {
Expand Down
1 change: 1 addition & 0 deletions factory/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type Configuration struct {
PlmnSupportList []models.PlmnId `yaml:"plmnSupportList,omitempty"`
EnableNrfCaching bool `yaml:"enableNrfCaching"`
NrfCacheEvictionInterval int `yaml:"nrfCacheEvictionInterval,omitempty"`
EnableScaling bool `yaml:"enableScaling,omitempty"`
}

type Sbi struct {
Expand Down
52 changes: 45 additions & 7 deletions producer/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import (
"encoding/hex"
"fmt"
"hash"
"sort"
"strconv"
"strings"
"time"

"github.com/antihax/optional"
Expand Down Expand Up @@ -272,20 +274,56 @@ func ConstructEapNoTypePkt(code radius.EapCode, pktID uint8) string {
return base64.StdEncoding.EncodeToString(b)
}

func GetUdmUrl(nrfUri string) string {
func GetUdmUrl(nrfUri string, id string) string {
udmUrl := "https://localhost:29503" // default
Uenf, ok := ausf_context.GetSelf().UeNfProfile.Load(id)
if ok {
nf1 := Uenf.(models.NfProfile)
ueauService := (*nf1.NfServices)[0]
ueauEndPoint := (*ueauService.IpEndPoints)[0]
udmUrl = string(ueauService.Scheme) + "://" + ueauEndPoint.Ipv4Address + ":" + strconv.Itoa(int(ueauEndPoint.Port))

// logger.ConsumerLog.Warnln("for Ue: ", id, " found targetNfType ", string(models.NfType_UDR), " NF is: ", *nf1)
return udmUrl
}

nfDiscoverParam := Nnrf_NFDiscovery.SearchNFInstancesParamOpts{
ServiceNames: optional.NewInterface([]models.ServiceName{models.ServiceName_NUDM_UEAU}),
}
res, err := consumer.SendSearchNFInstances(nrfUri, models.NfType_UDM, models.NfType_AUSF, &nfDiscoverParam)
if err != nil {
logger.UeAuthPostLog.Errorln("[Search UDM UEAU] ", err.Error())
logger.UeAuthPostLog.Errorln("[Search UDM UEAU] ", err.Error(), id, nrfUri)
} else if len(res.NfInstances) > 0 {
udmInstance := res.NfInstances[0]
if len(udmInstance.Ipv4Addresses) > 0 && udmInstance.NfServices != nil {
ueauService := (*udmInstance.NfServices)[0]
ueauEndPoint := (*ueauService.IpEndPoints)[0]
udmUrl = string(ueauService.Scheme) + "://" + ueauEndPoint.Ipv4Address + ":" + strconv.Itoa(int(ueauEndPoint.Port))
nfInstanceIds := make([]string, 0, len(res.NfInstances))
for _, profile := range res.NfInstances {
nfInstanceIds = append(nfInstanceIds, profile.NfInstanceId)
}
sort.Strings(nfInstanceIds)

nfInstanceIdIndexMap := make(map[string]int)
for index, value := range nfInstanceIds {
nfInstanceIdIndexMap[value] = index
}

nfInstanceIndex := 0
if ausf_context.GetSelf().EnableScaling == true {
parts := strings.Split(id, "-")
imsiNumber, _ := strconv.Atoi(parts[1])
nfInstanceIndex = imsiNumber % len(res.NfInstances)
}
for _, profile := range res.NfInstances {
if nfInstanceIndex != nfInstanceIdIndexMap[profile.NfInstanceId] {
continue
}
udmInstance := profile
if len(udmInstance.Ipv4Addresses) > 0 && udmInstance.NfServices != nil {
ausf_context.GetSelf().UeNfProfile.Store(id, profile)
ueauService := (*udmInstance.NfServices)[0]
ueauEndPoint := (*ueauService.IpEndPoints)[0]
udmUrl = string(ueauService.Scheme) + "://" + ueauEndPoint.Ipv4Address + ":" + strconv.Itoa(int(ueauEndPoint.Port))
logger.ConsumerLog.Warnln("for Ue: ", id, " nfInstanceIndex: ", nfInstanceIndex, " for targetNfType ", string(models.NfType_UDM), " NF is: ", udmInstance.Ipv4Addresses)
break
}
}
} else {
logger.UeAuthPostLog.Errorln("[Search UDM UEAU] len(NfInstances) = 0")
Expand Down
2 changes: 1 addition & 1 deletion producer/ue_authentication.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func UeAuthPostRequestProcedure(updateAuthenticationInfo models.AuthenticationIn
authInfoReq.ResynchronizationInfo = updateAuthenticationInfo.ResynchronizationInfo
}

udmUrl := GetUdmUrl(self.NrfUri)
udmUrl := GetUdmUrl(self.NrfUri, supiOrSuci)
client := createClientToUdmUeau(udmUrl)
authInfoResult, rsp, err := client.GenerateAuthDataApi.GenerateAuthData(context.Background(), supiOrSuci, authInfoReq)
if err != nil {
Expand Down
18 changes: 17 additions & 1 deletion service/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,23 @@ func (ausf *AUSF) Terminate() {
logger.InitLog.Infoln("deregister from NRF successfully")
}

logger.InitLog.Infoln("AUSF terminated")
ausfSelf := context.GetSelf()
ausfSelf.NfStatusSubscriptions.Range(func(nfInstanceId, v interface{}) bool {
if subscriptionId, ok := ausfSelf.NfStatusSubscriptions.Load(nfInstanceId); ok {
logger.InitLog.Debugf("SubscriptionId is %v", subscriptionId.(string))
problemDetails, err := consumer.SendRemoveSubscription(subscriptionId.(string))
if problemDetails != nil {
logger.InitLog.Errorf("Remove NF Subscription Failed Problem[%+v]", problemDetails)
} else if err != nil {
logger.InitLog.Errorf("Remove NF Subscription Error[%+v]", err)
} else {
logger.InitLog.Infoln("[AUSF] Remove NF Subscription successful")
}
}
return true
})
logger.InitLog.Infof("AUSF terminated")

}

func (ausf *AUSF) StartKeepAliveTimer(nfProfile models.NfProfile) {
Expand Down