blob: 9b024b9a9ae82251ef22c03b8e99ec9c14871f83 [file] [log] [blame]
slowr13fa5b02017-08-08 16:32:31 -07001/*
2 * Copyright 2015-present Open Networking Laboratory
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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 */
16
17package org.onosproject.xran.entities;
18
slowr8ddc2b12017-08-14 14:13:38 -070019import com.fasterxml.jackson.databind.JsonNode;
slowr89c2ac12017-08-15 16:20:06 -070020import com.google.common.collect.Lists;
slowr13fa5b02017-08-08 16:32:31 -070021import org.onosproject.xran.codecs.api.*;
22import org.onosproject.xran.codecs.pdu.PDCPMeasReportPerUe;
23import org.onosproject.xran.codecs.pdu.RRMConfig;
24import org.onosproject.xran.identifiers.LinkId;
slowr8ddc2b12017-08-14 14:13:38 -070025import org.openmuc.jasn1.ber.types.BerBitString;
slowr13fa5b02017-08-08 16:32:31 -070026import org.openmuc.jasn1.ber.types.BerInteger;
27
slowr67d05e42017-08-11 20:37:22 -070028import java.util.Arrays;
slowr8ddc2b12017-08-14 14:13:38 -070029import java.util.List;
slowr67d05e42017-08-11 20:37:22 -070030import java.util.Optional;
slowr13fa5b02017-08-08 16:32:31 -070031import java.util.Timer;
slowr8ddc2b12017-08-14 14:13:38 -070032import java.util.stream.Collectors;
33import java.util.stream.Stream;
slowr13fa5b02017-08-08 16:32:31 -070034
35/**
36 * Created by dimitris on 7/22/17.
37 */
38public class RnibLink {
39 private LinkId linkId;
40 // private String type;
41 private RRMConfig rrmParameters;
42
43 private TrafficSplitPercentage trafficPercent;
44 private ERABParams bearerParameters;
45
46 private LinkQuality quality;
47 private PDCPThroughput pdcpThroughput;
48 private PDCPPacketDelay pdcpPackDelay;
49 private ResourceUsage resourceUsage;
50 private Type type;
51 private Timer timer;
52
slowr67d05e42017-08-11 20:37:22 -070053 public RnibLink(RnibCell cell, RnibUe ue) {
slowr13fa5b02017-08-08 16:32:31 -070054 trafficPercent = new TrafficSplitPercentage();
slowr67d05e42017-08-11 20:37:22 -070055 trafficPercent.setEcgi(cell.getEcgi());
slowr13fa5b02017-08-08 16:32:31 -070056 trafficPercent.setTrafficPercentDl(new BerInteger(100));
57 trafficPercent.setTrafficPercentUl(new BerInteger(100));
58
59 pdcpThroughput = new PDCPThroughput();
60 quality = new LinkQuality();
61 pdcpPackDelay = new PDCPPacketDelay();
62 resourceUsage = new ResourceUsage();
63 timer = new Timer();
slowr67d05e42017-08-11 20:37:22 -070064
65 type = Type.NON_SERVING;
66
67 linkId = LinkId.valueOf(cell, ue);
slowr8ddc2b12017-08-14 14:13:38 -070068
slowr89c2ac12017-08-15 16:20:06 -070069 rrmParameters = new RRMConfig();
70 RRMConfig.Crnti crnti = new RRMConfig.Crnti();
71 crnti.addCRNTI(linkId.getUe().getRanId());
72 rrmParameters.setCrnti(crnti);
73 rrmParameters.setEcgi(linkId.getEcgi());
slowr13fa5b02017-08-08 16:32:31 -070074 }
75
76 public Timer getTimer() {
77 return timer;
78 }
79
80 public void setTimer(Timer timer) {
81 this.timer.cancel();
82 this.timer.purge();
83 this.timer = timer;
84 }
85
86 public LinkId getLinkId() {
87 return linkId;
88 }
89
90 public void setLinkId(LinkId linkId) {
91 this.linkId = linkId;
92 }
93
94 public void setLinkId(RnibCell cell, RnibUe ue) {
slowr67d05e42017-08-11 20:37:22 -070095 this.linkId = LinkId.valueOf(cell, ue);
slowr13fa5b02017-08-08 16:32:31 -070096 trafficPercent.setEcgi(cell.getEcgi());
97 }
98
99 public Type getType() {
100 return type;
101 }
102
103 public void setType(Type type) {
104 this.type = type;
105 }
106
107 public TrafficSplitPercentage getTrafficPercent() {
108 return trafficPercent;
109 }
110
111 public void setTrafficPercent(TrafficSplitPercentage trafficPercent) {
112 this.trafficPercent = trafficPercent;
113 }
114
115 public ERABParams getBearerParameters() {
116 return bearerParameters;
117 }
118
119 public void setBearerParameters(ERABParams bearerParameters) {
120 this.bearerParameters = bearerParameters;
121 }
122
123 public LinkQuality getQuality() {
124 return quality;
125 }
126
127 public void setQuality(LinkQuality quality) {
128 this.quality = quality;
129 }
130
131 public RRMConfig getRrmParameters() {
132 return rrmParameters;
133 }
134
135 public void setRrmParameters(RRMConfig rrmParameters) {
136 this.rrmParameters = rrmParameters;
137 }
138
slowr8ddc2b12017-08-14 14:13:38 -0700139 public void modifyRrmParameters(JsonNode rrmConfigNode) {
140 {
slowr89c2ac12017-08-15 16:20:06 -0700141 JsonNode start_prb_dl = rrmConfigNode.path("start_prb_dl");
142 if (!start_prb_dl.isMissingNode()) {
slowr8ddc2b12017-08-14 14:13:38 -0700143 RRMConfig.StartPrbDl startPrbDl = new RRMConfig.StartPrbDl();
slowr89c2ac12017-08-15 16:20:06 -0700144
145 List<BerInteger> collect = Lists.newArrayList();
146 collect.add(new BerInteger(start_prb_dl.asInt()));
147 startPrbDl.setSeqOf(collect);
148
slowr8ddc2b12017-08-14 14:13:38 -0700149 rrmParameters.setStartPrbDl(startPrbDl);
150 }
151 }
152
153 {
154 JsonNode end_prb_dl = rrmConfigNode.get("end_prb_dl");
slowr89c2ac12017-08-15 16:20:06 -0700155 if (!end_prb_dl.isMissingNode()) {
slowr8ddc2b12017-08-14 14:13:38 -0700156 RRMConfig.EndPrbDl endPrbDl = new RRMConfig.EndPrbDl();
slowr89c2ac12017-08-15 16:20:06 -0700157
158 List<BerInteger> collect = Lists.newArrayList();
159 collect.add(new BerInteger(end_prb_dl.asInt()));
160 endPrbDl.setSeqOf(collect);
161
slowr8ddc2b12017-08-14 14:13:38 -0700162 rrmParameters.setEndPrbDl(endPrbDl);
163 }
164 }
165
166 {
167 JsonNode start_prb_ul = rrmConfigNode.get("start_prb_ul");
slowr89c2ac12017-08-15 16:20:06 -0700168 if (!start_prb_ul.isMissingNode()) {
slowr8ddc2b12017-08-14 14:13:38 -0700169 RRMConfig.StartPrbUl startPrbUl = new RRMConfig.StartPrbUl();
slowr89c2ac12017-08-15 16:20:06 -0700170
171 List<BerInteger> collect = Lists.newArrayList();
172 collect.add(new BerInteger(start_prb_ul.asInt()));
173 startPrbUl.setSeqOf(collect);
174
slowr8ddc2b12017-08-14 14:13:38 -0700175 rrmParameters.setStartPrbUl(startPrbUl);
176 }
177 }
178
179 {
180 JsonNode end_prb_ul = rrmConfigNode.get("end_prb_ul");
slowr89c2ac12017-08-15 16:20:06 -0700181 if (!end_prb_ul.isMissingNode()) {
slowr8ddc2b12017-08-14 14:13:38 -0700182 RRMConfig.EndPrbUl endPrbUl = new RRMConfig.EndPrbUl();
slowr89c2ac12017-08-15 16:20:06 -0700183
184 List<BerInteger> collect = Lists.newArrayList();
185 collect.add(new BerInteger(end_prb_ul.asInt()));
186 endPrbUl.setSeqOf(collect);
187
slowr8ddc2b12017-08-14 14:13:38 -0700188 rrmParameters.setEndPrbUl(endPrbUl);
189 }
190 }
slowr8ddc2b12017-08-14 14:13:38 -0700191 }
192
slowr13fa5b02017-08-08 16:32:31 -0700193 public PDCPThroughput getPdcpThroughput() {
194 return pdcpThroughput;
195 }
196
197 public void setPdcpThroughput(PDCPThroughput pdcpThroughput) {
198 this.pdcpThroughput = pdcpThroughput;
199 }
200
201 public PDCPPacketDelay getPdcpPackDelay() {
202 return pdcpPackDelay;
203 }
204
205 public void setPdcpPackDelay(PDCPPacketDelay pdcpPackDelay) {
206 this.pdcpPackDelay = pdcpPackDelay;
207 }
208
209 public ResourceUsage getResourceUsage() {
210 return resourceUsage;
211 }
212
213 public void setResourceUsage(ResourceUsage resourceUsage) {
214 this.resourceUsage = resourceUsage;
215 }
216
217 @Override
218 public String toString() {
219 StringBuilder sb = new StringBuilder();
220 sb.append("{\n")
221 .append(linkId != null ? "\"link-id\":" + linkId : "")
222 .append(type != null ? ",\n\"type\":" + type : "")
223 .append(rrmParameters != null ? ",\n\"rrm-params\":" + rrmParameters : "")
224 .append(trafficPercent != null ? ",\n\"traffic-percent\":" + trafficPercent : "")
225 .append(bearerParameters != null ? ",\n\"bearer-params\":" + bearerParameters : "")
226 .append(quality != null ? ",\n\"quality\":" + quality : "")
227 .append(pdcpThroughput != null ? ",\n\"pdcp-throughput\":" + pdcpThroughput : "")
228 .append(pdcpPackDelay != null ? ",\n\"pdcp-packet-delay\":" + pdcpPackDelay : "")
229 .append(resourceUsage != null ? ",\n\"resource-usage\":" + resourceUsage : "")
230 .append("\n}\n");
231 return sb.toString();
232 }
233
234 @Override
235 public boolean equals(Object o) {
236 if (this == o) return true;
237 if (o == null || getClass() != o.getClass()) return false;
238
239 RnibLink link = (RnibLink) o;
240
241 return linkId.equals(link.linkId);
242 }
243
244 @Override
245 public int hashCode() {
246 return linkId.hashCode();
247 }
248
249 public enum Type {
slowr67d05e42017-08-11 20:37:22 -0700250 SERVING_PRIMARY("serving/primary") {
slowr13fa5b02017-08-08 16:32:31 -0700251 @Override
252 public String toString() {
253 return "\"serving/primary\"";
254 }
255 },
256 // TODO: Add CA/DC
slowr89c2ac12017-08-15 16:20:06 -0700257 SERVING_SECONDARY_CA("serving/secondary/ca") {
slowr13fa5b02017-08-08 16:32:31 -0700258 @Override
259 public String toString() {
slowr89c2ac12017-08-15 16:20:06 -0700260 return "\"serving/secondary/ca\"";
261 }
262 },
263 SERVING_SECONDARY_DC("serving/secondary/dc") {
264 @Override
265 public String toString() {
266 return "\"serving/secondary/dc\"";
slowr13fa5b02017-08-08 16:32:31 -0700267 }
268 },
slowr67d05e42017-08-11 20:37:22 -0700269 NON_SERVING("non-serving") {
slowr13fa5b02017-08-08 16:32:31 -0700270 @Override
271 public String toString() {
272 return "\"non-serving\"";
273 }
slowr67d05e42017-08-11 20:37:22 -0700274 };
275
276 private String name;
277
278 Type(String name) {
279 this.name = name;
280 }
281
282 public static Type getEnum(String name) {
283 Optional<Type> any = Arrays.stream(Type.values()).filter(typeStr -> typeStr.name.equals(name)).findAny();
284 if (any.isPresent()) {
285 return any.get();
286 }
287 throw new IllegalArgumentException("No enum defined for string: " + name);
slowr13fa5b02017-08-08 16:32:31 -0700288 }
289 }
290
291 public class PDCPThroughput {
292 private PDCPMeasReportPerUe.ThroughputDl dl;
293 private PDCPMeasReportPerUe.ThroughputUl ul;
294
295 public PDCPMeasReportPerUe.ThroughputDl getDl() {
296 return dl;
297 }
298
299 public void setDl(PDCPMeasReportPerUe.ThroughputDl dl) {
300 this.dl = dl;
301 }
302
303 public PDCPMeasReportPerUe.ThroughputUl getUl() {
304 return ul;
305 }
306
307 public void setUl(PDCPMeasReportPerUe.ThroughputUl ul) {
308 this.ul = ul;
309 }
310
311 @Override
312 public String toString() {
313 StringBuilder sb = new StringBuilder();
314 sb.append("{\n")
315 .append(dl != null ? "\"dl\":" + dl : "")
316 .append(ul != null ? ",\n\"ul\":" + ul : "")
317 .append("\n}\n");
318 return sb.toString();
319 }
320 }
321
322 public class PDCPPacketDelay {
323 PDCPMeasReportPerUe.PktDelayDl dl;
324 PDCPMeasReportPerUe.PktDelayUl ul;
325
326 public PDCPMeasReportPerUe.PktDelayDl getDl() {
327 return dl;
328 }
329
330 public void setDl(PDCPMeasReportPerUe.PktDelayDl dl) {
331 this.dl = dl;
332 }
333
334 public PDCPMeasReportPerUe.PktDelayUl getUl() {
335 return ul;
336 }
337
338 public void setUl(PDCPMeasReportPerUe.PktDelayUl ul) {
339 this.ul = ul;
340 }
341
342 @Override
343 public String toString() {
344 StringBuilder sb = new StringBuilder();
345 sb.append("{\n")
346 .append(dl != null ? "\"dl\":" + dl : "")
347 .append(ul != null ? ",\n\"ul\":" + ul : "")
348 .append("\n}\n");
349 return sb.toString();
350 }
351 }
352
353 public class ResourceUsage {
354 PRBUsage.PrbUsageDl dl;
355 PRBUsage.PrbUsageUl ul;
356
357 public PRBUsage.PrbUsageDl getDl() {
358 return dl;
359 }
360
361 public void setDl(PRBUsage.PrbUsageDl dl) {
362 this.dl = dl;
363 }
364
365 public PRBUsage.PrbUsageUl getUl() {
366 return ul;
367 }
368
369 public void setUl(PRBUsage.PrbUsageUl ul) {
370 this.ul = ul;
371 }
372
373 @Override
374 public String toString() {
375 StringBuilder sb = new StringBuilder();
376 sb.append("{\n")
377 .append(dl != null ? "\"dl\":" + dl : "")
378 .append(ul != null ? ",\n\"ul\":" + ul : "")
379 .append("\n}\n");
380 return sb.toString();
381 }
382 }
383
384 public class LinkQuality {
385 double rsrp;
386 double rsrq;
387 RadioRepPerServCell.CqiHist cqiHist;
388 double cqiMode;
389 double cqiMean;
390 SchedMeasRepPerServCell.McsDl mcs_dl;
391 SchedMeasRepPerServCell.McsUl mcs_ul;
392
393 public double getRsrp() {
394 return rsrp;
395 }
396
397 public void setRsrp(double rsrp) {
398 this.rsrp = rsrp;
399 }
400
401 public double getRsrq() {
402 return rsrq;
403 }
404
405 public void setRsrq(double rsrq) {
406 this.rsrq = rsrq;
407 }
408
409 public RadioRepPerServCell.CqiHist getCqiHist() {
410 return cqiHist;
411 }
412
413 public void setCqiHist(RadioRepPerServCell.CqiHist cqiHist) {
414 this.cqiHist = cqiHist;
415 }
416
417 public double getCqiMode() {
418 return cqiMode;
419 }
420
421 public void setCqiMode(double cqiMode) {
422 this.cqiMode = cqiMode;
423 }
424
425 public double getCqiMean() {
426 return cqiMean;
427 }
428
429 public void setCqiMean(double cqiMean) {
430 this.cqiMean = cqiMean;
431 }
432
433 public SchedMeasRepPerServCell.McsDl getMcs_dl() {
434 return mcs_dl;
435 }
436
437 public void setMcs_dl(SchedMeasRepPerServCell.McsDl mcs_dl) {
438 this.mcs_dl = mcs_dl;
439 }
440
441 public SchedMeasRepPerServCell.McsUl getMcs_ul() {
442 return mcs_ul;
443 }
444
445 public void setMcs_ul(SchedMeasRepPerServCell.McsUl mcs_ul) {
446 this.mcs_ul = mcs_ul;
447 }
448
449 @Override
450 public String toString() {
451 StringBuilder sb = new StringBuilder();
452 sb.append("{\n")
453 .append("\"rsrp\":" + rsrp)
454 .append(",\n\"rsrq\":" + rsrq)
455 .append(",\n\"cqiMode\":" + cqiMode)
456 .append(",\n\"cqiMean\":" + cqiMean)
457 .append(mcs_dl != null ? ",\n\"mcs-dl\":" + mcs_dl : "")
458 .append(mcs_ul != null ? ",\n\"mcs-ul\":" + mcs_ul : "")
459 .append("\n}\n");
460 return sb.toString();
461 }
462 }
463}