Skip to content

Commit

Permalink
monitor pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
muriloAvlis committed Apr 22, 2024
1 parent 8db7560 commit ed4f6c6
Show file tree
Hide file tree
Showing 4 changed files with 228 additions and 60 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.22.2
require (
github.com/atomix/atomix/api v0.8.0
github.com/gogo/protobuf v1.3.2
github.com/google/uuid v1.6.0
github.com/onosproject/onos-api/go v0.10.31
github.com/onosproject/onos-e2-sm/servicemodels/e2sm_rsm v0.8.43
github.com/onosproject/onos-lib-go v0.10.24
Expand All @@ -28,7 +29,6 @@ require (
github.com/golang/mock v1.6.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
github.com/hashicorp/go-uuid v1.0.2 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
Expand Down
176 changes: 172 additions & 4 deletions pkg/monitoring/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ package monitoring

import (
"context"
"fmt"

"github.com/google/uuid"
e2api "github.com/onosproject/onos-api/go/onos/e2t/e2/v1beta1"
topoapi "github.com/onosproject/onos-api/go/onos/topo"
uenib_api "github.com/onosproject/onos-api/go/onos/uenib"
e2sm_rsm "github.com/onosproject/onos-e2-sm/servicemodels/e2sm_rsm/v1/e2sm-rsm-ies"
"github.com/onosproject/onos-lib-go/pkg/errors"
"github.com/onosproject/onos-lib-go/pkg/logging"
"google.golang.org/protobuf/proto"
)
Expand All @@ -14,7 +18,7 @@ var log = logging.GetLogger("iqos-xapp", "monitoring")

// Return a new Monitor
func NewMonitor(config Config) *Monitor {
// set log level
// set log level (TODO: remove me)
log.SetLevel(logging.DebugLevel)

return &Monitor{
Expand Down Expand Up @@ -86,15 +90,179 @@ func (m *Monitor) processIndication(ctx context.Context, indMsg e2api.Indication

// Process indication message on format 1
func (m *Monitor) processMetricTypeMessage(_ context.Context, indHdr *e2sm_rsm.E2SmRsmIndicationHeaderFormat1, indMsg *e2sm_rsm.E2SmRsmIndicationMessageFormat1) error {
// TODO: use it to ensure elastic slice
log.Warnf("Received indication message (Metric) hdr: %v / msg: %v", indHdr, indMsg)
// TODO: use it to ensure slice's elasticity
log.Debugf("Received indication message (Metric) hdr: %v / msg: %v", indHdr, indMsg)

return nil
}

// Process indication message on format 2
func (m *Monitor) processEmmEventMessage(ctx context.Context, indHdr *e2sm_rsm.E2SmRsmIndicationHeaderFormat1, indMsg *e2sm_rsm.E2SmRsmIndicationMessageFormat2, cuNodeID string) error {
log.Warnf("Received indication message (EMM) hdr: %v / msg: %v", indHdr, indMsg)
log.Debugf("Received indication message (EMM) hdr: %v / msg: %v", indHdr, indMsg)

// UE's identify technology
var CuUeF1apID, DuUeF1apID, RanUeNgapID, AmfUeNgapID int64
var EnbUeS1apID int32
bIDList := make([]*uenib_api.BearerId, 0)

duNodeID, err := m.rnibClient.GetTargetDUE2NodeID(ctx, topoapi.ID(cuNodeID)) // get DU by CU ID
log.Debugf("Cu ID %v - Du ID %v", cuNodeID, duNodeID)
if err != nil {
log.Warn(err)
return err
}

for _, ID := range indMsg.GetUeIdlist() { // checks UE ID type
if ID.GetCuUeF1ApId() != nil {
CuUeF1apID = ID.GetCuUeF1ApId().GetValue()
} else if ID.GetDuUeF1ApId() != nil {
DuUeF1apID = ID.GetDuUeF1ApId().GetValue()
} else if ID.GetRanUeNgapId() != nil {
RanUeNgapID = ID.GetRanUeNgapId().GetValue()
} else if ID.GetAmfUeNgapId() != nil {
AmfUeNgapID = ID.GetAmfUeNgapId().GetValue()
} else if ID.GetEnbUeS1ApId() != nil {
EnbUeS1apID = ID.GetEnbUeS1ApId().GetValue()
} else {
return errors.NewNotFound("UE ID type not found!")
}
}

for _, bID := range indMsg.GetBearerId() { // checks bearer data
if bID.GetDrbId().GetFiveGdrbId() != nil {
// for 5G
flowMapToDrb := make([]*uenib_api.QoSflowLevelParameters, 0) // QoS param. list

for _, fItem := range bID.GetDrbId().GetFiveGdrbId().GetFlowsMapToDrb() { // Get 5QI
if fItem.GetNonDynamicFiveQi() != nil { // for not dinamic 5QI
flowMapToDrb = append(flowMapToDrb, &uenib_api.QoSflowLevelParameters{
QosFlowLevelParameters: &uenib_api.QoSflowLevelParameters_NonDynamicFiveQi{
NonDynamicFiveQi: &uenib_api.NonDynamicFiveQi{
FiveQi: &uenib_api.FiveQi{
Value: fItem.GetNonDynamicFiveQi().GetFiveQi().GetValue(),
},
},
},
})
} else if fItem.GetDynamicFiveQi() != nil { // for dinamic 5QI
flowMapToDrb = append(flowMapToDrb, &uenib_api.QoSflowLevelParameters{
QosFlowLevelParameters: &uenib_api.QoSflowLevelParameters_DynamicFiveQi{
DynamicFiveQi: &uenib_api.DynamicFiveQi{
PriorityLevel: fItem.GetDynamicFiveQi().GetPriorityLevel(),
PacketDelayBudge: fItem.GetDynamicFiveQi().GetPacketDelayBudget(),
PacketErrorRate: fItem.GetDynamicFiveQi().GetPacketErrorRate(),
},
},
})
}
}
uenibBID := uenib_api.BearerId{ // creates bearer ID with 5QI values
BearerId: &uenib_api.BearerId_DrbId{
DrbId: &uenib_api.DrbId{
DrbId: &uenib_api.DrbId_FiveGdrbId{
FiveGdrbId: &uenib_api.FiveGDrbId{
Value: bID.GetDrbId().GetFiveGdrbId().GetValue(),
Qfi: &uenib_api.Qfi{
Value: bID.GetDrbId().GetFiveGdrbId().GetQfi().GetValue(),
},
FlowsMapToDrb: flowMapToDrb,
},
},
},
},
}
bIDList = append(bIDList, &uenibBID)
} else if bID.GetDrbId().GetFourGdrbId() != nil {
// for 4G
uenibBID := uenib_api.BearerId{ // creates bearer ID with 4G values
BearerId: &uenib_api.BearerId_DrbId{
DrbId: &uenib_api.DrbId{
DrbId: &uenib_api.DrbId_FourGdrbId{
FourGdrbId: &uenib_api.FourGDrbId{
Value: bID.GetDrbId().GetFourGdrbId().GetValue(),
Qci: &uenib_api.Qci{
Value: bID.GetDrbId().GetFourGdrbId().GetQci().GetValue(),
},
},
},
},
},
}
bIDList = append(bIDList, &uenibBID)
}
}

switch indMsg.GetTriggerType() {
case e2sm_rsm.RsmEmmTriggerType_RSM_EMM_TRIGGER_TYPE_UE_ATTACH, e2sm_rsm.RsmEmmTriggerType_RSM_EMM_TRIGGER_TYPE_HAND_IN_UE_ATTACH:
// UE entry into the network
// TODO: Add logic to get GlobalUEID here after SMO is integrated - future

rsmUE := uenib_api.RsmUeInfo{ // creates a new RSM UE
GlobalUeID: "iqos-" + uuid.New().String(),
UeIdList: &uenib_api.UeIdentity{
CuUeF1apID: &uenib_api.CuUeF1ApID{
Value: CuUeF1apID,
},
DuUeF1apID: &uenib_api.DuUeF1ApID{
Value: DuUeF1apID,
},
RANUeNgapID: &uenib_api.RanUeNgapID{
Value: RanUeNgapID,
},
AMFUeNgapID: &uenib_api.AmfUeNgapID{
Value: AmfUeNgapID,
},
EnbUeS1apID: &uenib_api.EnbUeS1ApID{
Value: EnbUeS1apID,
},
},
BearerIdList: bIDList,
CellGlobalId: indHdr.GetCgi().String(),
CuE2NodeId: cuNodeID,
DuE2NodeId: string(duNodeID),
SliceList: make([]*uenib_api.SliceInfo, 0),
}
err := m.uenibClient.AddRsmUE(ctx, &rsmUE) // stores UE into UE-NIB
if err != nil {
return err
}

log.Debugf("pushed rsmUE: %v", rsmUE)

case e2sm_rsm.RsmEmmTriggerType_RSM_EMM_TRIGGER_TYPE_UE_DETACH, e2sm_rsm.RsmEmmTriggerType_RSM_EMM_TRIGGER_TYPE_HAND_OUT_UE_ATTACH:
// UE exit from the network
switch indMsg.GetPrefferedUeIdtype() { // checks UE ID type and delete it
case e2sm_rsm.UeIdType_UE_ID_TYPE_CU_UE_F1_AP_ID:
err := m.uenibClient.DeleteRsmUEWithPreferredID(ctx, cuNodeID, uenib_api.UeIdType_UE_ID_TYPE_CU_UE_F1_AP_ID, CuUeF1apID)
if err != nil {
return err
}
case e2sm_rsm.UeIdType_UE_ID_TYPE_DU_UE_F1_AP_ID:
err := m.uenibClient.DeleteRsmUEWithPreferredID(ctx, cuNodeID, uenib_api.UeIdType_UE_ID_TYPE_DU_UE_F1_AP_ID, DuUeF1apID)
if err != nil {
return err
}
case e2sm_rsm.UeIdType_UE_ID_TYPE_RAN_UE_NGAP_ID:
err := m.uenibClient.DeleteRsmUEWithPreferredID(ctx, cuNodeID, uenib_api.UeIdType_UE_ID_TYPE_RAN_UE_NGAP_ID, RanUeNgapID)
if err != nil {
return err
}
case e2sm_rsm.UeIdType_UE_ID_TYPE_AMF_UE_NGAP_ID:
err := m.uenibClient.DeleteRsmUEWithPreferredID(ctx, cuNodeID, uenib_api.UeIdType_UE_ID_TYPE_AMF_UE_NGAP_ID, AmfUeNgapID)
if err != nil {
return err
}
case e2sm_rsm.UeIdType_UE_ID_TYPE_ENB_UE_S1_AP_ID:
err := m.uenibClient.DeleteRsmUEWithPreferredID(ctx, cuNodeID, uenib_api.UeIdType_UE_ID_TYPE_ENB_UE_S1_AP_ID, int64(EnbUeS1apID))
if err != nil {
return err
}
default:
return errors.NewNotSupported(fmt.Sprintf("Unknown preferred ID type: %v", indMsg.GetPrefferedUeIdtype())) // UE ID type unknown
}
default:
return errors.NewNotSupported(fmt.Sprintf("Unknown EMM trigger type: %v", indMsg.GetTriggerType())) // Event trigger type unknown
}

return nil
}
Loading

0 comments on commit ed4f6c6

Please sign in to comment.