2 // ========================LICENSE_START=================================
5 // Copyright (C) 2021: Nordix Foundation
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 // ========================LICENSE_END===================================
31 "github.com/gorilla/mux"
32 "oransc.org/usecase/oduclosedloop/messages"
36 rand.Seed(time.Now().UnixNano())
37 port := flag.Int("port", 3905, "The port this message router will listen on")
41 r.HandleFunc("/events/unauthenticated.PERFORMANCE_MEASUREMENTS", sendStdMessage).Methods(http.MethodGet)
43 fmt.Println("Starting mr on port: ", *port)
45 http.ListenAndServe(fmt.Sprintf(":%v", *port), r)
50 // DU-ID: ERICSSON-O-DU-11220
54 func sendStdMessage(w http.ResponseWriter, r *http.Request) {
55 message := fetchMessage()
56 fmt.Println("-----------------------------------------------------------------------------")
57 fmt.Println("Sending message: ", message)
58 fmt.Println("-----------------------------------------------------------------------------")
59 response, _ := json.Marshal(message)
60 time.Sleep(time.Duration(rand.Intn(3)) * time.Second)
61 w.Header().Set("Content-Type", "application/json")
62 w.WriteHeader(http.StatusOK)
66 func fetchMessage() messages.StdDefinedMessage {
71 measurements := [5][]messages.Measurement{meas1, meas2, meas3, meas4, meas5}
73 message := messages.StdDefinedMessage{
74 Event: messages.Event{
75 CommonEventHeader: messages.CommonEventHeader{
76 Domain: "stndDefined",
77 StndDefinedNamespace: "o-ran-sc-du-hello-world-pm-streaming-oas3",
79 StndDefinedFields: messages.StndDefinedFields{
80 StndDefinedFieldsVersion: "1.0",
81 SchemaReference: "https://gerrit.o-ran-sc.org/r/gitweb?p=scp/oam/modeling.git;a=blob_plain;f=data-model/oas3/experimental/o-ran-sc-du-hello-world-oas3.json;hb=refs/heads/master",
84 Measurements: measurements[index],
92 var meas1 = []messages.Measurement{
94 MeasurementTypeInstanceReference: "/network-function/distributed-unit-functions[id='ERICSSON-O-DU-11220']/cell[id='cell1']/supported-measurements/performance-measurement-type[.='user-equipment-average-throughput-downlink']/supported-snssai-subcounter-instances/slice-differentiator[.=2][slice-service-type=1]",
100 var meas2 = []messages.Measurement{
102 MeasurementTypeInstanceReference: "/network-function/distributed-unit-functions[id='ERICSSON-O-DU-11220']/cell[id='cell1']/supported-measurements/performance-measurement-type[.='user-equipment-average-throughput-downlink']/supported-snssai-subcounter-instances/slice-differentiator[.=1]",
108 var meas3 = []messages.Measurement{
110 MeasurementTypeInstanceReference: "/network-function/distributed-unit-functions[id='ERICSSON-O-DU-11220']/cell[id='cell1']/supported-measurements/performance-measurement-type[.='user-equipment-average-throughput-uplink']/supported-snssai-subcounter-instances/slice-differentiator[.=2][slice-service-type=2]",
116 var meas4 = []messages.Measurement{
118 MeasurementTypeInstanceReference: "/network-function/distributed-unit-functions[id='ERICSSON-O-DU-11220']/cell[id='cell1']/supported-measurements/performance-measurement-type[.='user-equipment-average-throughput-downlink']/supported-snssai-subcounter-instances/slice-differentiator[.=1]",
124 var meas5 = []messages.Measurement{
126 MeasurementTypeInstanceReference: "/network-function/distributed-unit-functions[id='ERICSSON-O-DU-11220']/cell[id='cell1']/supported-measurements/performance-measurement-type[.='user-equipment-average-throughput-downlink']/supported-snssai-subcounter-instances/[slice-differentiator[.=2]][slice-service-type=1]",