12 "gerrit.o-ran-sc.org/r/ric-plt/sdlgo"
13 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
14 //"github.com/go-redis/redis"
18 ranList []string //nodeB list
19 eventCreateExpired int32 //maximum time for the RIC Subscription Request event creation procedure in the E2 Node
20 eventDeleteExpired int32 //maximum time for the RIC Subscription Request event deletion procedure in the E2 Node
21 rcChan chan *xapp.RMRParams //channel for receiving rmr message
22 //client *redis.Client //redis client
23 eventCreateExpiredMap map[string]bool //map for recording the RIC Subscription Request event creation procedure is expired or not
24 eventDeleteExpiredMap map[string]bool //map for recording the RIC Subscription Request event deletion procedure is expired or not
25 eventCreateExpiredMu *sync.Mutex //mutex for eventCreateExpiredMap
26 eventDeleteExpiredMu *sync.Mutex //mutex for eventDeleteExpiredMap
27 sdl *sdlgo.SdlInstance
31 file := "/opt/kpimon.log"
32 logFile, err := os.OpenFile(file, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0766)
36 log.SetOutput(logFile)
37 log.SetPrefix("[qSkipTool]")
38 log.SetFlags(log.LstdFlags | log.Lshortfile | log.LUTC)
39 xapp.Logger.SetLevel(4)
42 func NewControl() Control {
43 str := os.Getenv("ranList")
44 return Control{strings.Split(str, ","),
46 make(chan *xapp.RMRParams),
47 //redis.NewClient(&redis.Options{
48 // Addr: os.Getenv("DBAAS_SERVICE_HOST") + ":" + os.Getenv("DBAAS_SERVICE_PORT"), //"localhost:6379"
52 make(map[string]bool),
53 make(map[string]bool),
56 sdlgo.NewSdlInstance("kpimon", sdlgo.NewDatabase())}
59 func ReadyCB(i interface{}) {
66 func (c *Control) Run() {
67 //_, err := c.client.Ping().Result()
69 // xapp.Logger.Error("Failed to connect to Redis DB with %v", err)
70 // log.Printf("Failed to connect to Redis DB with %v", err)
72 if len(c.ranList) > 0 {
73 xapp.SetReadyCB(ReadyCB, c)
76 xapp.Logger.Error("gNodeB not set for subscription")
77 log.Printf("gNodeB not set for subscription")
82 func (c *Control) startTimerSubReq() {
83 timerSR := time.NewTimer(5 * time.Second)
86 go func(t *time.Timer) {
91 xapp.Logger.Debug("send RIC_SUB_REQ to gNodeB with cnt=%d", count)
92 log.Printf("send RIC_SUB_REQ to gNodeB with cnt=%d", count)
93 err := c.sendRicSubRequest(1001, 1001, 0)
94 if err != nil && count < MAX_SUBSCRIPTION_ATTEMPTS {
95 t.Reset(5 * time.Second)
103 func (c *Control) Consume(rp *xapp.RMRParams) (err error) {
108 func (c *Control) rmrSend(params *xapp.RMRParams) (err error) {
109 if !xapp.Rmr.Send(params, false) {
110 err = errors.New("rmr.Send() failed")
111 xapp.Logger.Error("Failed to rmrSend to %v", err)
112 log.Printf("Failed to rmrSend to %v", err)
117 func (c *Control) rmrReplyToSender(params *xapp.RMRParams) (err error) {
118 if !xapp.Rmr.Send(params, true) {
119 err = errors.New("rmr.Send() failed")
120 xapp.Logger.Error("Failed to rmrReplyToSender to %v", err)
121 log.Printf("Failed to rmrReplyToSender to %v", err)
126 func (c *Control) controlLoop() {
129 xapp.Logger.Debug("Received message type: %d", msg.Mtype)
130 log.Printf("Received message type: %d", msg.Mtype)
133 c.handleIndication(msg)
135 c.handleSubscriptionResponse(msg)
137 c.handleSubscriptionFailure(msg)
139 c.handleSubscriptionDeleteResponse(msg)
141 c.handleSubscriptionDeleteFailure(msg)
143 err := errors.New("Message Type " + strconv.Itoa(msg.Mtype) + " is discarded")
144 xapp.Logger.Error("Unknown message type: %v", err)
145 log.Printf("Unknown message type: %v", err)
150 func (c *Control) handleIndication(params *xapp.RMRParams) (err error) {
154 indicationMsg, err := e2ap.GetIndicationMessage(params.Payload)
156 xapp.Logger.Error("Failed to decode RIC Indication message: %v", err)
157 log.Printf("Failed to decode RIC Indication message: %v", err)
161 log.Printf("RIC Indication message from {%s} received", params.Meid.RanName)
162 log.Printf("RequestID: %d", indicationMsg.RequestID)
163 log.Printf("RequestSequenceNumber: %d", indicationMsg.RequestSequenceNumber)
164 log.Printf("FunctionID: %d", indicationMsg.FuncID)
165 log.Printf("ActionID: %d", indicationMsg.ActionID)
166 log.Printf("IndicationSN: %d", indicationMsg.IndSN)
167 log.Printf("IndicationType: %d", indicationMsg.IndType)
168 log.Printf("IndicationHeader: %x", indicationMsg.IndHeader)
169 log.Printf("IndicationMessage: %x", indicationMsg.IndMessage)
170 log.Printf("CallProcessID: %x", indicationMsg.CallProcessID)
172 indicationHdr, err := e2sm.GetIndicationHeader(indicationMsg.IndHeader)
174 xapp.Logger.Error("Failed to decode RIC Indication Header: %v", err)
175 log.Printf("Failed to decode RIC Indication Header: %v", err)
184 log.Printf("-----------RIC Indication Header-----------")
185 if indicationHdr.IndHdrType == 1 {
186 log.Printf("RIC Indication Header Format: %d", indicationHdr.IndHdrType)
187 indHdrFormat1 := indicationHdr.IndHdr.(*IndicationHeaderFormat1)
189 log.Printf("GlobalKPMnodeIDType: %d", indHdrFormat1.GlobalKPMnodeIDType)
191 if indHdrFormat1.GlobalKPMnodeIDType == 1 {
192 globalKPMnodegNBID := indHdrFormat1.GlobalKPMnodeID.(*GlobalKPMnodegNBIDType)
194 globalgNBID := globalKPMnodegNBID.GlobalgNBID
196 log.Printf("PlmnID: %x", globalgNBID.PlmnID.Buf)
197 log.Printf("gNB ID Type: %d", globalgNBID.GnbIDType)
198 if globalgNBID.GnbIDType == 1 {
199 gNBID := globalgNBID.GnbID.(*GNBID)
200 log.Printf("gNB ID ID: %x, Unused: %d", gNBID.Buf, gNBID.BitsUnused)
203 if globalKPMnodegNBID.GnbCUUPID != nil {
204 log.Printf("gNB-CU-UP ID: %x", globalKPMnodegNBID.GnbCUUPID.Buf)
207 if globalKPMnodegNBID.GnbDUID != nil {
208 log.Printf("gNB-DU ID: %x", globalKPMnodegNBID.GnbDUID.Buf)
210 } else if indHdrFormat1.GlobalKPMnodeIDType == 2 {
211 globalKPMnodeengNBID := indHdrFormat1.GlobalKPMnodeID.(*GlobalKPMnodeengNBIDType)
213 log.Printf("PlmnID: %x", globalKPMnodeengNBID.PlmnID.Buf)
214 log.Printf("en-gNB ID Type: %d", globalKPMnodeengNBID.GnbIDType)
215 if globalKPMnodeengNBID.GnbIDType == 1 {
216 engNBID := globalKPMnodeengNBID.GnbID.(*ENGNBID)
217 log.Printf("en-gNB ID ID: %x, Unused: %d", engNBID.Buf, engNBID.BitsUnused)
219 } else if indHdrFormat1.GlobalKPMnodeIDType == 3 {
220 globalKPMnodengeNBID := indHdrFormat1.GlobalKPMnodeID.(*GlobalKPMnodengeNBIDType)
222 log.Printf("PlmnID: %x", globalKPMnodengeNBID.PlmnID.Buf)
223 log.Printf("ng-eNB ID Type: %d", globalKPMnodengeNBID.EnbIDType)
224 if globalKPMnodengeNBID.EnbIDType == 1 {
225 ngeNBID := globalKPMnodengeNBID.EnbID.(*NGENBID_Macro)
226 log.Printf("ng-eNB ID ID: %x, Unused: %d", ngeNBID.Buf, ngeNBID.BitsUnused)
227 } else if globalKPMnodengeNBID.EnbIDType == 2 {
228 ngeNBID := globalKPMnodengeNBID.EnbID.(*NGENBID_ShortMacro)
229 log.Printf("ng-eNB ID ID: %x, Unused: %d", ngeNBID.Buf, ngeNBID.BitsUnused)
230 } else if globalKPMnodengeNBID.EnbIDType == 3 {
231 ngeNBID := globalKPMnodengeNBID.EnbID.(*NGENBID_LongMacro)
232 log.Printf("ng-eNB ID ID: %x, Unused: %d", ngeNBID.Buf, ngeNBID.BitsUnused)
234 } else if indHdrFormat1.GlobalKPMnodeIDType == 4 {
235 globalKPMnodeeNBID := indHdrFormat1.GlobalKPMnodeID.(*GlobalKPMnodeeNBIDType)
237 log.Printf("PlmnID: %x", globalKPMnodeeNBID.PlmnID.Buf)
238 log.Printf("eNB ID Type: %d", globalKPMnodeeNBID.EnbIDType)
239 if globalKPMnodeeNBID.EnbIDType == 1 {
240 eNBID := globalKPMnodeeNBID.EnbID.(*ENBID_Macro)
241 log.Printf("eNB ID ID: %x, Unused: %d", eNBID.Buf, eNBID.BitsUnused)
242 } else if globalKPMnodeeNBID.EnbIDType == 2 {
243 eNBID := globalKPMnodeeNBID.EnbID.(*ENBID_Home)
244 log.Printf("eNB ID ID: %x, Unused: %d", eNBID.Buf, eNBID.BitsUnused)
245 } else if globalKPMnodeeNBID.EnbIDType == 3 {
246 eNBID := globalKPMnodeeNBID.EnbID.(*ENBID_ShortMacro)
247 log.Printf("eNB ID ID: %x, Unused: %d", eNBID.Buf, eNBID.BitsUnused)
248 } else if globalKPMnodeeNBID.EnbIDType == 4 {
249 eNBID := globalKPMnodeeNBID.EnbID.(*ENBID_LongMacro)
250 log.Printf("eNB ID ID: %x, Unused: %d", eNBID.Buf, eNBID.BitsUnused)
255 if indHdrFormat1.NRCGI != nil {
257 log.Printf("nRCGI.PlmnID: %x", indHdrFormat1.NRCGI.PlmnID.Buf)
258 log.Printf("nRCGI.NRCellID ID: %x, Unused: %d", indHdrFormat1.NRCGI.NRCellID.Buf, indHdrFormat1.NRCGI.NRCellID.BitsUnused)
260 cellIDHdr, err = e2sm.ParseNRCGI(*indHdrFormat1.NRCGI)
262 xapp.Logger.Error("Failed to parse NRCGI in RIC Indication Header: %v", err)
263 log.Printf("Failed to parse NRCGI in RIC Indication Header: %v", err)
270 if indHdrFormat1.PlmnID != nil {
271 log.Printf("PlmnID: %x", indHdrFormat1.PlmnID.Buf)
273 plmnIDHdr, err = e2sm.ParsePLMNIdentity(indHdrFormat1.PlmnID.Buf, indHdrFormat1.PlmnID.Size)
275 xapp.Logger.Error("Failed to parse PlmnID in RIC Indication Header: %v", err)
276 log.Printf("Failed to parse PlmnID in RIC Indication Header: %v", err)
283 if indHdrFormat1.SliceID != nil {
284 log.Printf("SST: %x", indHdrFormat1.SliceID.SST.Buf)
286 if indHdrFormat1.SliceID.SD != nil {
287 log.Printf("SD: %x", indHdrFormat1.SliceID.SD.Buf)
290 sliceIDHdr, err = e2sm.ParseSliceID(*indHdrFormat1.SliceID)
292 xapp.Logger.Error("Failed to parse SliceID in RIC Indication Header: %v", err)
293 log.Printf("Failed to parse SliceID in RIC Indication Header: %v", err)
300 if indHdrFormat1.FiveQI != -1 {
301 log.Printf("5QI: %d", indHdrFormat1.FiveQI)
303 fiveQIHdr = indHdrFormat1.FiveQI
305 if indHdrFormat1.Qci != -1 {
306 log.Printf("QCI: %d", indHdrFormat1.Qci)
309 if indHdrFormat1.UeMessageType != -1 {
310 log.Printf("Ue Report type: %d", indHdrFormat1.UeMessageType)
313 if indHdrFormat1.GnbDUID != nil {
314 log.Printf("gNB-DU-ID: %x", indHdrFormat1.GnbDUID.Buf)
317 if indHdrFormat1.GnbNameType == 1 {
318 log.Printf("gNB-DU-Name: %x", (indHdrFormat1.GnbName.(*GNB_DU_Name)).Buf)
319 } else if indHdrFormat1.GnbNameType == 2 {
320 log.Printf("gNB-CU-CP-Name: %x", (indHdrFormat1.GnbName.(*GNB_CU_CP_Name)).Buf)
321 } else if indHdrFormat1.GnbNameType == 3 {
322 log.Printf("gNB-CU-UP-Name: %x", (indHdrFormat1.GnbName.(*GNB_CU_UP_Name)).Buf)
325 if indHdrFormat1.GlobalgNBID != nil {
326 log.Printf("PlmnID: %x", indHdrFormat1.GlobalgNBID.PlmnID.Buf)
327 log.Printf("gNB ID Type: %d", indHdrFormat1.GlobalgNBID.GnbIDType)
328 if indHdrFormat1.GlobalgNBID.GnbIDType == 1 {
329 gNBID := indHdrFormat1.GlobalgNBID.GnbID.(*GNBID)
330 log.Printf("gNB ID ID: %x, Unused: %d", gNBID.Buf, gNBID.BitsUnused)
335 xapp.Logger.Error("Unknown RIC Indication Header Format: %d", indicationHdr.IndHdrType)
336 log.Printf("Unknown RIC Indication Header Format: %d", indicationHdr.IndHdrType)
340 indMsg, err := e2sm.GetIndicationMessage(indicationMsg.IndMessage)
342 xapp.Logger.Error("Failed to decode RIC Indication Message: %v", err)
343 log.Printf("Failed to decode RIC Indication Message: %v", err)
348 var containerType int32
349 var timestampPDCPBytes *Timestamp
350 var dlPDCPBytes int64
351 var ulPDCPBytes int64
352 var timestampPRB *Timestamp
356 log.Printf("-----------RIC Indication Message-----------")
357 log.Printf("StyleType: %d", indMsg.StyleType)
358 if indMsg.IndMsgType == 1 {
359 log.Printf("RIC Indication Message Format: %d", indMsg.IndMsgType)
361 indMsgFormat1 := indMsg.IndMsg.(*IndicationMessageFormat1)
363 log.Printf("PMContainerCount: %d", indMsgFormat1.PMContainerCount)
365 for i := 0; i < indMsgFormat1.PMContainerCount; i++ {
367 timestampPDCPBytes = nil
374 log.Printf("PMContainer[%d]: ", i)
376 pmContainer := indMsgFormat1.PMContainers[i]
378 if pmContainer.PFContainer != nil {
379 containerType = pmContainer.PFContainer.ContainerType
381 log.Printf("PFContainerType: %d", containerType)
383 if containerType == 1 {
384 log.Printf("oDU PF Container: ")
386 oDU := pmContainer.PFContainer.Container.(*ODUPFContainerType)
388 cellResourceReportCount := oDU.CellResourceReportCount
389 log.Printf("CellResourceReportCount: %d", cellResourceReportCount)
391 for j := 0; j < cellResourceReportCount; j++ {
392 log.Printf("CellResourceReport[%d]: ", j)
394 cellResourceReport := oDU.CellResourceReports[j]
396 log.Printf("nRCGI.PlmnID: %x", cellResourceReport.NRCGI.PlmnID.Buf)
397 log.Printf("nRCGI.nRCellID: %x", cellResourceReport.NRCGI.NRCellID.Buf)
399 cellID, err := e2sm.ParseNRCGI(cellResourceReport.NRCGI)
401 xapp.Logger.Error("Failed to parse CellID in DU PF Container: %v", err)
402 log.Printf("Failed to parse CellID in DU PF Container: %v", err)
405 if cellID == cellIDHdr {
409 log.Printf("TotalofAvailablePRBsDL: %d", cellResourceReport.TotalofAvailablePRBs.DL)
410 log.Printf("TotalofAvailablePRBsUL: %d", cellResourceReport.TotalofAvailablePRBs.UL)
413 availPRBDL = cellResourceReport.TotalofAvailablePRBs.DL
414 availPRBUL = cellResourceReport.TotalofAvailablePRBs.UL
417 servedPlmnPerCellCount := cellResourceReport.ServedPlmnPerCellCount
418 log.Printf("ServedPlmnPerCellCount: %d", servedPlmnPerCellCount)
420 for k := 0; k < servedPlmnPerCellCount; k++ {
421 log.Printf("ServedPlmnPerCell[%d]: ", k)
423 servedPlmnPerCell := cellResourceReport.ServedPlmnPerCells[k]
425 log.Printf("PlmnID: %x", servedPlmnPerCell.PlmnID.Buf)
427 if servedPlmnPerCell.DUPM5GC != nil {
428 slicePerPlmnPerCellCount := servedPlmnPerCell.DUPM5GC.SlicePerPlmnPerCellCount
429 log.Printf("SlicePerPlmnPerCellCount: %d", slicePerPlmnPerCellCount)
431 for l := 0; l < slicePerPlmnPerCellCount; l++ {
432 log.Printf("SlicePerPlmnPerCell[%d]: ", l)
434 slicePerPlmnPerCell := servedPlmnPerCell.DUPM5GC.SlicePerPlmnPerCells[l]
436 log.Printf("SliceID.sST: %x", slicePerPlmnPerCell.SliceID.SST.Buf)
437 if slicePerPlmnPerCell.SliceID.SD != nil {
438 log.Printf("SliceID.sD: %x", slicePerPlmnPerCell.SliceID.SD.Buf)
441 fQIPERSlicesPerPlmnPerCellCount := slicePerPlmnPerCell.FQIPERSlicesPerPlmnPerCellCount
442 log.Printf("5QIPerSlicesPerPlmnPerCellCount: %d", fQIPERSlicesPerPlmnPerCellCount)
444 for m := 0; m < fQIPERSlicesPerPlmnPerCellCount; m++ {
445 log.Printf("5QIPerSlicesPerPlmnPerCell[%d]: ", m)
447 fQIPERSlicesPerPlmnPerCell := slicePerPlmnPerCell.FQIPERSlicesPerPlmnPerCells[m]
449 log.Printf("5QI: %d", fQIPERSlicesPerPlmnPerCell.FiveQI)
450 log.Printf("PrbUsageDL: %d", fQIPERSlicesPerPlmnPerCell.PrbUsage.DL)
451 log.Printf("PrbUsageUL: %d", fQIPERSlicesPerPlmnPerCell.PrbUsage.UL)
456 if servedPlmnPerCell.DUPMEPC != nil {
457 perQCIReportCount := servedPlmnPerCell.DUPMEPC.PerQCIReportCount
458 log.Printf("PerQCIReportCount: %d", perQCIReportCount)
460 for l := 0; l < perQCIReportCount; l++ {
461 log.Printf("PerQCIReports[%d]: ", l)
463 perQCIReport := servedPlmnPerCell.DUPMEPC.PerQCIReports[l]
465 log.Printf("QCI: %d", perQCIReport.QCI)
466 log.Printf("PrbUsageDL: %d", perQCIReport.PrbUsage.DL)
467 log.Printf("PrbUsageUL: %d", perQCIReport.PrbUsage.UL)
472 } else if containerType == 2 {
473 log.Printf("oCU-CP PF Container: ")
475 oCUCP := pmContainer.PFContainer.Container.(*OCUCPPFContainerType)
477 if oCUCP.GNBCUCPName != nil {
478 log.Printf("gNB-CU-CP Name: %x", oCUCP.GNBCUCPName.Buf)
481 log.Printf("NumberOfActiveUEs: %d", oCUCP.CUCPResourceStatus.NumberOfActiveUEs)
482 } else if containerType == 3 {
483 log.Printf("oCU-UP PF Container: ")
485 oCUUP := pmContainer.PFContainer.Container.(*OCUUPPFContainerType)
487 if oCUUP.GNBCUUPName != nil {
488 log.Printf("gNB-CU-UP Name: %x", oCUUP.GNBCUUPName.Buf)
491 cuUPPFContainerItemCount := oCUUP.CUUPPFContainerItemCount
492 log.Printf("CU-UP PF Container Item Count: %d", cuUPPFContainerItemCount)
494 for j := 0; j < cuUPPFContainerItemCount; j++ {
495 log.Printf("CU-UP PF Container Item [%d]: ", j)
497 cuUPPFContainerItem := oCUUP.CUUPPFContainerItems[j]
499 log.Printf("InterfaceType: %d", cuUPPFContainerItem.InterfaceType)
501 cuUPPlmnCount := cuUPPFContainerItem.OCUUPPMContainer.CUUPPlmnCount
502 log.Printf("CU-UP Plmn Count: %d", cuUPPlmnCount)
504 for k := 0; k < cuUPPlmnCount; k++ {
505 log.Printf("CU-UP Plmn [%d]: ", k)
507 cuUPPlmn := cuUPPFContainerItem.OCUUPPMContainer.CUUPPlmns[k]
509 log.Printf("PlmnID: %x", cuUPPlmn.PlmnID.Buf)
511 plmnID, err := e2sm.ParsePLMNIdentity(cuUPPlmn.PlmnID.Buf, cuUPPlmn.PlmnID.Size)
513 xapp.Logger.Error("Failed to parse PlmnID in CU-UP PF Container: %v", err)
514 log.Printf("Failed to parse PlmnID in CU-UP PF Container: %v", err)
518 if cuUPPlmn.CUUPPM5GC != nil {
519 sliceToReportCount := cuUPPlmn.CUUPPM5GC.SliceToReportCount
520 log.Printf("SliceToReportCount: %d", sliceToReportCount)
522 for l := 0; l < sliceToReportCount; l++ {
523 log.Printf("SliceToReport[%d]: ", l)
525 sliceToReport := cuUPPlmn.CUUPPM5GC.SliceToReports[l]
527 log.Printf("SliceID.sST: %x", sliceToReport.SliceID.SST.Buf)
528 if sliceToReport.SliceID.SD != nil {
529 log.Printf("SliceID.sD: %x", sliceToReport.SliceID.SD.Buf)
532 sliceID, err := e2sm.ParseSliceID(sliceToReport.SliceID)
534 xapp.Logger.Error("Failed to parse sliceID in CU-UP PF Container with PlmnID [%s]: %v", plmnID, err)
535 log.Printf("Failed to parse sliceID in CU-UP PF Container with PlmnID [%s]: %v", plmnID, err)
539 fQIPERSlicesPerPlmnCount := sliceToReport.FQIPERSlicesPerPlmnCount
540 log.Printf("5QIPerSlicesPerPlmnCount: %d", fQIPERSlicesPerPlmnCount)
542 for m := 0; m < fQIPERSlicesPerPlmnCount; m++ {
543 log.Printf("5QIPerSlicesPerPlmn[%d]: ", m)
545 fQIPERSlicesPerPlmn := sliceToReport.FQIPERSlicesPerPlmns[m]
547 fiveQI := fQIPERSlicesPerPlmn.FiveQI
548 log.Printf("5QI: %d", fiveQI)
550 if plmnID == plmnIDHdr && sliceID == sliceIDHdr && fiveQI == fiveQIHdr {
554 if fQIPERSlicesPerPlmn.PDCPBytesDL != nil {
555 log.Printf("PDCPBytesDL: %x", fQIPERSlicesPerPlmn.PDCPBytesDL.Buf)
558 dlPDCPBytes, err = e2sm.ParseInteger(fQIPERSlicesPerPlmn.PDCPBytesDL.Buf, fQIPERSlicesPerPlmn.PDCPBytesDL.Size)
560 xapp.Logger.Error("Failed to parse PDCPBytesDL in CU-UP PF Container with PlmnID [%s], SliceID [%d], 5QI [%d]: %v", plmnID, sliceID, fiveQI, err)
561 log.Printf("Failed to parse PDCPBytesDL in CU-UP PF Container with PlmnID [%s], SliceID [%d], 5QI [%d]: %v", plmnID, sliceID, fiveQI, err)
567 if fQIPERSlicesPerPlmn.PDCPBytesUL != nil {
568 log.Printf("PDCPBytesUL: %x", fQIPERSlicesPerPlmn.PDCPBytesUL.Buf)
571 ulPDCPBytes, err = e2sm.ParseInteger(fQIPERSlicesPerPlmn.PDCPBytesUL.Buf, fQIPERSlicesPerPlmn.PDCPBytesUL.Size)
573 xapp.Logger.Error("Failed to parse PDCPBytesUL in CU-UP PF Container with PlmnID [%s], SliceID [%d], 5QI [%d]: %v", plmnID, sliceID, fiveQI, err)
574 log.Printf("Failed to parse PDCPBytesUL in CU-UP PF Container with PlmnID [%s], SliceID [%d], 5QI [%d]: %v", plmnID, sliceID, fiveQI, err)
583 if cuUPPlmn.CUUPPMEPC != nil {
584 cuUPPMEPCPerQCIReportCount := cuUPPlmn.CUUPPMEPC.CUUPPMEPCPerQCIReportCount
585 log.Printf("PerQCIReportCount: %d", cuUPPMEPCPerQCIReportCount)
587 for l := 0; l < cuUPPMEPCPerQCIReportCount; l++ {
588 log.Printf("PerQCIReport[%d]: ", l)
590 cuUPPMEPCPerQCIReport := cuUPPlmn.CUUPPMEPC.CUUPPMEPCPerQCIReports[l]
592 log.Printf("QCI: %d", cuUPPMEPCPerQCIReport.QCI)
594 if cuUPPMEPCPerQCIReport.PDCPBytesDL != nil {
595 log.Printf("PDCPBytesDL: %x", cuUPPMEPCPerQCIReport.PDCPBytesDL.Buf)
597 if cuUPPMEPCPerQCIReport.PDCPBytesUL != nil {
598 log.Printf("PDCPBytesUL: %x", cuUPPMEPCPerQCIReport.PDCPBytesUL.Buf)
605 xapp.Logger.Error("Unknown PF Container type: %d", containerType)
606 log.Printf("Unknown PF Container type: %d", containerType)
611 if pmContainer.RANContainer != nil {
612 log.Printf("RANContainer: %x", pmContainer.RANContainer.Timestamp.Buf)
614 timestamp, _ := e2sm.ParseTimestamp(pmContainer.RANContainer.Timestamp.Buf, pmContainer.RANContainer.Timestamp.Size)
615 log.Printf("Timestamp=[sec: %d, nsec: %d]", timestamp.TVsec, timestamp.TVnsec)
617 containerType = pmContainer.RANContainer.ContainerType
618 if containerType == 1 {
619 log.Printf("DU Usage Report: ")
621 oDUUE := pmContainer.RANContainer.Container.(*DUUsageReportType)
623 for j := 0; j < oDUUE.CellResourceReportItemCount; j++ {
624 cellResourceReportItem := oDUUE.CellResourceReportItems[j]
626 log.Printf("nRCGI.PlmnID: %x", cellResourceReportItem.NRCGI.PlmnID.Buf)
627 log.Printf("nRCGI.NRCellID: %x, Unused: %d", cellResourceReportItem.NRCGI.NRCellID.Buf, cellResourceReportItem.NRCGI.NRCellID.BitsUnused)
629 servingCellID, err := e2sm.ParseNRCGI(cellResourceReportItem.NRCGI)
631 xapp.Logger.Error("Failed to parse NRCGI in DU Usage Report: %v", err)
632 log.Printf("Failed to parse NRCGI in DU Usage Report: %v", err)
636 for k := 0; k < cellResourceReportItem.UeResourceReportItemCount; k++ {
637 ueResourceReportItem := cellResourceReportItem.UeResourceReportItems[k]
639 log.Printf("C-RNTI: %x", ueResourceReportItem.CRNTI.Buf)
641 ueID, err := e2sm.ParseInteger(ueResourceReportItem.CRNTI.Buf, ueResourceReportItem.CRNTI.Size)
643 xapp.Logger.Error("Failed to parse C-RNTI in DU Usage Report with Serving Cell ID [%s]: %v", servingCellID, err)
644 log.Printf("Failed to parse C-RNTI in DU Usage Report with Serving Cell ID [%s]: %v", servingCellID, err)
648 var ueMetrics UeMetricsEntry
650 retStr, err := c.sdl.Get([]string{"{TS-UE-metrics}," + strconv.FormatInt(ueID, 10)})
653 xapp.Logger.Error("Failed to get ueMetrics from Redis!")
654 log.Printf("Failed to get ueMetrics from Redis!")
656 if retStr["{TS-UE-metrics}," + strconv.FormatInt(ueID, 10)] != nil {
657 ueJsonStr := retStr["{TS-UE-metrics}," + strconv.FormatInt(ueID, 10)].(string)
658 json.Unmarshal([]byte(ueJsonStr), &ueMetrics)
662 //if isUeExist, _ := c.client.Exists("{TS-UE-metrics}," + strconv.FormatInt(ueID, 10)).Result(); isUeExist == 1 {
663 // ueJsonStr, _ := c.client.Get("{TS-UE-metrics}," + strconv.FormatInt(ueID, 10)).Result()
664 // json.Unmarshal([]byte(ueJsonStr), &ueMetrics)
667 ueMetrics.UeID = ueID
668 log.Printf("UeID: %d", ueMetrics.UeID)
669 ueMetrics.ServingCellID = servingCellID
670 log.Printf("ServingCellID: %s", ueMetrics.ServingCellID)
671 ueMetrics.MeasPeriodRF = 20
674 timestampPRB = timestamp
677 ueMetrics.MeasTimestampPRB.TVsec = timestamp.TVsec
678 ueMetrics.MeasTimestampPRB.TVnsec = timestamp.TVnsec
680 if ueResourceReportItem.PRBUsageDL != -1 {
681 ueMetrics.PRBUsageDL = ueResourceReportItem.PRBUsageDL
682 log.Printf("PRBUsageDL: %d", ueMetrics.PRBUsageDL)
685 if ueResourceReportItem.PRBUsageUL != -1 {
686 ueMetrics.PRBUsageUL = ueResourceReportItem.PRBUsageUL
687 log.Printf("PRBUsageUL: %d", ueMetrics.PRBUsageUL)
690 newUeJsonStr, err := json.Marshal(&ueMetrics)
692 xapp.Logger.Error("Failed to marshal UeMetrics with UE ID [%d]: %v", ueID, err)
693 log.Printf("Failed to marshal UeMetrics with UE ID [%d]: %v", ueID, err)
697 err = c.sdl.Set("{TS-UE-metrics}," + strconv.FormatInt(ueID, 10), newUeJsonStr)
699 xapp.Logger.Error("Failed to set UeMetrics into redis with UE ID [%d]: %v", ueID, err)
700 log.Printf("Failed to set UeMetrics into redis with UE ID [%d]: %v", ueID, err)
704 //err = c.client.Set("{TS-UE-metrics}," + strconv.FormatInt(ueID, 10), newUeJsonStr, 0).Err()
706 // xapp.Logger.Error("Failed to set UeMetrics into redis with UE ID [%d]: %v", ueID, err)
707 // log.Printf("Failed to set UeMetrics into redis with UE ID [%d]: %v", ueID, err)
712 } else if containerType == 2 {
713 log.Printf("CU-CP Usage Report: ")
715 oCUCPUE := pmContainer.RANContainer.Container.(*CUCPUsageReportType)
717 for j := 0; j < oCUCPUE.CellResourceReportItemCount; j++ {
718 cellResourceReportItem := oCUCPUE.CellResourceReportItems[j]
720 log.Printf("nRCGI.PlmnID: %x", cellResourceReportItem.NRCGI.PlmnID.Buf)
721 log.Printf("nRCGI.NRCellID: %x, Unused: %d", cellResourceReportItem.NRCGI.NRCellID.Buf, cellResourceReportItem.NRCGI.NRCellID.BitsUnused)
723 servingCellID, err := e2sm.ParseNRCGI(cellResourceReportItem.NRCGI)
725 xapp.Logger.Error("Failed to parse NRCGI in CU-CP Usage Report: %v", err)
726 log.Printf("Failed to parse NRCGI in CU-CP Usage Report: %v", err)
730 for k := 0; k < cellResourceReportItem.UeResourceReportItemCount; k++ {
731 ueResourceReportItem := cellResourceReportItem.UeResourceReportItems[k]
733 log.Printf("C-RNTI: %x", ueResourceReportItem.CRNTI.Buf)
735 ueID, err := e2sm.ParseInteger(ueResourceReportItem.CRNTI.Buf, ueResourceReportItem.CRNTI.Size)
737 xapp.Logger.Error("Failed to parse C-RNTI in CU-CP Usage Report with Serving Cell ID [%s]: %v", err)
738 log.Printf("Failed to parse C-RNTI in CU-CP Usage Report with Serving Cell ID [%s]: %v", err)
742 var ueMetrics UeMetricsEntry
744 retStr, err := c.sdl.Get([]string{"{TS-UE-metrics}," + strconv.FormatInt(ueID, 10)})
747 xapp.Logger.Error("Failed to get ueMetrics from Redis!")
748 log.Printf("Failed to get ueMetrics from Redis!")
750 if retStr["{TS-UE-metrics}," + strconv.FormatInt(ueID, 10)] != nil {
751 ueJsonStr := retStr["{TS-UE-metrics}," + strconv.FormatInt(ueID, 10)].(string)
752 json.Unmarshal([]byte(ueJsonStr), &ueMetrics)
756 //if isUeExist, _ := c.client.Exists("{TS-UE-metrics}," + strconv.FormatInt(ueID, 10)).Result(); isUeExist == 1 {
757 // ueJsonStr, _ := c.client.Get("{TS-UE-metrics}," + strconv.FormatInt(ueID, 10)).Result()
758 // json.Unmarshal([]byte(ueJsonStr), &ueMetrics)
761 ueMetrics.UeID = ueID
762 log.Printf("UeID: %d", ueMetrics.UeID)
763 ueMetrics.ServingCellID = servingCellID
764 log.Printf("ServingCellID: %s", ueMetrics.ServingCellID)
766 ueMetrics.MeasTimeRF.TVsec = timestamp.TVsec
767 ueMetrics.MeasTimeRF.TVnsec = timestamp.TVnsec
769 ueMetrics.MeasPeriodPDCP = 20
770 ueMetrics.MeasPeriodPRB = 20
772 if ueResourceReportItem.ServingCellRF != nil {
773 err = json.Unmarshal(ueResourceReportItem.ServingCellRF.Buf, &ueMetrics.ServingCellRF)
774 log.Printf("ueMetrics.ServingCellRF: %+v", ueMetrics.ServingCellRF)
776 xapp.Logger.Error("Failed to Unmarshal ServingCellRF in CU-CP Usage Report with UE ID [%d]: %v", ueID, err)
777 log.Printf("Failed to Unmarshal ServingCellRF in CU-CP Usage Report with UE ID [%d]: %v", ueID, err)
778 log.Printf("ServingCellRF raw data: %x", ueResourceReportItem.ServingCellRF.Buf)
783 if ueResourceReportItem.NeighborCellRF != nil {
784 err = json.Unmarshal(ueResourceReportItem.NeighborCellRF.Buf, &ueMetrics.NeighborCellsRF)
785 log.Printf("ueMetrics.NeighborCellsRF: %+v", ueMetrics.NeighborCellsRF)
787 xapp.Logger.Error("Failed to Unmarshal NeighborCellRF in CU-CP Usage Report with UE ID [%d]: %v", ueID, err)
788 log.Printf("Failed to Unmarshal NeighborCellRF in CU-CP Usage Report with UE ID [%d]: %v", ueID, err)
789 log.Printf("NeighborCellRF raw data: %x", ueResourceReportItem.NeighborCellRF.Buf)
794 newUeJsonStr, err := json.Marshal(&ueMetrics)
796 xapp.Logger.Error("Failed to marshal UeMetrics with UE ID [%d]: %v", ueID, err)
797 log.Printf("Failed to marshal UeMetrics with UE ID [%d]: %v", ueID, err)
801 err = c.sdl.Set("{TS-UE-metrics}," + strconv.FormatInt(ueID, 10), newUeJsonStr)
803 xapp.Logger.Error("Failed to set UeMetrics into redis with UE ID [%d]: %v", ueID, err)
804 log.Printf("Failed to set UeMetrics into redis with UE ID [%d]: %v", ueID, err)
808 //err = c.client.Set("{TS-UE-metrics}," + strconv.FormatInt(ueID, 10), newUeJsonStr, 0).Err()
810 // xapp.Logger.Error("Failed to set UeMetrics into redis with UE ID [%d]: %v", ueID, err)
811 // log.Printf("Failed to set UeMetrics into redis with UE ID [%d]: %v", ueID, err)
816 } else if containerType == 3 {
817 log.Printf("CU-UP Usage Report: ")
819 oCUUPUE := pmContainer.RANContainer.Container.(*CUUPUsageReportType)
821 for j := 0; j < oCUUPUE.CellResourceReportItemCount; j++ {
822 cellResourceReportItem := oCUUPUE.CellResourceReportItems[j]
824 log.Printf("nRCGI.PlmnID: %x", cellResourceReportItem.NRCGI.PlmnID.Buf)
825 log.Printf("nRCGI.NRCellID: %x, Unused: %d", cellResourceReportItem.NRCGI.NRCellID.Buf, cellResourceReportItem.NRCGI.NRCellID.BitsUnused)
827 servingCellID, err := e2sm.ParseNRCGI(cellResourceReportItem.NRCGI)
829 xapp.Logger.Error("Failed to parse NRCGI in CU-UP Usage Report: %v", err)
830 log.Printf("Failed to parse NRCGI in CU-UP Usage Report: %v", err)
834 for k := 0; k < cellResourceReportItem.UeResourceReportItemCount; k++ {
835 ueResourceReportItem := cellResourceReportItem.UeResourceReportItems[k]
837 log.Printf("C-RNTI: %x", ueResourceReportItem.CRNTI.Buf)
839 ueID, err := e2sm.ParseInteger(ueResourceReportItem.CRNTI.Buf, ueResourceReportItem.CRNTI.Size)
841 xapp.Logger.Error("Failed to parse C-RNTI in CU-UP Usage Report Serving Cell ID [%s]: %v", servingCellID, err)
842 log.Printf("Failed to parse C-RNTI in CU-UP Usage Report Serving Cell ID [%s]: %v", servingCellID, err)
846 var ueMetrics UeMetricsEntry
848 retStr, err := c.sdl.Get([]string{"{TS-UE-metrics}," + strconv.FormatInt(ueID, 10)})
851 xapp.Logger.Error("Failed to get ueMetrics from Redis!")
852 log.Printf("Failed to get ueMetrics from Redis!")
854 if retStr["{TS-UE-metrics}," + strconv.FormatInt(ueID, 10)] != nil {
855 ueJsonStr := retStr["{TS-UE-metrics}," + strconv.FormatInt(ueID, 10)].(string)
856 json.Unmarshal([]byte(ueJsonStr), &ueMetrics)
860 //if isUeExist, _ := c.client.Exists("{TS-UE-metrics}," + strconv.FormatInt(ueID, 10)).Result(); isUeExist == 1 {
861 // ueJsonStr, _ := c.client.Get("{TS-UE-metrics}," + strconv.FormatInt(ueID, 10)).Result()
862 // json.Unmarshal([]byte(ueJsonStr), &ueMetrics)
865 ueMetrics.UeID = ueID
866 log.Printf("UeID: %d", ueMetrics.UeID)
867 ueMetrics.ServingCellID = servingCellID
868 log.Printf("ServingCellID: %s", ueMetrics.ServingCellID)
871 timestampPDCPBytes = timestamp
874 ueMetrics.MeasTimestampPDCPBytes.TVsec = timestamp.TVsec
875 ueMetrics.MeasTimestampPDCPBytes.TVnsec = timestamp.TVnsec
877 if ueResourceReportItem.PDCPBytesDL != nil {
878 ueMetrics.PDCPBytesDL, err = e2sm.ParseInteger(ueResourceReportItem.PDCPBytesDL.Buf, ueResourceReportItem.PDCPBytesDL.Size)
880 xapp.Logger.Error("Failed to parse PDCPBytesDL in CU-UP Usage Report with UE ID [%d]: %v", ueID, err)
881 log.Printf("Failed to parse PDCPBytesDL in CU-UP Usage Report with UE ID [%d]: %v", ueID, err)
886 if ueResourceReportItem.PDCPBytesUL != nil {
887 ueMetrics.PDCPBytesUL, err = e2sm.ParseInteger(ueResourceReportItem.PDCPBytesUL.Buf, ueResourceReportItem.PDCPBytesUL.Size)
889 xapp.Logger.Error("Failed to parse PDCPBytesUL in CU-UP Usage Report with UE ID [%d]: %v", ueID, err)
890 log.Printf("Failed to parse PDCPBytesUL in CU-UP Usage Report with UE ID [%d]: %v", ueID, err)
895 newUeJsonStr, err := json.Marshal(&ueMetrics)
897 xapp.Logger.Error("Failed to marshal UeMetrics with UE ID [%d]: %v", ueID, err)
898 log.Printf("Failed to marshal UeMetrics with UE ID [%d]: %v", ueID, err)
902 err = c.sdl.Set("{TS-UE-metrics}," + strconv.FormatInt(ueID, 10), newUeJsonStr)
904 xapp.Logger.Error("Failed to set UeMetrics into redis with UE ID [%d]: %v", ueID, err)
905 log.Printf("Failed to set UeMetrics into redis with UE ID [%d]: %v", ueID, err)
909 //err = c.client.Set("{TS-UE-metrics}," + strconv.FormatInt(ueID, 10), newUeJsonStr, 0).Err()
911 // xapp.Logger.Error("Failed to set UeMetrics into redis with UE ID [%d]: %v", ueID, err)
912 // log.Printf("Failed to set UeMetrics into redis with UE ID [%d]: %v", ueID, err)
918 xapp.Logger.Error("Unknown PF Container Type: %d", containerType)
919 log.Printf("Unknown PF Container Type: %d", containerType)
925 var cellMetrics CellMetricsEntry
927 retStr, err := c.sdl.Get([]string{"{TS-cell-metrics}," + cellIDHdr})
930 xapp.Logger.Error("Failed to get cellMetrics from Redis!")
931 log.Printf("Failed to get cellMetrics from Redis!")
933 if retStr["{TS-cell-metrics}," + cellIDHdr] != nil {
934 cellJsonStr := retStr["{TS-cell-metrics}," + cellIDHdr].(string)
935 json.Unmarshal([]byte(cellJsonStr), &cellMetrics)
939 //if isCellExist, _ := c.client.Exists("{TS-cell-metrics}," + cellIDHdr).Result(); isCellExist == 1 {
940 // cellJsonStr, _ := c.client.Get("{TS-cell-metrics}," + cellIDHdr).Result()
941 // json.Unmarshal([]byte(cellJsonStr), &cellMetrics)
944 cellMetrics.MeasPeriodPDCP = 20
945 cellMetrics.MeasPeriodPRB = 20
946 cellMetrics.CellID = cellIDHdr
948 if timestampPDCPBytes != nil {
949 cellMetrics.MeasTimestampPDCPBytes.TVsec = timestampPDCPBytes.TVsec
950 cellMetrics.MeasTimestampPDCPBytes.TVnsec = timestampPDCPBytes.TVnsec
952 if dlPDCPBytes != -1 {
953 cellMetrics.PDCPBytesDL = dlPDCPBytes
955 if ulPDCPBytes != -1 {
956 cellMetrics.PDCPBytesUL = ulPDCPBytes
958 if timestampPRB != nil {
959 cellMetrics.MeasTimestampPRB.TVsec = timestampPRB.TVsec
960 cellMetrics.MeasTimestampPRB.TVnsec = timestampPRB.TVnsec
962 if availPRBDL != -1 {
963 cellMetrics.AvailPRBDL = availPRBDL
965 if availPRBUL != -1 {
966 cellMetrics.AvailPRBUL = availPRBUL
969 newCellJsonStr, err := json.Marshal(&cellMetrics)
971 xapp.Logger.Error("Failed to marshal CellMetrics with CellID [%s]: %v", cellIDHdr, err)
972 log.Printf("Failed to marshal CellMetrics with CellID [%s]: %v", cellIDHdr, err)
976 err = c.sdl.Set("{TS-cell-metrics}," + cellIDHdr, newCellJsonStr)
978 xapp.Logger.Error("Failed to set CellMetrics into redis with CellID [%s]: %v", cellIDHdr, err)
979 log.Printf("Failed to set CellMetrics into redis with CellID [%s]: %v", cellIDHdr, err)
984 //err = c.client.Set("{TS-cell-metrics}," + cellIDHdr, newCellJsonStr, 0).Err()
986 // xapp.Logger.Error("Failed to set CellMetrics into redis with CellID [%s]: %v", cellIDHdr, err)
987 // log.Printf("Failed to set CellMetrics into redis with CellID [%s]: %v", cellIDHdr, err)
993 xapp.Logger.Error("Unknown RIC Indication Message Format: %d", indMsg.IndMsgType)
994 log.Printf("Unkonw RIC Indication Message Format: %d", indMsg.IndMsgType)
1001 func (c *Control) handleSubscriptionResponse(params *xapp.RMRParams) (err error) {
1002 xapp.Logger.Debug("The SubId in RIC_SUB_RESP is %d", params.SubId)
1003 log.Printf("The SubId in RIC_SUB_RESP is %d", params.SubId)
1005 ranName := params.Meid.RanName
1006 c.eventCreateExpiredMu.Lock()
1007 _, ok := c.eventCreateExpiredMap[ranName]
1009 c.eventCreateExpiredMu.Unlock()
1010 xapp.Logger.Debug("RIC_SUB_REQ has been deleted!")
1011 log.Printf("RIC_SUB_REQ has been deleted!")
1014 c.eventCreateExpiredMap[ranName] = true
1015 c.eventCreateExpiredMu.Unlock()
1019 subscriptionResp, err := cep.GetSubscriptionResponseMessage(params.Payload)
1021 xapp.Logger.Error("Failed to decode RIC Subscription Response message: %v", err)
1022 log.Printf("Failed to decode RIC Subscription Response message: %v", err)
1026 log.Printf("RIC Subscription Response message from {%s} received", params.Meid.RanName)
1027 log.Printf("SubscriptionID: %d", params.SubId)
1028 log.Printf("RequestID: %d", subscriptionResp.RequestID)
1029 log.Printf("RequestSequenceNumber: %d", subscriptionResp.RequestSequenceNumber)
1030 log.Printf("FunctionID: %d", subscriptionResp.FuncID)
1032 log.Printf("ActionAdmittedList:")
1033 for index := 0; index < subscriptionResp.ActionAdmittedList.Count; index++ {
1034 log.Printf("[%d]ActionID: %d", index, subscriptionResp.ActionAdmittedList.ActionID[index])
1037 log.Printf("ActionNotAdmittedList:")
1038 for index := 0; index < subscriptionResp.ActionNotAdmittedList.Count; index++ {
1039 log.Printf("[%d]ActionID: %d", index, subscriptionResp.ActionNotAdmittedList.ActionID[index])
1040 log.Printf("[%d]CauseType: %d CauseID: %d", index, subscriptionResp.ActionNotAdmittedList.Cause[index].CauseType, subscriptionResp.ActionNotAdmittedList.Cause[index].CauseID)
1046 func (c *Control) handleSubscriptionFailure(params *xapp.RMRParams) (err error) {
1047 xapp.Logger.Debug("The SubId in RIC_SUB_FAILURE is %d", params.SubId)
1048 log.Printf("The SubId in RIC_SUB_FAILURE is %d", params.SubId)
1050 ranName := params.Meid.RanName
1051 c.eventCreateExpiredMu.Lock()
1052 _, ok := c.eventCreateExpiredMap[ranName]
1054 c.eventCreateExpiredMu.Unlock()
1055 xapp.Logger.Debug("RIC_SUB_REQ has been deleted!")
1056 log.Printf("RIC_SUB_REQ has been deleted!")
1059 c.eventCreateExpiredMap[ranName] = true
1060 c.eventCreateExpiredMu.Unlock()
1066 func (c *Control) handleSubscriptionDeleteResponse(params *xapp.RMRParams) (err error) {
1067 xapp.Logger.Debug("The SubId in RIC_SUB_DEL_RESP is %d", params.SubId)
1068 log.Printf("The SubId in RIC_SUB_DEL_RESP is %d", params.SubId)
1070 ranName := params.Meid.RanName
1071 c.eventDeleteExpiredMu.Lock()
1072 _, ok := c.eventDeleteExpiredMap[ranName]
1074 c.eventDeleteExpiredMu.Unlock()
1075 xapp.Logger.Debug("RIC_SUB_DEL_REQ has been deleted!")
1076 log.Printf("RIC_SUB_DEL_REQ has been deleted!")
1079 c.eventDeleteExpiredMap[ranName] = true
1080 c.eventDeleteExpiredMu.Unlock()
1086 func (c *Control) handleSubscriptionDeleteFailure(params *xapp.RMRParams) (err error) {
1087 xapp.Logger.Debug("The SubId in RIC_SUB_DEL_FAILURE is %d", params.SubId)
1088 log.Printf("The SubId in RIC_SUB_DEL_FAILURE is %d", params.SubId)
1090 ranName := params.Meid.RanName
1091 c.eventDeleteExpiredMu.Lock()
1092 _, ok := c.eventDeleteExpiredMap[ranName]
1094 c.eventDeleteExpiredMu.Unlock()
1095 xapp.Logger.Debug("RIC_SUB_DEL_REQ has been deleted!")
1096 log.Printf("RIC_SUB_DEL_REQ has been deleted!")
1099 c.eventDeleteExpiredMap[ranName] = true
1100 c.eventDeleteExpiredMu.Unlock()
1106 func (c *Control) setEventCreateExpiredTimer(ranName string) {
1107 c.eventCreateExpiredMu.Lock()
1108 c.eventCreateExpiredMap[ranName] = false
1109 c.eventCreateExpiredMu.Unlock()
1111 timer := time.NewTimer(time.Duration(c.eventCreateExpired) * time.Second)
1112 go func(t *time.Timer) {
1114 xapp.Logger.Debug("RIC_SUB_REQ[%s]: Waiting for RIC_SUB_RESP...", ranName)
1115 log.Printf("RIC_SUB_REQ[%s]: Waiting for RIC_SUB_RESP...", ranName)
1119 c.eventCreateExpiredMu.Lock()
1120 isResponsed := c.eventCreateExpiredMap[ranName]
1121 delete(c.eventCreateExpiredMap, ranName)
1122 c.eventCreateExpiredMu.Unlock()
1124 xapp.Logger.Debug("RIC_SUB_REQ[%s]: RIC Event Create Timer experied!", ranName)
1125 log.Printf("RIC_SUB_REQ[%s]: RIC Event Create Timer experied!", ranName)
1126 // c.sendRicSubDelRequest(subID, requestSN, funcID)
1130 c.eventCreateExpiredMu.Lock()
1131 flag := c.eventCreateExpiredMap[ranName]
1133 delete(c.eventCreateExpiredMap, ranName)
1134 c.eventCreateExpiredMu.Unlock()
1135 xapp.Logger.Debug("RIC_SUB_REQ[%s]: RIC Event Create Timer canceled!", ranName)
1136 log.Printf("RIC_SUB_REQ[%s]: RIC Event Create Timer canceled!", ranName)
1139 c.eventCreateExpiredMu.Unlock()
1142 time.Sleep(100 * time.Millisecond)
1147 func (c *Control) setEventDeleteExpiredTimer(ranName string) {
1148 c.eventDeleteExpiredMu.Lock()
1149 c.eventDeleteExpiredMap[ranName] = false
1150 c.eventDeleteExpiredMu.Unlock()
1152 timer := time.NewTimer(time.Duration(c.eventDeleteExpired) * time.Second)
1153 go func(t *time.Timer) {
1155 xapp.Logger.Debug("RIC_SUB_DEL_REQ[%s]: Waiting for RIC_SUB_DEL_RESP...", ranName)
1156 log.Printf("RIC_SUB_DEL_REQ[%s]: Waiting for RIC_SUB_DEL_RESP...", ranName)
1160 c.eventDeleteExpiredMu.Lock()
1161 isResponsed := c.eventDeleteExpiredMap[ranName]
1162 delete(c.eventDeleteExpiredMap, ranName)
1163 c.eventDeleteExpiredMu.Unlock()
1165 xapp.Logger.Debug("RIC_SUB_DEL_REQ[%s]: RIC Event Delete Timer experied!", ranName)
1166 log.Printf("RIC_SUB_DEL_REQ[%s]: RIC Event Delete Timer experied!", ranName)
1170 c.eventDeleteExpiredMu.Lock()
1171 flag := c.eventDeleteExpiredMap[ranName]
1173 delete(c.eventDeleteExpiredMap, ranName)
1174 c.eventDeleteExpiredMu.Unlock()
1175 xapp.Logger.Debug("RIC_SUB_DEL_REQ[%s]: RIC Event Delete Timer canceled!", ranName)
1176 log.Printf("RIC_SUB_DEL_REQ[%s]: RIC Event Delete Timer canceled!", ranName)
1179 c.eventDeleteExpiredMu.Unlock()
1182 time.Sleep(100 * time.Millisecond)
1187 func (c *Control) sendRicSubRequest(subID int, requestSN int, funcID int) (err error) {
1191 var eventTriggerCount int = 1
1192 var periods []int64 = []int64{13}
1193 var eventTriggerDefinition []byte = make([]byte, 8)
1194 _, err = e2sm.SetEventTriggerDefinition(eventTriggerDefinition, eventTriggerCount, periods)
1196 xapp.Logger.Error("Failed to send RIC_SUB_REQ: %v", err)
1197 log.Printf("Failed to send RIC_SUB_REQ: %v", err)
1200 log.Printf("Set EventTriggerDefinition: %x", eventTriggerDefinition)
1202 var actionCount int = 1
1203 var ricStyleType []int64 = []int64{0}
1204 var actionIds []int64 = []int64{0}
1205 var actionTypes []int64 = []int64{0}
1206 var actionDefinitions []ActionDefinition = make([]ActionDefinition, actionCount)
1207 var subsequentActions []SubsequentAction = []SubsequentAction{SubsequentAction{0, 0, 0}}
1209 for index := 0; index < actionCount; index++ {
1210 if ricStyleType[index] == 0 {
1211 actionDefinitions[index].Buf = nil
1212 actionDefinitions[index].Size = 0
1214 actionDefinitions[index].Buf = make([]byte, 8)
1215 _, err = e2sm.SetActionDefinition(actionDefinitions[index].Buf, ricStyleType[index])
1217 xapp.Logger.Error("Failed to send RIC_SUB_REQ: %v", err)
1218 log.Printf("Failed to send RIC_SUB_REQ: %v", err)
1221 actionDefinitions[index].Size = len(actionDefinitions[index].Buf)
1223 log.Printf("Set ActionDefinition[%d]: %x", index, actionDefinitions[index].Buf)
1227 for index := 0; index < 1; index++ { //len(c.ranList)
1228 params := &xapp.RMRParams{}
1229 params.Mtype = 12010
1230 params.SubId = subID
1232 //xapp.Logger.Debug("Send RIC_SUB_REQ to {%s}", c.ranList[index])
1233 //log.Printf("Send RIC_SUB_REQ to {%s}", c.ranList[index])
1235 params.Payload = make([]byte, 1024)
1236 params.Payload, err = e2ap.SetSubscriptionRequestPayload(params.Payload, 1001, uint16(requestSN), uint16(funcID), eventTriggerDefinition, len(eventTriggerDefinition), actionCount, actionIds, actionTypes, actionDefinitions, subsequentActions)
1238 xapp.Logger.Error("Failed to send RIC_SUB_REQ: %v", err)
1239 log.Printf("Failed to send RIC_SUB_REQ: %v", err)
1243 log.Printf("Set Payload: %x", params.Payload)
1245 //params.Meid = &xapp.RMRMeid{RanName: c.ranList[index]}
1246 params.Meid = &xapp.RMRMeid{PlmnID: "373437", EnbID: "10110101110001100111011110001", RanName: "gnb_734_733_b5c67788"}
1247 xapp.Logger.Debug("The RMR message to be sent is %d with SubId=%d", params.Mtype, params.SubId)
1248 log.Printf("The RMR message to be sent is %d with SubId=%d", params.Mtype, params.SubId)
1250 err = c.rmrSend(params)
1252 xapp.Logger.Error("Failed to send RIC_SUB_REQ: %v", err)
1253 log.Printf("Failed to send RIC_SUB_REQ: %v", err)
1257 c.setEventCreateExpiredTimer(params.Meid.RanName)
1258 //c.ranList = append(c.ranList[:index], c.ranList[index+1:]...)
1265 func (c *Control) sendRicSubDelRequest(subID int, requestSN int, funcID int) (err error) {
1266 params := &xapp.RMRParams{}
1267 params.Mtype = 12020
1268 params.SubId = subID
1271 params.Payload = make([]byte, 1024)
1272 params.Payload, err = e2ap.SetSubscriptionDeleteRequestPayload(params.Payload, 100, uint16(requestSN), uint16(funcID))
1274 xapp.Logger.Error("Failed to send RIC_SUB_DEL_REQ: %v", err)
1278 log.Printf("Set Payload: %x", params.Payload)
1281 //params.Meid = &xapp.RMRMeid{PlmnID: "::", EnbID: "::", RanName: "0"}
1282 params.Meid = &xapp.RMRMeid{PlmnID: "373437", EnbID: "10110101110001100111011110001", RanName: "gnb_734_733_b5c67788"}
1284 //params.Meid = &xapp.RMRMeid{PlmnID: "::", EnbID: "::", RanName: "3"}
1285 params.Meid = &xapp.RMRMeid{PlmnID: "373437", EnbID: "10110101110001100111011110001", RanName: "gnb_734_733_b5c67788"}
1288 xapp.Logger.Debug("The RMR message to be sent is %d with SubId=%d", params.Mtype, params.SubId)
1289 log.Printf("The RMR message to be sent is %d with SubId=%d", params.Mtype, params.SubId)
1291 err = c.rmrSend(params)
1293 xapp.Logger.Error("Failed to send RIC_SUB_DEL_REQ: %v", err)
1294 log.Printf("Failed to send RIC_SUB_DEL_REQ: %v", err)
1298 c.setEventDeleteExpiredTimer(params.Meid.RanName)