slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package org.onosproject.xran.entities; |
| 18 | |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 19 | import com.fasterxml.jackson.databind.JsonNode; |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame^] | 20 | import com.google.common.collect.Lists; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 21 | import org.onosproject.xran.codecs.api.*; |
| 22 | import org.onosproject.xran.codecs.pdu.PDCPMeasReportPerUe; |
| 23 | import org.onosproject.xran.codecs.pdu.RRMConfig; |
| 24 | import org.onosproject.xran.identifiers.LinkId; |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 25 | import org.openmuc.jasn1.ber.types.BerBitString; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 26 | import org.openmuc.jasn1.ber.types.BerInteger; |
| 27 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 28 | import java.util.Arrays; |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 29 | import java.util.List; |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 30 | import java.util.Optional; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 31 | import java.util.Timer; |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 32 | import java.util.stream.Collectors; |
| 33 | import java.util.stream.Stream; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 34 | |
| 35 | /** |
| 36 | * Created by dimitris on 7/22/17. |
| 37 | */ |
| 38 | public 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 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 53 | public RnibLink(RnibCell cell, RnibUe ue) { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 54 | trafficPercent = new TrafficSplitPercentage(); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 55 | trafficPercent.setEcgi(cell.getEcgi()); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 56 | 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(); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 64 | |
| 65 | type = Type.NON_SERVING; |
| 66 | |
| 67 | linkId = LinkId.valueOf(cell, ue); |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 68 | |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame^] | 69 | 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()); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 74 | } |
| 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) { |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 95 | this.linkId = LinkId.valueOf(cell, ue); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 96 | 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 | |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 139 | public void modifyRrmParameters(JsonNode rrmConfigNode) { |
| 140 | { |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame^] | 141 | JsonNode start_prb_dl = rrmConfigNode.path("start_prb_dl"); |
| 142 | if (!start_prb_dl.isMissingNode()) { |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 143 | RRMConfig.StartPrbDl startPrbDl = new RRMConfig.StartPrbDl(); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame^] | 144 | |
| 145 | List<BerInteger> collect = Lists.newArrayList(); |
| 146 | collect.add(new BerInteger(start_prb_dl.asInt())); |
| 147 | startPrbDl.setSeqOf(collect); |
| 148 | |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 149 | rrmParameters.setStartPrbDl(startPrbDl); |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | { |
| 154 | JsonNode end_prb_dl = rrmConfigNode.get("end_prb_dl"); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame^] | 155 | if (!end_prb_dl.isMissingNode()) { |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 156 | RRMConfig.EndPrbDl endPrbDl = new RRMConfig.EndPrbDl(); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame^] | 157 | |
| 158 | List<BerInteger> collect = Lists.newArrayList(); |
| 159 | collect.add(new BerInteger(end_prb_dl.asInt())); |
| 160 | endPrbDl.setSeqOf(collect); |
| 161 | |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 162 | rrmParameters.setEndPrbDl(endPrbDl); |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | { |
| 167 | JsonNode start_prb_ul = rrmConfigNode.get("start_prb_ul"); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame^] | 168 | if (!start_prb_ul.isMissingNode()) { |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 169 | RRMConfig.StartPrbUl startPrbUl = new RRMConfig.StartPrbUl(); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame^] | 170 | |
| 171 | List<BerInteger> collect = Lists.newArrayList(); |
| 172 | collect.add(new BerInteger(start_prb_ul.asInt())); |
| 173 | startPrbUl.setSeqOf(collect); |
| 174 | |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 175 | rrmParameters.setStartPrbUl(startPrbUl); |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | { |
| 180 | JsonNode end_prb_ul = rrmConfigNode.get("end_prb_ul"); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame^] | 181 | if (!end_prb_ul.isMissingNode()) { |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 182 | RRMConfig.EndPrbUl endPrbUl = new RRMConfig.EndPrbUl(); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame^] | 183 | |
| 184 | List<BerInteger> collect = Lists.newArrayList(); |
| 185 | collect.add(new BerInteger(end_prb_ul.asInt())); |
| 186 | endPrbUl.setSeqOf(collect); |
| 187 | |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 188 | rrmParameters.setEndPrbUl(endPrbUl); |
| 189 | } |
| 190 | } |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 191 | } |
| 192 | |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 193 | 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 { |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 250 | SERVING_PRIMARY("serving/primary") { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 251 | @Override |
| 252 | public String toString() { |
| 253 | return "\"serving/primary\""; |
| 254 | } |
| 255 | }, |
| 256 | // TODO: Add CA/DC |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame^] | 257 | SERVING_SECONDARY_CA("serving/secondary/ca") { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 258 | @Override |
| 259 | public String toString() { |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame^] | 260 | return "\"serving/secondary/ca\""; |
| 261 | } |
| 262 | }, |
| 263 | SERVING_SECONDARY_DC("serving/secondary/dc") { |
| 264 | @Override |
| 265 | public String toString() { |
| 266 | return "\"serving/secondary/dc\""; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 267 | } |
| 268 | }, |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 269 | NON_SERVING("non-serving") { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 270 | @Override |
| 271 | public String toString() { |
| 272 | return "\"non-serving\""; |
| 273 | } |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 274 | }; |
| 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); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 288 | } |
| 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 | } |