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

Scenario manager #121

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion cmd/packetrusher.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func main() {
&cli.IntFlag{Name: "timeBeforeIdle", Value: 0, Aliases: []string{"idl"}, Usage: "The time in ms, before switching UE to Idle. 0 to disable Idling."},
&cli.IntFlag{Name: "timeBeforeReconnecting", Value: 1000, Aliases: []string{"tbr"}, Usage: "The time in ms, before reconnecting to gNodeB after switching to Idle state. Default is 1000 ms. Only work in conjunction with timeBeforeIdle."},
&cli.IntFlag{Name: "numPduSessions", Value: 1, Aliases: []string{"nPdu"}, Usage: "The number of PDU Sessions to create"},
&cli.BoolFlag{Name: "loop", Aliases: []string{"l"}, Usage: "Register UEs in a loop."},
&cli.BoolFlag{Name: "loop", Aliases: []string{"l"}, Usage: "Loop over all procedures."},
&cli.BoolFlag{Name: "tunnel", Aliases: []string{"t"}, Usage: "Enable the creation of the GTP-U tunnel interface."},
&cli.BoolFlag{Name: "tunnel-vrf", Value: true, Usage: "Enable/disable VRP usage of the GTP-U tunnel interface."},
&cli.BoolFlag{Name: "dedicatedGnb", Aliases: []string{"d"}, Usage: "Enable the creation of a dedicated gNB per UE. Require one IP on N2/N3 per gNB."},
Expand Down
18 changes: 9 additions & 9 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,24 +195,24 @@ func setLogLevel(cfg Config) {

}

func (config *Config) GetUESecurityCapability() *nasType.UESecurityCapability {
func (ue *Ue) GetUESecurityCapability() *nasType.UESecurityCapability {
UESecurityCapability := &nasType.UESecurityCapability{
Iei: nasMessage.RegistrationRequestUESecurityCapabilityType,
Len: 2,
Buffer: []uint8{0x00, 0x00},
}

// Ciphering algorithms
UESecurityCapability.SetEA0_5G(boolToUint8(config.Ue.Ciphering.Nea0))
UESecurityCapability.SetEA1_128_5G(boolToUint8(config.Ue.Ciphering.Nea1))
UESecurityCapability.SetEA2_128_5G(boolToUint8(config.Ue.Ciphering.Nea2))
UESecurityCapability.SetEA3_128_5G(boolToUint8(config.Ue.Ciphering.Nea3))
UESecurityCapability.SetEA0_5G(boolToUint8(ue.Ciphering.Nea0))
UESecurityCapability.SetEA1_128_5G(boolToUint8(ue.Ciphering.Nea1))
UESecurityCapability.SetEA2_128_5G(boolToUint8(ue.Ciphering.Nea2))
UESecurityCapability.SetEA3_128_5G(boolToUint8(ue.Ciphering.Nea3))

// Integrity algorithms
UESecurityCapability.SetIA0_5G(boolToUint8(config.Ue.Integrity.Nia0))
UESecurityCapability.SetIA1_128_5G(boolToUint8(config.Ue.Integrity.Nia1))
UESecurityCapability.SetIA2_128_5G(boolToUint8(config.Ue.Integrity.Nia2))
UESecurityCapability.SetIA3_128_5G(boolToUint8(config.Ue.Integrity.Nia3))
UESecurityCapability.SetIA0_5G(boolToUint8(ue.Integrity.Nia0))
UESecurityCapability.SetIA1_128_5G(boolToUint8(ue.Integrity.Nia1))
UESecurityCapability.SetIA2_128_5G(boolToUint8(ue.Integrity.Nia2))
UESecurityCapability.SetIA3_128_5G(boolToUint8(ue.Integrity.Nia3))

return UESecurityCapability
}
Expand Down
2 changes: 1 addition & 1 deletion config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ amfif:
- ip: "192.168.11.30"
port: 38412
logs:
level: 4
level: 4
4 changes: 2 additions & 2 deletions internal/common/tools/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func CreateGnbs(count int, cfg config.Config, wg *sync.WaitGroup) map[string]*gn
cfg.GNodeB.ControlIF.Ip = n2Ip
cfg.GNodeB.DataIF.Ip = n3Ip

gnbs[cfg.GNodeB.PlmnList.GnbId] = gnb.InitGnb(cfg, wg)
gnbs[cfg.GNodeB.PlmnList.GnbId] = gnb.InitGnb(cfg.GNodeB, cfg.AMFs, wg)
wg.Add(1)

// TODO: We could find the interfaces where N2/N3 are
Expand Down Expand Up @@ -127,7 +127,7 @@ func SimulateSingleUE(simConfig UESimulationConfig, wg *sync.WaitGroup) {

// Create a new UE coroutine
// ue.NewUE returns context of the new UE
ueTx := ue.NewUE(ueCfg, ueId, ueRx, simConfig.Gnbs[gnbIdGen(0)].GetInboundChannel(), wg)
ueTx := ue.NewUE(ueCfg.Ue, ueId, ueRx, simConfig.Gnbs[gnbIdGen(0)].GetInboundChannel(), wg)

// We tell the UE to perform a registration
ueRx <- procedures.UeTesterMessage{Type: procedures.Registration}
Expand Down
24 changes: 12 additions & 12 deletions internal/control_test_engine/gnb/gnb.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,26 @@ import (
log "github.com/sirupsen/logrus"
)

func InitGnb(conf config.Config, wg *sync.WaitGroup) *context.GNBContext {
func InitGnb(gnbConf config.GNodeB, amfConfs []*config.AMF, wg *sync.WaitGroup) *context.GNBContext {

// instance new gnb.
gnb := &context.GNBContext{}

// new gnb context.
gnb.NewRanGnbContext(
conf.GNodeB.PlmnList.GnbId,
conf.GNodeB.PlmnList.Mcc,
conf.GNodeB.PlmnList.Mnc,
conf.GNodeB.PlmnList.Tac,
conf.GNodeB.SliceSupportList.Sst,
conf.GNodeB.SliceSupportList.Sd,
conf.GNodeB.ControlIF.Ip,
conf.GNodeB.DataIF.Ip,
conf.GNodeB.ControlIF.Port,
conf.GNodeB.DataIF.Port)
gnbConf.PlmnList.GnbId,
gnbConf.PlmnList.Mcc,
gnbConf.PlmnList.Mnc,
gnbConf.PlmnList.Tac,
gnbConf.SliceSupportList.Sst,
gnbConf.SliceSupportList.Sd,
gnbConf.ControlIF.Ip,
gnbConf.DataIF.Ip,
gnbConf.ControlIF.Port,
gnbConf.DataIF.Port)

// start communication with AMF (server SCTP).
for _, amfConfig := range conf.AMFs {
for _, amfConfig := range amfConfs {
// new AMF context.
amf := gnb.NewGnBAmf(amfConfig.Ip, amfConfig.Port)

Expand Down
28 changes: 14 additions & 14 deletions internal/control_test_engine/ue/ue.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,27 @@ import (
log "github.com/sirupsen/logrus"
)

func NewUE(conf config.Config, id int, ueMgrChannel chan procedures.UeTesterMessage, gnbInboundChannel chan context2.UEMessage, wg *sync.WaitGroup) chan scenario.ScenarioMessage {
func NewUE(conf config.Ue, id int, ueMgrChannel chan procedures.UeTesterMessage, gnbInboundChannel chan context2.UEMessage, wg *sync.WaitGroup) chan scenario.ScenarioMessage {
// new UE instance.
ue := &context.UEContext{}
scenarioChan := make(chan scenario.ScenarioMessage)

// new UE context
ue.NewRanUeContext(
conf.Ue.Msin,
conf.Msin,
conf.GetUESecurityCapability(),
conf.Ue.Key,
conf.Ue.Opc,
conf.Key,
conf.Opc,
"c9e8763286b5b9ffbdf56e1297d0887b",
conf.Ue.Amf,
conf.Ue.Sqn,
conf.Ue.Hplmn.Mcc,
conf.Ue.Hplmn.Mnc,
conf.Ue.RoutingIndicator,
conf.Ue.Dnn,
int32(conf.Ue.Snssai.Sst),
conf.Ue.Snssai.Sd,
conf.Ue.TunnelMode,
conf.Amf,
conf.Sqn,
conf.Hplmn.Mcc,
conf.Hplmn.Mnc,
conf.RoutingIndicator,
conf.Dnn,
int32(conf.Snssai.Sst),
conf.Snssai.Sd,
conf.TunnelMode,
scenarioChan,
gnbInboundChannel,
id)
Expand All @@ -59,7 +59,7 @@ func NewUE(conf config.Config, id int, ueMgrChannel chan procedures.UeTesterMess
select {
case msg, open := <-ue.GetGnbTx():
if !open {
log.Warn("[UE][", ue.GetMsin(), "] Stopping UE as communication with gNB was closed")
log.Warn("[UE][", ue.GetMsin(), "] communication with gNB was closed")
ue.SetGnbTx(nil)
break
}
Expand Down
17 changes: 17 additions & 0 deletions internal/scenario/scenario.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* SPDX-License-Identifier: Apache-2.0
* © Copyright 2024 Hewlett Packard Enterprise Development LP
*/
package scenario

import (
"my5G-RANTester/config"
)

// Description of the scenario to be run for one UE
type UEScenario struct {
Config config.Ue
Tasks []Task
Loop bool // Restart scenario once done
Persist bool // Keep scenario going after all tasks are done
}
Loading
Loading