-
Notifications
You must be signed in to change notification settings - Fork 1
/
info_ue.chart.py
404 lines (350 loc) · 24.4 KB
/
info_ue.chart.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
from bases.FrameworkServices.SimpleService import SimpleService
priority = 90000
#those two imports are required to connect thous websockets
import websocket
#we tranform the result into json for easier manipulation
import json
#debug
from pprint import pprint
#update_every=2
ORDER = [
'random',
]
CHARTS = {
'random': {
'options': [None, 'A random number', 'random number', 'random', 'random', 'line'],
'lines': [
['random1']
]
}
}
class Service(SimpleService):
def __init__(self, configuration=None, name=None):
SimpleService.__init__(self, configuration=configuration, name=name)
self.order = ORDER
self.definitions = CHARTS
self.num_lines = self.configuration.get('num_lines', 1)
self.lower = self.configuration.get('lower', 0)
self.upper = self.configuration.get('upper', 100)
self.wsapp_gNodeB = websocket.WebSocket()
self.wsapp_mme = websocket.WebSocket()
while True:
self.wsapp_gNodeB.connect("ws://172.16.10.208:9001")
self.debug("check connection")
if self.wsapp_gNodeB.connected:
break
while True:
self.wsapp_mme.connect("ws://172.16.10.208:9000")
self.debug("check connection")
if self.wsapp_mme.connected:
break
self.data = dict()
@staticmethod
def check():
return True
def gNodeB_WS(self):
msg_to_send_mme="{\"message\":\"ue_get\",\"stats\":true}"
self.wsapp_gNodeB.send(msg_to_send_mme)
res=self.wsapp_gNodeB.recv()
return res
def mme_WS(self):
msg_to_send_mme="{\"message\":\"ue_get\",\"stats\":true}"
self.wsapp_mme.send(msg_to_send_mme)
res=self.wsapp_mme.recv()
return res
def get_data(self):
data = dict()
if(self.wsapp_gNodeB):
gNodeB_res=self.gNodeB_WS()
self.debug("gNB res: ", gNodeB_res)
if(self.wsapp_mme):
mme_res=self.mme_WS()
self.debug("mme_res: ", mme_res)
#Lets work on gNodeB
gNodeB_res_json=json.loads(gNodeB_res)
#Lets work on mme
mme_res_json=json.loads(mme_res)
###################################################################
# Create charts
self.UE_total_bytes(gNodeB_res_json, mme_res_json)
self.UE_Bitrate(gNodeB_res_json, mme_res_json)
self.UE_transmissions(gNodeB_res_json, mme_res_json)
self.UE_retransmissions(gNodeB_res_json, mme_res_json)
self.UE_pucch_SNR(gNodeB_res_json, mme_res_json)
self.UE_pusch_SNR(gNodeB_res_json, mme_res_json)
self.UE_ul_path_loss(gNodeB_res_json, mme_res_json)
for i in range(0, self.num_lines):
dimension_id = ''.join(['random', str(i)])
if dimension_id not in self.charts['random']:
self.charts['random'].add_dimension([dimension_id])
data[dimension_id] = 10
data=self.data
return data
#########################################################################
def UE_total_bytes(self, gNodeB_res_json, mme_res_json):
if "ue_list" in mme_res_json and len(mme_res_json["ue_list"]) > 0:
ue_list_in_mme=mme_res_json["ue_list"]
for ue_in_mme in ue_list_in_mme:
if "bearers" in ue_in_mme:
for bearer in ue_in_mme["bearers"]:
chart_name='_'.join(["UE", bearer["ip"], "total_bytes"])
#We add the chart name in the ORDER list
if chart_name not in ORDER:
ORDER.append(chart_name)
#We create the chart. For titles and units we get the info from the titles_for_charts and units_for_charts dictionaries
if chart_name not in self.charts:
CHARTS[chart_name]={\
'options': [None, ue_in_mme["imsi"], "B", "Total Bytes", "UE_STATS_MME", 'line']}#,\
#Now we add the newly created chart to the charts to be displayed.
params = [chart_name] + CHARTS[chart_name]['options']
self.charts.add_chart(params)
#Once the chart has been created we populate it with dimensions (i.e. data to be displayed)
dimension_id ='_'.join(["UE", bearer["ip"], "dl_total_bytes"])
if dimension_id not in self.charts[chart_name]:
self.charts[chart_name].add_dimension([dimension_id,"downlink total bytes",None,None,None])
self.data[dimension_id] = bearer["dl_total_bytes"]
dimension_id ='_'.join(["UE", bearer["ip"], "ul_total_bytes"])
if dimension_id not in self.charts[chart_name]:
self.charts[chart_name].add_dimension([dimension_id,"uplink total bytes",None,None,None])
self.data[dimension_id] = bearer["ul_total_bytes"]
else:
self.debug("=> MME UE list is Empty !")
def UE_Bitrate(self, gNodeB_res_json, mme_res_json):
if "ue_list" in gNodeB_res_json and len(gNodeB_res_json["ue_list"]) > 0:
ue_list_in_gNodeB=gNodeB_res_json["ue_list"]
for ue_in_gNodeB in ue_list_in_gNodeB:
if "enb_ue_id" in ue_in_gNodeB:
enb_ue_id = ue_in_gNodeB["enb_ue_id"]
mme_ue_id = ue_in_gNodeB["mme_ue_id"]
elif "ran_ue_id" in ue_in_gNodeB:
enb_ue_id = ue_in_gNodeB["ran_ue_id"]
mme_ue_id = ue_in_gNodeB["amf_ue_id"]
if "cells" in ue_in_gNodeB:
if "ue_list" in mme_res_json and len(mme_res_json["ue_list"]) > 0:
ue_list_in_mme=mme_res_json["ue_list"]
for ue_in_mme in ue_list_in_mme:
if(("enb_ue_id" in ue_in_mme and "mme_ue_id" in ue_in_mme and enb_ue_id == ue_in_mme["enb_ue_id"] and mme_ue_id == ue_in_mme["mme_ue_id"]) or
("ran_ue_id" in ue_in_mme and "amf_ue_id" in ue_in_mme and enb_ue_id == ue_in_mme["ran_ue_id"] and mme_ue_id == ue_in_mme["amf_ue_id"])):
for cell in ue_in_gNodeB["cells"]:
chart_name='_'.join(["UE", ue_in_mme["imsi"], "bitrate"])
#We add the chart name in the ORDER list
if chart_name not in ORDER:
ORDER.append(chart_name)
#We create the chart. For titles and units we get the info from the titles_for_charts and units_for_charts dictionaries
if chart_name not in self.charts:
CHARTS[chart_name]={\
'options': [None, ue_in_mme["imsi"], "bps", "Bitrate", "UE_STATS_GNODEB", 'line']}#,\
#Now we add the newly created chart to the charts to be displayed.
params = [chart_name] + CHARTS[chart_name]['options']
self.charts.add_chart(params)
#Once the chart has been created we populate it with dimensions (i.e. data to be displayed)
dimension_id ='_'.join(["UE", ue_in_mme["imsi"], "dl_bitrate"])
if dimension_id not in self.charts[chart_name]:
self.charts[chart_name].add_dimension([dimension_id,"downlink bitrate",None,None,None])
self.data[dimension_id] = cell["dl_bitrate"]
self.debug("*************************here")
dimension_id ='_'.join(["UE", ue_in_mme["imsi"], "ul_bitrate"])
if dimension_id not in self.charts[chart_name]:
self.charts[chart_name].add_dimension([dimension_id,"uplink bitrate",None,None,None])
self.data[dimension_id] = cell["ul_bitrate"]
self.debug("*************************here")
else:
self.debug("=> MME UE list is Empty !")
else:
self.debug("=> gNodeB UE list is Empty!")
def UE_transmissions(self, gNodeB_res_json, mme_res_json):
if "ue_list" in gNodeB_res_json and len(gNodeB_res_json["ue_list"]) > 0:
ue_list_in_gNodeB=gNodeB_res_json["ue_list"]
for ue_in_gNodeB in ue_list_in_gNodeB:
if "enb_ue_id" in ue_in_gNodeB:
enb_ue_id = ue_in_gNodeB["enb_ue_id"]
mme_ue_id = ue_in_gNodeB["mme_ue_id"]
elif "ran_ue_id" in ue_in_gNodeB:
enb_ue_id = ue_in_gNodeB["ran_ue_id"]
mme_ue_id = ue_in_gNodeB["amf_ue_id"]
if "cells" in ue_in_gNodeB:
if "ue_list" in mme_res_json and len(mme_res_json["ue_list"]) > 0:
ue_list_in_mme=mme_res_json["ue_list"]
for ue_in_mme in ue_list_in_mme:
if(("enb_ue_id" in ue_in_mme and "mme_ue_id" in ue_in_mme and enb_ue_id == ue_in_mme["enb_ue_id"] and mme_ue_id == ue_in_mme["mme_ue_id"]) or
("ran_ue_id" in ue_in_mme and "amf_ue_id" in ue_in_mme and enb_ue_id == ue_in_mme["ran_ue_id"] and mme_ue_id == ue_in_mme["amf_ue_id"])):
for cell in ue_in_gNodeB["cells"]:
chart_name='_'.join(["UE", ue_in_mme["imsi"], "transmissions"])
#We add the chart name in the ORDER list
if chart_name not in ORDER:
ORDER.append(chart_name)
#We create the chart. For titles and units we get the info from the titles_for_charts and units_for_charts dictionaries
if chart_name not in self.charts:
CHARTS[chart_name]={\
'options': [None, ue_in_mme["imsi"], "# of Transport blocks", "Transmissions", "UE_STATS_GNODEB", 'line']}#,\
#Now we add the newly created chart to the charts to be displayed.
params = [chart_name] + CHARTS[chart_name]['options']
self.charts.add_chart(params)
#Once the chart has been created we populate it with dimensions (i.e. data to be displayed)
dimension_id ='_'.join(["UE", ue_in_mme["imsi"], "dl_tx"])
if dimension_id not in self.charts[chart_name]:
self.charts[chart_name].add_dimension([dimension_id,"downlink tx",None,None,None])
self.data[dimension_id] = cell["dl_tx"]
dimension_id ='_'.join(["UE", ue_in_mme["imsi"], "ul_tx"])
if dimension_id not in self.charts[chart_name]:
self.charts[chart_name].add_dimension([dimension_id,"uplink tx",None,None,None])
self.data[dimension_id] = cell["ul_tx"]
else:
self.debug("=> MME UE list is Empty !")
else:
self.debug("=> gNodeB UE list is Empty!")
def UE_retransmissions(self, gNodeB_res_json, mme_res_json):
if "ue_list" in gNodeB_res_json and len(gNodeB_res_json["ue_list"]) > 0:
ue_list_in_gNodeB=gNodeB_res_json["ue_list"]
for ue_in_gNodeB in ue_list_in_gNodeB:
if "enb_ue_id" in ue_in_gNodeB:
enb_ue_id = ue_in_gNodeB["enb_ue_id"]
mme_ue_id = ue_in_gNodeB["mme_ue_id"]
elif "ran_ue_id" in ue_in_gNodeB:
enb_ue_id = ue_in_gNodeB["ran_ue_id"]
mme_ue_id = ue_in_gNodeB["amf_ue_id"]
if "cells" in ue_in_gNodeB:
if "ue_list" in mme_res_json and len(mme_res_json["ue_list"]) > 0:
ue_list_in_mme=mme_res_json["ue_list"]
for ue_in_mme in ue_list_in_mme:
if(("enb_ue_id" in ue_in_mme and "mme_ue_id" in ue_in_mme and enb_ue_id == ue_in_mme["enb_ue_id"] and mme_ue_id == ue_in_mme["mme_ue_id"]) or
("ran_ue_id" in ue_in_mme and "amf_ue_id" in ue_in_mme and enb_ue_id == ue_in_mme["ran_ue_id"] and mme_ue_id == ue_in_mme["amf_ue_id"])):
for cell in ue_in_gNodeB["cells"]:
chart_name='_'.join(["UE", ue_in_mme["imsi"], "Retransmissions"])
#We add the chart name in the ORDER list
if chart_name not in ORDER:
ORDER.append(chart_name)
#We create the chart. For titles and units we get the info from the titles_for_charts and units_for_charts dictionaries
if chart_name not in self.charts:
CHARTS[chart_name]={\
'options': [None, ue_in_mme["imsi"], "# of Transport blocks", "Retransmissions", "UE_STATS_GNODEB", 'line']}#,\
#Now we add the newly created chart to the charts to be displayed.
params = [chart_name] + CHARTS[chart_name]['options']
self.charts.add_chart(params)
#Once the chart has been created we populate it with dimensions (i.e. data to be displayed)
dimension_id ='_'.join(["UE", ue_in_mme["imsi"], "dl_retx"])
if dimension_id not in self.charts[chart_name]:
self.charts[chart_name].add_dimension([dimension_id,"downlink retx",None,None,None])
self.data[dimension_id] = cell["dl_tx"]
dimension_id ='_'.join(["UE", ue_in_mme["imsi"], "ul_retx"])
if dimension_id not in self.charts[chart_name]:
self.charts[chart_name].add_dimension([dimension_id,"uplink retx",None,None,None])
self.data[dimension_id] = cell["ul_retx"]
else:
self.debug("=> MME UE list is Empty !")
else:
self.debug("=> gNodeB UE list is Empty!")
def UE_pucch_SNR(self, gNodeB_res_json, mme_res_json):
if "ue_list" in gNodeB_res_json and len(gNodeB_res_json["ue_list"]) > 0:
ue_list_in_gNodeB=gNodeB_res_json["ue_list"]
for ue_in_gNodeB in ue_list_in_gNodeB:
if "enb_ue_id" in ue_in_gNodeB:
enb_ue_id = ue_in_gNodeB["enb_ue_id"]
mme_ue_id = ue_in_gNodeB["mme_ue_id"]
elif "ran_ue_id" in ue_in_gNodeB:
enb_ue_id = ue_in_gNodeB["ran_ue_id"]
mme_ue_id = ue_in_gNodeB["amf_ue_id"]
if "cells" in ue_in_gNodeB:
if "ue_list" in mme_res_json and len(mme_res_json["ue_list"]) > 0:
ue_list_in_mme=mme_res_json["ue_list"]
for ue_in_mme in ue_list_in_mme:
if(("enb_ue_id" in ue_in_mme and "mme_ue_id" in ue_in_mme and enb_ue_id == ue_in_mme["enb_ue_id"] and mme_ue_id == ue_in_mme["mme_ue_id"]) or
("ran_ue_id" in ue_in_mme and "amf_ue_id" in ue_in_mme and enb_ue_id == ue_in_mme["ran_ue_id"] and mme_ue_id == ue_in_mme["amf_ue_id"])):
for cell in ue_in_gNodeB["cells"]:
chart_name='_'.join(["UE", ue_in_mme["imsi"], "pucch_SNR"])
#We add the chart name in the ORDER list
if chart_name not in ORDER:
ORDER.append(chart_name)
#We create the chart. For titles and units we get the info from the titles_for_charts and units_for_charts dictionaries
if chart_name not in self.charts:
CHARTS[chart_name]={\
'options': [None, ue_in_mme["imsi"], "dB", "Physical Uplink Control Channel (PUCCH)", "UE_STATS_GNODEB", 'line']}#,\
#Now we add the newly created chart to the charts to be displayed.
params = [chart_name] + CHARTS[chart_name]['options']
self.charts.add_chart(params)
#Once the chart has been created we populate it with dimensions (i.e. data to be displayed)
dimension_id ='_'.join(["UE", ue_in_mme["imsi"], "pucch_snr"])
if dimension_id not in self.charts[chart_name]:
self.charts[chart_name].add_dimension([dimension_id,"pucch SNR",None,None,None])
if "pucch1_snr" in cell:
self.data[dimension_id] = cell["pucch1_snr"]
elif "pucch_snr" in cell:
self.data[dimension_id] = cell["pucch_snr"]
else:
self.debug("=> MME UE list is Empty !")
else:
self.debug("=> gNodeB UE list is Empty!")
def UE_pusch_SNR(self, gNodeB_res_json, mme_res_json):
if "ue_list" in gNodeB_res_json and len(gNodeB_res_json["ue_list"]) > 0:
ue_list_in_gNodeB=gNodeB_res_json["ue_list"]
for ue_in_gNodeB in ue_list_in_gNodeB:
if "enb_ue_id" in ue_in_gNodeB:
enb_ue_id = ue_in_gNodeB["enb_ue_id"]
mme_ue_id = ue_in_gNodeB["mme_ue_id"]
elif "ran_ue_id" in ue_in_gNodeB:
enb_ue_id = ue_in_gNodeB["ran_ue_id"]
mme_ue_id = ue_in_gNodeB["amf_ue_id"]
if "cells" in ue_in_gNodeB:
if "ue_list" in mme_res_json and len(mme_res_json["ue_list"]) > 0:
ue_list_in_mme=mme_res_json["ue_list"]
for ue_in_mme in ue_list_in_mme:
if(("enb_ue_id" in ue_in_mme and "mme_ue_id" in ue_in_mme and enb_ue_id == ue_in_mme["enb_ue_id"] and mme_ue_id == ue_in_mme["mme_ue_id"]) or
("ran_ue_id" in ue_in_mme and "amf_ue_id" in ue_in_mme and enb_ue_id == ue_in_mme["ran_ue_id"] and mme_ue_id == ue_in_mme["amf_ue_id"])):
for cell in ue_in_gNodeB["cells"]:
chart_name='_'.join(["UE", ue_in_mme["imsi"], "pusch_SNR"])
#We add the chart name in the ORDER list
if chart_name not in ORDER:
ORDER.append(chart_name)
#We create the chart. For titles and units we get the info from the titles_for_charts and units_for_charts dictionaries
if chart_name not in self.charts:
CHARTS[chart_name]={\
'options': [None, ue_in_mme["imsi"], "dB", "Physical Uplink Shared Channel (PUSCH) SNR", "UE_STATS_GNODEB", 'line']}#,\
#Now we add the newly created chart to the charts to be displayed.
params = [chart_name] + CHARTS[chart_name]['options']
self.charts.add_chart(params)
#Once the chart has been created we populate it with dimensions (i.e. data to be displayed)
dimension_id ='_'.join(["UE", ue_in_mme["imsi"], "pusch_snr"])
if dimension_id not in self.charts[chart_name]:
self.charts[chart_name].add_dimension([dimension_id,"pucch1 SNR",None,None,None])
self.data[dimension_id] = cell["pusch_snr"]
else:
self.debug("=> MME UE list is Empty !")
else:
self.debug("=> gNodeB UE list is Empty!")
def UE_ul_path_loss(self, gNodeB_res_json, mme_res_json):
if "ue_list" in gNodeB_res_json and len(gNodeB_res_json["ue_list"]) > 0:
ue_list_in_gNodeB=gNodeB_res_json["ue_list"]
for ue_in_gNodeB in ue_list_in_gNodeB:
if "enb_ue_id" in ue_in_gNodeB:
enb_ue_id = ue_in_gNodeB["enb_ue_id"]
mme_ue_id = ue_in_gNodeB["mme_ue_id"]
elif "ran_ue_id" in ue_in_gNodeB:
enb_ue_id = ue_in_gNodeB["ran_ue_id"]
mme_ue_id = ue_in_gNodeB["amf_ue_id"]
if "cells" in ue_in_gNodeB:
if "ue_list" in mme_res_json and len(mme_res_json["ue_list"]) > 0:
ue_list_in_mme=mme_res_json["ue_list"]
for ue_in_mme in ue_list_in_mme:
if(("enb_ue_id" in ue_in_mme and "mme_ue_id" in ue_in_mme and enb_ue_id == ue_in_mme["enb_ue_id"] and mme_ue_id == ue_in_mme["mme_ue_id"]) or
("ran_ue_id" in ue_in_mme and "amf_ue_id" in ue_in_mme and enb_ue_id == ue_in_mme["ran_ue_id"] and mme_ue_id == ue_in_mme["amf_ue_id"])):
for cell in ue_in_gNodeB["cells"]:
chart_name='_'.join(["UE", ue_in_mme["imsi"], "ul_path_loss"])
#We add the chart name in the ORDER list
if chart_name not in ORDER:
ORDER.append(chart_name)
#We create the chart. For titles and units we get the info from the titles_for_charts and units_for_charts dictionaries
if chart_name not in self.charts:
CHARTS[chart_name]={\
'options': [None, ue_in_mme["imsi"], "dB", "Uplink Path Loss", "UE_STATS_GNODEB", 'line']}#,\
#Now we add the newly created chart to the charts to be displayed.
params = [chart_name] + CHARTS[chart_name]['options']
self.charts.add_chart(params)
#Once the chart has been created we populate it with dimensions (i.e. data to be displayed)
dimension_id ='_'.join(["UE", ue_in_mme["imsi"], "ul_path_loss"])
if dimension_id not in self.charts[chart_name]:
self.charts[chart_name].add_dimension([dimension_id,"uplink path loss",None,None,None])
self.data[dimension_id] = cell["ul_path_loss"]
else:
self.debug("=> MME UE list is Empty !")
else:
self.debug("=> gNodeB UE list is Empty!")