public void AdmitNewCallToOngoingSession(ISession session, ICall call, IMobileTerminal mobileTerminal) { if (session == null) { throw new VerticalHandoverPredictionException($"{nameof(session)} is invalid"); } if (call == null) { throw new VerticalHandoverPredictionException($"{nameof(call)} is invalid"); } if (mobileTerminal == null) { throw new VerticalHandoverPredictionException($"{nameof(mobileTerminal)} is invalid"); } TakeNetworkResources(call.Service.ComputeRequiredNetworkResources()); session.AddToActiveCalls(call); var state = mobileTerminal.UpdateMobileTerminalStateWhenAdmitingNewCallToOngoingSession(session.ActiveCalls); session.AddToSessionSequence(state); }
public void Handover(ICall call, ISession session, IMobileTerminal mobileTerminal, IRat source) { if (call == null) { throw new VerticalHandoverPredictionException($"{nameof(call)} is invalid"); } if (session == null) { throw new VerticalHandoverPredictionException($"{nameof(session)} is invalid"); } if (mobileTerminal == null) { throw new VerticalHandoverPredictionException($"{nameof(mobileTerminal)} is invalid"); } if (source == null) { throw new VerticalHandoverPredictionException($"{nameof(source)} is invalid"); } var callsToHandedOverToTargetRat = session.ActiveCalls.Select(x => x.Service).ToList(); callsToHandedOverToTargetRat.Add(call.Service); var rats = Rats .Where(x => x.RatId != session.RatId && x.Services.ToHashSet().IsSupersetOf(callsToHandedOverToTargetRat)) .OrderBy(x => x.Services.Count()) .ToList(); var requiredNetworkResouces = 0; foreach (var service in callsToHandedOverToTargetRat) { requiredNetworkResouces += service.ComputeRequiredNetworkResources(); } foreach (var target in rats) { if (requiredNetworkResouces <= target.AvailableNetworkResources()) { UpdateHandovers(call.Service); source.RealeaseNetworkResources(requiredNetworkResouces - call.Service.ComputeRequiredNetworkResources()); source.RemoveSession(session); session.SetRatId(target.RatId); target.TakeNetworkResources(requiredNetworkResouces); session.AddToActiveCalls(call); var state = mobileTerminal.UpdateMobileTerminalState(session); session.AddToSessionSequence(state); target.AddSession(session); return; } } //If call cannot be handed over then the incoming call is blocked BlockedCalls++; }