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

SDCORE-490: Add PDU Session Est support in Real UE, Sim Ue and Profile #12

Merged
merged 1 commit into from
Sep 21, 2021
Merged
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
36 changes: 35 additions & 1 deletion common/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ const (
// Following events are numbered same as the NAS Message types in section 9.7 of
// 3GPP TS 24.501

// 5GS Mobility Management events.
const UE_5GS_MOBILITY_MANAGEMENT_EVENTS EventType = 64
const UE_5GS_SESSION_MANAGEMENT_EVENTS EventType = 192

// 5GS Mobility Management events.
const (
_ EventType = UE_5GS_MOBILITY_MANAGEMENT_EVENTS + iota

Expand All @@ -54,6 +56,38 @@ const (
SEC_MOD_COMMAND_EVENT
SEC_MOD_COMPLETE_EVENT
SEC_MOD_REJECT_EVENT //95

FIVE_GMM_STATUS_EVENT = UE_5GS_MOBILITY_MANAGEMENT_EVENTS + 14 + iota //86
NOTIFICATION_EVENT
NOTIFICATION_RESPONSE_EVENT
UL_NAS_TRANSPORT_EVENT
DL_NAS_TRANSPORT_EVENT
)

// 5GS Session Management events.
const (
_ EventType = UE_5GS_SESSION_MANAGEMENT_EVENTS + iota

PDU_SESS_EST_REQUEST_EVENT //93
PDU_SESS_EST_ACCEPT_EVENT
PDU_SESS_EST_REJECT_EVENT

PDU_SESS_AUTH_COMMAND_EVENT = UE_5GS_SESSION_MANAGEMENT_EVENTS + 1 + iota
PDU_SESS_AUTH_COMPLETE_EVENT
PDU_SESS_AUTH_RESULT_EVENT

PDU_SESS_MOD_REQUEST_EVENT = UE_5GS_SESSION_MANAGEMENT_EVENTS + 2 + iota
PDU_SESS_MOD_REJECT_EVENT
PDU_SESS_MOD_COMMAND_EVENT
PDU_SESS_MOD_COMPLETE_EVENT
PDU_SESS_MOD_CMD_REJECT_EVENT

PDU_SESS_REL_REQUEST_EVENT = UE_5GS_SESSION_MANAGEMENT_EVENTS + 5 + iota
PDU_SESS_REL_REJECT_EVENT
PDU_SESS_REL_COMMAND_EVENT
PDU_SESS_REL_COMPLETE_EVENT

FIVEGSM_STATUS_EVENT = UE_5GS_SESSION_MANAGEMENT_EVENTS + 6 + iota
)

// Events between GNodeB and AMF (N2)
Expand Down
1 change: 1 addition & 0 deletions common/procedures.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ type ProcedureType uint8

const (
REGISTRATION_PROCEDURE ProcedureType = 1 + iota
PDU_SESSION_ESTABLISHMENT_PROCEDURE
)
9 changes: 9 additions & 0 deletions config/gnbsim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ configuration:
gnbName: gnb1 # gNB to be used for this profile
startImsi: imsi-2089300007487
ueCount: 1
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)
- profileType: pdusessest # profile type
profileName: profile2 # uniqely identifies a profile within application
enable: false # Set true to execute the profile, false otherwise.
gnbName: gnb1 # gNB to be used for this profile
startImsi: imsi-2089300007487
ueCount: 1
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)
5 changes: 5 additions & 0 deletions gnbsim.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"gnbsim/logger"
"gnbsim/profile"
"gnbsim/profile/ngsetup"
"gnbsim/profile/pdusessest"
"gnbsim/profile/register"
)

Expand Down Expand Up @@ -45,6 +46,10 @@ func main() {
{
register.Register_test(profileCtx)
}
case "pdusessest":
{
pdusessest.PduSessEst_test(profileCtx)
}
case "deregister":
{
//deregister.Deregister_test(ranIpAddr, amfIpAddr)
Expand Down
61 changes: 61 additions & 0 deletions profile/pdusessest/pdusessest.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// SPDX-FileCopyrightText: 2021 Open Networking Foundation <info@opennetworking.org>
//
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0

package pdusessest

import (
"gnbsim/common"
"gnbsim/factory"
profctx "gnbsim/profile/context"
"gnbsim/profile/util"
"gnbsim/simue"
simuectx "gnbsim/simue/context"
"time"
// AJAY - Change required
)

func PduSessEst_test(profile *profctx.Profile) {
initEventMap(profile)
initProcedureList(profile)

gnb, err := factory.AppConfig.Configuration.GetGNodeB(profile.GnbName)
if err != nil {
profile.Log.Errorln("GetGNodeB returned:", err)
}

simUe := simuectx.NewSimUe(profile.StartImsi, gnb, profile)
go simue.Init(simUe)
util.SendToSimUe(simUe, common.PROFILE_START_EVENT)
msg := <-profile.ReadChan
switch msg.Event {
case common.PROFILE_PASS_EVENT:
profile.Log.Infoln("Result: PASS, SimUe:", msg.Supi)
case common.PROFILE_FAIL_EVENT:
profile.Log.Infoln("Result: FAIL, SimUe:", msg.Supi, "Failed Procedure:",
msg.Proc, "Error:", msg.ErrorMsg)
}

time.Sleep(2 * time.Second)
}

// initEventMap initializes the event map of profile with default values as per
// the procedures in the profile
func initEventMap(profile *profctx.Profile) {
profile.Events = map[common.EventType]common.EventType{
common.REG_REQUEST_EVENT: common.AUTH_REQUEST_EVENT,
common.AUTH_REQUEST_EVENT: common.AUTH_RESPONSE_EVENT,
common.SEC_MOD_COMMAND_EVENT: common.SEC_MOD_COMPLETE_EVENT,
common.REG_ACCEPT_EVENT: common.REG_COMPLETE_EVENT,
common.PDU_SESS_EST_REQUEST_EVENT: common.PDU_SESS_EST_ACCEPT_EVENT,
common.PDU_SESS_EST_ACCEPT_EVENT: common.PDU_SESS_EST_ACCEPT_EVENT,
}
}

func initProcedureList(profile *profctx.Profile) {
profile.Procedures = []common.ProcedureType{
common.REGISTRATION_PROCEDURE,
common.PDU_SESSION_ESTABLISHMENT_PROCEDURE,
}
}
45 changes: 45 additions & 0 deletions realue/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/free5gc/nas/nasMessage"
"github.com/free5gc/nas/nasTestpacket"
"github.com/free5gc/nas/nasType"
"github.com/free5gc/openapi/models"
"github.com/omec-project/nas"
)

Expand Down Expand Up @@ -113,6 +114,34 @@ func HandleRegCompleteEvent(ue *context.RealUe, msg *common.UuMessage) (err erro
return nil
}

func HandlePduSessEstRequestEvent(ue *context.RealUe, msg *common.UuMessage) (err error) {
ue.Log.Traceln("Handling PDU Session Establishment Request Event")

sNssai := models.Snssai{
Sst: 1,
Sd: "010203",
}
nasPdu := nasTestpacket.GetUlNasTransport_PduSessionEstablishmentRequest(10,
nasMessage.ULNASTransportRequestTypeInitialRequest, "internet", &sNssai)

nasPdu, err = test.EncodeNasPduWithSecurity(ue, nasPdu,
nas.SecurityHeaderTypeIntegrityProtectedAndCiphered, true, false)
if err != nil {
fmt.Println("Failed to encrypt PDU Session Establishment Request Message", err)
return
}

SendToSimUe(ue, common.PDU_SESS_EST_REQUEST_EVENT, nasPdu, nil)
ue.Log.Traceln("Sent Registration Complete Message to SimUe")
return nil
}

func HandlePduSessEstAcceptEvent(ue *context.RealUe, msg *common.UuMessage) (err error) {
ue.Log.Traceln("Handling PDU Session Establishment Accept Event")
//create new pdu session var and parse msg to pdu session var
return nil
}

func HandleDlInfoTransferEvent(ue *context.RealUe, msg *common.UuMessage) (err error) {
ue.Log.Traceln("Handling Downlink Nas Transport Event")
pdu := msg.NasPdu
Expand All @@ -124,6 +153,22 @@ func HandleDlInfoTransferEvent(ue *context.RealUe, msg *common.UuMessage) (err e
msgType := nasMsg.GmmHeader.GetMessageType()
ue.Log.Infoln("Received Message Type:", msgType)

if msgType == nas.MsgTypeDLNASTransport {
ue.Log.Info("Payload contaner type:",
nasMsg.GmmMessage.DLNASTransport.SpareHalfOctetAndPayloadContainerType)
payload := nasMsg.GmmMessage.DLNASTransport.PayloadContainer
buffer := payload.Buffer[:payload.Len]
m := nas.NewMessage()
err := m.PlainNasDecode(&buffer)
if err != nil {
ue.Log.Errorln("PlainNasDecode returned:", err)
return fmt.Errorf("failed to decode payload container")
}
nasMsg = m
msgType = nasMsg.GsmHeader.GetMessageType()

}

event := common.EventType(msgType)

// Simply notify SimUe about the received nas message. Later SimUe will
Expand Down
4 changes: 4 additions & 0 deletions realue/realue.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ func HandleEvent(ue *context.RealUe, msg *common.UuMessage) (err error) {
err = HandleRegCompleteEvent(ue, msg)
case common.DL_INFO_TRANSFER_EVENT:
err = HandleDlInfoTransferEvent(ue, msg)
case common.PDU_SESS_EST_REQUEST_EVENT:
err = HandlePduSessEstRequestEvent(ue, msg)
case common.PDU_SESS_EST_ACCEPT_EVENT:
err = HandlePduSessEstAcceptEvent(ue, msg)
default:
ue.Log.Infoln("Event", msg.Event, "is not supported")
}
Expand Down
39 changes: 39 additions & 0 deletions simue/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ func HandleAuthResponseEvent(ue *context.SimUe, msg *common.UuMessage) (err erro

func HandleSecModCommandEvent(ue *context.SimUe, msg *common.UuMessage) (err error) {
ue.Log.Traceln("Handling Security Mode Command Event")
// TODO: Should check if SecModCommandEvent event is expected

nextEvent, err := ue.ProfileCtx.GetNextEvent(msg.Event)
if err != nil {
ue.Log.Errorln("GetNextEvent returned:", err)
Expand Down Expand Up @@ -91,6 +93,7 @@ func HandleSecModCompleteEvent(ue *context.SimUe, msg *common.UuMessage) (err er

func HandleRegAcceptEvent(ue *context.SimUe, msg *common.UuMessage) (err error) {
ue.Log.Traceln("Handling Registration Accept Event")
// TODO: Should check if Registration Accept event is expected
nextEvent, err := ue.ProfileCtx.GetNextEvent(msg.Event)
if err != nil {
ue.Log.Errorln("GetNextEvent returned:", err)
Expand Down Expand Up @@ -124,6 +127,42 @@ func HandleRegCompleteEvent(ue *context.SimUe, msg *common.UuMessage) (err error
return nil
}

func HandlePduSessEstRequestEvent(ue *context.SimUe, msg *common.UuMessage) (err error) {
ue.Log.Traceln("Handling PDU Session Establishment Request Event")
SendToGnbUe(ue, msg)
msg.Event = common.UL_INFO_TRANSFER_EVENT
ue.Log.Traceln("Sent PDU Session Establishment Request to GnbUe")
return nil
}

func HandlePduSessEstAcceptEvent(ue *context.SimUe, msg *common.UuMessage) (err error) {
ue.Log.Traceln("Handling PDU Session Establishment Accept Event")
err = ue.ProfileCtx.CheckCurrentEvent(common.PDU_SESS_EST_REQUEST_EVENT, msg.Event)
if err != nil {
ue.Log.Errorln("CheckCurrentEvent returned:", err)
return err
}
nextEvent, err := ue.ProfileCtx.GetNextEvent(msg.Event)
if err != nil {
ue.Log.Errorln("GetNextEvent returned:", err)
return err
}
ue.Log.Infoln("Next Event:", nextEvent)
msg.Event = nextEvent
SendToRealUe(ue, msg)

nextProcedure := ue.ProfileCtx.GetNextProcedure(ue.Procedure)
if nextProcedure != 0 {
ue.Procedure = nextProcedure
ue.Log.Infoln("Updated procedure to", ue.Procedure)
HandleProcedure(ue)
} else {
SendToProfile(ue, common.PROFILE_PASS_EVENT, nil)
ue.Log.Traceln("Sent Profile Pass Event to Profile routine")
}
return nil
}

func HandleDlInfoTransferEvent(ue *context.SimUe, msg *common.UuMessage) (err error) {
ue.Log.Traceln("Handling DL Information Transfer Event")
SendToRealUe(ue, msg)
Expand Down
6 changes: 4 additions & 2 deletions simue/simue.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ func HandleEvent(ue *context.SimUe, msg common.InterfaceMessage) (err error) {
err = HandleRegAcceptEvent(ue, uuMsg)
case common.REG_COMPLETE_EVENT:
err = HandleRegCompleteEvent(ue, uuMsg)
case common.DL_INFO_TRANSFER_EVENT:
err = HandleDlInfoTransferEvent(ue, uuMsg)
case common.PDU_SESS_EST_REQUEST_EVENT:
err = HandlePduSessEstRequestEvent(ue, uuMsg)
case common.PDU_SESS_EST_ACCEPT_EVENT:
err = HandlePduSessEstAcceptEvent(ue, uuMsg)
default:
ue.Log.Infoln("Event", uuMsg.Event, "is not supported")
}
Expand Down