public static void CloudSim(Models.Tuple tuple, Services service, List <string> datacenter) { Debug.WriteLine("CloudSim" + tuple.ID); try { Stopwatch watch = new Stopwatch(); var result = new Results(); watch.Start(); result.InitiatesTime = watch.Elapsed.TotalMilliseconds.ToString(); var Broker = new CloudBroker() { Service = service, DatacenterList = DataCenterBusiness.GetDataCenterList().Where(a => datacenter.Any(z => a.Name.Contains(z))).ToList(), Tuple = tuple, // create VM SelectedVM = new VM(service.ID, 1, service.MIPS, service.NumberOfPes, service.RAM, service.BW, service.Size, service.Name, new CloudletScheduler(), new GeoLocation(47.599949, -122.326815)) }; Broker.SelectedDataCenter = BrokerUtility.GetValidDataCenter(Broker.Tuple, Broker.DatacenterList); if (Broker.SelectedDataCenter != null) { lock (Lock) { result.Link = linksList.Where(x => x.Source == tuple.Name && x.Destination == Broker.SelectedDataCenter.Name && x != null).FirstOrDefault(); result.Link.Propagationtime = Math.Round(result.Link.Propagationtime, 3);// + tuple.QueueDelay; } // returns the host by finding the appropirate and then add the vm into the vmlist of host object. Broker.SelectedHost = BrokerUtility.GetHostFromDataCenter(Broker.SelectedDataCenter, Broker.SelectedVM); if (Broker.SelectedHost != null) { result.CloudBroker = Broker; tuple.InternalProcessingTime = Math.Round(watch.Elapsed.TotalMilliseconds, 3); tuple.IsServed = true; // it will execute on policy 4 if (FogSimulator.IsCreateCache) { lock (cloudCahce) { cloudCahce.Add(new CloudCache() { DataType = tuple.DataType, Cloud = Broker.SelectedDataCenter.Name, InternalProcessingTime = tuple.InternalProcessingTime, link = result.Link }); } } ResourceUtility.ReleaseResources(Broker.SelectedHost, Broker.SelectedVM); } else { tuple.IsServerFound = false; tuple.IsServed = false; } result.ElapsedTime = (watch.Elapsed.TotalMilliseconds + result.Link.Propagationtime) - Convert.ToDouble(result.InitiatesTime); } else { tuple.IsReversed = true; } result.Tuple = tuple; watch.Stop(); // result.InActiveFogDecives = fogList.Where(x => x.IsActive == false).ToList(); CloudSimulator.resultList.Add(result); } catch (Exception ex) { throw new ArgumentException(ex.Message); } }