1 # -------------------------------------------------------------------------------
2 # Copyright (c) 2018-2019 AT&T Intellectual Property.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 # -------------------------------------------------------------------------------
22 import sgnb_reconfiguration_complete_pb2
23 import ue_context_release_pb2
24 import x2ap_streaming_pb2
27 # --------------------------------
34 conn_flnm = "MT_000010280"
35 dis_flnm = "MT_000010050"
37 fifo_dir = "/tmp/mcl/fifos"
39 # -------------------------------
42 def process_conn_record(ofl,gnb_id, ue_id, ts):
43 # print "Connected ue_iud="+str(ue_id)+", gnb_id="+str(gnb_id)
44 X2APStreaming = x2ap_streaming_pb2.X2APStreaming() # header message
45 X2APStreaming.header.gNbID.value = "Bar"
47 # root = sgnb_reconfiguration_complete_pb2.SgNBReconfigurationComplete()
48 root = X2APStreaming.sgNBReconfigurationComplete
50 root.id_MeNB_UE_X2AP_ID = ue_id
51 root.id_SgNB_UE_X2AP_ID = gnb_id
52 child = root.id_ResponseInformationSgNBReconfComp
53 child.success_SgNBReconfComp.meNBtoSgNBContainer.value = "foo"
55 v = X2APStreaming.SerializeToString()
58 ofl.write("{0:7}".format(vlen))
68 def process_dis_record(ofl, gnb_id, old_enb_id, new_enb_id, ts):
69 # print "Disconnected old_ue_iud="+str(old_enb_id)+", gnb_id="+str(gnb_id)+", new_ue_id="+str(new_enb_id)
70 X2APStreaming = x2ap_streaming_pb2.X2APStreaming() # header message
71 X2APStreaming.header.gNbID.value = "Bar"
73 # root = ue_context_release_pb2.UEContextRelease()
74 root = X2APStreaming.ueContextRelease
76 root.id_Old_eNB_UE_X2AP_ID = old_enb_id
77 root.id_New_eNB_UE_X2AP_ID = new_enb_id
78 root.id_SgNB_UE_X2AP_ID.value = gnb_id
80 v = X2APStreaming.SerializeToString()
83 ofl.write("{0:7}".format(vlen))
91 # -------------------------------
92 # main body of data generator
94 enb_to_ue = {} # avoid duplicate enb_ue_ids
95 gnb_to_ue = {} # avoid duplicate gnb_ue_ids
99 for i in xrange(0,n_ue):
100 enb_id = random.randint(1,ue_id_range)
101 while enb_id in enb_to_ue:
102 enb_id = random.randint(1,ue_id_range)
103 ue_list.append({"state": "dis", "enb_id": enb_id})
104 enb_to_ue[enb_id] = i
106 if not os.path.exists(fifo_dir + "/" + conn_flnm):
107 os.mkfifo(fifo_dir + "/" + conn_flnm)
109 if not os.path.exists(fifo_dir + "/" + dis_flnm):
110 os.mkfifo(fifo_dir + "/" + dis_flnm)
112 cfl = open(fifo_dir + "/" + conn_flnm,"w", 0)
113 dfl = open(fifo_dir + "/" + dis_flnm, "w", 0)
119 curr_time = int(time.time())
122 for i in xrange(0, events_per_fl):
123 ueix = random.randint(0,n_ue-1)
124 if ueix in processed:
125 ueix = random.randint(0,n_ue-1)
126 processed.append(ueix)
128 curr_ue = ue_list[ueix]
129 if curr_ue["state"] == "dis":
130 gnb_id = random.randint(1,ue_id_range)
131 while gnb_id in gnb_to_ue:
132 gnb_id = random.randint(1,ue_id_range)
133 gnb_to_ue[gnb_id] = ueix
134 curr_ue["gnb_id"] = gnb_id
135 curr_ue["state"] = "conn"
136 process_conn_record(cfl,curr_ue["gnb_id"], curr_ue["enb_id"],1000*curr_time +50*i)
138 new_enb_id = random.randint(1,ue_id_range)
139 while new_enb_id in enb_to_ue:
140 new_enb_id = random.randint(1,ue_id_range)
141 old_enb_id = curr_ue["enb_id"]
142 gnb_id = curr_ue["gnb_id"]
143 del enb_to_ue[old_enb_id]
144 del gnb_to_ue[gnb_id]
145 enb_to_ue[new_enb_id] = ueix
147 curr_ue["enb_id"] = new_enb_id
148 curr_ue["state"] = "dis"
149 process_dis_record(dfl,gnb_id, old_enb_id, new_enb_id,1000*curr_time +50*i)
151 time.sleep(epoch_len)