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 | |
| 19 | import org.onosproject.xran.codecs.api.*; |
| 20 | import org.onosproject.xran.codecs.pdu.PDCPMeasReportPerUe; |
| 21 | import org.onosproject.xran.codecs.pdu.RRMConfig; |
| 22 | import org.onosproject.xran.identifiers.LinkId; |
| 23 | import org.openmuc.jasn1.ber.types.BerInteger; |
| 24 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame^] | 25 | import java.util.Arrays; |
| 26 | import java.util.Optional; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 27 | import java.util.Timer; |
| 28 | |
| 29 | /** |
| 30 | * Created by dimitris on 7/22/17. |
| 31 | */ |
| 32 | public class RnibLink { |
| 33 | private LinkId linkId; |
| 34 | // private String type; |
| 35 | private RRMConfig rrmParameters; |
| 36 | |
| 37 | private TrafficSplitPercentage trafficPercent; |
| 38 | private ERABParams bearerParameters; |
| 39 | |
| 40 | private LinkQuality quality; |
| 41 | private PDCPThroughput pdcpThroughput; |
| 42 | private PDCPPacketDelay pdcpPackDelay; |
| 43 | private ResourceUsage resourceUsage; |
| 44 | private Type type; |
| 45 | private Timer timer; |
| 46 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame^] | 47 | public RnibLink(RnibCell cell, RnibUe ue) { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 48 | trafficPercent = new TrafficSplitPercentage(); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame^] | 49 | trafficPercent.setEcgi(cell.getEcgi()); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 50 | trafficPercent.setTrafficPercentDl(new BerInteger(100)); |
| 51 | trafficPercent.setTrafficPercentUl(new BerInteger(100)); |
| 52 | |
| 53 | pdcpThroughput = new PDCPThroughput(); |
| 54 | quality = new LinkQuality(); |
| 55 | pdcpPackDelay = new PDCPPacketDelay(); |
| 56 | resourceUsage = new ResourceUsage(); |
| 57 | timer = new Timer(); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame^] | 58 | |
| 59 | type = Type.NON_SERVING; |
| 60 | |
| 61 | linkId = LinkId.valueOf(cell, ue); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | public Timer getTimer() { |
| 65 | return timer; |
| 66 | } |
| 67 | |
| 68 | public void setTimer(Timer timer) { |
| 69 | this.timer.cancel(); |
| 70 | this.timer.purge(); |
| 71 | this.timer = timer; |
| 72 | } |
| 73 | |
| 74 | public LinkId getLinkId() { |
| 75 | return linkId; |
| 76 | } |
| 77 | |
| 78 | public void setLinkId(LinkId linkId) { |
| 79 | this.linkId = linkId; |
| 80 | } |
| 81 | |
| 82 | public void setLinkId(RnibCell cell, RnibUe ue) { |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame^] | 83 | this.linkId = LinkId.valueOf(cell, ue); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 84 | trafficPercent.setEcgi(cell.getEcgi()); |
| 85 | } |
| 86 | |
| 87 | public Type getType() { |
| 88 | return type; |
| 89 | } |
| 90 | |
| 91 | public void setType(Type type) { |
| 92 | this.type = type; |
| 93 | } |
| 94 | |
| 95 | public TrafficSplitPercentage getTrafficPercent() { |
| 96 | return trafficPercent; |
| 97 | } |
| 98 | |
| 99 | public void setTrafficPercent(TrafficSplitPercentage trafficPercent) { |
| 100 | this.trafficPercent = trafficPercent; |
| 101 | } |
| 102 | |
| 103 | public ERABParams getBearerParameters() { |
| 104 | return bearerParameters; |
| 105 | } |
| 106 | |
| 107 | public void setBearerParameters(ERABParams bearerParameters) { |
| 108 | this.bearerParameters = bearerParameters; |
| 109 | } |
| 110 | |
| 111 | public LinkQuality getQuality() { |
| 112 | return quality; |
| 113 | } |
| 114 | |
| 115 | public void setQuality(LinkQuality quality) { |
| 116 | this.quality = quality; |
| 117 | } |
| 118 | |
| 119 | public RRMConfig getRrmParameters() { |
| 120 | return rrmParameters; |
| 121 | } |
| 122 | |
| 123 | public void setRrmParameters(RRMConfig rrmParameters) { |
| 124 | this.rrmParameters = rrmParameters; |
| 125 | } |
| 126 | |
| 127 | public PDCPThroughput getPdcpThroughput() { |
| 128 | return pdcpThroughput; |
| 129 | } |
| 130 | |
| 131 | public void setPdcpThroughput(PDCPThroughput pdcpThroughput) { |
| 132 | this.pdcpThroughput = pdcpThroughput; |
| 133 | } |
| 134 | |
| 135 | public PDCPPacketDelay getPdcpPackDelay() { |
| 136 | return pdcpPackDelay; |
| 137 | } |
| 138 | |
| 139 | public void setPdcpPackDelay(PDCPPacketDelay pdcpPackDelay) { |
| 140 | this.pdcpPackDelay = pdcpPackDelay; |
| 141 | } |
| 142 | |
| 143 | public ResourceUsage getResourceUsage() { |
| 144 | return resourceUsage; |
| 145 | } |
| 146 | |
| 147 | public void setResourceUsage(ResourceUsage resourceUsage) { |
| 148 | this.resourceUsage = resourceUsage; |
| 149 | } |
| 150 | |
| 151 | @Override |
| 152 | public String toString() { |
| 153 | StringBuilder sb = new StringBuilder(); |
| 154 | sb.append("{\n") |
| 155 | .append(linkId != null ? "\"link-id\":" + linkId : "") |
| 156 | .append(type != null ? ",\n\"type\":" + type : "") |
| 157 | .append(rrmParameters != null ? ",\n\"rrm-params\":" + rrmParameters : "") |
| 158 | .append(trafficPercent != null ? ",\n\"traffic-percent\":" + trafficPercent : "") |
| 159 | .append(bearerParameters != null ? ",\n\"bearer-params\":" + bearerParameters : "") |
| 160 | .append(quality != null ? ",\n\"quality\":" + quality : "") |
| 161 | .append(pdcpThroughput != null ? ",\n\"pdcp-throughput\":" + pdcpThroughput : "") |
| 162 | .append(pdcpPackDelay != null ? ",\n\"pdcp-packet-delay\":" + pdcpPackDelay : "") |
| 163 | .append(resourceUsage != null ? ",\n\"resource-usage\":" + resourceUsage : "") |
| 164 | .append("\n}\n"); |
| 165 | return sb.toString(); |
| 166 | } |
| 167 | |
| 168 | @Override |
| 169 | public boolean equals(Object o) { |
| 170 | if (this == o) return true; |
| 171 | if (o == null || getClass() != o.getClass()) return false; |
| 172 | |
| 173 | RnibLink link = (RnibLink) o; |
| 174 | |
| 175 | return linkId.equals(link.linkId); |
| 176 | } |
| 177 | |
| 178 | @Override |
| 179 | public int hashCode() { |
| 180 | return linkId.hashCode(); |
| 181 | } |
| 182 | |
| 183 | public enum Type { |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame^] | 184 | SERVING_PRIMARY("serving/primary") { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 185 | @Override |
| 186 | public String toString() { |
| 187 | return "\"serving/primary\""; |
| 188 | } |
| 189 | }, |
| 190 | // TODO: Add CA/DC |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame^] | 191 | SERVING_SECONDARY("serving/secondary") { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 192 | @Override |
| 193 | public String toString() { |
| 194 | return "\"serving/secondary\""; |
| 195 | } |
| 196 | }, |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame^] | 197 | NON_SERVING("non-serving") { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 198 | @Override |
| 199 | public String toString() { |
| 200 | return "\"non-serving\""; |
| 201 | } |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame^] | 202 | }; |
| 203 | |
| 204 | private String name; |
| 205 | |
| 206 | Type(String name) { |
| 207 | this.name = name; |
| 208 | } |
| 209 | |
| 210 | public static Type getEnum(String name) { |
| 211 | Optional<Type> any = Arrays.stream(Type.values()).filter(typeStr -> typeStr.name.equals(name)).findAny(); |
| 212 | if (any.isPresent()) { |
| 213 | return any.get(); |
| 214 | } |
| 215 | throw new IllegalArgumentException("No enum defined for string: " + name); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 216 | } |
| 217 | } |
| 218 | |
| 219 | public class PDCPThroughput { |
| 220 | private PDCPMeasReportPerUe.ThroughputDl dl; |
| 221 | private PDCPMeasReportPerUe.ThroughputUl ul; |
| 222 | |
| 223 | public PDCPMeasReportPerUe.ThroughputDl getDl() { |
| 224 | return dl; |
| 225 | } |
| 226 | |
| 227 | public void setDl(PDCPMeasReportPerUe.ThroughputDl dl) { |
| 228 | this.dl = dl; |
| 229 | } |
| 230 | |
| 231 | public PDCPMeasReportPerUe.ThroughputUl getUl() { |
| 232 | return ul; |
| 233 | } |
| 234 | |
| 235 | public void setUl(PDCPMeasReportPerUe.ThroughputUl ul) { |
| 236 | this.ul = ul; |
| 237 | } |
| 238 | |
| 239 | @Override |
| 240 | public String toString() { |
| 241 | StringBuilder sb = new StringBuilder(); |
| 242 | sb.append("{\n") |
| 243 | .append(dl != null ? "\"dl\":" + dl : "") |
| 244 | .append(ul != null ? ",\n\"ul\":" + ul : "") |
| 245 | .append("\n}\n"); |
| 246 | return sb.toString(); |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | public class PDCPPacketDelay { |
| 251 | PDCPMeasReportPerUe.PktDelayDl dl; |
| 252 | PDCPMeasReportPerUe.PktDelayUl ul; |
| 253 | |
| 254 | public PDCPMeasReportPerUe.PktDelayDl getDl() { |
| 255 | return dl; |
| 256 | } |
| 257 | |
| 258 | public void setDl(PDCPMeasReportPerUe.PktDelayDl dl) { |
| 259 | this.dl = dl; |
| 260 | } |
| 261 | |
| 262 | public PDCPMeasReportPerUe.PktDelayUl getUl() { |
| 263 | return ul; |
| 264 | } |
| 265 | |
| 266 | public void setUl(PDCPMeasReportPerUe.PktDelayUl ul) { |
| 267 | this.ul = ul; |
| 268 | } |
| 269 | |
| 270 | @Override |
| 271 | public String toString() { |
| 272 | StringBuilder sb = new StringBuilder(); |
| 273 | sb.append("{\n") |
| 274 | .append(dl != null ? "\"dl\":" + dl : "") |
| 275 | .append(ul != null ? ",\n\"ul\":" + ul : "") |
| 276 | .append("\n}\n"); |
| 277 | return sb.toString(); |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | public class ResourceUsage { |
| 282 | PRBUsage.PrbUsageDl dl; |
| 283 | PRBUsage.PrbUsageUl ul; |
| 284 | |
| 285 | public PRBUsage.PrbUsageDl getDl() { |
| 286 | return dl; |
| 287 | } |
| 288 | |
| 289 | public void setDl(PRBUsage.PrbUsageDl dl) { |
| 290 | this.dl = dl; |
| 291 | } |
| 292 | |
| 293 | public PRBUsage.PrbUsageUl getUl() { |
| 294 | return ul; |
| 295 | } |
| 296 | |
| 297 | public void setUl(PRBUsage.PrbUsageUl ul) { |
| 298 | this.ul = ul; |
| 299 | } |
| 300 | |
| 301 | @Override |
| 302 | public String toString() { |
| 303 | StringBuilder sb = new StringBuilder(); |
| 304 | sb.append("{\n") |
| 305 | .append(dl != null ? "\"dl\":" + dl : "") |
| 306 | .append(ul != null ? ",\n\"ul\":" + ul : "") |
| 307 | .append("\n}\n"); |
| 308 | return sb.toString(); |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | public class LinkQuality { |
| 313 | double rsrp; |
| 314 | double rsrq; |
| 315 | RadioRepPerServCell.CqiHist cqiHist; |
| 316 | double cqiMode; |
| 317 | double cqiMean; |
| 318 | SchedMeasRepPerServCell.McsDl mcs_dl; |
| 319 | SchedMeasRepPerServCell.McsUl mcs_ul; |
| 320 | |
| 321 | public double getRsrp() { |
| 322 | return rsrp; |
| 323 | } |
| 324 | |
| 325 | public void setRsrp(double rsrp) { |
| 326 | this.rsrp = rsrp; |
| 327 | } |
| 328 | |
| 329 | public double getRsrq() { |
| 330 | return rsrq; |
| 331 | } |
| 332 | |
| 333 | public void setRsrq(double rsrq) { |
| 334 | this.rsrq = rsrq; |
| 335 | } |
| 336 | |
| 337 | public RadioRepPerServCell.CqiHist getCqiHist() { |
| 338 | return cqiHist; |
| 339 | } |
| 340 | |
| 341 | public void setCqiHist(RadioRepPerServCell.CqiHist cqiHist) { |
| 342 | this.cqiHist = cqiHist; |
| 343 | } |
| 344 | |
| 345 | public double getCqiMode() { |
| 346 | return cqiMode; |
| 347 | } |
| 348 | |
| 349 | public void setCqiMode(double cqiMode) { |
| 350 | this.cqiMode = cqiMode; |
| 351 | } |
| 352 | |
| 353 | public double getCqiMean() { |
| 354 | return cqiMean; |
| 355 | } |
| 356 | |
| 357 | public void setCqiMean(double cqiMean) { |
| 358 | this.cqiMean = cqiMean; |
| 359 | } |
| 360 | |
| 361 | public SchedMeasRepPerServCell.McsDl getMcs_dl() { |
| 362 | return mcs_dl; |
| 363 | } |
| 364 | |
| 365 | public void setMcs_dl(SchedMeasRepPerServCell.McsDl mcs_dl) { |
| 366 | this.mcs_dl = mcs_dl; |
| 367 | } |
| 368 | |
| 369 | public SchedMeasRepPerServCell.McsUl getMcs_ul() { |
| 370 | return mcs_ul; |
| 371 | } |
| 372 | |
| 373 | public void setMcs_ul(SchedMeasRepPerServCell.McsUl mcs_ul) { |
| 374 | this.mcs_ul = mcs_ul; |
| 375 | } |
| 376 | |
| 377 | @Override |
| 378 | public String toString() { |
| 379 | StringBuilder sb = new StringBuilder(); |
| 380 | sb.append("{\n") |
| 381 | .append("\"rsrp\":" + rsrp) |
| 382 | .append(",\n\"rsrq\":" + rsrq) |
| 383 | .append(",\n\"cqiMode\":" + cqiMode) |
| 384 | .append(",\n\"cqiMean\":" + cqiMean) |
| 385 | .append(mcs_dl != null ? ",\n\"mcs-dl\":" + mcs_dl : "") |
| 386 | .append(mcs_ul != null ? ",\n\"mcs-ul\":" + mcs_ul : "") |
| 387 | .append("\n}\n"); |
| 388 | return sb.toString(); |
| 389 | } |
| 390 | } |
| 391 | } |