6 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
7 "github.com/go-redis/redis"
17 ranList []string //nodeB list
18 eventCreateExpired int32 //maximum time for the RIC Subscription Request event creation procedure in the E2 Node
19 eventDeleteExpired int32 //maximum time for the RIC Subscription Request event deletion procedure in the E2 Node
20 rcChan chan *xapp.RMRParams //channel for receiving rmr message
21 client *redis.Client //redis client
22 eventCreateExpiredMap map[string]bool //map for recording the RIC Subscription Request event creation procedure is expired or not
23 eventDeleteExpiredMap map[string]bool //map for recording the RIC Subscription Request event deletion procedure is expired or not
24 eventCreateExpiredMu *sync.Mutex //mutex for eventCreateExpiredMap
25 eventDeleteExpiredMu *sync.Mutex //mutex for eventDeleteExpiredMap
29 file := "/opt/kpimon.log"
30 logFile, err := os.OpenFile(file, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0766)
34 log.SetOutput(logFile)
35 log.SetPrefix("[qSkipTool]")
36 log.SetFlags(log.LstdFlags | log.Lshortfile | log.LUTC)
37 xapp.Logger.SetLevel(4)
40 func NewControl() Control {
41 str := os.Getenv("ranList")
42 return Control{strings.Split(str, ","),
44 make(chan *xapp.RMRParams),
45 redis.NewClient(&redis.Options{
46 Addr: os.Getenv("redisAddr"), //"localhost:6379"
50 make(map[string]bool),
51 make(map[string]bool),
56 func ReadyCB(i interface{}) {
63 func (c *Control) Run() {
64 _, err := c.client.Ping().Result()
66 xapp.Logger.Error("Failed to connect to Redis DB with %v", err)
67 log.Printf("Failed to connect to Redis DB with %v", err)
69 if len(c.ranList) > 0 {
70 xapp.SetReadyCB(ReadyCB, c)
73 xapp.Logger.Error("gNodeB not set for subscription")
74 log.Printf("gNodeB not set for subscription")
79 func (c *Control) startTimerSubReq() {
80 timerSR := time.NewTimer(5 * time.Second)
83 go func(t *time.Timer) {
88 xapp.Logger.Debug("send RIC_SUB_REQ to gNodeB with cnt=%d", count)
89 log.Printf("send RIC_SUB_REQ to gNodeB with cnt=%d", count)
90 err := c.sendRicSubRequest(1001, 1001, 0)
91 if err != nil && count < MAX_SUBSCRIPTION_ATTEMPTS {
92 t.Reset(5 * time.Second)
100 func (c *Control) Consume(rp *xapp.RMRParams) (err error) {
105 func (c *Control) rmrSend(params *xapp.RMRParams) (err error) {
106 if !xapp.Rmr.Send(params, false) {
107 err = errors.New("rmr.Send() failed")
108 xapp.Logger.Error("Failed to rmrSend to %v", err)
109 log.Printf("Failed to rmrSend to %v", err)
114 func (c *Control) rmrReplyToSender(params *xapp.RMRParams) (err error) {
115 if !xapp.Rmr.Send(params, true) {
116 err = errors.New("rmr.Send() failed")
117 xapp.Logger.Error("Failed to rmrReplyToSender to %v", err)
118 log.Printf("Failed to rmrReplyToSender to %v", err)
123 func (c *Control) controlLoop() {
126 xapp.Logger.Debug("Received message type: %d", msg.Mtype)
127 log.Printf("Received message type: %d", msg.Mtype)
130 c.handleIndication(msg)
132 c.handleSubscriptionResponse(msg)
134 c.handleSubscriptionFailure(msg)
136 c.handleSubscriptionDeleteResponse(msg)
138 c.handleSubscriptionDeleteFailure(msg)
140 err := errors.New("Message Type " + strconv.Itoa(msg.Mtype) + " is discarded")
141 xapp.Logger.Error("Unknown message type: %v", err)
142 log.Printf("Unknown message type: %v", err)
147 func (c *Control) handleIndication(params *xapp.RMRParams) (err error) {
151 indicationMsg, err := e2ap.GetIndicationMessage(params.Payload)
153 xapp.Logger.Error("Failed to decode RIC Indication message: %v", err)
154 log.Printf("Failed to decode RIC Indication message: %v", err)
158 log.Printf("RIC Indication message from {%s} received", params.Meid.RanName)
159 log.Printf("RequestID: %d", indicationMsg.RequestID)
160 log.Printf("RequestSequenceNumber: %d", indicationMsg.RequestSequenceNumber)
161 log.Printf("FunctionID: %d", indicationMsg.FuncID)
162 log.Printf("ActionID: %d", indicationMsg.ActionID)
163 log.Printf("IndicationSN: %d", indicationMsg.IndSN)
164 log.Printf("IndicationType: %d", indicationMsg.IndType)
165 log.Printf("IndicationHeader: %x", indicationMsg.IndHeader)
166 log.Printf("IndicationMessage: %x", indicationMsg.IndMessage)
167 log.Printf("CallProcessID: %x", indicationMsg.CallProcessID)
169 indicationHdr, err := e2sm.GetIndicationHeader(indicationMsg.IndHeader)
171 xapp.Logger.Error("Failed to decode RIC Indication Header: %v", err)
172 log.Printf("Failed to decode RIC Indication Header: %v", err)
181 log.Printf("-----------RIC Indication Header-----------")
182 if indicationHdr.IndHdrType == 1 {
183 log.Printf("RIC Indication Header Format: %d", indicationHdr.IndHdrType)
184 indHdrFormat1 := indicationHdr.IndHdr.(IndicationHeaderFormat1)
186 log.Printf("GlobalKPMnodeIDType: %d", indHdrFormat1.GlobalKPMnodeIDType)
188 if indHdrFormat1.GlobalKPMnodeIDType == 1 {
189 globalKPMnodegNBID := indHdrFormat1.GlobalKPMnodeID.(GlobalKPMnodegNBIDType)
191 globalgNBID := globalKPMnodegNBID.GlobalgNBID
193 log.Printf("PlmnID: %x", globalgNBID.PlmnID.Buf)
194 log.Printf("gNB ID Type: %d", globalgNBID.GnbIDType)
195 if globalgNBID.GnbIDType == 1 {
196 gNBID := globalgNBID.GnbID.(GNBID)
197 log.Printf("gNB ID ID: %x, Unused: %d", gNBID.Buf, gNBID.BitsUnused)
200 if globalKPMnodegNBID.GnbCUUPID != nil {
201 log.Printf("gNB-CU-UP ID: %x", globalKPMnodegNBID.GnbCUUPID.Buf)
204 if globalKPMnodegNBID.GnbDUID != nil {
205 log.Printf("gNB-DU ID: %x", globalKPMnodegNBID.GnbDUID.Buf)
207 } else if indHdrFormat1.GlobalKPMnodeIDType == 2 {
208 globalKPMnodeengNBID := indHdrFormat1.GlobalKPMnodeID.(GlobalKPMnodeengNBIDType)
210 log.Printf("PlmnID: %x", globalKPMnodeengNBID.PlmnID.Buf)
211 log.Printf("en-gNB ID Type: %d", globalKPMnodeengNBID.GnbIDType)
212 if globalKPMnodeengNBID.GnbIDType == 1 {
213 engNBID := globalKPMnodeengNBID.GnbID.(ENGNBID)
214 log.Printf("en-gNB ID ID: %x, Unused: %d", engNBID.Buf, engNBID.BitsUnused)
216 } else if indHdrFormat1.GlobalKPMnodeIDType == 3 {
217 globalKPMnodengeNBID := indHdrFormat1.GlobalKPMnodeID.(GlobalKPMnodengeNBIDType)
219 log.Printf("PlmnID: %x", globalKPMnodengeNBID.PlmnID.Buf)
220 log.Printf("ng-eNB ID Type: %d", globalKPMnodengeNBID.EnbIDType)
221 if globalKPMnodengeNBID.EnbIDType == 1 {
222 ngeNBID := globalKPMnodengeNBID.EnbID.(NGENBID_Macro)
223 log.Printf("ng-eNB ID ID: %x, Unused: %d", ngeNBID.Buf, ngeNBID.BitsUnused)
224 } else if globalKPMnodengeNBID.EnbIDType == 2 {
225 ngeNBID := globalKPMnodengeNBID.EnbID.(NGENBID_ShortMacro)
226 log.Printf("ng-eNB ID ID: %x, Unused: %d", ngeNBID.Buf, ngeNBID.BitsUnused)
227 } else if globalKPMnodengeNBID.EnbIDType == 3 {
228 ngeNBID := globalKPMnodengeNBID.EnbID.(NGENBID_LongMacro)
229 log.Printf("ng-eNB ID ID: %x, Unused: %d", ngeNBID.Buf, ngeNBID.BitsUnused)
231 } else if indHdrFormat1.GlobalKPMnodeIDType == 4 {
232 globalKPMnodeeNBID := indHdrFormat1.GlobalKPMnodeID.(GlobalKPMnodeeNBIDType)
234 log.Printf("PlmnID: %x", globalKPMnodeeNBID.PlmnID.Buf)
235 log.Printf("eNB ID Type: %d", globalKPMnodeeNBID.EnbIDType)
236 if globalKPMnodeeNBID.EnbIDType == 1 {
237 eNBID := globalKPMnodeeNBID.EnbID.(ENBID_Macro)
238 log.Printf("eNB ID ID: %x, Unused: %d", eNBID.Buf, eNBID.BitsUnused)
239 } else if globalKPMnodeeNBID.EnbIDType == 2 {
240 eNBID := globalKPMnodeeNBID.EnbID.(ENBID_Home)
241 log.Printf("eNB ID ID: %x, Unused: %d", eNBID.Buf, eNBID.BitsUnused)
242 } else if globalKPMnodeeNBID.EnbIDType == 3 {
243 eNBID := globalKPMnodeeNBID.EnbID.(ENBID_ShortMacro)
244 log.Printf("eNB ID ID: %x, Unused: %d", eNBID.Buf, eNBID.BitsUnused)
245 } else if globalKPMnodeeNBID.EnbIDType == 4 {
246 eNBID := globalKPMnodeeNBID.EnbID.(ENBID_LongMacro)
247 log.Printf("eNB ID ID: %x, Unused: %d", eNBID.Buf, eNBID.BitsUnused)
252 if indHdrFormat1.NRCGI != nil {
254 log.Printf("nRCGI.PlmnID: %x", indHdrFormat1.NRCGI.PlmnID.Buf)
255 log.Printf("nRCGI.NRCellID ID: %x, Unused: %d", indHdrFormat1.NRCGI.NRCellID.Buf, indHdrFormat1.NRCGI.NRCellID.BitsUnused)
257 cellIDHdr, err = e2sm.ParseNRCGI(*indHdrFormat1.NRCGI)
259 xapp.Logger.Error("Failed to parse NRCGI in RIC Indication Header: %v", err)
260 log.Printf("Failed to parse NRCGI in RIC Indication Header: %v", err)
267 if indHdrFormat1.PlmnID != nil {
268 log.Printf("PlmnID: %x", indHdrFormat1.PlmnID.Buf)
270 plmnIDHdr, err = e2sm.ParsePLMNIdentity(indHdrFormat1.PlmnID.Buf, indHdrFormat1.PlmnID.Size)
272 xapp.Logger.Error("Failed to parse PlmnID in RIC Indication Header: %v", err)
273 log.Printf("Failed to parse PlmnID in RIC Indication Header: %v", err)
280 if indHdrFormat1.SliceID != nil {
281 log.Printf("SST: %x", indHdrFormat1.SliceID.SST.Buf)
283 if indHdrFormat1.SliceID.SD != nil {
284 log.Printf("SD: %x", indHdrFormat1.SliceID.SD.Buf)
287 sliceIDHdr, err = e2sm.ParseSliceID(*indHdrFormat1.SliceID)
289 xapp.Logger.Error("Failed to parse SliceID in RIC Indication Header: %v", err)
290 log.Printf("Failed to parse SliceID in RIC Indication Header: %v", err)
297 if indHdrFormat1.FiveQI != -1 {
298 log.Printf("5QI: %d", indHdrFormat1.FiveQI)
300 fiveQIHdr = indHdrFormat1.FiveQI
302 if indHdrFormat1.Qci != -1 {
303 log.Printf("QCI: %d", indHdrFormat1.Qci)
306 if indHdrFormat1.UeMessageType != -1 {
307 log.Printf("Ue Report type: %d", indHdrFormat1.UeMessageType)
310 if indHdrFormat1.GnbDUID != nil {
311 log.Printf("gNB-DU-ID: %x", indHdrFormat1.GnbDUID.Buf)
314 if indHdrFormat1.GnbNameType == 1 {
315 log.Printf("gNB-DU-Name: %x", (indHdrFormat1.GnbName.(GNB_DU_Name)).Buf)
316 } else if indHdrFormat1.GnbNameType == 2 {
317 log.Printf("gNB-CU-CP-Name: %x", (indHdrFormat1.GnbName.(GNB_CU_CP_Name)).Buf)
318 } else if indHdrFormat1.GnbNameType == 3 {
319 log.Printf("gNB-CU-UP-Name: %x", (indHdrFormat1.GnbName.(GNB_CU_UP_Name)).Buf)
322 if indHdrFormat1.GlobalgNBID != nil {
323 log.Printf("PlmnID: %x", indHdrFormat1.GlobalgNBID.PlmnID.Buf)
324 log.Printf("gNB ID Type: %d", indHdrFormat1.GlobalgNBID.GnbIDType)
325 if indHdrFormat1.GlobalgNBID.GnbIDType == 1 {
326 gNBID := indHdrFormat1.GlobalgNBID.GnbID.(GNBID)
327 log.Printf("gNB ID ID: %x, Unused: %d", gNBID.Buf, gNBID.BitsUnused)
332 xapp.Logger.Error("Unknown RIC Indication Header Format: %d", indicationHdr.IndHdrType)
333 log.Printf("Unknown RIC Indication Header Format: %d", indicationHdr.IndHdrType)
337 indMsg, err := e2sm.GetIndicationMessage(indicationMsg.IndMessage)
339 xapp.Logger.Error("Failed to decode RIC Indication Message: %v", err)
340 log.Printf("Failed to decode RIC Indication Message: %v", err)
345 var containerType int32
346 var timestampPDCPBytes *Timestamp
347 var dlPDCPBytes int64
348 var ulPDCPBytes int64
349 var timestampPRB *Timestamp
353 log.Printf("-----------RIC Indication Message-----------")
354 log.Printf("StyleType: %d", indMsg.StyleType)
355 if indMsg.IndMsgType == 1 {
356 log.Printf("RIC Indication Message Format: %d", indMsg.IndMsgType)
358 indMsgFormat1 := indMsg.IndMsg.(IndicationMessageFormat1)
360 log.Printf("PMContainerCount: %d", indMsgFormat1.PMContainerCount)
362 for i := 0; i < indMsgFormat1.PMContainerCount; i++ {
364 timestampPDCPBytes = nil
371 log.Printf("PMContainer[%d]: ", i)
373 pmContainer := indMsgFormat1.PMContainers[i]
375 if pmContainer.PFContainer != nil {
376 containerType = pmContainer.PFContainer.ContainerType
378 log.Printf("PFContainerType: %d", containerType)
380 if containerType == 1 {
381 log.Printf("oDU PF Container: ")
383 oDU := pmContainer.PFContainer.Container.(ODUPFContainerType)
385 cellResourceReportCount := oDU.CellResourceReportCount
386 log.Printf("CellResourceReportCount: %d", cellResourceReportCount)
388 for j := 0; j < cellResourceReportCount; j++ {
389 log.Printf("CellResourceReport[%d]: ", j)
391 cellResourceReport := oDU.CellResourceReports[j]
393 log.Printf("nRCGI.PlmnID: %x", cellResourceReport.NRCGI.PlmnID.Buf)
394 log.Printf("nRCGI.nRCellID: %x", cellResourceReport.NRCGI.NRCellID.Buf)
396 cellID, err := e2sm.ParseNRCGI(cellResourceReport.NRCGI)
398 xapp.Logger.Error("Failed to parse CellID in DU PF Container: %v", err)
399 log.Printf("Failed to parse CellID in DU PF Container: %v", err)
402 if cellID == cellIDHdr {
406 log.Printf("TotalofAvailablePRBsDL: %d", cellResourceReport.TotalofAvailablePRBs.DL)
407 log.Printf("TotalofAvailablePRBsUL: %d", cellResourceReport.TotalofAvailablePRBs.UL)
410 availPRBDL = cellResourceReport.TotalofAvailablePRBs.DL
411 availPRBUL = cellResourceReport.TotalofAvailablePRBs.UL
414 servedPlmnPerCellCount := cellResourceReport.ServedPlmnPerCellCount
415 log.Printf("ServedPlmnPerCellCount: %d", servedPlmnPerCellCount)
417 for k := 0; k < servedPlmnPerCellCount; k++ {
418 log.Printf("ServedPlmnPerCell[%d]: ", k)
420 servedPlmnPerCell := cellResourceReport.ServedPlmnPerCells[k]
422 log.Printf("PlmnID: %x", servedPlmnPerCell.PlmnID.Buf)
424 if servedPlmnPerCell.DUPM5GC != nil {
425 slicePerPlmnPerCellCount := servedPlmnPerCell.DUPM5GC.SlicePerPlmnPerCellCount
426 log.Printf("SlicePerPlmnPerCellCount: %d", slicePerPlmnPerCellCount)
428 for l := 0; l < slicePerPlmnPerCellCount; l++ {
429 log.Printf("SlicePerPlmnPerCell[%d]: ", l)
431 slicePerPlmnPerCell := servedPlmnPerCell.DUPM5GC.SlicePerPlmnPerCells[l]
433 log.Printf("SliceID.sST: %x", slicePerPlmnPerCell.SliceID.SST.Buf)
434 if slicePerPlmnPerCell.SliceID.SD != nil {
435 log.Printf("SliceID.sD: %x", slicePerPlmnPerCell.SliceID.SD.Buf)
438 fQIPERSlicesPerPlmnPerCellCount := slicePerPlmnPerCell.FQIPERSlicesPerPlmnPerCellCount
439 log.Printf("5QIPerSlicesPerPlmnPerCellCount: %d", fQIPERSlicesPerPlmnPerCellCount)
441 for m := 0; m < fQIPERSlicesPerPlmnPerCellCount; m++ {
442 log.Printf("5QIPerSlicesPerPlmnPerCell[%d]: ", m)
444 fQIPERSlicesPerPlmnPerCell := slicePerPlmnPerCell.FQIPERSlicesPerPlmnPerCells[m]
446 log.Printf("5QI: %d", fQIPERSlicesPerPlmnPerCell.FiveQI)
447 log.Printf("PrbUsageDL: %d", fQIPERSlicesPerPlmnPerCell.PrbUsage.DL)
448 log.Printf("PrbUsageUL: %d", fQIPERSlicesPerPlmnPerCell.PrbUsage.UL)
453 if servedPlmnPerCell.DUPMEPC != nil {
454 perQCIReportCount := servedPlmnPerCell.DUPMEPC.PerQCIReportCount
455 log.Printf("PerQCIReportCount: %d", perQCIReportCount)
457 for l := 0; l < perQCIReportCount; l++ {
458 log.Printf("PerQCIReports[%d]: ", l)
460 perQCIReport := servedPlmnPerCell.DUPMEPC.PerQCIReports[l]
462 log.Printf("QCI: %d", perQCIReport.QCI)
463 log.Printf("PrbUsageDL: %d", perQCIReport.PrbUsage.DL)
464 log.Printf("PrbUsageUL: %d", perQCIReport.PrbUsage.UL)
469 } else if containerType == 2 {
470 log.Printf("oCU-CP PF Container: ")
472 oCUCP := pmContainer.PFContainer.Container.(OCUCPPFContainerType)
474 if oCUCP.GNBCUCPName != nil {
475 log.Printf("gNB-CU-CP Name: %x", oCUCP.GNBCUCPName.Buf)
478 log.Printf("NumberOfActiveUEs: %d", oCUCP.CUCPResourceStatus.NumberOfActiveUEs)
479 } else if containerType == 3 {
480 log.Printf("oCU-UP PF Container: ")
482 oCUUP := pmContainer.PFContainer.Container.(OCUUPPFContainerType)
484 if oCUUP.GNBCUUPName != nil {
485 log.Printf("gNB-CU-UP Name: %x", oCUUP.GNBCUUPName.Buf)
488 cuUPPFContainerItemCount := oCUUP.CUUPPFContainerItemCount
489 log.Printf("CU-UP PF Container Item Count: %d", cuUPPFContainerItemCount)
491 for j := 0; j < cuUPPFContainerItemCount; j++ {
492 log.Printf("CU-UP PF Container Item [%d]: ", j)
494 cuUPPFContainerItem := oCUUP.CUUPPFContainerItems[j]
496 log.Printf("InterfaceType: %d", cuUPPFContainerItem.InterfaceType)
498 cuUPPlmnCount := cuUPPFContainerItem.OCUUPPMContainer.CUUPPlmnCount
499 log.Printf("CU-UP Plmn Count: %d", cuUPPlmnCount)
501 for k := 0; k < cuUPPlmnCount; k++ {
502 log.Printf("CU-UP Plmn [%d]: ")
504 cuUPPlmn := cuUPPFContainerItem.OCUUPPMContainer.CUUPPlmns[k]
506 log.Printf("PlmnID: %x", cuUPPlmn.PlmnID.Buf)
508 plmnID, err := e2sm.ParsePLMNIdentity(cuUPPlmn.PlmnID.Buf, cuUPPlmn.PlmnID.Size)
510 xapp.Logger.Error("Failed to parse PlmnID in CU-UP PF Container: %v", err)
511 log.Printf("Failed to parse PlmnID in CU-UP PF Container: %v", err)
515 if cuUPPlmn.CUUPPM5GC != nil {
516 sliceToReportCount := cuUPPlmn.CUUPPM5GC.SliceToReportCount
517 log.Printf("SliceToReportCount: %d", sliceToReportCount)
519 for l := 0; l < sliceToReportCount; l++ {
520 log.Printf("SliceToReport[%d]: ", l)
522 sliceToReport := cuUPPlmn.CUUPPM5GC.SliceToReports[l]
524 log.Printf("SliceID.sST: %x", sliceToReport.SliceID.SST.Buf)
525 if sliceToReport.SliceID.SD != nil {
526 log.Printf("SliceID.sD: %x", sliceToReport.SliceID.SD.Buf)
529 sliceID, err := e2sm.ParseSliceID(sliceToReport.SliceID)
531 xapp.Logger.Error("Failed to parse sliceID in CU-UP PF Container with PlmnID [%s]: %v", plmnID, err)
532 log.Printf("Failed to parse sliceID in CU-UP PF Container with PlmnID [%s]: %v", plmnID, err)
536 fQIPERSlicesPerPlmnCount := sliceToReport.FQIPERSlicesPerPlmnCount
537 log.Printf("5QIPerSlicesPerPlmnCount: %d", fQIPERSlicesPerPlmnCount)
539 for m := 0; m < fQIPERSlicesPerPlmnCount; m++ {
540 log.Printf("5QIPerSlicesPerPlmn[%d]: ", m)
542 fQIPERSlicesPerPlmn := sliceToReport.FQIPERSlicesPerPlmns[m]
544 fiveQI := fQIPERSlicesPerPlmn.FiveQI
545 log.Printf("5QI: %d", fiveQI)
547 if plmnID == plmnIDHdr && sliceID == sliceIDHdr && fiveQI == fiveQIHdr {
551 if fQIPERSlicesPerPlmn.PDCPBytesDL != nil {
552 log.Printf("PDCPBytesDL: %x", fQIPERSlicesPerPlmn.PDCPBytesDL.Buf)
555 dlPDCPBytes, err = e2sm.ParseInteger(fQIPERSlicesPerPlmn.PDCPBytesDL.Buf, fQIPERSlicesPerPlmn.PDCPBytesDL.Size)
557 xapp.Logger.Error("Failed to parse PDCPBytesDL in CU-UP PF Container with PlmnID [%s], SliceID [%d], 5QI [%d]: %v", plmnID, sliceID, fiveQI, err)
558 log.Printf("Failed to parse PDCPBytesDL in CU-UP PF Container with PlmnID [%s], SliceID [%d], 5QI [%d]: %v", plmnID, sliceID, fiveQI, err)
564 if fQIPERSlicesPerPlmn.PDCPBytesUL != nil {
565 log.Printf("PDCPBytesUL: %x", fQIPERSlicesPerPlmn.PDCPBytesUL.Buf)
568 ulPDCPBytes, err = e2sm.ParseInteger(fQIPERSlicesPerPlmn.PDCPBytesUL.Buf, fQIPERSlicesPerPlmn.PDCPBytesUL.Size)
570 xapp.Logger.Error("Failed to parse PDCPBytesUL in CU-UP PF Container with PlmnID [%s], SliceID [%d], 5QI [%d]: %v", plmnID, sliceID, fiveQI, err)
571 log.Printf("Failed to parse PDCPBytesUL in CU-UP PF Container with PlmnID [%s], SliceID [%d], 5QI [%d]: %v", plmnID, sliceID, fiveQI, err)
580 if cuUPPlmn.CUUPPMEPC != nil {
581 cuUPPMEPCPerQCIReportCount := cuUPPlmn.CUUPPMEPC.CUUPPMEPCPerQCIReportCount
582 log.Printf("PerQCIReportCount: %d", cuUPPMEPCPerQCIReportCount)
584 for l := 0; l < cuUPPMEPCPerQCIReportCount; l++ {
585 log.Printf("PerQCIReport[%d]: ")
587 cuUPPMEPCPerQCIReport := cuUPPlmn.CUUPPMEPC.CUUPPMEPCPerQCIReports[l]
589 log.Printf("QCI: %d", cuUPPMEPCPerQCIReport.QCI)
591 if cuUPPMEPCPerQCIReport.PDCPBytesDL != nil {
592 log.Printf("PDCPBytesDL: %x", cuUPPMEPCPerQCIReport.PDCPBytesDL.Buf)
594 if cuUPPMEPCPerQCIReport.PDCPBytesUL != nil {
595 log.Printf("PDCPBytesUL: %x", cuUPPMEPCPerQCIReport.PDCPBytesUL.Buf)
602 xapp.Logger.Error("Unknown PF Container type: %d", containerType)
603 log.Printf("Unknown PF Container type: %d", containerType)
608 if pmContainer.RANContainer != nil {
609 log.Printf("RANContainer: %x", pmContainer.RANContainer.Timestamp.Buf)
611 timestamp, _ := e2sm.ParseTimestamp(pmContainer.RANContainer.Timestamp.Buf, pmContainer.RANContainer.Timestamp.Size)
612 log.Printf("Timestamp=[sec: %d, nsec: %d]", timestamp.TVsec, timestamp.TVnsec)
614 containerType = pmContainer.RANContainer.ContainerType
615 if containerType == 1 {
616 log.Printf("DU Usage Report: ")
618 oDUUE := pmContainer.RANContainer.Container.(DUUsageReportType)
620 for j := 0; j < oDUUE.CellResourceReportItemCount; j++ {
621 cellResourceReportItem := oDUUE.CellResourceReportItems[j]
623 log.Printf("nRCGI.PlmnID: %x", cellResourceReportItem.NRCGI.PlmnID.Buf)
624 log.Printf("nRCGI.NRCellID: %x, Unused: %d", cellResourceReportItem.NRCGI.NRCellID.Buf, cellResourceReportItem.NRCGI.NRCellID.BitsUnused)
626 servingCellID, err := e2sm.ParseNRCGI(cellResourceReportItem.NRCGI)
628 xapp.Logger.Error("Failed to parse NRCGI in DU Usage Report: %v", err)
629 log.Printf("Failed to parse NRCGI in DU Usage Report: %v", err)
633 for k := 0; k < cellResourceReportItem.UeResourceReportItemCount; k++ {
634 ueResourceReportItem := cellResourceReportItem.UeResourceReportItems[k]
636 log.Printf("C-RNTI: %x", ueResourceReportItem.CRNTI.Buf)
638 ueID, err := e2sm.ParseInteger(ueResourceReportItem.CRNTI.Buf, ueResourceReportItem.CRNTI.Size)
640 xapp.Logger.Error("Failed to parse C-RNTI in DU Usage Report with Serving Cell ID [%s]: %v", servingCellID, err)
641 log.Printf("Failed to parse C-RNTI in DU Usage Report with Serving Cell ID [%s]: %v", servingCellID, err)
645 var ueMetrics *UeMetricsEntry
646 if isUeExist, _ := c.client.Exists(strconv.FormatInt(ueID, 10)).Result(); isUeExist == 1 {
647 ueJsonStr, _ := c.client.Get(strconv.FormatInt(ueID, 10)).Result()
648 json.Unmarshal([]byte(ueJsonStr), ueMetrics)
650 ueMetrics = &UeMetricsEntry{}
653 ueMetrics.ServingCellID = servingCellID
656 timestampPRB = timestamp
659 ueMetrics.MeasTimestampPRB.TVsec = timestamp.TVsec
660 ueMetrics.MeasTimestampPRB.TVnsec = timestamp.TVnsec
662 if ueResourceReportItem.PRBUsageDL != -1 {
663 ueMetrics.PRBUsageDL = ueResourceReportItem.PRBUsageDL
666 if ueResourceReportItem.PRBUsageUL != -1 {
667 ueMetrics.PRBUsageUL = ueResourceReportItem.PRBUsageUL
670 newUeJsonStr, err := json.Marshal(ueMetrics)
672 xapp.Logger.Error("Failed to marshal UeMetrics with UE ID [%s]: %v", ueID, err)
673 log.Printf("Failed to marshal UeMetrics with UE ID [%s]: %v", ueID, err)
676 err = c.client.Set(strconv.FormatInt(ueID, 10), newUeJsonStr, 0).Err()
678 xapp.Logger.Error("Failed to set UeMetrics into redis with UE ID [%s]: %v", ueID, err)
679 log.Printf("Failed to set UeMetrics into redis with UE ID [%s]: %v", ueID, err)
684 } else if containerType == 2 {
685 log.Printf("CU-CP Usage Report: ")
687 oCUCPUE := pmContainer.RANContainer.Container.(CUCPUsageReportType)
689 for j := 0; j < oCUCPUE.CellResourceReportItemCount; j++ {
690 cellResourceReportItem := oCUCPUE.CellResourceReportItems[j]
692 log.Printf("nRCGI.PlmnID: %x", cellResourceReportItem.NRCGI.PlmnID.Buf)
693 log.Printf("nRCGI.NRCellID: %x, Unused: %d", cellResourceReportItem.NRCGI.NRCellID.Buf, cellResourceReportItem.NRCGI.NRCellID.BitsUnused)
695 servingCellID, err := e2sm.ParseNRCGI(cellResourceReportItem.NRCGI)
697 xapp.Logger.Error("Failed to parse NRCGI in CU-CP Usage Report: %v", err)
698 log.Printf("Failed to parse NRCGI in CU-CP Usage Report: %v", err)
702 for k := 0; k < cellResourceReportItem.UeResourceReportItemCount; k++ {
703 ueResourceReportItem := cellResourceReportItem.UeResourceReportItems[k]
705 log.Printf("C-RNTI: %x", ueResourceReportItem.CRNTI.Buf)
707 ueID, err := e2sm.ParseInteger(ueResourceReportItem.CRNTI.Buf, ueResourceReportItem.CRNTI.Size)
709 xapp.Logger.Error("Failed to parse C-RNTI in CU-CP Usage Report with Serving Cell ID [%s]: %v", err)
710 log.Printf("Failed to parse C-RNTI in CU-CP Usage Report with Serving Cell ID [%s]: %v", err)
714 var ueMetrics *UeMetricsEntry
715 if isUeExist, _ := c.client.Exists(strconv.FormatInt(ueID, 10)).Result(); isUeExist == 1 {
716 ueJsonStr, _ := c.client.Get(strconv.FormatInt(ueID, 10)).Result()
717 json.Unmarshal([]byte(ueJsonStr), ueMetrics)
719 ueMetrics = &UeMetricsEntry{}
722 ueMetrics.ServingCellID = servingCellID
724 ueMetrics.MeasTimeRF.TVsec = timestamp.TVsec
725 ueMetrics.MeasTimeRF.TVnsec = timestamp.TVnsec
727 if ueResourceReportItem.ServingCellRF != nil {
728 err = json.Unmarshal(ueResourceReportItem.ServingCellRF.Buf, &ueMetrics.ServingCellRF)
730 xapp.Logger.Error("Failed to Unmarshal ServingCellRF in CU-CP Usage Report with UE ID [%s]: %v", ueID, err)
731 log.Printf("Failed to Unmarshal ServingCellRF in CU-CP Usage Report with UE ID [%s]: %v", ueID, err)
736 if ueResourceReportItem.NeighborCellRF != nil {
737 err = json.Unmarshal(ueResourceReportItem.NeighborCellRF.Buf, &ueMetrics.NeighborCellsRF)
739 xapp.Logger.Error("Failed to Unmarshal NeighborCellRF in CU-CP Usage Report with UE ID [%s]: %v", ueID, err)
740 log.Printf("Failed to Unmarshal NeighborCellRF in CU-CP Usage Report with UE ID [%s]: %v", ueID, err)
745 newUeJsonStr, err := json.Marshal(ueMetrics)
747 xapp.Logger.Error("Failed to marshal UeMetrics with UE ID [%s]: %v", ueID, err)
748 log.Printf("Failed to marshal UeMetrics with UE ID [%s]: %v", ueID, err)
751 err = c.client.Set(strconv.FormatInt(ueID, 10), newUeJsonStr, 0).Err()
753 xapp.Logger.Error("Failed to set UeMetrics into redis with UE ID [%s]: %v", ueID, err)
754 log.Printf("Failed to set UeMetrics into redis with UE ID [%s]: %v", ueID, err)
759 } else if containerType == 6 {
760 log.Printf("CU-UP Usage Report: ")
762 oCUUPUE := pmContainer.RANContainer.Container.(CUUPUsageReportType)
764 for j := 0; j < oCUUPUE.CellResourceReportItemCount; j++ {
765 cellResourceReportItem := oCUUPUE.CellResourceReportItems[j]
767 log.Printf("nRCGI.PlmnID: %x", cellResourceReportItem.NRCGI.PlmnID.Buf)
768 log.Printf("nRCGI.NRCellID: %x, Unused: %d", cellResourceReportItem.NRCGI.NRCellID.Buf, cellResourceReportItem.NRCGI.NRCellID.BitsUnused)
770 servingCellID, err := e2sm.ParseNRCGI(cellResourceReportItem.NRCGI)
772 xapp.Logger.Error("Failed to parse NRCGI in CU-UP Usage Report: %v", err)
773 log.Printf("Failed to parse NRCGI in CU-UP Usage Report: %v", err)
777 for k := 0; k < cellResourceReportItem.UeResourceReportItemCount; k++ {
778 ueResourceReportItem := cellResourceReportItem.UeResourceReportItems[k]
780 log.Printf("C-RNTI: %x", ueResourceReportItem.CRNTI.Buf)
782 ueID, err := e2sm.ParseInteger(ueResourceReportItem.CRNTI.Buf, ueResourceReportItem.CRNTI.Size)
784 xapp.Logger.Error("Failed to parse C-RNTI in CU-UP Usage Report Serving Cell ID [%s]: %v", servingCellID, err)
785 log.Printf("Failed to parse C-RNTI in CU-UP Usage Report Serving Cell ID [%s]: %v", servingCellID, err)
789 var ueMetrics *UeMetricsEntry
790 if isUeExist, _ := c.client.Exists(strconv.FormatInt(ueID, 10)).Result(); isUeExist == 1 {
791 ueJsonStr, _ := c.client.Get(strconv.FormatInt(ueID, 10)).Result()
792 json.Unmarshal([]byte(ueJsonStr), ueMetrics)
794 ueMetrics = &UeMetricsEntry{}
797 ueMetrics.ServingCellID = servingCellID
800 timestampPDCPBytes = timestamp
803 ueMetrics.MeasTimestampPDCPBytes.TVsec = timestamp.TVsec
804 ueMetrics.MeasTimestampPDCPBytes.TVnsec = timestamp.TVnsec
806 if ueResourceReportItem.PDCPBytesDL != nil {
807 ueMetrics.PDCPBytesDL, err = e2sm.ParseInteger(ueResourceReportItem.PDCPBytesDL.Buf, ueResourceReportItem.PDCPBytesDL.Size)
809 xapp.Logger.Error("Failed to parse PDCPBytesDL in CU-UP Usage Report with UE ID [%s]: %v", ueID, err)
810 log.Printf("Failed to parse PDCPBytesDL in CU-UP Usage Report with UE ID [%s]: %v", ueID, err)
815 if ueResourceReportItem.PDCPBytesUL != nil {
816 ueMetrics.PDCPBytesUL, err = e2sm.ParseInteger(ueResourceReportItem.PDCPBytesUL.Buf, ueResourceReportItem.PDCPBytesUL.Size)
818 xapp.Logger.Error("Failed to parse PDCPBytesUL in CU-UP Usage Report with UE ID [%s]: %v", ueID, err)
819 log.Printf("Failed to parse PDCPBytesUL in CU-UP Usage Report with UE ID [%s]: %v", ueID, err)
824 newUeJsonStr, err := json.Marshal(ueMetrics)
826 xapp.Logger.Error("Failed to marshal UeMetrics with UE ID [%s]: %v", ueID, err)
827 log.Printf("Failed to marshal UeMetrics with UE ID [%s]: %v", ueID, err)
830 err = c.client.Set(strconv.FormatInt(ueID, 10), newUeJsonStr, 0).Err()
832 xapp.Logger.Error("Failed to set UeMetrics into redis with UE ID [%s]: %v", ueID, err)
833 log.Printf("Failed to set UeMetrics into redis with UE ID [%s]: %v", ueID, err)
839 xapp.Logger.Error("Unknown PF Container Type: %d", containerType)
840 log.Printf("Unknown PF Container Type: %d", containerType)
846 var cellMetrics *CellMetricsEntry
847 if isCellExist, _ := c.client.Exists(cellIDHdr).Result(); isCellExist == 1 {
848 cellJsonStr, _ := c.client.Get(cellIDHdr).Result()
849 json.Unmarshal([]byte(cellJsonStr), cellMetrics)
851 cellMetrics = &CellMetricsEntry{}
854 if timestampPDCPBytes != nil {
855 cellMetrics.MeasTimestampPDCPBytes.TVsec = timestampPDCPBytes.TVsec
856 cellMetrics.MeasTimestampPDCPBytes.TVnsec = timestampPDCPBytes.TVnsec
858 if dlPDCPBytes != -1 {
859 cellMetrics.PDCPBytesDL = dlPDCPBytes
861 if ulPDCPBytes != -1 {
862 cellMetrics.PDCPBytesUL = ulPDCPBytes
864 if timestampPRB != nil {
865 cellMetrics.MeasTimestampPRB.TVsec = timestampPRB.TVsec
866 cellMetrics.MeasTimestampPRB.TVnsec = timestampPRB.TVnsec
868 if availPRBDL != -1 {
869 cellMetrics.AvailPRBDL = availPRBDL
871 if availPRBUL != -1 {
872 cellMetrics.AvailPRBUL = availPRBUL
875 newCellJsonStr, err := json.Marshal(cellMetrics)
877 xapp.Logger.Error("Failed to marshal CellMetrics with CellID [%s]: %v", cellIDHdr, err)
878 log.Printf("Failed to marshal CellMetrics with CellID [%s]: %v", cellIDHdr, err)
881 err = c.client.Set(cellIDHdr, newCellJsonStr, 0).Err()
883 xapp.Logger.Error("Failed to set CellMetrics into redis with CellID [%s]: %v", cellIDHdr, err)
884 log.Printf("Failed to set CellMetrics into redis with CellID [%s]: %v", cellIDHdr, err)
890 xapp.Logger.Error("Unknown RIC Indication Message Format: %d", indMsg.IndMsgType)
891 log.Printf("Unkonw RIC Indication Message Format: %d", indMsg.IndMsgType)
898 func (c *Control) handleSubscriptionResponse(params *xapp.RMRParams) (err error) {
899 xapp.Logger.Debug("The SubId in RIC_SUB_RESP is %d", params.SubId)
900 log.Printf("The SubId in RIC_SUB_RESP is %d", params.SubId)
902 ranName := params.Meid.RanName
903 c.eventCreateExpiredMu.Lock()
904 _, ok := c.eventCreateExpiredMap[ranName]
906 c.eventCreateExpiredMu.Unlock()
907 xapp.Logger.Debug("RIC_SUB_REQ has been deleted!")
908 log.Printf("RIC_SUB_REQ has been deleted!")
911 c.eventCreateExpiredMap[ranName] = true
912 c.eventCreateExpiredMu.Unlock()
916 subscriptionResp, err := cep.GetSubscriptionResponseMessage(params.Payload)
918 xapp.Logger.Error("Failed to decode RIC Subscription Response message: %v", err)
919 log.Printf("Failed to decode RIC Subscription Response message: %v", err)
923 log.Printf("RIC Subscription Response message from {%s} received", params.Meid.RanName)
924 log.Printf("SubscriptionID: %d", params.SubId)
925 log.Printf("RequestID: %d", subscriptionResp.RequestID)
926 log.Printf("RequestSequenceNumber: %d", subscriptionResp.RequestSequenceNumber)
927 log.Printf("FunctionID: %d", subscriptionResp.FuncID)
929 log.Printf("ActionAdmittedList:")
930 for index := 0; index < subscriptionResp.ActionAdmittedList.Count; index++ {
931 log.Printf("[%d]ActionID: %d", index, subscriptionResp.ActionAdmittedList.ActionID[index])
934 log.Printf("ActionNotAdmittedList:")
935 for index := 0; index < subscriptionResp.ActionNotAdmittedList.Count; index++ {
936 log.Printf("[%d]ActionID: %d", index, subscriptionResp.ActionNotAdmittedList.ActionID[index])
937 log.Printf("[%d]CauseType: %d CauseID: %d", index, subscriptionResp.ActionNotAdmittedList.Cause[index].CauseType, subscriptionResp.ActionNotAdmittedList.Cause[index].CauseID)
943 func (c *Control) handleSubscriptionFailure(params *xapp.RMRParams) (err error) {
944 xapp.Logger.Debug("The SubId in RIC_SUB_FAILURE is %d", params.SubId)
945 log.Printf("The SubId in RIC_SUB_FAILURE is %d", params.SubId)
947 ranName := params.Meid.RanName
948 c.eventCreateExpiredMu.Lock()
949 _, ok := c.eventCreateExpiredMap[ranName]
951 c.eventCreateExpiredMu.Unlock()
952 xapp.Logger.Debug("RIC_SUB_REQ has been deleted!")
953 log.Printf("RIC_SUB_REQ has been deleted!")
956 c.eventCreateExpiredMap[ranName] = true
957 c.eventCreateExpiredMu.Unlock()
963 func (c *Control) handleSubscriptionDeleteResponse(params *xapp.RMRParams) (err error) {
964 xapp.Logger.Debug("The SubId in RIC_SUB_DEL_RESP is %d", params.SubId)
965 log.Printf("The SubId in RIC_SUB_DEL_RESP is %d", params.SubId)
967 ranName := params.Meid.RanName
968 c.eventDeleteExpiredMu.Lock()
969 _, ok := c.eventDeleteExpiredMap[ranName]
971 c.eventDeleteExpiredMu.Unlock()
972 xapp.Logger.Debug("RIC_SUB_DEL_REQ has been deleted!")
973 log.Printf("RIC_SUB_DEL_REQ has been deleted!")
976 c.eventDeleteExpiredMap[ranName] = true
977 c.eventDeleteExpiredMu.Unlock()
983 func (c *Control) handleSubscriptionDeleteFailure(params *xapp.RMRParams) (err error) {
984 xapp.Logger.Debug("The SubId in RIC_SUB_DEL_FAILURE is %d", params.SubId)
985 log.Printf("The SubId in RIC_SUB_DEL_FAILURE is %d", params.SubId)
987 ranName := params.Meid.RanName
988 c.eventDeleteExpiredMu.Lock()
989 _, ok := c.eventDeleteExpiredMap[ranName]
991 c.eventDeleteExpiredMu.Unlock()
992 xapp.Logger.Debug("RIC_SUB_DEL_REQ has been deleted!")
993 log.Printf("RIC_SUB_DEL_REQ has been deleted!")
996 c.eventDeleteExpiredMap[ranName] = true
997 c.eventDeleteExpiredMu.Unlock()
1003 func (c *Control) setEventCreateExpiredTimer(ranName string) {
1004 c.eventCreateExpiredMu.Lock()
1005 c.eventCreateExpiredMap[ranName] = false
1006 c.eventCreateExpiredMu.Unlock()
1008 timer := time.NewTimer(time.Duration(c.eventCreateExpired) * time.Second)
1009 go func(t *time.Timer) {
1011 xapp.Logger.Debug("RIC_SUB_REQ[%s]: Waiting for RIC_SUB_RESP...", ranName)
1012 log.Printf("RIC_SUB_REQ[%s]: Waiting for RIC_SUB_RESP...", ranName)
1016 c.eventCreateExpiredMu.Lock()
1017 isResponsed := c.eventCreateExpiredMap[ranName]
1018 delete(c.eventCreateExpiredMap, ranName)
1019 c.eventCreateExpiredMu.Unlock()
1021 xapp.Logger.Debug("RIC_SUB_REQ[%s]: RIC Event Create Timer experied!", ranName)
1022 log.Printf("RIC_SUB_REQ[%s]: RIC Event Create Timer experied!", ranName)
1023 // c.sendRicSubDelRequest(subID, requestSN, funcID)
1027 c.eventCreateExpiredMu.Lock()
1028 flag := c.eventCreateExpiredMap[ranName]
1030 delete(c.eventCreateExpiredMap, ranName)
1031 c.eventCreateExpiredMu.Unlock()
1032 xapp.Logger.Debug("RIC_SUB_REQ[%s]: RIC Event Create Timer canceled!", ranName)
1033 log.Printf("RIC_SUB_REQ[%s]: RIC Event Create Timer canceled!", ranName)
1036 c.eventCreateExpiredMu.Unlock()
1039 time.Sleep(100 * time.Millisecond)
1044 func (c *Control) setEventDeleteExpiredTimer(ranName string) {
1045 c.eventDeleteExpiredMu.Lock()
1046 c.eventDeleteExpiredMap[ranName] = false
1047 c.eventDeleteExpiredMu.Unlock()
1049 timer := time.NewTimer(time.Duration(c.eventDeleteExpired) * time.Second)
1050 go func(t *time.Timer) {
1052 xapp.Logger.Debug("RIC_SUB_DEL_REQ[%s]: Waiting for RIC_SUB_DEL_RESP...", ranName)
1053 log.Printf("RIC_SUB_DEL_REQ[%s]: Waiting for RIC_SUB_DEL_RESP...", ranName)
1057 c.eventDeleteExpiredMu.Lock()
1058 isResponsed := c.eventDeleteExpiredMap[ranName]
1059 delete(c.eventDeleteExpiredMap, ranName)
1060 c.eventDeleteExpiredMu.Unlock()
1062 xapp.Logger.Debug("RIC_SUB_DEL_REQ[%s]: RIC Event Delete Timer experied!", ranName)
1063 log.Printf("RIC_SUB_DEL_REQ[%s]: RIC Event Delete Timer experied!", ranName)
1067 c.eventDeleteExpiredMu.Lock()
1068 flag := c.eventDeleteExpiredMap[ranName]
1070 delete(c.eventDeleteExpiredMap, ranName)
1071 c.eventDeleteExpiredMu.Unlock()
1072 xapp.Logger.Debug("RIC_SUB_DEL_REQ[%s]: RIC Event Delete Timer canceled!", ranName)
1073 log.Printf("RIC_SUB_DEL_REQ[%s]: RIC Event Delete Timer canceled!", ranName)
1076 c.eventDeleteExpiredMu.Unlock()
1079 time.Sleep(100 * time.Millisecond)
1084 func (c *Control) sendRicSubRequest(subID int, requestSN int, funcID int) (err error) {
1088 var eventTriggerCount int = 1
1089 var periods []int64 = []int64{13}
1090 var eventTriggerDefinition []byte = make([]byte, 8)
1091 _, err = e2sm.SetEventTriggerDefinition(eventTriggerDefinition, eventTriggerCount, periods)
1093 xapp.Logger.Error("Failed to send RIC_SUB_REQ: %v", err)
1094 log.Printf("Failed to send RIC_SUB_REQ: %v", err)
1098 log.Printf("Set EventTriggerDefinition: %x", eventTriggerDefinition)
1100 var actionCount int = 1
1101 var ricStyleType []int64 = []int64{0}
1102 var actionIds []int64 = []int64{0}
1103 var actionTypes []int64 = []int64{0}
1104 var actionDefinitions []ActionDefinition = make([]ActionDefinition, actionCount)
1105 var subsequentActions []SubsequentAction = []SubsequentAction{SubsequentAction{0, 0, 0}}
1107 for index := 0; index < actionCount; index++ {
1108 if ricStyleType[index] == 0 {
1109 actionDefinitions[index].Buf = nil
1110 actionDefinitions[index].Size = 0
1112 actionDefinitions[index].Buf = make([]byte, 8)
1113 _, err = e2sm.SetActionDefinition(actionDefinitions[index].Buf, ricStyleType[index])
1115 xapp.Logger.Error("Failed to send RIC_SUB_REQ: %v", err)
1116 log.Printf("Failed to send RIC_SUB_REQ: %v", err)
1119 actionDefinitions[index].Size = len(actionDefinitions[index].Buf)
1121 log.Printf("Set ActionDefinition[%d]: %x", index, actionDefinitions[index].Buf)
1125 for index := 0; index < len(c.ranList); index++ {
1126 params := &xapp.RMRParams{}
1127 params.Mtype = 12010
1128 params.SubId = subID
1130 xapp.Logger.Debug("Send RIC_SUB_REQ to {%s}", c.ranList[index])
1131 log.Printf("Send RIC_SUB_REQ to {%s}", c.ranList[index])
1133 params.Payload = make([]byte, 1024)
1134 params.Payload, err = e2ap.SetSubscriptionRequestPayload(params.Payload, 1001, uint16(requestSN), uint16(funcID), eventTriggerDefinition, len(eventTriggerDefinition), actionCount, actionIds, actionTypes, actionDefinitions, subsequentActions)
1136 xapp.Logger.Error("Failed to send RIC_SUB_REQ: %v", err)
1137 log.Printf("Failed to send RIC_SUB_REQ: %v", err)
1141 log.Printf("Set Payload: %x", params.Payload)
1143 params.Meid = &xapp.RMRMeid{RanName: c.ranList[index]}
1144 xapp.Logger.Debug("The RMR message to be sent is %d with SubId=%d", params.Mtype, params.SubId)
1145 log.Printf("The RMR message to be sent is %d with SubId=%d", params.Mtype, params.SubId)
1147 err = c.rmrSend(params)
1149 xapp.Logger.Error("Failed to send RIC_SUB_REQ: %v", err)
1150 log.Printf("Failed to send RIC_SUB_REQ: %v", err)
1154 c.setEventCreateExpiredTimer(params.Meid.RanName)
1155 c.ranList = append(c.ranList[:index], c.ranList[index+1:]...)
1162 func (c *Control) sendRicSubDelRequest(subID int, requestSN int, funcID int) (err error) {
1163 params := &xapp.RMRParams{}
1164 params.Mtype = 12020
1165 params.SubId = subID
1168 params.Payload = make([]byte, 1024)
1169 params.Payload, err = e2ap.SetSubscriptionDeleteRequestPayload(params.Payload, 100, uint16(requestSN), uint16(funcID))
1171 xapp.Logger.Error("Failed to send RIC_SUB_DEL_REQ: %v", err)
1175 log.Printf("Set Payload: %x", params.Payload)
1178 params.Meid = &xapp.RMRMeid{PlmnID: "::", EnbID: "::", RanName: "0"}
1180 params.Meid = &xapp.RMRMeid{PlmnID: "::", EnbID: "::", RanName: "3"}
1183 xapp.Logger.Debug("The RMR message to be sent is %d with SubId=%d", params.Mtype, params.SubId)
1184 log.Printf("The RMR message to be sent is %d with SubId=%d", params.Mtype, params.SubId)
1186 err = c.rmrSend(params)
1188 xapp.Logger.Error("Failed to send RIC_SUB_DEL_REQ: %v", err)
1189 log.Printf("Failed to send RIC_SUB_DEL_REQ: %v", err)
1193 c.setEventDeleteExpiredTimer(params.Meid.RanName)