slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1 | /* |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 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.controller; |
| 18 | |
| 19 | import com.google.common.collect.Sets; |
| 20 | import io.netty.channel.ChannelHandlerContext; |
| 21 | import io.netty.channel.sctp.SctpMessage; |
| 22 | import org.apache.commons.lang.exception.ExceptionUtils; |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 23 | import org.apache.felix.scr.annotations.Activate; |
| 24 | import org.apache.felix.scr.annotations.Component; |
| 25 | import org.apache.felix.scr.annotations.Deactivate; |
| 26 | import org.apache.felix.scr.annotations.Reference; |
| 27 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
| 28 | import org.apache.felix.scr.annotations.Service; |
| 29 | import org.onlab.packet.IpAddress; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 30 | import org.onosproject.core.ApplicationId; |
| 31 | import org.onosproject.core.CoreService; |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 32 | import org.onosproject.net.config.Config; |
| 33 | import org.onosproject.net.config.ConfigFactory; |
| 34 | import org.onosproject.net.config.NetworkConfigEvent; |
| 35 | import org.onosproject.net.config.NetworkConfigListener; |
| 36 | import org.onosproject.net.config.NetworkConfigRegistry; |
| 37 | import org.onosproject.net.config.NetworkConfigService; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 38 | import org.onosproject.net.config.basics.SubjectFactories; |
| 39 | import org.onosproject.net.device.DeviceEvent; |
| 40 | import org.onosproject.net.device.DeviceListener; |
| 41 | import org.onosproject.net.device.DeviceService; |
| 42 | import org.onosproject.net.host.HostEvent; |
| 43 | import org.onosproject.net.host.HostListener; |
| 44 | import org.onosproject.net.host.HostService; |
| 45 | import org.onosproject.xran.XranStore; |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 46 | import org.onosproject.xran.codecs.api.CRNTI; |
| 47 | import org.onosproject.xran.codecs.api.ECGI; |
| 48 | import org.onosproject.xran.codecs.api.ERABID; |
| 49 | import org.onosproject.xran.codecs.api.ERABParams; |
| 50 | import org.onosproject.xran.codecs.api.ERABParamsItem; |
| 51 | import org.onosproject.xran.codecs.api.PCIARFCN; |
| 52 | import org.onosproject.xran.codecs.api.PropScell; |
| 53 | import org.onosproject.xran.codecs.api.RSRPRange; |
| 54 | import org.onosproject.xran.codecs.api.RSRQRange; |
| 55 | import org.onosproject.xran.codecs.api.RXSigReport; |
| 56 | import org.onosproject.xran.codecs.api.RadioRepPerServCell; |
| 57 | import org.onosproject.xran.codecs.api.SchedMeasRepPerServCell; |
| 58 | import org.onosproject.xran.codecs.api.TrafficSplitPercentage; |
slowr | c153ad9 | 2017-08-16 19:47:52 -0700 | [diff] [blame] | 59 | import org.onosproject.xran.codecs.ber.types.BerInteger; |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 60 | import org.onosproject.xran.codecs.pdu.BearerAdmissionRequest; |
| 61 | import org.onosproject.xran.codecs.pdu.BearerAdmissionResponse; |
| 62 | import org.onosproject.xran.codecs.pdu.BearerAdmissionStatus; |
| 63 | import org.onosproject.xran.codecs.pdu.BearerReleaseInd; |
| 64 | import org.onosproject.xran.codecs.pdu.CellConfigReport; |
| 65 | import org.onosproject.xran.codecs.pdu.CellConfigRequest; |
| 66 | import org.onosproject.xran.codecs.pdu.HOComplete; |
| 67 | import org.onosproject.xran.codecs.pdu.HOFailure; |
| 68 | import org.onosproject.xran.codecs.pdu.HORequest; |
| 69 | import org.onosproject.xran.codecs.pdu.L2MeasConfig; |
| 70 | import org.onosproject.xran.codecs.pdu.PDCPMeasReportPerUe; |
| 71 | import org.onosproject.xran.codecs.pdu.RRMConfig; |
| 72 | import org.onosproject.xran.codecs.pdu.RRMConfigStatus; |
| 73 | import org.onosproject.xran.codecs.pdu.RXSigMeasConfig; |
| 74 | import org.onosproject.xran.codecs.pdu.RXSigMeasReport; |
| 75 | import org.onosproject.xran.codecs.pdu.RadioMeasReportPerCell; |
| 76 | import org.onosproject.xran.codecs.pdu.RadioMeasReportPerUE; |
| 77 | import org.onosproject.xran.codecs.pdu.ScellAdd; |
| 78 | import org.onosproject.xran.codecs.pdu.ScellAddStatus; |
| 79 | import org.onosproject.xran.codecs.pdu.ScellDelete; |
| 80 | import org.onosproject.xran.codecs.pdu.SchedMeasReportPerCell; |
| 81 | import org.onosproject.xran.codecs.pdu.SchedMeasReportPerUE; |
| 82 | import org.onosproject.xran.codecs.pdu.TrafficSplitConfig; |
| 83 | import org.onosproject.xran.codecs.pdu.UEAdmissionRequest; |
| 84 | import org.onosproject.xran.codecs.pdu.UEAdmissionResponse; |
| 85 | import org.onosproject.xran.codecs.pdu.UEAdmissionStatus; |
| 86 | import org.onosproject.xran.codecs.pdu.UECapabilityEnquiry; |
| 87 | import org.onosproject.xran.codecs.pdu.UECapabilityInfo; |
| 88 | import org.onosproject.xran.codecs.pdu.UEContextUpdate; |
| 89 | import org.onosproject.xran.codecs.pdu.UEReconfigInd; |
| 90 | import org.onosproject.xran.codecs.pdu.UEReleaseInd; |
| 91 | import org.onosproject.xran.codecs.pdu.XICICConfig; |
| 92 | import org.onosproject.xran.codecs.pdu.XrancPdu; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 93 | import org.onosproject.xran.entities.RnibCell; |
| 94 | import org.onosproject.xran.entities.RnibLink; |
| 95 | import org.onosproject.xran.entities.RnibUe; |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 96 | import org.onosproject.xran.identifiers.ContextUpdateHandler; |
slowr | c86750e | 2017-08-22 17:26:47 -0700 | [diff] [blame] | 97 | import org.onosproject.xran.identifiers.EcgiCrntiPair; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 98 | import org.onosproject.xran.identifiers.LinkId; |
| 99 | import org.onosproject.xran.impl.XranConfig; |
| 100 | import org.onosproject.xran.providers.XranDeviceListener; |
| 101 | import org.onosproject.xran.providers.XranHostListener; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 102 | import org.onosproject.xran.wrapper.CellMap; |
| 103 | import org.onosproject.xran.wrapper.LinkMap; |
| 104 | import org.onosproject.xran.wrapper.UeMap; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 105 | import org.slf4j.Logger; |
| 106 | import org.slf4j.LoggerFactory; |
| 107 | |
| 108 | import java.io.IOException; |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 109 | import java.util.ArrayList; |
| 110 | import java.util.List; |
| 111 | import java.util.Optional; |
| 112 | import java.util.Set; |
| 113 | import java.util.Timer; |
| 114 | import java.util.TimerTask; |
| 115 | import java.util.concurrent.BlockingQueue; |
| 116 | import java.util.concurrent.ConcurrentHashMap; |
| 117 | import java.util.concurrent.ConcurrentMap; |
| 118 | import java.util.concurrent.CopyOnWriteArraySet; |
| 119 | import java.util.concurrent.LinkedBlockingQueue; |
| 120 | import java.util.concurrent.SynchronousQueue; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 121 | import java.util.stream.Collectors; |
| 122 | |
| 123 | import static org.onosproject.net.DeviceId.deviceId; |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 124 | import static org.onosproject.xran.controller.XranChannelHandler.getSctpMessage; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 125 | import static org.onosproject.xran.entities.RnibCell.decodeDeviceId; |
| 126 | import static org.onosproject.xran.entities.RnibCell.uri; |
slowr | c86750e | 2017-08-22 17:26:47 -0700 | [diff] [blame] | 127 | import static org.onosproject.xran.entities.RnibUe.hostIdtoUEId; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 128 | |
| 129 | /** |
| 130 | * Created by dimitris on 7/20/17. |
| 131 | */ |
| 132 | @Component(immediate = true) |
| 133 | @Service |
| 134 | public class XranControllerImpl implements XranController { |
| 135 | private static final String XRAN_APP_ID = "org.onosproject.xran"; |
| 136 | private static final Class<XranConfig> CONFIG_CLASS = XranConfig.class; |
| 137 | |
| 138 | private static final Logger log = |
| 139 | LoggerFactory.getLogger(XranControllerImpl.class); |
| 140 | /* CONFIG */ |
| 141 | private final InternalNetworkConfigListener configListener = |
| 142 | new InternalNetworkConfigListener(); |
| 143 | /* VARIABLES */ |
| 144 | private final Controller controller = new Controller(); |
| 145 | private XranConfig xranConfig; |
| 146 | private ApplicationId appId; |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 147 | private int northboundTimeout; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 148 | /* Services */ |
| 149 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 150 | private DeviceService deviceService; |
| 151 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 152 | private HostService hostService; |
| 153 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 154 | private NetworkConfigRegistry registry; |
| 155 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 156 | private NetworkConfigService configService; |
| 157 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 158 | private CoreService coreService; |
| 159 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 160 | private XranStore xranStore; |
| 161 | private ConfigFactory<ApplicationId, XranConfig> xranConfigFactory = |
| 162 | new ConfigFactory<ApplicationId, XranConfig>( |
| 163 | SubjectFactories.APP_SUBJECT_FACTORY, CONFIG_CLASS, "xran") { |
| 164 | @Override |
| 165 | public XranConfig createConfig() { |
| 166 | return new XranConfig(); |
| 167 | } |
| 168 | }; |
| 169 | /* WRAPPERS */ |
| 170 | private CellMap cellMap; |
| 171 | private UeMap ueMap; |
| 172 | private LinkMap linkMap; |
| 173 | /* MAPS */ |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 174 | private ConcurrentMap<IpAddress, ECGI> legitCells = new ConcurrentHashMap<>(); |
slowr | c86750e | 2017-08-22 17:26:47 -0700 | [diff] [blame] | 175 | private ConcurrentMap<ECGI, SynchronousQueue<String>> hoMap = new ConcurrentHashMap<>(); |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 176 | private ConcurrentMap<ECGI, SynchronousQueue<String>> rrmcellMap = new ConcurrentHashMap<>(); |
slowr | c86750e | 2017-08-22 17:26:47 -0700 | [diff] [blame] | 177 | private ConcurrentMap<CRNTI, SynchronousQueue<String>> scellAddMap = new ConcurrentHashMap<>(); |
slowr | ab685ef | 2017-08-31 17:17:35 -0700 | [diff] [blame] | 178 | // Map used to keep messages in pairs (HO Complete - CTX Update, Adm Status - CTX Update) |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 179 | private ConcurrentMap<EcgiCrntiPair, ContextUpdateHandler> contextUpdateMap = new ConcurrentHashMap<>(); |
slowr | c86750e | 2017-08-22 17:26:47 -0700 | [diff] [blame] | 180 | /* QUEUE */ |
| 181 | private BlockingQueue<Long> ueIdQueue = new LinkedBlockingQueue<>(); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 182 | /* AGENTS */ |
| 183 | private InternalXranDeviceAgent deviceAgent = new InternalXranDeviceAgent(); |
| 184 | private InternalXranHostAgent hostAgent = new InternalXranHostAgent(); |
| 185 | private InternalXranPacketAgent packetAgent = new InternalXranPacketAgent(); |
| 186 | /* LISTENERS */ |
| 187 | private Set<XranDeviceListener> xranDeviceListeners = new CopyOnWriteArraySet<>(); |
| 188 | private Set<XranHostListener> xranHostListeners = new CopyOnWriteArraySet<>(); |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 189 | private InternalDeviceListener deviceListener = new InternalDeviceListener(); |
| 190 | private InternalHostListener hostListener = new InternalHostListener(); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 191 | |
| 192 | @Activate |
| 193 | public void activate() { |
| 194 | appId = coreService.registerApplication(XRAN_APP_ID); |
| 195 | |
| 196 | configService.addListener(configListener); |
| 197 | registry.registerConfigFactory(xranConfigFactory); |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 198 | deviceService.addListener(deviceListener); |
| 199 | hostService.addListener(hostListener); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 200 | |
| 201 | cellMap = new CellMap(xranStore); |
| 202 | ueMap = new UeMap(xranStore); |
slowr | d337c93 | 2017-08-18 13:54:02 -0700 | [diff] [blame] | 203 | linkMap = new LinkMap(xranStore, ueMap); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 204 | |
| 205 | xranStore.setController(this); |
| 206 | |
| 207 | log.info("XRAN Controller Started"); |
| 208 | } |
| 209 | |
| 210 | @Deactivate |
| 211 | public void deactivate() { |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 212 | deviceService.removeListener(deviceListener); |
| 213 | hostService.removeListener(hostListener); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 214 | configService.removeListener(configListener); |
| 215 | registry.unregisterConfigFactory(xranConfigFactory); |
| 216 | |
slowr | 23a93e1 | 2017-09-01 13:26:18 -0700 | [diff] [blame^] | 217 | cleanup(); |
| 218 | |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 219 | log.info("XRAN Controller Stopped"); |
| 220 | } |
| 221 | |
slowr | 23a93e1 | 2017-09-01 13:26:18 -0700 | [diff] [blame^] | 222 | private void cleanup() { |
| 223 | xranStore.getuenodes().forEach(ue -> { |
| 224 | for (XranHostListener l : xranHostListeners) { |
| 225 | l.hostRemoved(((RnibUe) ue).getHostId()); |
| 226 | } |
| 227 | }); |
| 228 | |
| 229 | xranStore.getcellnodes().forEach(cell -> { |
| 230 | for (XranDeviceListener l : xranDeviceListeners) { |
| 231 | l.deviceRemoved(deviceId(uri(((RnibCell) cell).getEcgi()))); |
| 232 | } |
| 233 | }); |
| 234 | |
| 235 | controller.stop(); |
| 236 | |
| 237 | legitCells.clear(); |
| 238 | hoMap.clear(); |
| 239 | rrmcellMap.clear(); |
| 240 | scellAddMap.clear(); |
| 241 | contextUpdateMap.clear(); |
| 242 | ueIdQueue.clear(); |
| 243 | xranDeviceListeners.clear(); |
| 244 | xranHostListeners.clear(); |
| 245 | |
| 246 | cellMap = null; |
| 247 | ueMap = null; |
| 248 | linkMap = null; |
| 249 | } |
| 250 | |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 251 | @Override |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 252 | public SynchronousQueue<String> sendHORequest(RnibLink linkT, RnibLink linkS) throws InterruptedException { |
| 253 | ECGI ecgiT = linkT.getLinkId().getEcgi(), |
| 254 | ecgiS = linkS.getLinkId().getEcgi(); |
slowr | 73b4eae | 2017-08-17 16:09:09 -0700 | [diff] [blame] | 255 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 256 | CRNTI crnti = linkMap.getCrnti(linkT.getLinkId().getUeId()); |
| 257 | ChannelHandlerContext ctxT = cellMap.getCtx(ecgiT), |
| 258 | ctxS = cellMap.getCtx(ecgiS); |
slowr | c86750e | 2017-08-22 17:26:47 -0700 | [diff] [blame] | 259 | |
| 260 | SynchronousQueue<String> queue = new SynchronousQueue<>(); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 261 | try { |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 262 | XrancPdu xrancPdu = HORequest.constructPacket(crnti, ecgiS, ecgiT); |
slowr | c86750e | 2017-08-22 17:26:47 -0700 | [diff] [blame] | 263 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 264 | // temporary map that has ECGI source of a handoff to a queue waiting for REST response. |
| 265 | hoMap.put(ecgiS, queue); |
slowr | c86750e | 2017-08-22 17:26:47 -0700 | [diff] [blame] | 266 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 267 | ctxT.writeAndFlush(getSctpMessage(xrancPdu)); |
| 268 | ctxS.writeAndFlush(getSctpMessage(xrancPdu)); |
| 269 | |
| 270 | // FIXME: only works for one HO at a time. |
| 271 | ueIdQueue.put(linkT.getLinkId().getUeId()); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 272 | } catch (IOException e) { |
| 273 | e.printStackTrace(); |
| 274 | } |
| 275 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 276 | return queue; |
| 277 | } |
| 278 | |
| 279 | @Override |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 280 | public void addListener(XranDeviceListener listener) { |
| 281 | xranDeviceListeners.add(listener); |
| 282 | } |
| 283 | |
| 284 | @Override |
| 285 | public void addListener(XranHostListener listener) { |
| 286 | xranHostListeners.add(listener); |
| 287 | } |
| 288 | |
| 289 | @Override |
| 290 | public void removeListener(XranDeviceListener listener) { |
| 291 | xranDeviceListeners.remove(listener); |
| 292 | } |
| 293 | |
| 294 | @Override |
| 295 | public void removeListener(XranHostListener listener) { |
| 296 | xranHostListeners.remove(listener); |
| 297 | } |
| 298 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 299 | @Override |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 300 | public int getNorthboundTimeout() { |
| 301 | return northboundTimeout; |
slowr | c86750e | 2017-08-22 17:26:47 -0700 | [diff] [blame] | 302 | } |
| 303 | |
| 304 | @Override |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 305 | public SynchronousQueue<String> sendmodifiedrrmconf(RRMConfig rrmConfig, boolean xicic) { |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 306 | ECGI ecgi = rrmConfig.getEcgi(); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 307 | ChannelHandlerContext ctx = cellMap.getCtx(ecgi); |
| 308 | try { |
slowr | c86750e | 2017-08-22 17:26:47 -0700 | [diff] [blame] | 309 | XrancPdu pdu; |
slowr | 73b4eae | 2017-08-17 16:09:09 -0700 | [diff] [blame] | 310 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 311 | if (xicic) { |
slowr | 73b4eae | 2017-08-17 16:09:09 -0700 | [diff] [blame] | 312 | CellConfigReport cellConfigReport = cellMap.get(ecgi).getConf(); |
| 313 | if (cellConfigReport != null) { |
| 314 | pdu = XICICConfig.constructPacket(rrmConfig, cellConfigReport); |
| 315 | ctx.writeAndFlush(getSctpMessage(pdu)); |
| 316 | } |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 317 | } else { |
| 318 | pdu = RRMConfig.constructPacket(rrmConfig); |
slowr | 73b4eae | 2017-08-17 16:09:09 -0700 | [diff] [blame] | 319 | ctx.writeAndFlush(getSctpMessage(pdu)); |
| 320 | SynchronousQueue<String> queue = new SynchronousQueue<>(); |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 321 | rrmcellMap.put(ecgi, queue); |
slowr | 73b4eae | 2017-08-17 16:09:09 -0700 | [diff] [blame] | 322 | return queue; |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 323 | } |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 324 | } catch (IOException e) { |
| 325 | e.printStackTrace(); |
| 326 | } |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 327 | |
slowr | 73b4eae | 2017-08-17 16:09:09 -0700 | [diff] [blame] | 328 | return null; |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 329 | } |
| 330 | |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 331 | @Override |
| 332 | public SynchronousQueue<String> sendScellAdd(RnibLink link) { |
| 333 | RnibCell secondaryCell = link.getLinkId().getCell(), |
| 334 | primaryCell = linkMap.getPrimaryCell(link.getLinkId().getUe()); |
| 335 | ECGI primaryEcgi = primaryCell.getEcgi(); |
| 336 | ChannelHandlerContext ctx = cellMap.getCtx(primaryEcgi); |
| 337 | |
slowr | c86750e | 2017-08-22 17:26:47 -0700 | [diff] [blame] | 338 | CRNTI crnti = linkMap.getCrnti(link.getLinkId().getUeId()); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 339 | |
| 340 | CellConfigReport cellReport = secondaryCell.getConf(); |
| 341 | |
| 342 | if (cellReport != null) { |
| 343 | PCIARFCN pciarfcn = new PCIARFCN(); |
| 344 | pciarfcn.setPci(cellReport.getPci()); |
| 345 | pciarfcn.setEarfcnDl(cellReport.getEarfcnDl()); |
| 346 | |
| 347 | PropScell propScell = new PropScell(); |
| 348 | propScell.setPciArfcn(pciarfcn); |
| 349 | |
| 350 | XrancPdu pdu = ScellAdd.constructPacket(primaryEcgi, crnti, propScell); |
| 351 | try { |
| 352 | ctx.writeAndFlush(getSctpMessage(pdu)); |
| 353 | SynchronousQueue<String> queue = new SynchronousQueue<>(); |
slowr | c86750e | 2017-08-22 17:26:47 -0700 | [diff] [blame] | 354 | scellAddMap.put(crnti, queue); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 355 | |
| 356 | return queue; |
| 357 | } catch (IOException e) { |
| 358 | log.error(ExceptionUtils.getFullStackTrace(e)); |
| 359 | e.printStackTrace(); |
| 360 | } |
| 361 | } |
| 362 | return null; |
| 363 | } |
| 364 | |
| 365 | @Override |
| 366 | public boolean sendScellDelete(RnibLink link) { |
| 367 | RnibCell secondaryCell = link.getLinkId().getCell(), |
| 368 | primaryCell = linkMap.getPrimaryCell(link.getLinkId().getUe()); |
| 369 | ECGI primaryEcgi = primaryCell.getEcgi(); |
| 370 | ChannelHandlerContext ctx = cellMap.getCtx(primaryEcgi); |
| 371 | |
slowr | c86750e | 2017-08-22 17:26:47 -0700 | [diff] [blame] | 372 | CRNTI crnti = linkMap.getCrnti(link.getLinkId().getUeId()); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 373 | |
| 374 | CellConfigReport cellReport = secondaryCell.getConf(); |
| 375 | |
| 376 | if (cellReport != null) { |
| 377 | PCIARFCN pciarfcn = new PCIARFCN(); |
| 378 | pciarfcn.setPci(cellReport.getPci()); |
| 379 | pciarfcn.setEarfcnDl(cellReport.getEarfcnDl()); |
| 380 | |
| 381 | XrancPdu pdu = ScellDelete.constructPacket(primaryEcgi, crnti, pciarfcn); |
| 382 | |
| 383 | try { |
| 384 | ctx.writeAndFlush(getSctpMessage(pdu)); |
| 385 | link.setType(RnibLink.Type.NON_SERVING); |
| 386 | return true; |
| 387 | } catch (IOException e) { |
| 388 | log.error(ExceptionUtils.getFullStackTrace(e)); |
| 389 | e.printStackTrace(); |
| 390 | } |
| 391 | } |
| 392 | return false; |
| 393 | } |
| 394 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 395 | /** |
| 396 | * Timer to delete UE after being IDLE. |
| 397 | * |
| 398 | * @param ue UE entity |
| 399 | */ |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 400 | private void restartTimer(RnibUe ue) { |
| 401 | Timer timer = new Timer(); |
| 402 | ue.setTimer(timer); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 403 | timer.schedule(new TimerTask() { |
| 404 | @Override |
| 405 | public void run() { |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 406 | if (ue.getState() == RnibUe.State.IDLE) { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 407 | hostAgent.removeConnectedHost(ue); |
slowr | c86750e | 2017-08-22 17:26:47 -0700 | [diff] [blame] | 408 | log.info("UE is removed after {} ms of IDLE", xranConfig.getIdleUeRemoval()); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 409 | } else { |
| 410 | log.info("UE not removed cause its ACTIVE"); |
| 411 | } |
| 412 | } |
slowr | d337c93 | 2017-08-18 13:54:02 -0700 | [diff] [blame] | 413 | }, xranConfig.getIdleUeRemoval()); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 414 | } |
| 415 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 416 | /** |
| 417 | * Timer to delete LINK after not receiving measurements. |
| 418 | * |
| 419 | * @param link LINK entity |
| 420 | */ |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 421 | private void restartTimer(RnibLink link) { |
| 422 | Timer timer = new Timer(); |
| 423 | link.setTimer(timer); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 424 | timer.schedule(new TimerTask() { |
| 425 | @Override |
| 426 | public void run() { |
| 427 | LinkId linkId = link.getLinkId(); |
| 428 | xranStore.removeLink(linkId); |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 429 | log.info("Link is removed after not receiving Meas Reports for {} ms", |
| 430 | xranConfig.getNoMeasLinkRemoval()); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 431 | } |
slowr | d337c93 | 2017-08-18 13:54:02 -0700 | [diff] [blame] | 432 | }, xranConfig.getNoMeasLinkRemoval()); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 433 | |
| 434 | } |
| 435 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 436 | /** |
| 437 | * Request measurement configuration field of specified UE. |
| 438 | * |
| 439 | * @param primary primary CELL |
| 440 | * @param ue UE entity |
| 441 | */ |
| 442 | private void populateMeasConfig(RnibCell primary, RnibUe ue) { |
| 443 | try { |
| 444 | ChannelHandlerContext ctx = cellMap.getCtx(primary.getEcgi()); |
| 445 | RXSigMeasConfig.MeasCells measCells = new RXSigMeasConfig.MeasCells(); |
| 446 | xranStore.getcellnodes().forEach(cell -> { |
| 447 | CellConfigReport cellReport = ((RnibCell) cell).getConf(); |
| 448 | if (cellReport != null) { |
| 449 | PCIARFCN pciarfcn = new PCIARFCN(); |
| 450 | pciarfcn.setPci(cellReport.getPci()); |
| 451 | pciarfcn.setEarfcnDl(cellReport.getEarfcnDl()); |
| 452 | measCells.setPCIARFCN(pciarfcn); |
| 453 | } |
| 454 | }); |
| 455 | XrancPdu xrancPdu = RXSigMeasConfig.constructPacket( |
| 456 | primary.getEcgi(), |
| 457 | ue.getCrnti(), |
| 458 | measCells, |
| 459 | xranConfig.getRxSignalInterval() |
| 460 | ); |
| 461 | ue.setMeasConfig(xrancPdu.getBody().getRXSigMeasConfig()); |
| 462 | ctx.writeAndFlush(getSctpMessage(xrancPdu)); |
| 463 | } catch (IOException e) { |
| 464 | log.warn(ExceptionUtils.getFullStackTrace(e)); |
| 465 | e.printStackTrace(); |
| 466 | } |
| 467 | } |
| 468 | |
| 469 | /** |
| 470 | * Internal device listener. |
| 471 | */ |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 472 | class InternalDeviceListener implements DeviceListener { |
| 473 | |
| 474 | @Override |
| 475 | public void event(DeviceEvent event) { |
| 476 | log.info("Device Event {}", event); |
| 477 | switch (event.type()) { |
| 478 | case DEVICE_ADDED: { |
| 479 | try { |
| 480 | ECGI ecgi = decodeDeviceId(event.subject().id()); |
| 481 | RnibCell cell = cellMap.get(ecgi); |
| 482 | if (cell != null) { |
| 483 | Timer timer = new Timer(); |
| 484 | timer.scheduleAtFixedRate( |
| 485 | new TimerTask() { |
| 486 | @Override |
| 487 | public void run() { |
| 488 | CellConfigReport conf = cell.getConf(); |
| 489 | if (conf == null) { |
| 490 | try { |
| 491 | ChannelHandlerContext ctx = cellMap.getCtx(ecgi); |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 492 | XrancPdu xrancPdu = CellConfigRequest.constructPacket(ecgi); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 493 | ctx.writeAndFlush(getSctpMessage(xrancPdu)); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 494 | } catch (IOException e) { |
| 495 | log.error(ExceptionUtils.getFullStackTrace(e)); |
| 496 | e.printStackTrace(); |
| 497 | } |
| 498 | } else { |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 499 | List<Object> ueNodes = xranStore.getuenodes(); |
slowr | d337c93 | 2017-08-18 13:54:02 -0700 | [diff] [blame] | 500 | ueNodes.forEach(object -> { |
| 501 | RnibUe ue = (RnibUe) object; |
| 502 | try { |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 503 | ECGI primaryEcgi = linkMap.getPrimaryCell(ue).getEcgi(); |
| 504 | ChannelHandlerContext ctx = cellMap.getCtx(primaryEcgi); |
| 505 | RXSigMeasConfig.MeasCells measCells = |
| 506 | new RXSigMeasConfig.MeasCells(); |
| 507 | xranStore.getcellnodes().forEach(cell -> { |
slowr | d337c93 | 2017-08-18 13:54:02 -0700 | [diff] [blame] | 508 | CellConfigReport cellReport = ((RnibCell) cell).getConf(); |
| 509 | if (cellReport != null) { |
| 510 | PCIARFCN pciarfcn = new PCIARFCN(); |
| 511 | pciarfcn.setPci(cellReport.getPci()); |
| 512 | pciarfcn.setEarfcnDl(cellReport.getEarfcnDl()); |
| 513 | measCells.setPCIARFCN(pciarfcn); |
| 514 | } |
| 515 | }); |
| 516 | XrancPdu xrancPdu = RXSigMeasConfig.constructPacket( |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 517 | primaryEcgi, |
slowr | c86750e | 2017-08-22 17:26:47 -0700 | [diff] [blame] | 518 | ue.getCrnti(), |
slowr | d337c93 | 2017-08-18 13:54:02 -0700 | [diff] [blame] | 519 | measCells, |
| 520 | xranConfig.getRxSignalInterval() |
| 521 | ); |
| 522 | ue.setMeasConfig(xrancPdu.getBody().getRXSigMeasConfig()); |
| 523 | ctx.writeAndFlush(getSctpMessage(xrancPdu)); |
| 524 | } catch (IOException e) { |
| 525 | log.warn(ExceptionUtils.getFullStackTrace(e)); |
| 526 | e.printStackTrace(); |
| 527 | } |
| 528 | }); |
| 529 | |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 530 | try { |
slowr | d337c93 | 2017-08-18 13:54:02 -0700 | [diff] [blame] | 531 | ChannelHandlerContext ctx = cellMap.getCtx(ecgi); |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 532 | XrancPdu xrancPdu = L2MeasConfig |
| 533 | .constructPacket(ecgi, xranConfig.getL2MeasInterval()); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 534 | cell.setMeasConfig(xrancPdu.getBody().getL2MeasConfig()); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 535 | SctpMessage sctpMessage = getSctpMessage(xrancPdu); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 536 | ctx.writeAndFlush(sctpMessage); |
| 537 | } catch (IOException e) { |
| 538 | log.error(ExceptionUtils.getFullStackTrace(e)); |
| 539 | e.printStackTrace(); |
| 540 | } |
| 541 | timer.cancel(); |
| 542 | timer.purge(); |
| 543 | } |
| 544 | } |
| 545 | }, |
| 546 | 0, |
| 547 | xranConfig.getConfigRequestInterval() * 1000 |
| 548 | ); |
| 549 | } |
| 550 | } catch (IOException e) { |
| 551 | log.error(ExceptionUtils.getFullStackTrace(e)); |
| 552 | e.printStackTrace(); |
| 553 | } |
| 554 | break; |
| 555 | } |
| 556 | default: { |
| 557 | break; |
| 558 | } |
| 559 | } |
| 560 | } |
| 561 | } |
| 562 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 563 | /** |
| 564 | * Internal host listener. |
| 565 | */ |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 566 | class InternalHostListener implements HostListener { |
| 567 | |
| 568 | @Override |
| 569 | public void event(HostEvent event) { |
| 570 | log.info("Host Event {}", event); |
| 571 | switch (event.type()) { |
| 572 | case HOST_ADDED: |
| 573 | case HOST_MOVED: { |
slowr | c86750e | 2017-08-22 17:26:47 -0700 | [diff] [blame] | 574 | RnibUe ue = ueMap.get(hostIdtoUEId(event.subject().id())); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 575 | if (ue != null) { |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 576 | ECGI ecgiPrimary = linkMap.getPrimaryCell(ue).getEcgi(); |
| 577 | RnibCell primary = cellMap.get(ecgiPrimary); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 578 | ue.setMeasConfig(null); |
| 579 | if (primary != null) { |
| 580 | Timer timer = new Timer(); |
| 581 | timer.scheduleAtFixedRate( |
| 582 | new TimerTask() { |
| 583 | @Override |
| 584 | public void run() { |
slowr | ed74ec7 | 2017-08-17 11:25:01 -0700 | [diff] [blame] | 585 | if (ue.getCapability() == null && primary.getVersion() >= 3) { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 586 | try { |
| 587 | ChannelHandlerContext ctx = cellMap.getCtx(primary.getEcgi()); |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 588 | XrancPdu xrancPdu = UECapabilityEnquiry.constructPacket( |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 589 | primary.getEcgi(), |
slowr | c86750e | 2017-08-22 17:26:47 -0700 | [diff] [blame] | 590 | ue.getCrnti()); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 591 | ctx.writeAndFlush(getSctpMessage(xrancPdu)); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 592 | } catch (IOException e) { |
| 593 | log.warn(ExceptionUtils.getFullStackTrace(e)); |
| 594 | e.printStackTrace(); |
| 595 | } |
| 596 | } else { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 597 | timer.cancel(); |
| 598 | timer.purge(); |
| 599 | } |
| 600 | } |
| 601 | }, |
| 602 | 0, |
| 603 | xranConfig.getConfigRequestInterval() * 1000 |
| 604 | ); |
slowr | ed74ec7 | 2017-08-17 11:25:01 -0700 | [diff] [blame] | 605 | if (ue.getMeasConfig() == null) { |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 606 | populateMeasConfig(primary, ue); |
slowr | ed74ec7 | 2017-08-17 11:25:01 -0700 | [diff] [blame] | 607 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 608 | } |
| 609 | } |
| 610 | break; |
| 611 | } |
| 612 | default: { |
| 613 | break; |
| 614 | } |
| 615 | } |
| 616 | } |
| 617 | } |
| 618 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 619 | /** |
| 620 | * Internal xran device agent. |
| 621 | */ |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 622 | public class InternalXranDeviceAgent implements XranDeviceAgent { |
| 623 | |
| 624 | private final Logger log = LoggerFactory.getLogger(InternalXranDeviceAgent.class); |
| 625 | |
| 626 | @Override |
| 627 | public boolean addConnectedCell(String host, ChannelHandlerContext ctx) { |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 628 | ECGI ecgi = legitCells.get(IpAddress.valueOf(host)); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 629 | |
| 630 | if (ecgi == null) { |
| 631 | log.error("Device is not a legit source; ignoring..."); |
| 632 | } else { |
| 633 | log.info("Device exists in configuration; registering..."); |
| 634 | RnibCell storeCell = cellMap.get(ecgi); |
| 635 | if (storeCell == null) { |
| 636 | storeCell = new RnibCell(); |
| 637 | storeCell.setEcgi(ecgi); |
| 638 | cellMap.put(storeCell, ctx); |
| 639 | |
| 640 | for (XranDeviceListener l : xranDeviceListeners) { |
| 641 | l.deviceAdded(storeCell); |
| 642 | } |
| 643 | return true; |
| 644 | } else { |
| 645 | log.error("Device already registered; ignoring..."); |
| 646 | } |
| 647 | } |
| 648 | ctx.close(); |
| 649 | return false; |
| 650 | } |
| 651 | |
| 652 | @Override |
| 653 | public boolean removeConnectedCell(String host) { |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 654 | ECGI ecgi = legitCells.get(IpAddress.valueOf(host)); |
| 655 | List<RnibLink> linksbyecgi = xranStore.getlinksbyecgi(ecgi); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 656 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 657 | linksbyecgi.forEach(rnibLink -> xranStore.removeLink(rnibLink.getLinkId())); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 658 | |
| 659 | if (cellMap.remove(ecgi)) { |
| 660 | for (XranDeviceListener l : xranDeviceListeners) { |
| 661 | l.deviceRemoved(deviceId(uri(ecgi))); |
| 662 | } |
| 663 | return true; |
| 664 | } |
| 665 | return false; |
| 666 | } |
| 667 | } |
| 668 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 669 | /** |
| 670 | * Internal xran host agent. |
| 671 | */ |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 672 | public class InternalXranHostAgent implements XranHostAgent { |
| 673 | |
| 674 | @Override |
| 675 | public boolean addConnectedHost(RnibUe ue, RnibCell cell, ChannelHandlerContext ctx) { |
| 676 | |
slowr | c86750e | 2017-08-22 17:26:47 -0700 | [diff] [blame] | 677 | if (ue.getId() != null && ueMap.get(ue.getId()) != null) { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 678 | linkMap.putPrimaryLink(cell, ue); |
| 679 | |
slowr | c86750e | 2017-08-22 17:26:47 -0700 | [diff] [blame] | 680 | Set<ECGI> ecgiSet = Sets.newConcurrentHashSet(); |
| 681 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 682 | xranStore.getlinksbyueid(ue.getId()) |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 683 | .stream() |
slowr | c86750e | 2017-08-22 17:26:47 -0700 | [diff] [blame] | 684 | .filter(l -> l.getType().equals(RnibLink.Type.SERVING_PRIMARY)) |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 685 | .findFirst() |
| 686 | .ifPresent(l -> ecgiSet.add(l.getLinkId().getEcgi())); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 687 | |
| 688 | for (XranHostListener l : xranHostListeners) { |
| 689 | l.hostAdded(ue, ecgiSet); |
| 690 | } |
| 691 | return true; |
| 692 | } else { |
slowr | d337c93 | 2017-08-18 13:54:02 -0700 | [diff] [blame] | 693 | ueMap.put(cell, ue); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 694 | linkMap.putPrimaryLink(cell, ue); |
| 695 | |
| 696 | Set<ECGI> ecgiSet = Sets.newConcurrentHashSet(); |
| 697 | ecgiSet.add(cell.getEcgi()); |
| 698 | for (XranHostListener l : xranHostListeners) { |
| 699 | l.hostAdded(ue, ecgiSet); |
| 700 | } |
| 701 | return true; |
| 702 | } |
| 703 | |
| 704 | } |
| 705 | |
| 706 | @Override |
| 707 | public boolean removeConnectedHost(RnibUe ue) { |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 708 | List<RnibLink> links = xranStore.getlinksbyueid(ue.getId()); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 709 | links.forEach(rnibLink -> xranStore.removeLink(rnibLink.getLinkId())); |
slowr | c86750e | 2017-08-22 17:26:47 -0700 | [diff] [blame] | 710 | if (ueMap.remove(ue.getId())) { |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 711 | for (XranHostListener l : xranHostListeners) { |
| 712 | l.hostRemoved(ue.getHostId()); |
| 713 | } |
| 714 | return true; |
| 715 | } |
| 716 | return false; |
| 717 | } |
| 718 | } |
| 719 | |
| 720 | public class InternalXranPacketAgent implements XranPacketProcessor { |
| 721 | @Override |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 722 | public void handlePacket(XrancPdu recvPdu, ChannelHandlerContext ctx) |
| 723 | throws IOException, InterruptedException { |
| 724 | XrancPdu sendPdu; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 725 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 726 | int apiID = recvPdu.getHdr().getApiId().intValue(); |
| 727 | log.debug("Received message: {}", recvPdu); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 728 | switch (apiID) { |
| 729 | case 1: { |
| 730 | // Decode Cell config report. |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 731 | CellConfigReport report = recvPdu.getBody().getCellConfigReport(); |
| 732 | handleCellconfigreport(report, recvPdu.getHdr().getVer().toString()); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 733 | break; |
| 734 | } |
| 735 | case 2: { |
| 736 | // Decode UE Admission Request. |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 737 | UEAdmissionRequest ueAdmissionRequest = recvPdu.getBody().getUEAdmissionRequest(); |
| 738 | handleUeadmissionrequest(ueAdmissionRequest, ctx); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 739 | break; |
| 740 | } |
| 741 | case 4: { |
| 742 | // Decode UE Admission Status. |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 743 | UEAdmissionStatus ueAdmissionStatus = recvPdu.getBody().getUEAdmissionStatus(); |
| 744 | handleAdmissionstatus(ueAdmissionStatus, ctx); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 745 | break; |
| 746 | } |
| 747 | case 5: { |
slowr | c86750e | 2017-08-22 17:26:47 -0700 | [diff] [blame] | 748 | // Decode UE Context Update. |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 749 | UEContextUpdate ueContextUpdate = recvPdu.getBody().getUEContextUpdate(); |
| 750 | handleUecontextupdate(ueContextUpdate, ctx); |
slowr | 73b4eae | 2017-08-17 16:09:09 -0700 | [diff] [blame] | 751 | |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 752 | break; |
| 753 | } |
| 754 | case 6: { |
| 755 | // Decode UE Reconfig_Ind. |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 756 | UEReconfigInd ueReconfigInd = recvPdu.getBody().getUEReconfigInd(); |
| 757 | handleUereconfigind(ueReconfigInd); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 758 | break; |
| 759 | } |
| 760 | case 7: { |
| 761 | // If xRANc wants to deactivate UE, we pass UEReleaseInd from xRANc to eNB. |
| 762 | // Decode UE Release_Ind. |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 763 | UEReleaseInd ueReleaseInd = recvPdu.getBody().getUEReleaseInd(); |
| 764 | handleUereleaseind(ueReleaseInd); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 765 | break; |
| 766 | } |
| 767 | case 8: { |
| 768 | // Decode Bearer Adm Request |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 769 | BearerAdmissionRequest bearerAdmissionRequest = recvPdu.getBody().getBearerAdmissionRequest(); |
| 770 | handleBeareradmissionrequest(bearerAdmissionRequest, ctx); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 771 | break; |
| 772 | } |
| 773 | case 10: { |
| 774 | //Decode Bearer Admission Status |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 775 | BearerAdmissionStatus bearerAdmissionStatus = recvPdu.getBody().getBearerAdmissionStatus(); |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 776 | break; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 777 | } |
| 778 | case 11: { |
| 779 | //Decode Bearer Release Ind |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 780 | BearerReleaseInd bearerReleaseInd = recvPdu.getBody().getBearerReleaseInd(); |
| 781 | handleBearerreleaseind(bearerReleaseInd); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 782 | break; |
| 783 | } |
| 784 | case 13: { |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 785 | HOFailure hoFailure = recvPdu.getBody().getHOFailure(); |
| 786 | handleHofailure(hoFailure); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 787 | break; |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 788 | |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 789 | } |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 790 | case 14: { |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 791 | HOComplete hoComplete = recvPdu.getBody().getHOComplete(); |
| 792 | handleHocomplete(hoComplete, ctx); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 793 | break; |
| 794 | } |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 795 | |
| 796 | case 16: { |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 797 | // Decode Rx Sig Meas Report. |
| 798 | RXSigMeasReport rxSigMeasReport = recvPdu.getBody().getRXSigMeasReport(); |
| 799 | handleRxsigmeasreport(rxSigMeasReport); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 800 | break; |
| 801 | } |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 802 | case 18: { |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 803 | RadioMeasReportPerUE radioMeasReportPerUE = recvPdu.getBody().getRadioMeasReportPerUE(); |
| 804 | handleRadionmeasreportperue(radioMeasReportPerUE); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 805 | break; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 806 | } |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 807 | case 19: { |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 808 | RadioMeasReportPerCell radioMeasReportPerCell = recvPdu.getBody().getRadioMeasReportPerCell(); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 809 | break; |
| 810 | } |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 811 | case 20: { |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 812 | SchedMeasReportPerUE schedMeasReportPerUE = recvPdu.getBody().getSchedMeasReportPerUE(); |
| 813 | handleSchedmeasreportperue(schedMeasReportPerUE); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 814 | break; |
| 815 | } |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 816 | case 21: { |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 817 | SchedMeasReportPerCell schedMeasReportPerCell = recvPdu.getBody().getSchedMeasReportPerCell(); |
| 818 | handleSchedmeasreportpercell(schedMeasReportPerCell); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 819 | break; |
| 820 | } |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 821 | case 22: { |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 822 | PDCPMeasReportPerUe pdcpMeasReportPerUe = recvPdu.getBody().getPDCPMeasReportPerUe(); |
| 823 | handlePdcpmeasreportperue(pdcpMeasReportPerUe); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 824 | break; |
| 825 | } |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 826 | case 24: { |
| 827 | // Decode UE Capability Info |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 828 | UECapabilityInfo capabilityInfo = recvPdu.getBody().getUECapabilityInfo(); |
| 829 | handleCapabilityinfo(capabilityInfo); |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 830 | break; |
| 831 | } |
| 832 | case 25: { |
| 833 | // Don't know what will invoke sending UE CAPABILITY ENQUIRY |
| 834 | // Encode and send UE CAPABILITY ENQUIRY |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 835 | UECapabilityEnquiry ueCapabilityEnquiry = recvPdu.getBody().getUECapabilityEnquiry(); |
| 836 | handleUecapabilityenquiry(ueCapabilityEnquiry, ctx); |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 837 | break; |
| 838 | } |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 839 | case 27: { |
| 840 | //Decode ScellAddStatus |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 841 | ScellAddStatus scellAddStatus = recvPdu.getBody().getScellAddStatus(); |
| 842 | handleScelladdstatus(scellAddStatus); |
slowr | 89c2ac1 | 2017-08-15 16:20:06 -0700 | [diff] [blame] | 843 | break; |
| 844 | } |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 845 | case 30: { |
| 846 | // Decode RRMConfig Status |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 847 | RRMConfigStatus rrmConfigStatus = recvPdu.getBody().getRRMConfigStatus(); |
| 848 | handleRrmconfigstatus(rrmConfigStatus); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 849 | break; |
| 850 | } |
slowr | 8ddc2b1 | 2017-08-14 14:13:38 -0700 | [diff] [blame] | 851 | //TODO Case 31: SeNBAdd 32: SeNBAddStatus 33: SeNBDelete |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 852 | case 34: { |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 853 | TrafficSplitConfig trafficSplitConfig = recvPdu.getBody().getTrafficSplitConfig(); |
| 854 | handleTrafficSplitConfig(trafficSplitConfig); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 855 | break; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 856 | } |
| 857 | default: { |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 858 | log.warn("Wrong API ID: {}", recvPdu); |
slowr | 67d05e4 | 2017-08-11 20:37:22 -0700 | [diff] [blame] | 859 | break; |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 860 | } |
| 861 | } |
| 862 | |
| 863 | } |
slowr | c86750e | 2017-08-22 17:26:47 -0700 | [diff] [blame] | 864 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 865 | /** |
| 866 | * Handle Cellconfigreport. |
slowr | 23a93e1 | 2017-09-01 13:26:18 -0700 | [diff] [blame^] | 867 | * |
| 868 | * @param report CellConfigReport |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 869 | * @param version String version ID |
| 870 | */ |
| 871 | private void handleCellconfigreport(CellConfigReport report, String version) { |
| 872 | ECGI ecgi = report.getEcgi(); |
| 873 | |
| 874 | RnibCell cell = xranStore.getCell(ecgi); |
| 875 | cell.setVersion(version); |
| 876 | cell.setConf(report); |
| 877 | cellMap.putPciArfcn(cell); |
| 878 | } |
| 879 | |
| 880 | /** |
| 881 | * Handle Ueadmissionrequest. |
slowr | 23a93e1 | 2017-09-01 13:26:18 -0700 | [diff] [blame^] | 882 | * |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 883 | * @param ueAdmissionRequest UEAdmissionRequest |
slowr | 23a93e1 | 2017-09-01 13:26:18 -0700 | [diff] [blame^] | 884 | * @param ctx ChannelHandlerContext |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 885 | * @throws IOException IO Exception |
| 886 | */ |
| 887 | private void handleUeadmissionrequest(UEAdmissionRequest ueAdmissionRequest, ChannelHandlerContext ctx) |
| 888 | throws IOException { |
| 889 | ECGI ecgi = ueAdmissionRequest.getEcgi(); |
| 890 | if (xranStore.getCell(ecgi) != null) { |
| 891 | CRNTI crnti = ueAdmissionRequest.getCrnti(); |
| 892 | XrancPdu sendPdu = UEAdmissionResponse.constructPacket(ecgi, crnti, xranConfig.admissionFlag()); |
| 893 | ctx.writeAndFlush(getSctpMessage(sendPdu)); |
| 894 | } else { |
| 895 | log.warn("Could not find ECGI in registered cells: {}", ecgi); |
| 896 | } |
| 897 | } |
| 898 | |
| 899 | /** |
| 900 | * Handle UEAdmissionStatus. |
slowr | 23a93e1 | 2017-09-01 13:26:18 -0700 | [diff] [blame^] | 901 | * |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 902 | * @param ueAdmissionStatus UEAdmissionStatus |
slowr | 23a93e1 | 2017-09-01 13:26:18 -0700 | [diff] [blame^] | 903 | * @param ctx ChannelHandlerContext |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 904 | */ |
| 905 | private void handleAdmissionstatus(UEAdmissionStatus ueAdmissionStatus, ChannelHandlerContext ctx) { |
| 906 | RnibUe ue = ueMap.get(ueAdmissionStatus.getEcgi(), ueAdmissionStatus.getCrnti()); |
| 907 | if (ue != null) { |
| 908 | if (ueAdmissionStatus.getAdmEstStatus().value.intValue() == 0) { |
| 909 | ue.setState(RnibUe.State.ACTIVE); |
| 910 | } else { |
| 911 | ue.setState(RnibUe.State.IDLE); |
| 912 | } |
| 913 | } |
| 914 | |
| 915 | if (ueAdmissionStatus.getAdmEstStatus().value.intValue() == 0) { |
| 916 | EcgiCrntiPair ecgiCrntiPair = EcgiCrntiPair |
| 917 | .valueOf(ueAdmissionStatus.getEcgi(), ueAdmissionStatus.getCrnti()); |
| 918 | contextUpdateMap.compute(ecgiCrntiPair, (k, v) -> { |
| 919 | if (v == null) { |
| 920 | v = new ContextUpdateHandler(); |
| 921 | } |
| 922 | if (v.setAdmissionStatus(ueAdmissionStatus)) { |
slowr | ab685ef | 2017-08-31 17:17:35 -0700 | [diff] [blame] | 923 | handlePairedPackets(v.getContextUpdate(), ctx, false); |
| 924 | v.reset(); |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 925 | } |
| 926 | return v; |
| 927 | }); |
| 928 | } |
| 929 | } |
| 930 | |
| 931 | /** |
| 932 | * Handle UEContextUpdate. |
slowr | 23a93e1 | 2017-09-01 13:26:18 -0700 | [diff] [blame^] | 933 | * |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 934 | * @param ueContextUpdate UEContextUpdate |
slowr | 23a93e1 | 2017-09-01 13:26:18 -0700 | [diff] [blame^] | 935 | * @param ctx ChannelHandlerContext |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 936 | */ |
| 937 | private void handleUecontextupdate(UEContextUpdate ueContextUpdate, ChannelHandlerContext ctx) { |
| 938 | EcgiCrntiPair ecgiCrntiPair = EcgiCrntiPair |
| 939 | .valueOf(ueContextUpdate.getEcgi(), ueContextUpdate.getCrnti()); |
| 940 | |
| 941 | contextUpdateMap.compute(ecgiCrntiPair, (k, v) -> { |
| 942 | if (v == null) { |
| 943 | v = new ContextUpdateHandler(); |
| 944 | } |
| 945 | if (v.setContextUpdate(ueContextUpdate)) { |
| 946 | HOComplete hoComplete = v.getHoComplete(); |
slowr | ab685ef | 2017-08-31 17:17:35 -0700 | [diff] [blame] | 947 | handlePairedPackets(ueContextUpdate, ctx, hoComplete != null); |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 948 | if (hoComplete != null) { |
| 949 | try { |
| 950 | hoMap.get(hoComplete.getEcgiS()).put("Hand Over Completed"); |
| 951 | } catch (InterruptedException e) { |
| 952 | log.error(ExceptionUtils.getFullStackTrace(e)); |
| 953 | e.printStackTrace(); |
| 954 | } finally { |
| 955 | hoMap.remove(hoComplete.getEcgiS()); |
| 956 | } |
| 957 | } |
slowr | ab685ef | 2017-08-31 17:17:35 -0700 | [diff] [blame] | 958 | v.reset(); |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 959 | } |
| 960 | return v; |
| 961 | }); |
| 962 | } |
| 963 | |
| 964 | /** |
| 965 | * Handle UEReconfigInd. |
slowr | 23a93e1 | 2017-09-01 13:26:18 -0700 | [diff] [blame^] | 966 | * |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 967 | * @param ueReconfigInd UEReconfigInd |
| 968 | */ |
| 969 | private void handleUereconfigind(UEReconfigInd ueReconfigInd) { |
| 970 | RnibUe ue = ueMap.get(ueReconfigInd.getEcgi(), ueReconfigInd.getCrntiOld()); |
| 971 | RnibCell cell = cellMap.get(ueReconfigInd.getEcgi()); |
| 972 | |
| 973 | if (ue != null && cell != null) { |
| 974 | ue.setCrnti(ueReconfigInd.getCrntiNew()); |
| 975 | ueMap.putCrnti(cell, ue); |
| 976 | } else { |
| 977 | log.warn("Could not find UE with this CRNTI: {}", ueReconfigInd.getCrntiOld()); |
| 978 | } |
| 979 | } |
| 980 | |
| 981 | /** |
| 982 | * Handle UEReleaseInd. |
slowr | 23a93e1 | 2017-09-01 13:26:18 -0700 | [diff] [blame^] | 983 | * |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 984 | * @param ueReleaseInd UEReleaseInd |
| 985 | */ |
| 986 | private void handleUereleaseind(UEReleaseInd ueReleaseInd) { |
| 987 | ECGI ecgi = ueReleaseInd.getEcgi(); |
| 988 | CRNTI crnti = ueReleaseInd.getCrnti(); |
| 989 | RnibUe ue = ueMap.get(ecgi, crnti); |
| 990 | |
| 991 | // Check if there is an ongoing handoff and only remove if ue is not part of the handoff. |
| 992 | Long peek = ueIdQueue.peek(); |
| 993 | if (peek != null) { |
| 994 | EcgiCrntiPair ecgiCrntiPair = ueMap.getCrntUe().inverse().get(peek); |
| 995 | if (ecgiCrntiPair != null && ecgiCrntiPair.equals(EcgiCrntiPair.valueOf(ecgi, crnti))) { |
| 996 | return; |
| 997 | } |
| 998 | } |
| 999 | |
| 1000 | if (ue != null) { |
| 1001 | ue.setState(RnibUe.State.IDLE); |
| 1002 | restartTimer(ue); |
| 1003 | } else { |
| 1004 | log.warn("Cannot release UE from non primary link."); |
| 1005 | } |
| 1006 | } |
| 1007 | |
| 1008 | /** |
| 1009 | * Handle BearerAdmissionRequest. |
slowr | 23a93e1 | 2017-09-01 13:26:18 -0700 | [diff] [blame^] | 1010 | * |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 1011 | * @param bearerAdmissionRequest BearerAdmissionRequest |
slowr | 23a93e1 | 2017-09-01 13:26:18 -0700 | [diff] [blame^] | 1012 | * @param ctx ChannelHandlerContext |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 1013 | * @throws IOException IO Exception |
| 1014 | */ |
| 1015 | private void handleBeareradmissionrequest(BearerAdmissionRequest bearerAdmissionRequest, |
| 1016 | ChannelHandlerContext ctx) throws IOException { |
| 1017 | ECGI ecgi = bearerAdmissionRequest.getEcgi(); |
| 1018 | CRNTI crnti = bearerAdmissionRequest.getCrnti(); |
| 1019 | ERABParams erabParams = bearerAdmissionRequest.getErabParams(); |
| 1020 | RnibLink link = linkMap.get(ecgi, crnti); |
| 1021 | if (link != null) { |
| 1022 | link.setBearerParameters(erabParams); |
| 1023 | } else { |
| 1024 | log.warn("Could not find link between {}-{}", ecgi, crnti); |
| 1025 | } |
| 1026 | |
| 1027 | BerInteger numErabs = bearerAdmissionRequest.getNumErabs(); |
| 1028 | // Encode and send Bearer Admission Response |
| 1029 | XrancPdu sendPdu = BearerAdmissionResponse |
| 1030 | .constructPacket(ecgi, crnti, erabParams, numErabs, xranConfig.bearerFlag()); |
| 1031 | ctx.writeAndFlush(getSctpMessage(sendPdu)); |
| 1032 | } |
| 1033 | |
| 1034 | /** |
| 1035 | * Handle BearerReleaseInd. |
slowr | 23a93e1 | 2017-09-01 13:26:18 -0700 | [diff] [blame^] | 1036 | * |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 1037 | * @param bearerReleaseInd |
| 1038 | */ |
| 1039 | private void handleBearerreleaseind(BearerReleaseInd bearerReleaseInd) { |
| 1040 | ECGI ecgi = bearerReleaseInd.getEcgi(); |
| 1041 | CRNTI crnti = bearerReleaseInd.getCrnti(); |
| 1042 | RnibLink link = linkMap.get(ecgi, crnti); |
| 1043 | |
| 1044 | List<ERABID> erabidsRelease = bearerReleaseInd.getErabIds().getERABID(); |
| 1045 | List<ERABParamsItem> erabParamsItem = link.getBearerParameters().getERABParamsItem(); |
| 1046 | |
| 1047 | List<ERABParamsItem> unreleased = erabParamsItem |
| 1048 | .stream() |
| 1049 | .filter(item -> { |
| 1050 | Optional<ERABID> any = erabidsRelease.stream() |
| 1051 | .filter(id -> id.equals(item.getId())).findAny(); |
| 1052 | return !any.isPresent(); |
| 1053 | }).collect(Collectors.toList()); |
| 1054 | |
| 1055 | link.getBearerParameters().setERABParamsItem(new ArrayList<>(unreleased)); |
| 1056 | } |
| 1057 | |
| 1058 | /** |
| 1059 | * Handle HOFailure. |
slowr | 23a93e1 | 2017-09-01 13:26:18 -0700 | [diff] [blame^] | 1060 | * |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 1061 | * @param hoFailure HOFailure |
| 1062 | * @throws InterruptedException ueIdQueue interruption |
| 1063 | */ |
| 1064 | private void handleHofailure(HOFailure hoFailure) throws InterruptedException { |
| 1065 | try { |
| 1066 | hoMap.get(hoFailure.getEcgi()) |
| 1067 | .put("Hand Over Failed with cause: " + hoFailure.getCause()); |
| 1068 | } catch (InterruptedException e) { |
| 1069 | log.error(ExceptionUtils.getFullStackTrace(e)); |
| 1070 | e.printStackTrace(); |
| 1071 | } finally { |
| 1072 | hoMap.remove(hoFailure.getEcgi()); |
| 1073 | ueIdQueue.take(); |
| 1074 | } |
| 1075 | } |
| 1076 | |
| 1077 | /** |
| 1078 | * Handle HOComplete. |
slowr | 23a93e1 | 2017-09-01 13:26:18 -0700 | [diff] [blame^] | 1079 | * |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 1080 | * @param hoComplete HOComplete |
slowr | 23a93e1 | 2017-09-01 13:26:18 -0700 | [diff] [blame^] | 1081 | * @param ctx ChannelHandlerContext |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 1082 | */ |
| 1083 | private void handleHocomplete(HOComplete hoComplete, ChannelHandlerContext ctx) { |
| 1084 | EcgiCrntiPair ecgiCrntiPair = EcgiCrntiPair.valueOf(hoComplete.getEcgiT(), |
| 1085 | hoComplete.getCrntiNew()); |
| 1086 | contextUpdateMap.compute(ecgiCrntiPair, (k, v) -> { |
| 1087 | if (v == null) { |
| 1088 | v = new ContextUpdateHandler(); |
| 1089 | } |
| 1090 | if (v.setHoComplete(hoComplete)) { |
slowr | ab685ef | 2017-08-31 17:17:35 -0700 | [diff] [blame] | 1091 | handlePairedPackets(v.getContextUpdate(), ctx, true); |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 1092 | |
| 1093 | try { |
| 1094 | hoMap.get(hoComplete.getEcgiS()).put("Hand Over Completed"); |
| 1095 | } catch (InterruptedException e) { |
| 1096 | log.error(ExceptionUtils.getFullStackTrace(e)); |
| 1097 | e.printStackTrace(); |
| 1098 | } finally { |
| 1099 | hoMap.remove(hoComplete.getEcgiS()); |
| 1100 | } |
slowr | ab685ef | 2017-08-31 17:17:35 -0700 | [diff] [blame] | 1101 | v.reset(); |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 1102 | } |
| 1103 | return v; |
| 1104 | }); |
| 1105 | } |
| 1106 | |
| 1107 | /** |
| 1108 | * Handle RXSigMeasReport. |
slowr | 23a93e1 | 2017-09-01 13:26:18 -0700 | [diff] [blame^] | 1109 | * |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 1110 | * @param rxSigMeasReport RXSigMeasReport |
| 1111 | */ |
| 1112 | private void handleRxsigmeasreport(RXSigMeasReport rxSigMeasReport) { |
| 1113 | List<RXSigReport> rxSigReportList = rxSigMeasReport.getCellMeasReports().getRXSigReport(); |
| 1114 | |
| 1115 | RnibUe ue = ueMap.get(rxSigMeasReport.getEcgi(), rxSigMeasReport.getCrnti()); |
| 1116 | if (ue != null) { |
| 1117 | Long ueId = ue.getId(); |
| 1118 | |
| 1119 | if (!rxSigReportList.isEmpty()) { |
| 1120 | rxSigReportList.forEach(rxSigReport -> { |
| 1121 | RnibCell cell = cellMap.get(rxSigReport.getPciArfcn()); |
| 1122 | if (cell != null) { |
| 1123 | ECGI ecgi = cell.getEcgi(); |
| 1124 | |
| 1125 | RnibLink link = linkMap.get(ecgi, ueId); |
| 1126 | if (link == null) { |
| 1127 | log.warn("Could not find link between: {}-{} | Creating non-serving link..", |
| 1128 | ecgi, ueId); |
| 1129 | link = linkMap.putNonServingLink(cell, ueId); |
| 1130 | } |
| 1131 | |
| 1132 | if (link != null) { |
| 1133 | if (link.getType().equals(RnibLink.Type.NON_SERVING)) { |
| 1134 | restartTimer(link); |
| 1135 | } |
| 1136 | |
| 1137 | RSRQRange rsrq = rxSigReport.getRsrq(); |
| 1138 | RSRPRange rsrp = rxSigReport.getRsrp(); |
| 1139 | |
| 1140 | RnibLink.LinkQuality quality = link.getQuality(); |
| 1141 | quality.setRx(new RnibLink.LinkQuality.Rx( |
| 1142 | rsrp.value.intValue() - 140, |
| 1143 | (rsrq.value.intValue() * 0.5) - 19.5 |
| 1144 | )); |
| 1145 | } |
| 1146 | } else { |
| 1147 | log.warn("case 16: Could not find cell with PCI-ARFCN: {}", |
| 1148 | rxSigReport.getPciArfcn()); |
| 1149 | } |
| 1150 | }); |
| 1151 | } |
| 1152 | } |
| 1153 | } |
| 1154 | |
| 1155 | /** |
| 1156 | * Handle RadioMeasReportPerUE. |
slowr | 23a93e1 | 2017-09-01 13:26:18 -0700 | [diff] [blame^] | 1157 | * |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 1158 | * @param radioMeasReportPerUE RadioMeasReportPerUE |
| 1159 | */ |
| 1160 | private void handleRadionmeasreportperue(RadioMeasReportPerUE radioMeasReportPerUE) { |
| 1161 | RnibUe ue = ueMap.get(radioMeasReportPerUE.getEcgi(), radioMeasReportPerUE.getCrnti()); |
| 1162 | if (ue != null) { |
| 1163 | Long ueId = ue.getId(); |
| 1164 | List<RadioRepPerServCell> servCells = radioMeasReportPerUE.getRadioReportServCells() |
| 1165 | .getRadioRepPerServCell(); |
| 1166 | |
| 1167 | servCells.forEach(servCell -> { |
| 1168 | RnibCell cell = cellMap.get(servCell.getPciArfcn()); |
| 1169 | if (cell != null) { |
| 1170 | RnibLink link = linkMap.get(cell.getEcgi(), ueId); |
| 1171 | if (link != null) { |
| 1172 | RadioRepPerServCell.CqiHist cqiHist = servCell.getCqiHist(); |
| 1173 | RnibLink.LinkQuality quality = link.getQuality(); |
| 1174 | |
| 1175 | final double[] values = {0, 0, 0}; |
| 1176 | final int[] i = {1}; |
| 1177 | cqiHist.getBerInteger().forEach(value -> { |
| 1178 | values[0] = Math.max(values[0], value.intValue()); |
| 1179 | values[1] += i[0] * value.intValue(); |
| 1180 | values[2] += value.intValue(); |
| 1181 | i[0]++; |
| 1182 | }); |
| 1183 | |
| 1184 | quality.setCqi(new RnibLink.LinkQuality.Cqi( |
| 1185 | cqiHist, |
| 1186 | values[0], |
| 1187 | values[1] / values[0] |
| 1188 | )); |
| 1189 | |
| 1190 | } else { |
| 1191 | log.warn("Could not find link between: {}-{}", cell.getEcgi(), ueId); |
| 1192 | } |
| 1193 | } else { |
| 1194 | log.warn("case 18: Could not find cell with PCI-ARFCN: {}", servCell.getPciArfcn()); |
| 1195 | } |
| 1196 | }); |
| 1197 | } |
| 1198 | } |
| 1199 | |
| 1200 | /** |
| 1201 | * Handle SchedMeasReportPerUE. |
slowr | 23a93e1 | 2017-09-01 13:26:18 -0700 | [diff] [blame^] | 1202 | * |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 1203 | * @param schedMeasReportPerUE SchedMeasReportPerUE |
| 1204 | */ |
| 1205 | private void handleSchedmeasreportperue(SchedMeasReportPerUE schedMeasReportPerUE) { |
| 1206 | RnibUe ue = ueMap.get(schedMeasReportPerUE.getEcgi(), schedMeasReportPerUE.getCrnti()); |
| 1207 | if (ue != null) { |
| 1208 | Long ueId = ue.getId(); |
| 1209 | |
| 1210 | List<SchedMeasRepPerServCell> servCells = schedMeasReportPerUE.getSchedReportServCells() |
| 1211 | .getSchedMeasRepPerServCell(); |
| 1212 | |
| 1213 | servCells.forEach(servCell -> { |
| 1214 | RnibCell cell = cellMap.get(servCell.getPciArfcn()); |
| 1215 | if (cell != null) { |
| 1216 | RnibLink link = linkMap.get(cell.getEcgi(), ueId); |
| 1217 | if (link != null) { |
| 1218 | link.getQuality().setMcs(new RnibLink.LinkQuality.Mcs( |
| 1219 | servCell.getMcsDl(), |
| 1220 | servCell.getMcsUl() |
| 1221 | )); |
| 1222 | |
| 1223 | link.setResourceUsage(new RnibLink.ResourceUsage( |
| 1224 | servCell.getPrbUsage().getPrbUsageDl(), |
| 1225 | servCell.getPrbUsage().getPrbUsageUl() |
| 1226 | )); |
| 1227 | } else { |
| 1228 | log.warn("Could not find link between: {}-{}", cell.getEcgi(), ueId); |
| 1229 | } |
| 1230 | } else { |
| 1231 | log.warn("case 20: Could not find cell with PCI-ARFCN: {}", servCell.getPciArfcn()); |
| 1232 | } |
| 1233 | }); |
| 1234 | } |
| 1235 | } |
| 1236 | |
| 1237 | /** |
| 1238 | * Handle SchedMeasReportPerCell. |
slowr | 23a93e1 | 2017-09-01 13:26:18 -0700 | [diff] [blame^] | 1239 | * |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 1240 | * @param schedMeasReportPerCell SchedMeasReportPerCell |
| 1241 | */ |
| 1242 | private void handleSchedmeasreportpercell(SchedMeasReportPerCell schedMeasReportPerCell) { |
| 1243 | RnibCell cell = cellMap.get(schedMeasReportPerCell.getEcgi()); |
| 1244 | if (cell != null) { |
| 1245 | cell.setPrbUsage(new RnibCell.PrbUsageContainer( |
| 1246 | schedMeasReportPerCell.getPrbUsagePcell(), |
| 1247 | schedMeasReportPerCell.getPrbUsageScell() |
| 1248 | )); |
| 1249 | |
| 1250 | cell.setQci(schedMeasReportPerCell.getQciVals()); |
| 1251 | } else { |
| 1252 | log.warn("Could not find cell with ECGI: {}", schedMeasReportPerCell.getEcgi()); |
| 1253 | } |
| 1254 | } |
| 1255 | |
| 1256 | /** |
| 1257 | * Handle PDCPMeasReportPerUe. |
slowr | 23a93e1 | 2017-09-01 13:26:18 -0700 | [diff] [blame^] | 1258 | * |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 1259 | * @param pdcpMeasReportPerUe PDCPMeasReportPerUe |
| 1260 | */ |
| 1261 | private void handlePdcpmeasreportperue(PDCPMeasReportPerUe pdcpMeasReportPerUe) { |
| 1262 | RnibUe ue = ueMap.get(pdcpMeasReportPerUe.getEcgi(), pdcpMeasReportPerUe.getCrnti()); |
| 1263 | if (ue != null) { |
| 1264 | Long ueId = ue.getId(); |
| 1265 | RnibLink link = linkMap.get(pdcpMeasReportPerUe.getEcgi(), ueId); |
| 1266 | if (link != null) { |
| 1267 | link.setPdcpThroughput(new RnibLink.PdcpThroughput( |
| 1268 | pdcpMeasReportPerUe.getThroughputDl(), |
| 1269 | pdcpMeasReportPerUe.getThroughputUl() |
| 1270 | )); |
| 1271 | |
| 1272 | link.setPdcpPackDelay(new RnibLink.PdcpPacketdelay( |
| 1273 | pdcpMeasReportPerUe.getPktDelayDl(), |
| 1274 | pdcpMeasReportPerUe.getPktDelayUl() |
| 1275 | )); |
| 1276 | } else { |
| 1277 | log.warn("Could not find link between: {}-{}", pdcpMeasReportPerUe.getEcgi(), ueId); |
| 1278 | } |
| 1279 | } |
| 1280 | } |
| 1281 | |
| 1282 | /** |
| 1283 | * Handle UECapabilityInfo. |
slowr | 23a93e1 | 2017-09-01 13:26:18 -0700 | [diff] [blame^] | 1284 | * |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 1285 | * @param capabilityInfo UECapabilityInfo |
| 1286 | */ |
| 1287 | private void handleCapabilityinfo(UECapabilityInfo capabilityInfo) { |
| 1288 | RnibUe ue = ueMap.get(capabilityInfo.getEcgi(), capabilityInfo.getCrnti()); |
| 1289 | if (ue != null) { |
| 1290 | ue.setCapability(capabilityInfo); |
| 1291 | } else { |
| 1292 | log.warn("Could not find UE with this CRNTI: {}", capabilityInfo.getCrnti()); |
| 1293 | } |
| 1294 | } |
| 1295 | |
| 1296 | /** |
| 1297 | * Handle UECapabilityEnquiry. |
slowr | 23a93e1 | 2017-09-01 13:26:18 -0700 | [diff] [blame^] | 1298 | * |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 1299 | * @param ueCapabilityEnquiry UECapabilityEnquiry |
slowr | 23a93e1 | 2017-09-01 13:26:18 -0700 | [diff] [blame^] | 1300 | * @param ctx ChannelHandlerContext |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 1301 | * @throws IOException IO Exception |
| 1302 | */ |
| 1303 | private void handleUecapabilityenquiry(UECapabilityEnquiry ueCapabilityEnquiry, ChannelHandlerContext ctx) |
| 1304 | throws IOException { |
| 1305 | XrancPdu xrancPdu = UECapabilityEnquiry.constructPacket(ueCapabilityEnquiry.getEcgi(), |
| 1306 | ueCapabilityEnquiry.getCrnti()); |
| 1307 | ctx.writeAndFlush(getSctpMessage(xrancPdu)); |
| 1308 | } |
| 1309 | |
| 1310 | /** |
| 1311 | * Handle ScellAddStatus. |
slowr | 23a93e1 | 2017-09-01 13:26:18 -0700 | [diff] [blame^] | 1312 | * |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 1313 | * @param scellAddStatus ScellAddStatus |
| 1314 | */ |
| 1315 | private void handleScelladdstatus(ScellAddStatus scellAddStatus) { |
| 1316 | RnibUe ue = ueMap.get(scellAddStatus.getEcgi(), scellAddStatus.getCrnti()); |
| 1317 | if (ue != null) { |
| 1318 | Long ueId = ue.getId(); |
| 1319 | try { |
| 1320 | scellAddMap.get(scellAddStatus.getCrnti()).put("Scell's status: " + |
| 1321 | scellAddStatus.getStatus()); |
| 1322 | final int[] i = {0}; |
| 1323 | scellAddStatus.getScellsInd().getPCIARFCN().forEach( |
| 1324 | pciarfcn -> { |
| 1325 | if (scellAddStatus.getStatus().getBerEnum().get(i[0]).value.intValue() == 0) { |
| 1326 | RnibCell cell = cellMap.get(pciarfcn); |
| 1327 | RnibLink link = linkMap.get(cell.getEcgi(), ueId); |
| 1328 | link.setType(RnibLink.Type.SERVING_SECONDARY_CA); |
| 1329 | } |
| 1330 | i[0]++; |
| 1331 | } |
| 1332 | ); |
| 1333 | |
| 1334 | } catch (InterruptedException e) { |
| 1335 | log.error(ExceptionUtils.getFullStackTrace(e)); |
| 1336 | e.printStackTrace(); |
| 1337 | } finally { |
| 1338 | scellAddMap.remove(scellAddStatus.getCrnti()); |
| 1339 | } |
| 1340 | } |
| 1341 | } |
| 1342 | |
| 1343 | /** |
| 1344 | * Handle RRMConfigStatus. |
slowr | 23a93e1 | 2017-09-01 13:26:18 -0700 | [diff] [blame^] | 1345 | * |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 1346 | * @param rrmConfigStatus RRMConfigStatus |
| 1347 | */ |
| 1348 | private void handleRrmconfigstatus(RRMConfigStatus rrmConfigStatus) { |
| 1349 | try { |
| 1350 | rrmcellMap.get(rrmConfigStatus.getEcgi()) |
| 1351 | .put("RRM Config's status: " + rrmConfigStatus.getStatus()); |
| 1352 | } catch (InterruptedException e) { |
| 1353 | log.error(ExceptionUtils.getFullStackTrace(e)); |
| 1354 | e.printStackTrace(); |
| 1355 | } finally { |
| 1356 | rrmcellMap.remove(rrmConfigStatus.getEcgi()); |
| 1357 | } |
| 1358 | } |
| 1359 | |
| 1360 | /** |
| 1361 | * Handle TrafficSplitConfig. |
slowr | 23a93e1 | 2017-09-01 13:26:18 -0700 | [diff] [blame^] | 1362 | * |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 1363 | * @param trafficSplitConfig TrafficSplitConfig |
| 1364 | */ |
| 1365 | private void handleTrafficSplitConfig(TrafficSplitConfig trafficSplitConfig) { |
| 1366 | RnibUe ue = ueMap.get(trafficSplitConfig.getEcgi(), trafficSplitConfig.getCrnti()); |
| 1367 | if (ue != null) { |
| 1368 | Long ueId = ue.getId(); |
| 1369 | List<TrafficSplitPercentage> splitPercentages = trafficSplitConfig |
| 1370 | .getTrafficSplitPercent().getTrafficSplitPercentage(); |
| 1371 | |
| 1372 | splitPercentages.forEach(trafficSplitPercentage -> { |
| 1373 | RnibCell cell = cellMap.get(trafficSplitPercentage.getEcgi()); |
| 1374 | if (cell != null) { |
| 1375 | RnibLink link = linkMap.get(cell.getEcgi(), ueId); |
| 1376 | if (link != null) { |
| 1377 | link.setTrafficPercent(trafficSplitPercentage); |
| 1378 | } else { |
| 1379 | log.warn("Could not find link between: {}-{}", cell.getEcgi(), ueId); |
| 1380 | } |
| 1381 | } else { |
| 1382 | log.warn("Could not find cell with ECGI: {}", trafficSplitConfig.getEcgi()); |
| 1383 | } |
| 1384 | }); |
| 1385 | } |
| 1386 | } |
| 1387 | |
| 1388 | /** |
| 1389 | * Handle context update depending if its handoff or not. |
| 1390 | * |
| 1391 | * @param contextUpdate context update packet |
| 1392 | * @param ctx channel context for the CELL |
| 1393 | * @param handoff true if we handle a Hand Off |
| 1394 | */ |
slowr | ab685ef | 2017-08-31 17:17:35 -0700 | [diff] [blame] | 1395 | private void handlePairedPackets(UEContextUpdate contextUpdate, ChannelHandlerContext ctx, boolean handoff) { |
slowr | c86750e | 2017-08-22 17:26:47 -0700 | [diff] [blame] | 1396 | RnibUe ue; |
| 1397 | RnibCell cell = xranStore.getCell(contextUpdate.getEcgi()); |
| 1398 | |
| 1399 | if (handoff) { |
| 1400 | try { |
| 1401 | ue = ueMap.get(ueIdQueue.take()); |
| 1402 | } catch (InterruptedException e) { |
| 1403 | e.printStackTrace(); |
| 1404 | log.error(ExceptionUtils.getFullStackTrace(e)); |
| 1405 | ue = new RnibUe(); |
| 1406 | } |
| 1407 | } else { |
| 1408 | ue = new RnibUe(); |
| 1409 | } |
| 1410 | |
| 1411 | ue.setMmeS1apId(contextUpdate.getMMEUES1APID()); |
| 1412 | ue.setEnbS1apId(contextUpdate.getENBUES1APID()); |
| 1413 | ue.setCrnti(contextUpdate.getCrnti()); |
| 1414 | |
| 1415 | hostAgent.addConnectedHost(ue, cell, ctx); |
| 1416 | } |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1417 | } |
| 1418 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 1419 | /** |
| 1420 | * Internal class for NetworkConfigListener. |
| 1421 | */ |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1422 | class InternalNetworkConfigListener implements NetworkConfigListener { |
| 1423 | |
| 1424 | @Override |
| 1425 | public void event(NetworkConfigEvent event) { |
| 1426 | switch (event.type()) { |
| 1427 | case CONFIG_REGISTERED: |
| 1428 | break; |
| 1429 | case CONFIG_UNREGISTERED: |
| 1430 | break; |
| 1431 | case CONFIG_ADDED: |
| 1432 | case CONFIG_UPDATED: |
| 1433 | if (event.configClass() == CONFIG_CLASS) { |
| 1434 | handleConfigEvent(event.config()); |
| 1435 | } |
| 1436 | break; |
| 1437 | case CONFIG_REMOVED: |
| 1438 | break; |
| 1439 | default: |
| 1440 | break; |
| 1441 | } |
| 1442 | } |
| 1443 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 1444 | /** |
| 1445 | * Handle config event. |
| 1446 | * |
| 1447 | * @param config |
| 1448 | */ |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1449 | private void handleConfigEvent(Optional<Config> config) { |
| 1450 | if (!config.isPresent()) { |
| 1451 | return; |
| 1452 | } |
| 1453 | |
| 1454 | xranConfig = (XranConfig) config.get(); |
| 1455 | |
slowr | 577f322 | 2017-08-28 10:49:08 -0700 | [diff] [blame] | 1456 | northboundTimeout = xranConfig.getNorthBoundTimeout(); |
slowr | d337c93 | 2017-08-18 13:54:02 -0700 | [diff] [blame] | 1457 | |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1458 | legitCells.putAll(xranConfig.activeCellSet()); |
| 1459 | |
slowr | 23a93e1 | 2017-09-01 13:26:18 -0700 | [diff] [blame^] | 1460 | controller.start(deviceAgent, hostAgent, packetAgent, xranConfig.getXrancIp(), xranConfig.getXrancPort()); |
slowr | 13fa5b0 | 2017-08-08 16:32:31 -0700 | [diff] [blame] | 1461 | } |
| 1462 | } |
| 1463 | } |