Research breakthrough possible @S-Logix pro@slogix.in

Office Address

Social List

How to Create a Cloud DataCenter in IFogSim?

Create a Cloud DataCenter in IFogSim

Condition for Create a Cloud DataCenter in IFogSim

  • Description:
    Creating a cloud datacenter in iFogSim involves defining a high-capacity fog device that acts as the datacenter at the top level of the fog hierarchy. This requires specifying the device's computational resources, such as MIPS (Million Instructions Per Second), RAM, bandwidth, and storage capacity. The datacenter's processing capabilities are defined through a host, which includes a list of processing elements (PEs) configured with overbooking provisioners for RAM and bandwidth to handle dynamic workloads efficiently. The device characteristics, such as architecture, operating system, virtualization technology, and cost parameters, are set along with a power model to simulate energy consumption. The datacenter typically connects to other fog devices or IoT nodes via uplink and downlink bandwidth and can be customized to include latency settings for simulating network delays. The cloud datacenter generally operates at the root level in the fog hierarchy, managing computationally intensive tasks and providing robust resources for applications.
Sample Code
  • CloudDatacenterExample.java:
    package fogsamples;
    import org.cloudbus.cloudsim.core.CloudSim;
    import org.cloudbus.cloudsim.power.PowerHost;
    import org.cloudbus.cloudsim.power.models.PowerModel;
    import org.cloudbus.cloudsim.power.models.PowerModelLinear;
    import org.cloudbus.cloudsim.provisioners.RamProvisionerSimple;
    import org.fog.application.Application;
    import org.fog.entities.FogBroker;
    import org.fog.entities.FogDevice;
    import org.fog.scheduler.StreamOperatorScheduler;
    import org.fog.utils.FogUtils;
    import org.fog.utils.TimeKeeper;
    import java.util.ArrayList;
    import java.util.Calendar;
    import java.util.LinkedList;
    import java.util.List;
    import org.cloudbus.cloudsim.Host;
    import org.cloudbus.cloudsim.Pe;
    import org.cloudbus.cloudsim.Storage;
    import org.cloudbus.cloudsim.sdn.overbooking.BwProvisionerOverbooking;
    import org.cloudbus.cloudsim.sdn.overbooking.PeProvisionerOverbooking;
    import org.fog.entities.FogDeviceCharacteristics;
    import org.fog.policy.AppModuleAllocationPolicy;
    public class CloudDatacenterExample {
     public static void main(String[] args) {
      try {
       // Initialize CloudSim
       int num_user = 1;
       Calendar calendar = Calendar.getInstance();
       boolean trace_flag = false;
       CloudSim.init(num_user, calendar, trace_flag);
       TimeKeeper.getInstance().setSimulationStartTime(System.currentTimeMillis());
       // Initialize Fog application
       String appId = "iotFogApps";
       FogBroker broker = new FogBroker("broker");
       Application application = createApplication(appId, broker.getId());
       application.setUserId(broker.getId());
       // Create a cloud datacenter
       FogDevice cloud = createCloudDatacenter();
       cloud.setParentId(-1);
       System.out.println("Cloud datacenter created: " + cloud.getName());
       // Simulate
       CloudSim.startSimulation();
       CloudSim.stopSimulation();
       System.out.println("Simulation finished.");
      } catch (Exception e) {
       e.printStackTrace();
       System.out.println("Error: " + e.getMessage());
      }
     }
     /**
      * Creates a cloud datacenter as a FogDevice.
      */
     private static FogDevice createCloudDatacenter() {
      String name = "Cloud-DataCenter";
      long mips = 44800; // Total MIPS
      int ram = 40000; // RAM in MB
      long upBw = 10000; // Upload bandwidth in Mbps
      long downBw = 10000; // Download bandwidth in Mbps
      int level = 0; // Level in fog hierarchy (0 = cloud)
      double ratePerMips = 0.01;
      // Define power model for the host
      PowerModel powerModel = new PowerModelLinear(100, 500);
      // Create processing elements
      List peList = new ArrayList<>();
      peList.add(new Pe(0, new PeProvisionerOverbooking(mips)));
      // Create host
      int hostId = FogUtils.generateEntityId();
      long storage = 1000000; // Storage capacity
      int bw = 10000;
      PowerHost host = new PowerHost(
       hostId,
       new RamProvisionerSimple(ram),
       new BwProvisionerOverbooking(bw),
       storage,
       peList,
       new StreamOperatorScheduler(peList),
       powerModel
      );
      // Create list of hosts
      List hostList = new ArrayList<>();
      hostList.add(host);
      // Set device characteristics
      String arch = "x86";
      String os = "Linux";
      String vmm = "Xen";
      double timeZone = 10.0;
      double cost = 3.0;
      double costPerMem = 0.05;
      double costPerStorage = 0.001;
      double costPerBw = 0.0;
      LinkedList storageList = new LinkedList<>();
      FogDeviceCharacteristics characteristics = new FogDeviceCharacteristics(
       arch, os, vmm, host, timeZone, cost, costPerMem, costPerStorage, costPerBw
      );
      FogDevice fogDevice = null;
      try {
       fogDevice = new FogDevice(
        name,
        characteristics,
        new AppModuleAllocationPolicy(hostList),
        storageList,
        10, upBw, downBw, 0, ratePerMips
       );
      } catch (Exception e) {
       e.printStackTrace();
      }
      fogDevice.setLevel(level);
      fogDevice.setUplinkLatency(0); // Assume no latency
      return fogDevice;
     }
     /**
      * Dummy method for application creation. Replace with actual implementation.
      */
     private static Application createApplication(String appId, int userId) {
      // Replace this with actual application creation logic
      return new Application(appId, userId);
     }
    }
ScreenShots
  • Cloud DataCenter