blob: ade8f58f60a75fce06498529404574546bc49624 [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
slowr60d4d102017-08-16 18:33:58 -070019import com.fasterxml.jackson.annotation.JsonIgnore;
20import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
21import com.fasterxml.jackson.annotation.JsonProperty;
22import com.fasterxml.jackson.annotation.JsonPropertyOrder;
slowr8ddc2b12017-08-14 14:13:38 -070023import com.fasterxml.jackson.databind.JsonNode;
slowr89c2ac12017-08-15 16:20:06 -070024import com.google.common.collect.Lists;
slowr13fa5b02017-08-08 16:32:31 -070025import org.onosproject.xran.codecs.api.*;
26import org.onosproject.xran.codecs.pdu.PDCPMeasReportPerUe;
27import org.onosproject.xran.codecs.pdu.RRMConfig;
28import org.onosproject.xran.identifiers.LinkId;
slowr60d4d102017-08-16 18:33:58 -070029import org.onosproject.xran.codecs.ber.types.BerInteger;
slowr13fa5b02017-08-08 16:32:31 -070030
slowr67d05e42017-08-11 20:37:22 -070031import java.util.Arrays;
slowr8ddc2b12017-08-14 14:13:38 -070032import java.util.List;
slowr67d05e42017-08-11 20:37:22 -070033import java.util.Optional;
slowr13fa5b02017-08-08 16:32:31 -070034import java.util.Timer;
35
36/**
37 * Created by dimitris on 7/22/17.
38 */
slowr60d4d102017-08-16 18:33:58 -070039@JsonPropertyOrder({
40 "Link-ID",
41 "Type",
42 "RRMConfiguration",
43 "TrafficPercent",
44 "BearerParameters",
45 "Quality",
46 "PDCP-Throughput",
47 "PDCP-Packet-Delay",
48 "Resource-Usage"
49})
50@JsonIgnoreProperties(ignoreUnknown = true)
slowr13fa5b02017-08-08 16:32:31 -070051public class RnibLink {
slowr60d4d102017-08-16 18:33:58 -070052 @JsonProperty("Link-ID")
slowr13fa5b02017-08-08 16:32:31 -070053 private LinkId linkId;
slowr60d4d102017-08-16 18:33:58 -070054 @JsonProperty("RRMConfiguration")
slowr13fa5b02017-08-08 16:32:31 -070055 private RRMConfig rrmParameters;
slowr60d4d102017-08-16 18:33:58 -070056 @JsonProperty("TrafficPercent")
slowr13fa5b02017-08-08 16:32:31 -070057 private TrafficSplitPercentage trafficPercent;
slowr60d4d102017-08-16 18:33:58 -070058 @JsonProperty("BearerParameters")
slowr13fa5b02017-08-08 16:32:31 -070059 private ERABParams bearerParameters;
slowr60d4d102017-08-16 18:33:58 -070060 @JsonProperty("Quality")
slowr13fa5b02017-08-08 16:32:31 -070061 private LinkQuality quality;
slowr60d4d102017-08-16 18:33:58 -070062 @JsonProperty("PDCP-Throughput")
slowr13fa5b02017-08-08 16:32:31 -070063 private PDCPThroughput pdcpThroughput;
slowr60d4d102017-08-16 18:33:58 -070064 @JsonProperty("PDCP-Packet-Delay")
slowr13fa5b02017-08-08 16:32:31 -070065 private PDCPPacketDelay pdcpPackDelay;
slowr60d4d102017-08-16 18:33:58 -070066 @JsonProperty("Resource-Usage")
slowr13fa5b02017-08-08 16:32:31 -070067 private ResourceUsage resourceUsage;
slowr60d4d102017-08-16 18:33:58 -070068 @JsonProperty("Type")
slowr13fa5b02017-08-08 16:32:31 -070069 private Type type;
slowr60d4d102017-08-16 18:33:58 -070070 @JsonIgnore
slowr13fa5b02017-08-08 16:32:31 -070071 private Timer timer;
72
slowr67d05e42017-08-11 20:37:22 -070073 public RnibLink(RnibCell cell, RnibUe ue) {
slowr13fa5b02017-08-08 16:32:31 -070074 trafficPercent = new TrafficSplitPercentage();
slowr67d05e42017-08-11 20:37:22 -070075 trafficPercent.setEcgi(cell.getEcgi());
slowr13fa5b02017-08-08 16:32:31 -070076 trafficPercent.setTrafficPercentDl(new BerInteger(100));
77 trafficPercent.setTrafficPercentUl(new BerInteger(100));
78
79 pdcpThroughput = new PDCPThroughput();
80 quality = new LinkQuality();
81 pdcpPackDelay = new PDCPPacketDelay();
82 resourceUsage = new ResourceUsage();
83 timer = new Timer();
slowr67d05e42017-08-11 20:37:22 -070084
85 type = Type.NON_SERVING;
86
87 linkId = LinkId.valueOf(cell, ue);
slowr8ddc2b12017-08-14 14:13:38 -070088
slowr89c2ac12017-08-15 16:20:06 -070089 rrmParameters = new RRMConfig();
90 RRMConfig.Crnti crnti = new RRMConfig.Crnti();
91 crnti.addCRNTI(linkId.getUe().getRanId());
92 rrmParameters.setCrnti(crnti);
93 rrmParameters.setEcgi(linkId.getEcgi());
slowr13fa5b02017-08-08 16:32:31 -070094 }
95
96 public Timer getTimer() {
97 return timer;
98 }
99
100 public void setTimer(Timer timer) {
101 this.timer.cancel();
102 this.timer.purge();
103 this.timer = timer;
104 }
105
slowr60d4d102017-08-16 18:33:58 -0700106 @JsonProperty("Link-ID")
slowr13fa5b02017-08-08 16:32:31 -0700107 public LinkId getLinkId() {
108 return linkId;
109 }
110
slowr60d4d102017-08-16 18:33:58 -0700111 @JsonProperty("Link-ID")
slowr13fa5b02017-08-08 16:32:31 -0700112 public void setLinkId(LinkId linkId) {
113 this.linkId = linkId;
114 }
115
116 public void setLinkId(RnibCell cell, RnibUe ue) {
slowr67d05e42017-08-11 20:37:22 -0700117 this.linkId = LinkId.valueOf(cell, ue);
slowr13fa5b02017-08-08 16:32:31 -0700118 trafficPercent.setEcgi(cell.getEcgi());
119 }
120
slowr60d4d102017-08-16 18:33:58 -0700121 @JsonProperty("Type")
slowr13fa5b02017-08-08 16:32:31 -0700122 public Type getType() {
123 return type;
124 }
125
slowr60d4d102017-08-16 18:33:58 -0700126 @JsonProperty("Type")
slowr13fa5b02017-08-08 16:32:31 -0700127 public void setType(Type type) {
128 this.type = type;
129 }
130
slowr60d4d102017-08-16 18:33:58 -0700131 @JsonProperty("TrafficPercent")
slowr13fa5b02017-08-08 16:32:31 -0700132 public TrafficSplitPercentage getTrafficPercent() {
133 return trafficPercent;
134 }
135
slowr60d4d102017-08-16 18:33:58 -0700136 @JsonProperty("TrafficPercent")
slowr13fa5b02017-08-08 16:32:31 -0700137 public void setTrafficPercent(TrafficSplitPercentage trafficPercent) {
138 this.trafficPercent = trafficPercent;
139 }
140
slowr60d4d102017-08-16 18:33:58 -0700141 @JsonProperty("BearerParameters")
slowr13fa5b02017-08-08 16:32:31 -0700142 public ERABParams getBearerParameters() {
143 return bearerParameters;
144 }
145
slowr60d4d102017-08-16 18:33:58 -0700146 @JsonProperty("BearerParameters")
slowr13fa5b02017-08-08 16:32:31 -0700147 public void setBearerParameters(ERABParams bearerParameters) {
148 this.bearerParameters = bearerParameters;
149 }
150
slowr60d4d102017-08-16 18:33:58 -0700151 @JsonProperty("Quality")
slowr13fa5b02017-08-08 16:32:31 -0700152 public LinkQuality getQuality() {
153 return quality;
154 }
155
slowr60d4d102017-08-16 18:33:58 -0700156 @JsonProperty("Quality")
slowr13fa5b02017-08-08 16:32:31 -0700157 public void setQuality(LinkQuality quality) {
158 this.quality = quality;
159 }
160
slowr60d4d102017-08-16 18:33:58 -0700161 @JsonProperty("RRMConfiguration")
slowr13fa5b02017-08-08 16:32:31 -0700162 public RRMConfig getRrmParameters() {
163 return rrmParameters;
164 }
165
slowr60d4d102017-08-16 18:33:58 -0700166 @JsonProperty("RRMConfiguration")
slowr13fa5b02017-08-08 16:32:31 -0700167 public void setRrmParameters(RRMConfig rrmParameters) {
168 this.rrmParameters = rrmParameters;
169 }
170
slowr8ddc2b12017-08-14 14:13:38 -0700171 public void modifyRrmParameters(JsonNode rrmConfigNode) {
172 {
slowr89c2ac12017-08-15 16:20:06 -0700173 JsonNode start_prb_dl = rrmConfigNode.path("start_prb_dl");
174 if (!start_prb_dl.isMissingNode()) {
slowr8ddc2b12017-08-14 14:13:38 -0700175 RRMConfig.StartPrbDl startPrbDl = new RRMConfig.StartPrbDl();
slowr89c2ac12017-08-15 16:20:06 -0700176
177 List<BerInteger> collect = Lists.newArrayList();
178 collect.add(new BerInteger(start_prb_dl.asInt()));
179 startPrbDl.setSeqOf(collect);
180
slowr8ddc2b12017-08-14 14:13:38 -0700181 rrmParameters.setStartPrbDl(startPrbDl);
182 }
183 }
184
185 {
slowr60d4d102017-08-16 18:33:58 -0700186 JsonNode end_prb_dl = rrmConfigNode.path("end_prb_dl");
slowr89c2ac12017-08-15 16:20:06 -0700187 if (!end_prb_dl.isMissingNode()) {
slowr8ddc2b12017-08-14 14:13:38 -0700188 RRMConfig.EndPrbDl endPrbDl = new RRMConfig.EndPrbDl();
slowr89c2ac12017-08-15 16:20:06 -0700189
190 List<BerInteger> collect = Lists.newArrayList();
191 collect.add(new BerInteger(end_prb_dl.asInt()));
192 endPrbDl.setSeqOf(collect);
193
slowr8ddc2b12017-08-14 14:13:38 -0700194 rrmParameters.setEndPrbDl(endPrbDl);
195 }
196 }
197
198 {
slowr60d4d102017-08-16 18:33:58 -0700199 JsonNode start_prb_ul = rrmConfigNode.path("start_prb_ul");
slowr89c2ac12017-08-15 16:20:06 -0700200 if (!start_prb_ul.isMissingNode()) {
slowr8ddc2b12017-08-14 14:13:38 -0700201 RRMConfig.StartPrbUl startPrbUl = new RRMConfig.StartPrbUl();
slowr89c2ac12017-08-15 16:20:06 -0700202
203 List<BerInteger> collect = Lists.newArrayList();
204 collect.add(new BerInteger(start_prb_ul.asInt()));
205 startPrbUl.setSeqOf(collect);
206
slowr8ddc2b12017-08-14 14:13:38 -0700207 rrmParameters.setStartPrbUl(startPrbUl);
208 }
209 }
210
211 {
slowr60d4d102017-08-16 18:33:58 -0700212 JsonNode end_prb_ul = rrmConfigNode.path("end_prb_ul");
slowr89c2ac12017-08-15 16:20:06 -0700213 if (!end_prb_ul.isMissingNode()) {
slowr8ddc2b12017-08-14 14:13:38 -0700214 RRMConfig.EndPrbUl endPrbUl = new RRMConfig.EndPrbUl();
slowr89c2ac12017-08-15 16:20:06 -0700215
216 List<BerInteger> collect = Lists.newArrayList();
217 collect.add(new BerInteger(end_prb_ul.asInt()));
218 endPrbUl.setSeqOf(collect);
219
slowr8ddc2b12017-08-14 14:13:38 -0700220 rrmParameters.setEndPrbUl(endPrbUl);
221 }
222 }
slowr8ddc2b12017-08-14 14:13:38 -0700223 }
224
slowr60d4d102017-08-16 18:33:58 -0700225 @JsonProperty("PDCP-Throughput")
slowr13fa5b02017-08-08 16:32:31 -0700226 public PDCPThroughput getPdcpThroughput() {
227 return pdcpThroughput;
228 }
229
slowr60d4d102017-08-16 18:33:58 -0700230 @JsonProperty("PDCP-Throughput")
slowr13fa5b02017-08-08 16:32:31 -0700231 public void setPdcpThroughput(PDCPThroughput pdcpThroughput) {
232 this.pdcpThroughput = pdcpThroughput;
233 }
234
slowr60d4d102017-08-16 18:33:58 -0700235 @JsonProperty("PDCP-Packet-Delay")
slowr13fa5b02017-08-08 16:32:31 -0700236 public PDCPPacketDelay getPdcpPackDelay() {
237 return pdcpPackDelay;
238 }
239
slowr60d4d102017-08-16 18:33:58 -0700240 @JsonProperty("PDCP-Packet-Delay")
slowr13fa5b02017-08-08 16:32:31 -0700241 public void setPdcpPackDelay(PDCPPacketDelay pdcpPackDelay) {
242 this.pdcpPackDelay = pdcpPackDelay;
243 }
244
slowr60d4d102017-08-16 18:33:58 -0700245 @JsonProperty("Resource-Usage")
slowr13fa5b02017-08-08 16:32:31 -0700246 public ResourceUsage getResourceUsage() {
247 return resourceUsage;
248 }
249
slowr60d4d102017-08-16 18:33:58 -0700250 @JsonProperty("Resource-Usage")
slowr13fa5b02017-08-08 16:32:31 -0700251 public void setResourceUsage(ResourceUsage resourceUsage) {
252 this.resourceUsage = resourceUsage;
253 }
254
255 @Override
256 public String toString() {
slowr60d4d102017-08-16 18:33:58 -0700257 return "RnibLink{" +
258 "linkId=" + linkId +
259 ", rrmParameters=" + rrmParameters +
260 ", trafficPercent=" + trafficPercent +
261 ", bearerParameters=" + bearerParameters +
262 ", quality=" + quality +
263 ", pdcpThroughput=" + pdcpThroughput +
264 ", pdcpPackDelay=" + pdcpPackDelay +
265 ", resourceUsage=" + resourceUsage +
266 ", type=" + type +
267 ", timer=" + timer +
268 '}';
slowr13fa5b02017-08-08 16:32:31 -0700269 }
270
271 @Override
272 public boolean equals(Object o) {
273 if (this == o) return true;
274 if (o == null || getClass() != o.getClass()) return false;
275
276 RnibLink link = (RnibLink) o;
277
278 return linkId.equals(link.linkId);
279 }
280
281 @Override
282 public int hashCode() {
283 return linkId.hashCode();
284 }
285
286 public enum Type {
slowr67d05e42017-08-11 20:37:22 -0700287 SERVING_PRIMARY("serving/primary") {
slowr13fa5b02017-08-08 16:32:31 -0700288 @Override
289 public String toString() {
290 return "\"serving/primary\"";
291 }
292 },
293 // TODO: Add CA/DC
slowr89c2ac12017-08-15 16:20:06 -0700294 SERVING_SECONDARY_CA("serving/secondary/ca") {
slowr13fa5b02017-08-08 16:32:31 -0700295 @Override
296 public String toString() {
slowr89c2ac12017-08-15 16:20:06 -0700297 return "\"serving/secondary/ca\"";
298 }
299 },
300 SERVING_SECONDARY_DC("serving/secondary/dc") {
301 @Override
302 public String toString() {
303 return "\"serving/secondary/dc\"";
slowr13fa5b02017-08-08 16:32:31 -0700304 }
305 },
slowr67d05e42017-08-11 20:37:22 -0700306 NON_SERVING("non-serving") {
slowr13fa5b02017-08-08 16:32:31 -0700307 @Override
308 public String toString() {
309 return "\"non-serving\"";
310 }
slowr67d05e42017-08-11 20:37:22 -0700311 };
312
313 private String name;
314
315 Type(String name) {
316 this.name = name;
317 }
318
319 public static Type getEnum(String name) {
320 Optional<Type> any = Arrays.stream(Type.values()).filter(typeStr -> typeStr.name.equals(name)).findAny();
321 if (any.isPresent()) {
322 return any.get();
323 }
324 throw new IllegalArgumentException("No enum defined for string: " + name);
slowr13fa5b02017-08-08 16:32:31 -0700325 }
326 }
327
slowr60d4d102017-08-16 18:33:58 -0700328 @JsonPropertyOrder({
329 "dl",
330 "ul"
331 })
332 @JsonIgnoreProperties(ignoreUnknown = true)
slowr13fa5b02017-08-08 16:32:31 -0700333 public class PDCPThroughput {
334 private PDCPMeasReportPerUe.ThroughputDl dl;
335 private PDCPMeasReportPerUe.ThroughputUl ul;
336
337 public PDCPMeasReportPerUe.ThroughputDl getDl() {
338 return dl;
339 }
340
341 public void setDl(PDCPMeasReportPerUe.ThroughputDl dl) {
342 this.dl = dl;
343 }
344
345 public PDCPMeasReportPerUe.ThroughputUl getUl() {
346 return ul;
347 }
348
349 public void setUl(PDCPMeasReportPerUe.ThroughputUl ul) {
350 this.ul = ul;
351 }
352
353 @Override
354 public String toString() {
slowr60d4d102017-08-16 18:33:58 -0700355 return "PDCPThroughput{" +
356 "dl=" + dl +
357 ", ul=" + ul +
358 '}';
slowr13fa5b02017-08-08 16:32:31 -0700359 }
360 }
361
slowr60d4d102017-08-16 18:33:58 -0700362 @JsonPropertyOrder({
363 "dl",
364 "ul"
365 })
366 @JsonIgnoreProperties(ignoreUnknown = true)
slowr13fa5b02017-08-08 16:32:31 -0700367 public class PDCPPacketDelay {
368 PDCPMeasReportPerUe.PktDelayDl dl;
369 PDCPMeasReportPerUe.PktDelayUl ul;
370
371 public PDCPMeasReportPerUe.PktDelayDl getDl() {
372 return dl;
373 }
374
375 public void setDl(PDCPMeasReportPerUe.PktDelayDl dl) {
376 this.dl = dl;
377 }
378
379 public PDCPMeasReportPerUe.PktDelayUl getUl() {
380 return ul;
381 }
382
383 public void setUl(PDCPMeasReportPerUe.PktDelayUl ul) {
384 this.ul = ul;
385 }
386
387 @Override
388 public String toString() {
slowr60d4d102017-08-16 18:33:58 -0700389 return "PDCPPacketDelay{" +
390 "dl=" + dl +
391 ", ul=" + ul +
392 '}';
slowr13fa5b02017-08-08 16:32:31 -0700393 }
394 }
395
slowr60d4d102017-08-16 18:33:58 -0700396 @JsonPropertyOrder({
397 "dl",
398 "ul"
399 })
400 @JsonIgnoreProperties(ignoreUnknown = true)
slowr13fa5b02017-08-08 16:32:31 -0700401 public class ResourceUsage {
402 PRBUsage.PrbUsageDl dl;
403 PRBUsage.PrbUsageUl ul;
404
405 public PRBUsage.PrbUsageDl getDl() {
406 return dl;
407 }
408
409 public void setDl(PRBUsage.PrbUsageDl dl) {
410 this.dl = dl;
411 }
412
413 public PRBUsage.PrbUsageUl getUl() {
414 return ul;
415 }
416
417 public void setUl(PRBUsage.PrbUsageUl ul) {
418 this.ul = ul;
419 }
420
421 @Override
422 public String toString() {
slowr60d4d102017-08-16 18:33:58 -0700423 return "ResourceUsage{" +
424 "dl=" + dl +
425 ", ul=" + ul +
426 '}';
slowr13fa5b02017-08-08 16:32:31 -0700427 }
428 }
429
slowr60d4d102017-08-16 18:33:58 -0700430 @JsonPropertyOrder({
431 "rsrp",
432 "rsrq",
433 "cqiHist",
434 "cqiMode",
435 "cqiMean",
436 "mcsDl",
437 "mcsUl"
438 })
439 @JsonIgnoreProperties(ignoreUnknown = true)
slowr13fa5b02017-08-08 16:32:31 -0700440 public class LinkQuality {
441 double rsrp;
442 double rsrq;
443 RadioRepPerServCell.CqiHist cqiHist;
444 double cqiMode;
445 double cqiMean;
slowr60d4d102017-08-16 18:33:58 -0700446 SchedMeasRepPerServCell.McsDl mcsDl;
447 SchedMeasRepPerServCell.McsUl mcsUl;
slowr13fa5b02017-08-08 16:32:31 -0700448
449 public double getRsrp() {
450 return rsrp;
451 }
452
453 public void setRsrp(double rsrp) {
454 this.rsrp = rsrp;
455 }
456
457 public double getRsrq() {
458 return rsrq;
459 }
460
461 public void setRsrq(double rsrq) {
462 this.rsrq = rsrq;
463 }
464
465 public RadioRepPerServCell.CqiHist getCqiHist() {
466 return cqiHist;
467 }
468
469 public void setCqiHist(RadioRepPerServCell.CqiHist cqiHist) {
470 this.cqiHist = cqiHist;
471 }
472
473 public double getCqiMode() {
474 return cqiMode;
475 }
476
477 public void setCqiMode(double cqiMode) {
478 this.cqiMode = cqiMode;
479 }
480
481 public double getCqiMean() {
482 return cqiMean;
483 }
484
485 public void setCqiMean(double cqiMean) {
486 this.cqiMean = cqiMean;
487 }
488
slowr60d4d102017-08-16 18:33:58 -0700489 public SchedMeasRepPerServCell.McsDl getMcsDl() {
490 return mcsDl;
slowr13fa5b02017-08-08 16:32:31 -0700491 }
492
slowr60d4d102017-08-16 18:33:58 -0700493 public void setMcsDl(SchedMeasRepPerServCell.McsDl mcsDl) {
494 this.mcsDl = mcsDl;
slowr13fa5b02017-08-08 16:32:31 -0700495 }
496
slowr60d4d102017-08-16 18:33:58 -0700497 public SchedMeasRepPerServCell.McsUl getMcsUl() {
498 return mcsUl;
slowr13fa5b02017-08-08 16:32:31 -0700499 }
500
slowr60d4d102017-08-16 18:33:58 -0700501 public void setMcsUl(SchedMeasRepPerServCell.McsUl mcsUl) {
502 this.mcsUl = mcsUl;
slowr13fa5b02017-08-08 16:32:31 -0700503 }
504
505 @Override
506 public String toString() {
slowr60d4d102017-08-16 18:33:58 -0700507 return "LinkQuality{" +
508 "rsrp=" + rsrp +
509 ", rsrq=" + rsrq +
510 ", cqiHist=" + cqiHist +
511 ", cqiMode=" + cqiMode +
512 ", cqiMean=" + cqiMean +
513 ", mcsDl=" + mcsDl +
514 ", mcsUl=" + mcsUl +
515 '}';
slowr13fa5b02017-08-08 16:32:31 -0700516 }
517 }
518}