Skip to content

Commit

Permalink
Support for step execution and multiple iteration
Browse files Browse the repository at this point in the history
- Support for custom profile
  • Loading branch information
thakurajayL committed Sep 20, 2022
1 parent 8595a14 commit 2379ad8
Show file tree
Hide file tree
Showing 21 changed files with 768 additions and 244 deletions.
14 changes: 8 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
# SPDX-License-Identifier: Apache-2.0
#

FROM golang:1.14.4-stretch AS sim
FROM golang:1.18.0-stretch AS gnb

LABEL maintainer="ONF <omec-dev@opennetworking.org>"

RUN apt-get update
RUN apt-get -y install vim
RUN apt-get -y install ethtool
RUN apt-get update && apt-get -y install vim ethtool
RUN cd $GOPATH/src && mkdir -p gnbsim
COPY . $GOPATH/src/gnbsim
RUN cd $GOPATH/src/gnbsim && go build -mod=vendor

FROM sim AS gnbsim
FROM alpine:3.16 AS gnbsim
RUN apk update && apk add -U gcompat vim strace net-tools curl netcat-openbsd bind-tools bash

RUN mkdir -p /gnbsim/bin
COPY --from=sim $GOPATH/src/gnbsim/gnbsim /gnbsim/bin/

# Copy executable
COPY --from=gnb /go/src/gnbsim/gnbsim /gnbsim/bin/
WORKDIR /gnbsim/bin
14 changes: 14 additions & 0 deletions common/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const (
PROFILE_SIMUE_EVENT EventType = 0x5000000
SIMUE_REALUE_EVENT EventType = 0x6000000
COMMON_EVENT EventType = 0x7000000
PROC_SIMUE_EVENT EventType = 0x8000000
)

const (
Expand All @@ -33,6 +34,14 @@ const (
PROFILE_START_EVENT EventType = PROFILE_SIMUE_EVENT + 1 + iota
PROFILE_PASS_EVENT
PROFILE_FAIL_EVENT
PROFILE_STEP_EVENT
PROFILE_ADDCALLS_EVENT
)

const (
PROC_START_EVENT EventType = PROC_SIMUE_EVENT + 1 + iota
PROC_PASS_EVENT
PROC_FAIL_EVENT
)

/* Events between SimUe and RealUE */
Expand Down Expand Up @@ -158,6 +167,8 @@ var evtStrMap map[EventType]string = map[EventType]string{
PROFILE_START_EVENT: "PROFILE-START-EVENT",
PROFILE_PASS_EVENT: "PROFILE-PASS-EVENT",
PROFILE_FAIL_EVENT: "PROFILE-FAIL-EVENT",
PROFILE_STEP_EVENT: "PROFILE-STEP-EVENT",
PROFILE_ADDCALLS_EVENT: "PROFILE-ADDCALLS-EVENT",
DATA_PKT_GEN_REQUEST_EVENT: "DATA-PACKET-GENERATION-REQUEST-EVENT",
DATA_PKT_GEN_SUCCESS_EVENT: "DATA-PACKET-SUCCESS-EVENT",
DATA_PKT_GEN_FAILURE_EVENT: "DATA-PACKET-FAILURE-EVENT",
Expand Down Expand Up @@ -221,6 +232,9 @@ var evtStrMap map[EventType]string = map[EventType]string{
PDU_SESS_RESOURCE_SETUP_REQUEST_EVENT: "PDU-SESSION-RESOURCE-SETUP-REQUEST-EVENT",
UE_CTX_RELEASE_COMMAND_EVENT: "UE-CONTEXT-RELEASE-COMMAND-EVENT",
DL_UE_DATA_TRANSPORT_EVENT: "DL-UE-DATA-TRANSPORT-EVENT",
PROC_START_EVENT: "PROC-START-EVENT",
PROC_PASS_EVENT: "PROC-PASS-EVENT",
PROC_FAIL_EVENT: "PROC-FAIL-EVENT",
}

func (id EventType) String() string {
Expand Down
14 changes: 13 additions & 1 deletion common/procedures.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import "github.com/omec-project/gnbsim/logger"
type ProcedureType uint8

const (
REGISTRATION_PROCEDURE ProcedureType = 1 + iota
UNKNOWN_PROCEDURE ProcedureType = 0 + iota
REGISTRATION_PROCEDURE
PDU_SESSION_ESTABLISHMENT_PROCEDURE
UE_REQUESTED_PDU_SESSION_RELEASE_PROCEDURE
USER_DATA_PKT_GENERATION_PROCEDURE
Expand All @@ -22,6 +23,7 @@ const (
)

var procStrMap = map[ProcedureType]string{
UNKNOWN_PROCEDURE: "UNKNOWN-PROCEDURE",
REGISTRATION_PROCEDURE: "REGISTRATION-PROCEDURE",
PDU_SESSION_ESTABLISHMENT_PROCEDURE: "PDU-SESSION-ESTABLISHMENT-PROCEDURE",
USER_DATA_PKT_GENERATION_PROCEDURE: "USER-DATA-PACKET-GENERATION-PROCEDURE",
Expand All @@ -41,3 +43,13 @@ func (id ProcedureType) String() string {
}
return procStr
}

func GetProcId(name string) ProcedureType {
var p ProcedureType = UNKNOWN_PROCEDURE
for id, v := range procStrMap {
if v == name {
return id
}
}
return p
}
36 changes: 36 additions & 0 deletions config/gnbsim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,42 @@ configuration:
hostName: amf # Host name of AMF
ipAddr: # AMF IP address
port: 38412 # AMF port

customProfiles:
customProfiles1:
profileType: custom1 # profile type
profileName: custom1 # uniqely identifies a profile within application
enable: false # Set true to execute the profile, false otherwise.
execInParallel: false #run all subscribers in parallel
stepTrigger: true #wait for trigger to move to next step
gnbName: gnb1 # gNB to be used for this profile
startImsi: 208930100007487
ueCount: 5
defaultAs: "192.168.250.1" #default icmp pkt destination
opc: "981d464c7c52eb6e5036234984ad0bcf"
key: "5122250214c33e723a5dd523fc145fc0"
sequenceNumber: "16f3b3f70fc2"
plmnId: # Public Land Mobile Network ID, <PLMN ID> = <MCC><MNC>
mcc: 208 # Mobile Country Code (3 digits string, digit: 0~9)
mnc: 93 # Mobile Network Code (2 or 3 digits string, digit: 0~9)
startiteration: iteration1
iterations:
#at max 7 actions
- "name": "iteration1"
"1": "REGISTRATION-PROCEDURE 5"
"2": "PDU-SESSION-ESTABLISHMENT-PROCEDURE 5"
"3": "USER-DATA-PACKET-GENERATION-PROCEDURE 10"
"next": "iteration2"
- "name": "iteration2"
"1": "AN-RELEASE-PROCEDURE 100"
"2": "UE-TRIGGERED-SERVICE-REQUEST-PROCEDURE 10"
"repeat": 5
"next": "iteration3"
- "name": "iteration3"
"1": "UE-INITIATED-DEREGISTRATION-PROCEDURE 10"
#"repeat": 0 #default value 0 . i.e execute once
#"next": "quit" #default value quit. i.e. no further iteration to run

profiles: # profile information
- profileType: register # profile type
profileName: profile1 # uniqely identifies a profile within application
Expand Down
70 changes: 65 additions & 5 deletions factory/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ package factory
import (
"fmt"
"os"
"strconv"
"strings"

"github.com/omec-project/gnbsim/common"
gnbctx "github.com/omec-project/gnbsim/gnodeb/context"
profctx "github.com/omec-project/gnbsim/profile/context"
)
Expand All @@ -35,11 +38,12 @@ type Info struct {
}

type Configuration struct {
Gnbs map[string]*gnbctx.GNodeB `yaml:"gnbs"`
Profiles []*profctx.Profile `yaml:"profiles"`
SingleInterface bool `yaml:"singleInterface"`
ExecInParallel bool `yaml:"execInParallel"`
Server HttpServer `yaml:"httpServer"`
Gnbs map[string]*gnbctx.GNodeB `yaml:"gnbs"`
CustomProfiles map[string]*profctx.Profile `yaml:"customProfiles"`
Profiles []*profctx.Profile `yaml:"profiles"`
SingleInterface bool `yaml:"singleInterface"`
ExecInParallel bool `yaml:"execInParallel"`
Server HttpServer `yaml:"httpServer"`
}

type HttpServer struct {
Expand Down Expand Up @@ -89,6 +93,62 @@ func (c *Config) Validate() (err error) {
return fmt.Errorf("no profile information available")
}

if len(c.Configuration.CustomProfiles) != 0 {
for _, v := range c.Configuration.CustomProfiles {
it := v.Iterations
v.PIterations = make(map[string]*profctx.PIterations)
for _, v1 := range it {
if len(v1.Next) == 0 {
v1.Next = "quit" // default value
}
PIter := &profctx.PIterations{Name: v1.Name, NextItr: v1.Next, Repeat: v1.Repeat}
PIter.ProcMap = make(map[int]common.ProcedureType)
PIter.WaitMap = make(map[int]int)
PIter.WaitMap[0] = 0
if len(v1.First) > 0 {
x := strings.Fields(v1.First)
PIter.ProcMap[1] = common.GetProcId(x[0])
PIter.WaitMap[1], err = strconv.Atoi(x[1])
}
if len(v1.Second) > 0 {
x := strings.Fields(v1.Second)
PIter.ProcMap[2] = common.GetProcId(x[0])
PIter.WaitMap[2], err = strconv.Atoi(x[1])
}
if len(v1.Third) > 0 {
x := strings.Fields(v1.Third)
PIter.ProcMap[3] = common.GetProcId(x[0])
PIter.WaitMap[3], err = strconv.Atoi(x[1])
}
if len(v1.Fourth) > 0 {
x := strings.Fields(v1.Fourth)
PIter.ProcMap[4] = common.GetProcId(x[0])
PIter.WaitMap[4], err = strconv.Atoi(x[1])
}
if len(v1.Fifth) > 0 {
x := strings.Fields(v1.Fifth)
PIter.ProcMap[5] = common.GetProcId(x[0])
PIter.WaitMap[5], err = strconv.Atoi(x[1])
}
if len(v1.Sixth) > 0 {
x := strings.Fields(v1.Sixth)
PIter.ProcMap[6] = common.GetProcId(x[0])
PIter.WaitMap[6], err = strconv.Atoi(x[1])
}
if len(v1.Seventh) > 0 {
x := strings.Fields(v1.Seventh)
PIter.ProcMap[7] = common.GetProcId(x[0])
PIter.WaitMap[7], err = strconv.Atoi(x[1])
}
v.PIterations[v1.Name] = PIter // add iterations in the custom profile
}
}

for _, v := range c.Configuration.CustomProfiles {
c.Configuration.Profiles = append(c.Configuration.Profiles, v)
}
}

return nil
}

Expand Down
10 changes: 9 additions & 1 deletion gnbsim.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ func action(c *cli.Context) error {

var appWaitGrp sync.WaitGroup
if config.Configuration.Server.Enable {
appWaitGrp.Add(1)
go func() {
appWaitGrp.Add(1)
defer appWaitGrp.Done()
err := httpserver.StartHttpServer()
if err != nil {
Expand All @@ -92,17 +92,23 @@ func action(c *cli.Context) error {
signal.Notify(signalChannel, os.Interrupt, syscall.SIGTERM)
go func() {
<-signalChannel
logger.AppLog.Infoln("StopHttpServer called")
httpserver.StopHttpServer()
logger.AppLog.Infoln("StopHttpServer returned ")
}()
}

var profileWaitGrp sync.WaitGroup
// start profile and wait for it to finish (success or failure)
// Keep running gnbsim as long as profiles are not finished
for _, profile := range config.Configuration.Profiles {
if !profile.Enable {
continue
}
profileWaitGrp.Add(1)

prof.InitProfile(profile, profctx.SummaryChan)

go func(profileCtx *profctx.Profile) {
defer profileWaitGrp.Done()
prof.ExecuteProfile(profileCtx, profctx.SummaryChan)
Expand Down Expand Up @@ -134,8 +140,10 @@ func getCliFlags() []cli.Flag {
}
}

// TODO : we don't keep track of how many profiles are started...
func ListenAndLogSummary() {
for intfcMsg := range profctx.SummaryChan {
// TODO: do we need this event ?
if intfcMsg.GetEventType() == common.QUIT_EVENT {
return
}
Expand Down
2 changes: 1 addition & 1 deletion gnodeb/gnodeb.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func Init(gnb *gnbctx.GNodeB) error {

go gnb.CpTransport.ReceiveFromPeer(gnb.DefaultAmf)

gnb.Log.Traceln("GNodeB Initialized")
gnb.Log.Tracef("GNodeB Initialized %v ", gnb)
return nil
}

Expand Down
1 change: 1 addition & 0 deletions gnodeb/worker/gnbcpueworker/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ func HandleInitialContextSetupRequest(gnbue *gnbctx.GnbCpUe,
gnbue.Log.Errorln("AMFUENGAPID is nil")
return
}
gnbue.AmfUeNgapId = amfUeNgapId.Value
case ngapType.ProtocolIEIDNASPDU:
nasPdu = ie.Value.NASPDU
if nasPdu == nil {
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ github.com/omec-project/logger_util v1.1.0/go.mod h1:UkD09amIhlh8P0k82A6Uz/atiZG
github.com/omec-project/milenage v1.1.0 h1:yVBtBB4hd+SQx4gFkE6mZ8mfzO5na/1d2j31G6jYlCA=
github.com/omec-project/milenage v1.1.0/go.mod h1:Tw5HLvxWEQN0JA+EXEVwZ17TL9adEZk3kWqKGgsNmHc=
github.com/omec-project/nas v1.1.1/go.mod h1:gXqi/IZwEGXno26X8wg8ITsAUiemRQ7PkIJOWP1NzGA=
github.com/omec-project/nas v1.1.2 h1:ApgVHVVvxPydy8H5Dd2fuiGafrvjCIgGgf37h824kd8=
github.com/omec-project/nas v1.1.2/go.mod h1:gXqi/IZwEGXno26X8wg8ITsAUiemRQ7PkIJOWP1NzGA=
github.com/omec-project/nas v1.1.3 h1:2GuvNz/1tr3M6wpHlcuDCOJaxAa3Fm54xt5Wggklwrg=
github.com/omec-project/nas v1.1.3/go.mod h1:gXqi/IZwEGXno26X8wg8ITsAUiemRQ7PkIJOWP1NzGA=
github.com/omec-project/ngap v1.1.0 h1:J9bkPEzzyGd1787nGY/aZVp3gckkZBoJB4tkTo59eyw=
github.com/omec-project/ngap v1.1.0/go.mod h1:A+T3+JKk+6AuhnMr6W319Tc7E176ig6rIRDVSKQ7E5g=
github.com/omec-project/openapi v1.0.100-dev/go.mod h1:Fv9ajWROYypcNER+ZwWXPhLCdV4pBz75KqFp/R/2gCw=
Expand Down
2 changes: 2 additions & 0 deletions logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var (
PsuppLog *logrus.Entry
GinLog *logrus.Entry
HttpLog *logrus.Entry
ProfUeCtxLog *logrus.Entry
)

const (
Expand Down Expand Up @@ -82,6 +83,7 @@ func init() {
AppSummaryLog = summaryLog.WithFields(logrus.Fields{"component": "GNBSIM", "category": "Summary"})
RealUeLog = log.WithFields(logrus.Fields{"component": "GNBSIM", "category": "RealUe"})
SimUeLog = log.WithFields(logrus.Fields{"component": "GNBSIM", "category": "SimUe"})
ProfUeCtxLog = log.WithFields(logrus.Fields{"component": "GNBSIM", "category": "ProfUeCtx"})
ProfileLog = log.WithFields(logrus.Fields{"component": "GNBSIM", "category": "Profile"})
GNodeBLog = log.WithFields(logrus.Fields{"component": "GNBSIM", "category": "GNodeB"})
GinLog = log.WithFields(logrus.Fields{"component": "GNBSIM", "category": "Gin"})
Expand Down

0 comments on commit 2379ad8

Please sign in to comment.