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

Add a performance test to connect multiple UEs in parallel #52

Open
wants to merge 56 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
cf5d4de
Add paralle test
Jun 17, 2022
e340aed
Removed go submodule
Jun 17, 2022
49fad86
Remove stopwatch
Jun 24, 2022
3bfe8fe
Remove unused dependency
Jun 24, 2022
628e022
Add metrics generator
Jun 29, 2022
8052d63
Change Ue ID locatuin
Jun 29, 2022
b687297
Fix time
Jun 29, 2022
89c9fd3
Fix comma
Jun 29, 2022
ff695e1
Fix comma
Jun 29, 2022
522a561
Fix issue
Jun 29, 2022
18f8888
Fix issue
Jun 29, 2022
a245cfc
Fix issue
Jun 29, 2022
2956e06
Fix issue
Jun 29, 2022
b07e8c2
Fix issue
Jun 29, 2022
496d8d6
Fix issue
Jun 29, 2022
d125c01
Fix issue
Jun 29, 2022
d92d190
Fix issue
Jun 29, 2022
b3e04a4
Improve analytics
Jul 7, 2022
09086b2
Fix issue
Jul 7, 2022
b58820e
Fix issue
Jul 7, 2022
ec18d32
Fix issue
Jul 7, 2022
91ffcf5
Fix issue
Jul 7, 2022
3701fa9
Fix issue
Jul 7, 2022
1c6e0c8
Fix issue
Jul 7, 2022
f1ade42
Add UE FSM logs
Jul 11, 2022
6dd0887
Update analytics
Jul 20, 2022
e0e37d2
Change UE ID from uint8 to uint8 trying to fix crash with Open5GS
gabriel-lando Jul 24, 2022
1118888
Change UE ID from uint8 to uint8 trying to fix crash with Open5GS
gabriel-lando Jul 24, 2022
d3bb67d
Change UE ID from uint8 to uint8 trying to fix crash with Open5GS
gabriel-lando Jul 24, 2022
158fd4c
Change UE ID from uint8 to int64 trying to fix crash with Open5GS
gabriel-lando Jul 24, 2022
241f17a
Change UE ID from uint8 to int64 trying to fix crash with Open5GS
gabriel-lando Jul 24, 2022
ca974ec
Change UE ID from uint8 to int64 trying to fix crash with Open5GS
gabriel-lando Jul 24, 2022
b14c34b
Add DataPlaneReady event
gabriel-lando Jul 29, 2022
4b3a823
Update test-multi-ues-in-parallel.go
gabriel-lando Jul 29, 2022
94823a8
Update test-multi-ues-in-parallel.go
gabriel-lando Jul 30, 2022
19789d6
Update test-multi-ues-in-parallel.go
gabriel-lando Jul 30, 2022
a9fce58
Update test-multi-ues-in-parallel.go
gabriel-lando Jul 30, 2022
51aef4a
Update test-multi-ues-in-parallel.go
gabriel-lando Jul 30, 2022
11d2993
Update test-multi-ues-in-parallel.go
gabriel-lando Jul 30, 2022
7f95fa1
Update test-multi-ues-in-parallel.go
gabriel-lando Jul 30, 2022
dba9e40
Add delay to disconnect parameter
gabriel-lando Jul 30, 2022
9723195
Test repeat same UE multiple times
gabriel-lando Jul 30, 2022
5b8a8bd
Rollback to single UE
gabriel-lando Jul 30, 2022
738c244
Change event to close entire UE
gabriel-lando Jul 30, 2022
3da0e63
Fix issue
gabriel-lando Jul 30, 2022
838f290
Update ue.go
gabriel-lando Jul 30, 2022
c684ef4
Update ue.go
gabriel-lando Jul 30, 2022
cdb98ed
Fix event name
gabriel-lando Jul 30, 2022
62bb9a3
Remove delay to disconnect
gabriel-lando Aug 6, 2022
3a5711e
Remove unnecessary imports
gabriel-lando Aug 6, 2022
f62418f
Add gNB ID to analytics
gabriel-lando Aug 7, 2022
4642a0d
Fix tipo
gabriel-lando Aug 7, 2022
7a5c258
Fix issue with atoi parser
gabriel-lando Aug 7, 2022
722447d
Fix typo
gabriel-lando Aug 7, 2022
8036134
Merge remote-tracking branch 'upstream/master'
Jun 8, 2023
8b6614f
Update RegistrationUeMonitor id to int64
gabriel-lando Jun 8, 2023
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
41 changes: 41 additions & 0 deletions cmd/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,47 @@ func main() {
return nil
},
},
{
Name: "load-test-parallel",
Aliases: []string{"load-test-parallel"},
Usage: "\nLoad endurance stress tests.\n" +
"Example for testing multiple UEs: load-test-parallel -n 1000 -d 30 -t 30 -a\n",
Flags: []cli.Flag{
&cli.IntFlag{Name: "number-of-ues", Value: 1, Aliases: []string{"n"}},
&cli.IntFlag{Name: "delay-per-ue", Value: 1, Aliases: []string{"d"}},
&cli.IntFlag{Name: "startup-delay", Value: 1, Aliases: []string{"t"}},
&cli.BoolFlag{Name: "enable-analytics", Aliases: []string{"a"}},
},
Action: func(c *cli.Context) error {
var numUes int
var delayUes int
var delayStart int
var showAnalytics bool
name := "Testing registration of multiple UEs in parallel"
cfg := config.Data

if c.IsSet("number-of-ues") && c.IsSet("delay-per-ue") && c.IsSet("startup-delay") {
numUes = c.Int("number-of-ues")
delayUes = c.Int("delay-per-ue")
delayStart = c.Int("startup-delay")
showAnalytics = c.Bool("enable-analytics")
} else {
log.Info(c.Command.Usage)
return nil
}

log.Info("---------------------------------------")
log.Info("[TESTER] Starting test function: ", name)
log.Info("[TESTER][UE] Number of UEs: ", numUes)
log.Info("[TESTER][GNB] gNodeB control interface IP/Port: ", cfg.GNodeB.ControlIF.Ip, "/", cfg.GNodeB.ControlIF.Port)
log.Info("[TESTER][GNB] gNodeB data interface IP/Port: ", cfg.GNodeB.DataIF.Ip, "/", cfg.GNodeB.DataIF.Port)
log.Info("[TESTER][AMF] AMF IP/Port: ", cfg.AMF.Ip, "/", cfg.AMF.Port)
log.Info("---------------------------------------")
templates.TestMultiUesInParallel(numUes, delayUes, delayStart, showAnalytics)

return nil
},
},
},
}
err := app.Run(os.Args)
Expand Down
31 changes: 31 additions & 0 deletions internal/analytics/log_time/log_time.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package analytics

import (
"fmt"
"time"
log "github.com/sirupsen/logrus"
)

var enabled = true
func ChangeAnalyticsState(state bool){
enabled = state
}

var gnbid = 0
func SetGnodebId(id int){
gnbid = id
}

func LogUeTime(id string, task string) {

now := time.Now()

go ShowUeLog(id, task, now)
}

func ShowUeLog(id string, task string, now time.Time) {
if enabled {
nsec_now := now.UnixNano()
log.Info(fmt.Sprintf("[ANALYTICS] %d, %s, %s, %d", gnbid, id, task, nsec_now))
}
}
21 changes: 16 additions & 5 deletions internal/control_test_engine/ue/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
"net"
"reflect"
"regexp"

log_time "my5G-RANTester/internal/analytics/log_time"
)

// 5GMM main states in the UE.
Expand All @@ -31,7 +33,7 @@ const SM5G_PDU_SESSION_ACTIVE_PENDING = 0x07
const SM5G_PDU_SESSION_ACTIVE = 0x08

type UEContext struct {
id uint8
id int64
UeSecurity SECURITY
StateMM int
StateSM int
Expand All @@ -47,7 +49,7 @@ type Amf struct {
}

type PDUSession struct {
Id uint8
Id int64
ueIP string
ueGnbIP net.IP
Dnn string
Expand Down Expand Up @@ -79,7 +81,7 @@ type SECURITY struct {
func (ue *UEContext) NewRanUeContext(msin string,
cipheringAlg, integrityAlg uint8,
k, opc, op, amf, sqn, mcc, mnc, dnn string,
sst int32, sd string, id uint8) {
sst int32, sd string, id int64) {

// added SUPI.
ue.UeSecurity.Msin = msin
Expand Down Expand Up @@ -146,7 +148,7 @@ func (ue *UEContext) NewRanUeContext(msin string,

}

func (ue *UEContext) GetUeId() uint8 {
func (ue *UEContext) GetUeId() int64 {
return ue.id
}

Expand All @@ -164,38 +166,47 @@ func (ue *UEContext) GetSupi() string {

func (ue *UEContext) SetStateSM_PDU_SESSION_INACTIVE() {
ue.StateSM = SM5G_PDU_SESSION_INACTIVE
log_time.LogUeTime(ue.GetMsin(), "SM5G_PDU_SESSION_INACTIVE")
}

func (ue *UEContext) SetStateSM_PDU_SESSION_ACTIVE() {
ue.StateSM = SM5G_PDU_SESSION_ACTIVE
log_time.LogUeTime(ue.GetMsin(), "SM5G_PDU_SESSION_ACTIVE")
}

func (ue *UEContext) SetStateSM_PDU_SESSION_PENDING() {
ue.StateSM = SM5G_PDU_SESSION_ACTIVE_PENDING
log_time.LogUeTime(ue.GetMsin(), "SM5G_PDU_SESSION_ACTIVE_PENDING")
}

func (ue *UEContext) SetStateMM_DEREGISTERED_INITIATED() {
ue.StateMM = MM5G_DEREGISTERED_INIT
log_time.LogUeTime(ue.GetMsin(), "MM5G_DEREGISTERED_INIT")
}

func (ue *UEContext) SetStateMM_MM5G_SERVICE_REQ_INIT() {
ue.StateMM = MM5G_SERVICE_REQ_INIT
log_time.LogUeTime(ue.GetMsin(), "MM5G_SERVICE_REQ_INIT")
}

func (ue *UEContext) SetStateMM_REGISTERED_INITIATED() {
ue.StateMM = MM5G_REGISTERED_INITIATED
log_time.LogUeTime(ue.GetMsin(), "MM5G_REGISTERED_INITIATED")
}

func (ue *UEContext) SetStateMM_REGISTERED() {
ue.StateMM = MM5G_REGISTERED
log_time.LogUeTime(ue.GetMsin(), "MM5G_REGISTERED")
}

func (ue *UEContext) SetStateMM_NULL() {
ue.StateMM = MM5G_NULL
log_time.LogUeTime(ue.GetMsin(), "MM5G_NULL")
}

func (ue *UEContext) SetStateMM_DEREGISTERED() {
ue.StateMM = MM5G_DEREGISTERED
log_time.LogUeTime(ue.GetMsin(), "MM5G_DEREGISTERED")
}

func (ue *UEContext) GetStateSM() int {
Expand Down Expand Up @@ -234,7 +245,7 @@ func (ue *UEContext) GetGnbIp() net.IP {
return ue.PduSession.ueGnbIP
}

func (ue *UEContext) GetPduSesssionId() uint8 {
func (ue *UEContext) GetPduSesssionId() int64 {
return ue.PduSession.Id
}

Expand Down
5 changes: 4 additions & 1 deletion internal/control_test_engine/ue/data/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"github.com/vishvananda/netlink"
"my5G-RANTester/internal/control_test_engine/ue/context"
"net"

log_time "my5G-RANTester/internal/analytics/log_time"
)

func InitDataPlane(ue *context.UEContext, message []byte) {
Expand Down Expand Up @@ -84,9 +86,10 @@ func InitDataPlane(ue *context.UEContext, message []byte) {

log.Info("[UE][DATA] UE is ready for using data plane")

log_time.LogUeTime(ue.GetMsin(), "DataPlaneReady")

// contex of tun interface
ue.SetTunInterface(newInterface)
ue.SetTunRoute(ueRoute)
ue.SetTunRule(ueRule)

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func GetRegistrationRequest(registrationType uint8, requestedNSSAI *nasType.Requ
registrationRequest.SpareHalfOctetAndSecurityHeaderType.SetSpareHalfOctet(0x00)
registrationRequest.RegistrationRequestMessageIdentity.SetMessageType(nas.MsgTypeRegistrationRequest)
registrationRequest.NgksiAndRegistrationType5GS.SetTSC(nasMessage.TypeOfSecurityContextFlagNative)
registrationRequest.NgksiAndRegistrationType5GS.SetNasKeySetIdentifiler(ue.GetUeId())
registrationRequest.NgksiAndRegistrationType5GS.SetNasKeySetIdentifiler(uint8(ue.GetUeId()))
registrationRequest.NgksiAndRegistrationType5GS.SetRegistrationType5GS(registrationType)
registrationRequest.MobileIdentity5GS = ue.GetSuci()
if capability {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func UlNasTransport(ue *context.UEContext, requestType uint8) ([]byte, error) {
return pdu, nil
}

func getUlNasTransport_PduSessionEstablishmentRequest(pduSessionId uint8, requestType uint8, dnnString string, sNssai *models.Snssai) (nasPdu []byte) {
func getUlNasTransport_PduSessionEstablishmentRequest(pduSessionId int64, requestType uint8, dnnString string, sNssai *models.Snssai) (nasPdu []byte) {

pduSessionEstablishmentRequest := sm_5gs.GetPduSessionEstablishmentRequest(pduSessionId)

Expand All @@ -41,7 +41,7 @@ func getUlNasTransport_PduSessionEstablishmentRequest(pduSessionId uint8, reques
ulNasTransport.ExtendedProtocolDiscriminator.SetExtendedProtocolDiscriminator(nasMessage.Epd5GSMobilityManagementMessage)
ulNasTransport.PduSessionID2Value = new(nasType.PduSessionID2Value)
ulNasTransport.PduSessionID2Value.SetIei(nasMessage.ULNASTransportPduSessionID2ValueType)
ulNasTransport.PduSessionID2Value.SetPduSessionID2Value(pduSessionId)
ulNasTransport.PduSessionID2Value.SetPduSessionID2Value(uint8(pduSessionId))
ulNasTransport.RequestType = new(nasType.RequestType)
ulNasTransport.RequestType.SetIei(nasMessage.ULNASTransportRequestTypeType)
ulNasTransport.RequestType.SetRequestTypeValue(requestType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"my5G-RANTester/lib/nas/nasType"
)

func GetPduSessionEstablishmentRequest(pduSessionId uint8) (nasPdu []byte) {
func GetPduSessionEstablishmentRequest(pduSessionId int64) (nasPdu []byte) {

m := nas.NewMessage()
m.GsmMessage = nas.NewGsmMessage()
Expand All @@ -18,7 +18,7 @@ func GetPduSessionEstablishmentRequest(pduSessionId uint8) (nasPdu []byte) {
pduSessionEstablishmentRequest := nasMessage.NewPDUSessionEstablishmentRequest(0)
pduSessionEstablishmentRequest.ExtendedProtocolDiscriminator.SetExtendedProtocolDiscriminator(nasMessage.Epd5GSSessionManagementMessage)
pduSessionEstablishmentRequest.SetMessageType(nas.MsgTypePDUSessionEstablishmentRequest)
pduSessionEstablishmentRequest.PDUSessionID.SetPDUSessionID(pduSessionId)
pduSessionEstablishmentRequest.PDUSessionID.SetPDUSessionID(uint8(pduSessionId))
pduSessionEstablishmentRequest.PTI.SetPTI(0x01)
pduSessionEstablishmentRequest.IntegrityProtectionMaximumDataRate.SetMaximumDataRatePerUEForUserPlaneIntegrityProtectionForDownLink(0xff)
pduSessionEstablishmentRequest.IntegrityProtectionMaximumDataRate.SetMaximumDataRatePerUEForUserPlaneIntegrityProtectionForUpLink(0xff)
Expand Down
2 changes: 1 addition & 1 deletion internal/control_test_engine/ue/nas/message/sender/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
)

func SendToGnb(ue *context.UEContext, message []byte) {

conn := ue.GetUnixConn()

_, err := conn.Write(message)
if err != nil {
fmt.Println("Tratar o erro")
Expand Down
1 change: 0 additions & 1 deletion internal/control_test_engine/ue/nas/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ func InitConn(ue *context.UEContext) error {
return nil
}

// ue listen unix sockets.
func UeListen(ue *context.UEContext) {

buf := make([]byte, 65535)
Expand Down
1 change: 0 additions & 1 deletion internal/control_test_engine/ue/nas/trigger/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
)

func InitRegistration(ue *context.UEContext) {

// registration procedure started.
registrationRequest := mm_5gs.GetRegistrationRequest(
nasMessage.RegistrationType5GSInitialRegistration,
Expand Down
4 changes: 3 additions & 1 deletion internal/control_test_engine/ue/state/dispatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import (
func DispatchState(ue *context.UEContext, message []byte) {

// if state is PDU session inactive send to analyze NAS
switch ue.GetStateSM() {
var state = ue.GetStateSM()

switch state {

case context.SM5G_PDU_SESSION_INACTIVE:
nas.DispatchNas(ue, message)
Expand Down
9 changes: 2 additions & 7 deletions internal/control_test_engine/ue/ue.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ import (
"time"
)

func RegistrationUe(conf config.Config, id uint8, wg *sync.WaitGroup) {

// wg := sync.WaitGroup{}
func RegistrationUe(conf config.Config, id int64, wg *sync.WaitGroup) {

// new UE instance.
ue := &context.UEContext{}
Expand Down Expand Up @@ -50,8 +48,6 @@ func RegistrationUe(conf config.Config, id uint8, wg *sync.WaitGroup) {
// registration procedure started.
trigger.InitRegistration(ue)

// wg.Wait()

// control the signals
sigUe := make(chan os.Signal, 1)
signal.Notify(sigUe, os.Interrupt)
Expand All @@ -61,11 +57,10 @@ func RegistrationUe(conf config.Config, id uint8, wg *sync.WaitGroup) {
ue.Terminate()
wg.Done()
// os.Exit(0)

}

func RegistrationUeMonitor(conf config.Config,
id uint8, monitor *monitoring.Monitor, wg *sync.WaitGroup, start time.Time) {
id int64, monitor *monitoring.Monitor, wg *sync.WaitGroup, start time.Time) {

// new UE instance.
ue := &context.UEContext{}
Expand Down
51 changes: 51 additions & 0 deletions internal/templates/test-multi-ues-in-parallel.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package templates

import (
log "github.com/sirupsen/logrus"
"my5G-RANTester/config"
"my5G-RANTester/internal/control_test_engine/gnb"
"my5G-RANTester/internal/control_test_engine/ue"
"sync"
"time"

log_time "my5G-RANTester/internal/analytics/log_time"
"strconv"
)

func TestMultiUesInParallel(numUes int, delayUes int, delayStart int, showAnalytics bool) {

wg := sync.WaitGroup{}

cfg, err := config.GetConfig()
if err != nil {
//return nil
log.Fatal("Error in get configuration")
}

gnbid, err := strconv.Atoi(cfg.GNodeB.PlmnList.GnbId) // Parse gNB ID
log_time.SetGnodebId(gnbid) // Set gNB ID
log_time.ChangeAnalyticsState(showAnalytics) // Enable/Disable analytics

go gnb.InitGnb(cfg, &wg)

wg.Add(1)

time.Sleep(time.Duration(delayStart) * time.Second)
msin := cfg.Ue.Msin

for i := 1; i <= numUes; i++ {
go registerSingleUe(cfg, wg, msin, i)
time.Sleep(time.Duration(delayUes) * time.Millisecond)
}

wg.Wait()
}

func registerSingleUe(cfg config.Config, wg sync.WaitGroup, msin string, i int) {
imsi := imsiGenerator(i, msin)
log.Info("[TESTER] TESTING REGISTRATION USING IMSI ", imsi, " UE")
cfg.Ue.Msin = imsi
log_time.LogUeTime(imsi, "StartRegistration")
go ue.RegistrationUe(cfg, int64(i), &wg)
//wg.Add(1)
}
2 changes: 1 addition & 1 deletion internal/templates/test-multi-ues-in-queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestMultiUesInQueue(numUes int) {
imsi := imsiGenerator(i, msin)
log.Info("[TESTER] TESTING REGISTRATION USING IMSI ", imsi, " UE")
cfg.Ue.Msin = imsi
go ue.RegistrationUe(cfg, uint8(i), &wg)
go ue.RegistrationUe(cfg, int64(i), &wg)
wg.Add(1)

time.Sleep(10 * time.Second)
Expand Down
2 changes: 1 addition & 1 deletion internal/templates/test-ue-latency-in-interval.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestUesLatencyInInterval(interval int) int64 {

time.Sleep(400 * time.Millisecond)

go ue.RegistrationUeMonitor(cfg, uint8(i), &monitor, &wg, start)
go ue.RegistrationUeMonitor(cfg, int64(i), &monitor, &wg, start)

wg.Add(1)

Expand Down