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 #337

Draft
wants to merge 25 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6b7a006
Aether Scaling, Initial Commit
mbilal92 Sep 23, 2024
e55c520
Aether Scaling, Initial Commit
mbilal92 Sep 23, 2024
bd9e917
chore(deps): bump peter-evans/create-pull-request from 6 to 7 (#303)
dependabot[bot] Sep 9, 2024
c5fff56
chore(deps): bump github.com/prometheus/client_golang (#304)
dependabot[bot] Sep 9, 2024
5cda355
chore(deps): bump golang from 1.23.0-bookworm to 1.23.1-bookworm (#302)
dependabot[bot] Sep 9, 2024
0cf6b92
feat: use DRSM only when database is enabled (#305)
dariofaccin Sep 12, 2024
7fa9c6e
Create version 1.5.2 (#306)
dariofaccin Sep 13, 2024
d39dde2
Update version (#307)
onf-bot Sep 13, 2024
7f974b2
chore(deps): bump github.com/omec-project/config5g from 1.4.3 to 1.4.…
dependabot[bot] Sep 16, 2024
04e1379
Update dependencies (#309)
gab-arrobo Sep 20, 2024
9c7e9fd
Release SMF (#310)
thakurajayL Sep 20, 2024
2218840
Update version (#311)
onf-bot Sep 20, 2024
59d58b8
chore(deps): bump github.com/prometheus/client_golang (#313)
dependabot[bot] Sep 23, 2024
6a10a37
PDU Session Establishment request with Sesssion type 'unstructured' …
mbilal92 Sep 28, 2024
b02c516
Merge branch 'master' of github.com:mbilal92/smf
mbilal92 Sep 28, 2024
b4c796e
Merge branch 'master' of github.com:mbilal92/smf
mbilal92 Sep 28, 2024
1d89672
update go.mod
mbilal92 Sep 28, 2024
5d29efe
fix lnt errors
mbilal92 Oct 12, 2024
253303c
Merge remote-tracking branch 'omec/master'
mbilal92 Oct 12, 2024
9c62d88
Fix log errors
mbilal92 Oct 12, 2024
879a3f9
Fix lint error
mbilal92 Oct 12, 2024
c19b1ec
fix lint issue
mbilal92 Oct 14, 2024
02cd2ca
fix lint issue
mbilal92 Oct 14, 2024
3a1ad42
fix lint error
mbilal92 Oct 14, 2024
56019e3
Merge branch 'omec-project:main' into main
mbilal92 Oct 19, 2024
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
72 changes: 67 additions & 5 deletions consumer/nnrf.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import (
"context"
"fmt"
"net/http"
"sort"
"strconv"
"strings"
"sync"
"time"

"github.com/antihax/optional"
Expand All @@ -27,6 +30,8 @@ import (
"github.com/omec-project/smf/msgtypes/svcmsgtypes"
)

var SmContextlenMutex sync.Mutex

func SendNFRegistration() (*models.NfProfile, error) {
var rep models.NfProfile
sNssais := []models.Snssai{}
Expand All @@ -51,6 +56,7 @@ func SendNFRegistration() (*models.NfProfile, error) {
SNssais: &sNssais,
PlmnList: smf_context.SmfPlmnConfig(),
AllowedPlmns: smf_context.SmfPlmnConfig(),
Load: smf_context.GetSmContextLen(),
}

var res *http.Response
Expand Down Expand Up @@ -250,7 +256,31 @@ func SendNrfForNfInstance(nrfUri string, targetNfType, requestNfType models.NfTy
return result, localErr
}

func SendNFDiscoveryUDM() (*models.ProblemDetails, error) {
func SendNFDiscoveryUDM(smContext *smf_context.SMContext) (*models.ProblemDetails, error) {
// func SendNFDiscoveryUDM(id string) (*models.ProblemDetails, error) {
id := smContext.Supi

value, ok := smf_context.SMF_Self().UdmProfileMap.Load(id)
if ok {
smContext.SelectedUdmProfile = value.(models.NfProfile)
smContext.UdmIP = smContext.SelectedUdmProfile.Ipv4Addresses[0]
for _, service := range *smContext.SelectedUdmProfile.NfServices {
if service.ServiceName == models.ServiceName_NUDM_SDM {
SDMConf := Nudm_SubscriberDataManagement.NewConfiguration()
SDMConf.SetBasePath(service.ApiPrefix)
smContext.SubscriberDataManagementClient = Nudm_SubscriberDataManagement.NewAPIClient(SDMConf)
}
}
return nil, nil
}

SmContextlenMutex.Lock()
smf_context.IncSmContextLen()
if _, err := SendNFRegistration(); err != nil {
fmt.Println("NRF Registration failure ", err.Error())
}
SmContextlenMutex.Unlock()

localVarOptionals := Nnrf_NFDiscovery.SearchNFInstancesParamOpts{}

var result models.SearchResult
Expand All @@ -263,17 +293,48 @@ func SendNFDiscoveryUDM() (*models.ProblemDetails, error) {
}

if localErr == nil {
smf_context.SMF_Self().UDMProfile = result.NfInstances[0]
// smf_context.SMF_Self().UDMProfile = result.NfInstances[0]
nfInstanceIds := make([]string, 0, len(result.NfInstances))
for _, nfProfile := range result.NfInstances {
nfInstanceIds = append(nfInstanceIds, nfProfile.NfInstanceId)
}
sort.Strings(nfInstanceIds)
nfInstanceIdIndexMap := make(map[string]int)
for index, value := range nfInstanceIds {
nfInstanceIdIndexMap[value] = index
}

for _, service := range *smf_context.SMF_Self().UDMProfile.NfServices {
nfInstanceIndex := 0
if smf_context.SMF_Self().EnableScaling {
parts := strings.Split(id, "-")
imsiNumber, err := strconv.Atoi(parts[1])
if err != nil {
logger.ConsumerLog.Warnln("imsiNumber conversion failed")
return nil, err
}
nfInstanceIndex = imsiNumber % len(result.NfInstances)
}

for _, nfProfile := range result.NfInstances {
if nfInstanceIndex != nfInstanceIdIndexMap[nfProfile.NfInstanceId] {
continue
}
smContext.SelectedUdmProfile = nfProfile
smContext.UdmIP = nfProfile.Ipv4Addresses[0]
smf_context.SMF_Self().UdmProfileMap.Store(id, nfProfile)
logger.ConsumerLog.Warnln("for Ue: ", id, " nfInstanceIndex: ", nfInstanceIndex, " for targetNfType ", string(models.NfType_UDM), " NF is: ", nfProfile.Ipv4Addresses)

break
}
for _, service := range *smContext.SelectedUdmProfile.NfServices {
if service.ServiceName == models.ServiceName_NUDM_SDM {
SDMConf := Nudm_SubscriberDataManagement.NewConfiguration()
SDMConf.SetBasePath(service.ApiPrefix)
smf_context.SMF_Self().SubscriberDataManagementClient = Nudm_SubscriberDataManagement.NewAPIClient(SDMConf)
smContext.SubscriberDataManagementClient = Nudm_SubscriberDataManagement.NewAPIClient(SDMConf)
}
}

if smf_context.SMF_Self().SubscriberDataManagementClient == nil {
if smContext.SubscriberDataManagementClient == nil {
logger.ConsumerLog.Warnln("sdm client failed")
}
} else {
Expand Down Expand Up @@ -334,6 +395,7 @@ func SendNFDiscoveryServingAMF(smContext *smf_context.SMContext) (*models.Proble
return nil, openapi.ReportError("NfInstances is nil")
}
smContext.SubConsumerLog.Info("send NF Discovery Serving AMF Successful")
// FIX: FIND AMF based on smContext.Supi
smContext.AMFProfile = deepcopy.Copy(result.NfInstances[0]).(models.NfProfile)
} else {
apiError, ok := localErr.(openapi.GenericOpenAPIError)
Expand Down
18 changes: 16 additions & 2 deletions context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"sync/atomic"
"time"

"github.com/go-redis/redis"
"github.com/google/uuid"
"github.com/omec-project/openapi/Nnrf_NFDiscovery"
"github.com/omec-project/openapi/Nnrf_NFManagement"
Expand Down Expand Up @@ -80,10 +81,15 @@ type SMFContext struct {
CPNodeID NodeID
PFCPPort int
UDMProfile models.NfProfile
UdmProfileMap sync.Map
PcfProfileMap sync.Map
NrfCacheEvictionInterval time.Duration
SBIPort int
LocalSEIDCount uint64
EnableNrfCaching bool
EnableScaling bool
RedisClient *redis.Client
RedisDb int

// For ULCL
ULCLSupport bool
Expand Down Expand Up @@ -249,7 +255,7 @@ func InitSmfContext(config *factory.Config) *SMFContext {
smfContext.UserPlaneInformation = NewUserPlaneInformation(&configuration.UserPlaneInformation)

smfContext.EnableNrfCaching = configuration.EnableNrfCaching

smfContext.EnableScaling = configuration.EnableScaling
if configuration.EnableNrfCaching {
if configuration.NrfCacheEvictionInterval == 0 {
smfContext.NrfCacheEvictionInterval = time.Duration(900) // 15 mins
Expand All @@ -260,7 +266,13 @@ func InitSmfContext(config *factory.Config) *SMFContext {

smfContext.PodIp = os.Getenv("POD_IP")
SetupNFProfile(config)

if smfContext.EnableScaling {
smfContext.RedisClient = redis.NewClient(&redis.Options{
Addr: "redis:6379",
Password: "",
DB: factory.SmfConfig.Configuration.RedisDb,
})
}
return &smfContext
}

Expand Down Expand Up @@ -433,13 +445,15 @@ func (smfCtxt *SMFContext) InitDrsm() error {
db := drsm.DbInfo{Url: dbUrl, Name: dbName}

// for local FSEID
// if drsmCtxt, err := drsm.InitDRSM("fseid", podId, db, opt, factory.SmfConfig.Configuration.DrsmPunchLiveTime); err == nil {
if drsmCtxt, err := drsm.InitDRSM("fseid", podId, db, opt); err == nil {
smfCtxt.DrsmCtxts.SeidPool = drsmCtxt
} else {
return err
}

// for local FTEID
// if drsmCtxt, err := drsm.InitDRSM("fteid", podId, db, opt, factory.SmfConfig.Configuration.DrsmPunchLiveTime); err == nil {
if drsmCtxt, err := drsm.InitDRSM("fteid", podId, db, opt); err == nil {
smfCtxt.DrsmCtxts.TeidPool = drsmCtxt
} else {
Expand Down
Loading