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

Adding code to get lock before NAS Mac calculation #92

Merged
merged 9 commits into from
Dec 7, 2023
Merged
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ FROM golang:1.18.0-stretch AS gnb

LABEL maintainer="ONF <[email protected]>"

RUN echo "deb http://archive.debian.org/debian stretch main" > /etc/apt/sources.list
RUN apt-get update && apt-get -y install vim ethtool
RUN cd $GOPATH/src && mkdir -p gnbsim
COPY . $GOPATH/src/gnbsim
Expand Down
1 change: 1 addition & 0 deletions config/gnbsim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ info:
description: GNBSIM initial local configuration

configuration:
runConfigProfilesAtStart: true
singleInterface: false #default value
execInParallel: false #run all profiles in parallel
httpServer: # Serves APIs to create/control profiles on the go
Expand Down
1 change: 1 addition & 0 deletions gnbsim.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ func action(c *cli.Context) error {
// Keep running gnbsim as long as profiles are not finished
for _, profile := range config.Configuration.Profiles {
if !profile.Enable {
logger.AppLog.Errorln("disbaled profileType ", profile.ProfileType)
continue
}
profileWaitGrp.Add(1)
Expand Down
35 changes: 24 additions & 11 deletions gnodeb/worker/gnbcpueworker/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,31 @@ func HandleInitialUEMessage(gnbue *gnbctx.GnbCpUe,
intfcMsg common.InterfaceMessage) {

msg := intfcMsg.(*common.UuMessage)
sendMsg, err := test.GetInitialUEMessage(gnbue.GnbUeNgapId, msg.NasPdus[0], "")
if err != nil {
gnbue.Log.Errorln("GetInitialUEMessage failed:", err)
return
}
err = gnbue.Gnb.CpTransport.SendToPeer(gnbue.Amf, sendMsg)
if err != nil {
gnbue.Log.Errorln("SendToPeer failed:", err)
return
if gnbue.AmfUeNgapId != 0 {
sendMsg, err := test.GetUplinkNASTransport(gnbue.AmfUeNgapId, gnbue.GnbUeNgapId, msg.NasPdus[0])
if err != nil {
gnbue.Log.Errorln("GetUplinkNASMessage failed:", err)
return
}
err = gnbue.Gnb.CpTransport.SendToPeer(gnbue.Amf, sendMsg)
if err != nil {
gnbue.Log.Errorln("SendToPeer failed:", err)
return
}
gnbue.Log.Traceln("Sent Uplink NAS Message to AMF")
} else {
sendMsg, err := test.GetInitialUEMessage(gnbue.GnbUeNgapId, msg.NasPdus[0], "")
if err != nil {
gnbue.Log.Errorln("GetInitialUEMessage failed:", err)
return
}
err = gnbue.Gnb.CpTransport.SendToPeer(gnbue.Amf, sendMsg)
if err != nil {
gnbue.Log.Errorln("SendToPeer failed:", err)
return
}
gnbue.Log.Traceln("Sent Initial UE Message to AMF")
}

gnbue.Log.Traceln("Sent Initial UE Message to AMF")
}

func HandleDownlinkNasTransport(gnbue *gnbctx.GnbCpUe,
Expand Down
2 changes: 1 addition & 1 deletion profile/context/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func (p *Profile) GetNextProcedure(pCtx *ProfileUeContext, currentProcedure comm
itp, found := p.PIterations[pCtx.CurrentItr]
pCtx.Log.Infoln("Current Iteration map - ", itp)
if itp.WaitMap[pCtx.CurrentProcIndex] != 0 {
time.Sleep(time.Second * time.Duration(itp.WaitMap[pCtx.CurrentProcIndex]))
time.Sleep(time.Millisecond * time.Duration(itp.WaitMap[pCtx.CurrentProcIndex]))
}
nextProcIndex := pCtx.CurrentProcIndex + 1
nextProcedure, found := itp.ProcMap[nextProcIndex]
Expand Down
8 changes: 8 additions & 0 deletions realue/nas/nas_security.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package nas
import (
"fmt"
"reflect"
"sync"

realuectx "github.com/omec-project/gnbsim/realue/context"

Expand All @@ -17,6 +18,8 @@ import (
"github.com/omec-project/ngap/ngapType"
)

var mutex sync.Mutex

func EncodeNasPduWithSecurity(ue *realuectx.RealUe, pdu []byte, securityHeaderType uint8,
securityContextAvailable bool) ([]byte, error) {
m := nas.NewMessage()
Expand Down Expand Up @@ -68,6 +71,8 @@ func GetNasPduSetupRequest(ue *realuectx.RealUe, msg *ngapType.PDUSessionResourc

func NASEncode(ue *realuectx.RealUe, msg *nas.Message, securityContextAvailable bool) (
payload []byte, err error) {
mutex.Lock()
defer mutex.Unlock()

if ue == nil {
err = fmt.Errorf("amfUe is nil")
Expand Down Expand Up @@ -137,6 +142,9 @@ func NASEncode(ue *realuectx.RealUe, msg *nas.Message, securityContextAvailable
}

func NASDecode(ue *realuectx.RealUe, securityHeaderType uint8, payload []byte) (msg *nas.Message, err error) {
mutex.Lock()
defer mutex.Unlock()

if ue == nil {
err = fmt.Errorf("amfUe is nil")
return
Expand Down