diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/bin/org/fog/test/perfeval/Birbnetes.class b/bin/org/fog/test/perfeval/Birbnetes.class index 091773b..9592208 100644 Binary files a/bin/org/fog/test/perfeval/Birbnetes.class and b/bin/org/fog/test/perfeval/Birbnetes.class differ diff --git a/bin/org/fog/test/perfeval/DCNSFog.class b/bin/org/fog/test/perfeval/DCNSFog.class index 7853824..1ba3f1b 100644 Binary files a/bin/org/fog/test/perfeval/DCNSFog.class and b/bin/org/fog/test/perfeval/DCNSFog.class differ diff --git a/bin/org/fog/test/perfeval/TestApplication$1.class b/bin/org/fog/test/perfeval/TestApplication$1.class index 5d5cd73..81087f0 100644 Binary files a/bin/org/fog/test/perfeval/TestApplication$1.class and b/bin/org/fog/test/perfeval/TestApplication$1.class differ diff --git a/bin/org/fog/test/perfeval/TestApplication$2.class b/bin/org/fog/test/perfeval/TestApplication$2.class index e048290..ae9d2cb 100644 Binary files a/bin/org/fog/test/perfeval/TestApplication$2.class and b/bin/org/fog/test/perfeval/TestApplication$2.class differ diff --git a/bin/org/fog/test/perfeval/TestApplication.class b/bin/org/fog/test/perfeval/TestApplication.class index ce1f3ab..5faf4eb 100644 Binary files a/bin/org/fog/test/perfeval/TestApplication.class and b/bin/org/fog/test/perfeval/TestApplication.class differ diff --git a/bin/org/fog/test/perfeval/VRGameFog.class b/bin/org/fog/test/perfeval/VRGameFog.class index 01ff286..06beef0 100644 Binary files a/bin/org/fog/test/perfeval/VRGameFog.class and b/bin/org/fog/test/perfeval/VRGameFog.class differ diff --git a/src/org/fog/entities/FogDevice.java b/src/org/fog/entities/FogDevice.java index 283579b..1ce4186 100644 --- a/src/org/fog/entities/FogDevice.java +++ b/src/org/fog/entities/FogDevice.java @@ -743,7 +743,7 @@ public class FogDevice extends PowerDatacenter { processCloudletSubmit(ev, false); updateAllocatedMips(moduleName); /*for(Vm vm : getHost().getVmList()){ - Logger.error(getName(), "MIPS allocated to "+((AppModule)vm).getName()+" = "+getHost().getTotalAllocatedMipsForVm(vm)); + Log.printLine("MIPS allocated to "+((AppModule)vm).getName()+" = "+getHost().getTotalAllocatedMipsForVm(vm)); }*/ } diff --git a/src/org/fog/test/perfeval/Birbnetes.java b/src/org/fog/test/perfeval/Birbnetes.java index 6084458..062ab95 100644 --- a/src/org/fog/test/perfeval/Birbnetes.java +++ b/src/org/fog/test/perfeval/Birbnetes.java @@ -28,7 +28,7 @@ import java.util.*; public class Birbnetes { static int numOfFogDevices = 2; - static int numOfClientsPerFogDevice = 10; + static int numOfClientsPerFogDevice = 1; static List fogDevices = new ArrayList<>(); static Map getIdByName = new HashMap<>(); static List sensors = new ArrayList<>(); @@ -117,7 +117,7 @@ public class Birbnetes { "OutputData"); actuators.add(actuator); sensor.setGatewayDeviceId(lowLevelFogDevice.getId()); - sensor.setLatency(6.0); + sensor.setLatency(10.0); actuator.setGatewayDeviceId(lowLevelFogDevice.getId()); actuator.setLatency(1.0); return lowLevelFogDevice; @@ -156,7 +156,7 @@ public class Birbnetes { Log.printLine("Starting Birbnetes..."); try { - Log.disable(); + //Log.disable(); int num_user = 1; // number of cloud users Calendar calendar = Calendar.getInstance(); diff --git a/src/org/fog/test/perfeval/Birbnetes_copyofdcnsfog.java b/src/org/fog/test/perfeval/Birbnetes_copyofdcnsfog.java new file mode 100644 index 0000000..28be0ad --- /dev/null +++ b/src/org/fog/test/perfeval/Birbnetes_copyofdcnsfog.java @@ -0,0 +1,260 @@ +package org.fog.test.perfeval; + +import org.cloudbus.cloudsim.Host; +import org.cloudbus.cloudsim.Log; +import org.cloudbus.cloudsim.Pe; +import org.cloudbus.cloudsim.Storage; +import org.cloudbus.cloudsim.core.CloudSim; +import org.cloudbus.cloudsim.power.PowerHost; +import org.cloudbus.cloudsim.provisioners.RamProvisionerSimple; +import org.cloudbus.cloudsim.sdn.overbooking.BwProvisionerOverbooking; +import org.cloudbus.cloudsim.sdn.overbooking.PeProvisionerOverbooking; +import org.fog.application.AppEdge; +import org.fog.application.AppLoop; +import org.fog.application.Application; +import org.fog.application.selectivity.FractionalSelectivity; +import org.fog.entities.*; +import org.fog.placement.Controller; +import org.fog.placement.ModuleMapping; +import org.fog.placement.ModulePlacementEdgewards; +import org.fog.placement.ModulePlacementMapping; +import org.fog.policy.AppModuleAllocationPolicy; +import org.fog.scheduler.StreamOperatorScheduler; +import org.fog.utils.FogLinearPowerModel; +import org.fog.utils.FogUtils; +import org.fog.utils.TimeKeeper; +import org.fog.utils.distribution.DeterministicDistribution; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.LinkedList; +import java.util.List; + +/** + * Simulation setup for case study 2 - Intelligent Surveillance + * @author Harshit Gupta + * + */ +public class Birbnetes_copyofdcnsfog { + static List fogDevices = new ArrayList(); + static List sensors = new ArrayList(); + static List actuators = new ArrayList(); + static int numOfAreas = 1; + static int numOfCamerasPerArea = 4; + + private static boolean CLOUD = false; + + public static void main(String[] args) { + + Log.printLine("Starting DCNS..."); + + try { + Log.disable(); + int num_user = 1; // number of cloud users + Calendar calendar = Calendar.getInstance(); + boolean trace_flag = false; // mean trace events + + CloudSim.init(num_user, calendar, trace_flag); + + String appId = "dcns"; // identifier of the application + + FogBroker broker = new FogBroker("broker"); + + Application application = createApplication(appId, broker.getId()); + application.setUserId(broker.getId()); + + createFogDevices(broker.getId(), appId); + + Controller controller = null; + + ModuleMapping moduleMapping = ModuleMapping.createModuleMapping(); // initializing a module mapping + for(FogDevice device : fogDevices){ + if(device.getName().startsWith("m")){ // names of all Smart Cameras start with 'm' + moduleMapping.addModuleToDevice("motion_detector", device.getName()); // fixing 1 instance of the Motion Detector module to each Smart Camera + } + } + moduleMapping.addModuleToDevice("user_interface", "cloud"); // fixing instances of User Interface module in the Cloud + if(CLOUD){ + // if the mode of deployment is cloud-based + moduleMapping.addModuleToDevice("object_detector", "cloud"); // placing all instances of Object Detector module in the Cloud + moduleMapping.addModuleToDevice("object_tracker", "cloud"); // placing all instances of Object Tracker module in the Cloud + } + + controller = new Controller("master-controller", fogDevices, sensors, + actuators); + + controller.submitApplication(application, + (CLOUD)?(new ModulePlacementMapping(fogDevices, application, moduleMapping)) + :(new ModulePlacementEdgewards(fogDevices, sensors, actuators, application, moduleMapping))); + + TimeKeeper.getInstance().setSimulationStartTime(Calendar.getInstance().getTimeInMillis()); + + CloudSim.startSimulation(); + + CloudSim.stopSimulation(); + + Log.printLine("VRGame finished!"); + } catch (Exception e) { + e.printStackTrace(); + Log.printLine("Unwanted errors happen"); + } + } + + /** + * Creates the fog devices in the physical topology of the simulation. + * @param userId + * @param appId + */ + private static void createFogDevices(int userId, String appId) { + FogDevice cloud = createFogDevice("cloud", 44800, 40000, 100, 10000, 0, 0.01, 16*103, 16*83.25); + cloud.setParentId(-1); + fogDevices.add(cloud); + FogDevice proxy = createFogDevice("proxy-server", 2800, 4000, 10000, 10000, 1, 0.0, 107.339, 83.4333); + proxy.setParentId(cloud.getId()); + proxy.setUplinkLatency(100); // latency of connection between proxy server and cloud is 100 ms + fogDevices.add(proxy); + for(int i=0;i peList = new ArrayList(); + + // 3. Create PEs and add these into a list. + peList.add(new Pe(0, new PeProvisionerOverbooking(mips))); // need to store Pe id and MIPS Rating + + int hostId = FogUtils.generateEntityId(); + long storage = 1000000; // host storage + int bw = 10000; + + PowerHost host = new PowerHost( + hostId, + new RamProvisionerSimple(ram), + new BwProvisionerOverbooking(bw), + storage, + peList, + new StreamOperatorScheduler(peList), + new FogLinearPowerModel(busyPower, idlePower) + ); + + List hostList = new ArrayList(); + hostList.add(host); + + String arch = "x86"; // system architecture + String os = "Linux"; // operating system + String vmm = "Xen"; + double time_zone = 10.0; // time zone this resource located + double cost = 3.0; // the cost of using processing in this resource + double costPerMem = 0.05; // the cost of using memory in this resource + double costPerStorage = 0.001; // the cost of using storage in this + // resource + double costPerBw = 0.0; // the cost of using bw in this resource + LinkedList storageList = new LinkedList(); // we are not adding SAN + // devices by now + + FogDeviceCharacteristics characteristics = new FogDeviceCharacteristics( + arch, os, vmm, host, time_zone, cost, costPerMem, + costPerStorage, costPerBw); + + FogDevice fogdevice = null; + try { + fogdevice = new FogDevice(nodeName, characteristics, + new AppModuleAllocationPolicy(hostList), storageList, 10, upBw, downBw, 0, ratePerMips); + } catch (Exception e) { + e.printStackTrace(); + } + + fogdevice.setLevel(level); + return fogdevice; + } + + /** + * Function to create the Intelligent Surveillance application in the DDF model. + * @param appId unique identifier of the application + * @param userId identifier of the user of the application + * @return + */ + @SuppressWarnings({"serial" }) + private static Application createApplication(String appId, int userId){ + + Application application = Application.createApplication(appId, userId); + /* + * Adding modules (vertices) to the application model (directed graph) + */ + application.addAppModule("object_detector", 10); + application.addAppModule("motion_detector", 10); + application.addAppModule("object_tracker", 10); + application.addAppModule("user_interface", 10); + + /* + * Connecting the application modules (vertices) in the application model (directed graph) with edges + */ + application.addAppEdge("CAMERA", "motion_detector", 1000, 20000, "CAMERA", Tuple.UP, AppEdge.SENSOR); // adding edge from CAMERA (sensor) to Motion Detector module carrying tuples of type CAMERA + application.addAppEdge("motion_detector", "object_detector", 2000, 2000, "MOTION_VIDEO_STREAM", Tuple.UP, AppEdge.MODULE); // adding edge from Motion Detector to Object Detector module carrying tuples of type MOTION_VIDEO_STREAM + application.addAppEdge("object_detector", "user_interface", 500, 2000, "DETECTED_OBJECT", Tuple.UP, AppEdge.MODULE); // adding edge from Object Detector to User Interface module carrying tuples of type DETECTED_OBJECT + application.addAppEdge("object_detector", "object_tracker", 1000, 100, "OBJECT_LOCATION", Tuple.UP, AppEdge.MODULE); // adding edge from Object Detector to Object Tracker module carrying tuples of type OBJECT_LOCATION + application.addAppEdge("object_tracker", "PTZ_CONTROL", 100, 28, 100, "PTZ_PARAMS", Tuple.DOWN, AppEdge.ACTUATOR); // adding edge from Object Tracker to PTZ CONTROL (actuator) carrying tuples of type PTZ_PARAMS + + /* + * Defining the input-output relationships (represented by selectivity) of the application modules. + */ + application.addTupleMapping("motion_detector", "CAMERA", "MOTION_VIDEO_STREAM", new FractionalSelectivity(1.0)); // 1.0 tuples of type MOTION_VIDEO_STREAM are emitted by Motion Detector module per incoming tuple of type CAMERA + application.addTupleMapping("object_detector", "MOTION_VIDEO_STREAM", "OBJECT_LOCATION", new FractionalSelectivity(1.0)); // 1.0 tuples of type OBJECT_LOCATION are emitted by Object Detector module per incoming tuple of type MOTION_VIDEO_STREAM + application.addTupleMapping("object_detector", "MOTION_VIDEO_STREAM", "DETECTED_OBJECT", new FractionalSelectivity(0.05)); // 0.05 tuples of type MOTION_VIDEO_STREAM are emitted by Object Detector module per incoming tuple of type MOTION_VIDEO_STREAM + + /* + * Defining application loops (maybe incomplete loops) to monitor the latency of. + * Here, we add two loops for monitoring : Motion Detector -> Object Detector -> Object Tracker and Object Tracker -> PTZ Control + */ + final AppLoop loop1 = new AppLoop(new ArrayList(){{add("motion_detector");add("object_detector");add("object_tracker");}}); + final AppLoop loop2 = new AppLoop(new ArrayList(){{add("object_tracker");add("PTZ_CONTROL");}}); + List loops = new ArrayList(){{add(loop1);add(loop2);}}; + + application.setLoops(loops); + return application; + } +} \ No newline at end of file diff --git a/src/org/fog/test/perfeval/TestApplication.java b/src/org/fog/test/perfeval/TestApplication.java index 1e8a3bd..3772b91 100644 --- a/src/org/fog/test/perfeval/TestApplication.java +++ b/src/org/fog/test/perfeval/TestApplication.java @@ -202,7 +202,7 @@ public class TestApplication { @SuppressWarnings({"serial" }) private static MyApplication createApplication(String appId, int userId){ - + MyApplication application = MyApplication.createApplication(appId, userId); application.addAppModule("clientModule",10, 1000, 1000, 100); application.addAppModule("mainModule", 50, 1500, 4000, 800); @@ -228,6 +228,7 @@ public class TestApplication { moduleAddMips.put("mainModule", getvalue(0, 500)); deadlineInfo.put(id, moduleDeadline); additionalMipsInfo.put(id,moduleAddMips); + } final AppLoop loop1 = new AppLoop(new ArrayList(){{add("IoTSensor");add("clientModule");add("mainModule");add("clientModule");add("IoTActuator");}}); diff --git a/src/org/fog/test/perfeval/VRGameFog.java b/src/org/fog/test/perfeval/VRGameFog.java index 7045d32..76953a8 100644 --- a/src/org/fog/test/perfeval/VRGameFog.java +++ b/src/org/fog/test/perfeval/VRGameFog.java @@ -57,7 +57,7 @@ public class VRGameFog { Log.printLine("Starting VRGame..."); try { - Log.disable(); + //Log.disable(); int num_user = 1; // number of cloud users Calendar calendar = Calendar.getInstance(); boolean trace_flag = false; // mean trace events @@ -74,7 +74,7 @@ public class VRGameFog { createFogDevices(broker.getId(), appId); ModuleMapping moduleMapping = ModuleMapping.createModuleMapping(); // initializing a module mapping - + if(CLOUD){ // if the mode of deployment is cloud-based /*moduleMapping.addModuleToDevice("connector", "cloud", numOfDepts*numOfMobilesPerDept); // fixing all instances of the Connector module to the Cloud @@ -263,15 +263,15 @@ public class VRGameFog { application.addAppEdge("client", "DISPLAY", 1000, 500, "GLOBAL_STATE_UPDATE", Tuple.DOWN, AppEdge.ACTUATOR); // adding edge from Client module to Display (actuator) carrying tuples of type GLOBAL_STATE_UPDATE /* - * Defining the input-output relationships (represented by selectivity) of the application modules. + * Defining the input-output relationships (represented by selectivity) of the application modules. */ application.addTupleMapping("client", "EEG", "_SENSOR", new FractionalSelectivity(0.9)); // 0.9 tuples of type _SENSOR are emitted by Client module per incoming tuple of type EEG application.addTupleMapping("client", "CONCENTRATION", "SELF_STATE_UPDATE", new FractionalSelectivity(1.0)); // 1.0 tuples of type SELF_STATE_UPDATE are emitted by Client module per incoming tuple of type CONCENTRATION application.addTupleMapping("concentration_calculator", "_SENSOR", "CONCENTRATION", new FractionalSelectivity(1.0)); // 1.0 tuples of type CONCENTRATION are emitted by Concentration Calculator module per incoming tuple of type _SENSOR application.addTupleMapping("client", "GLOBAL_GAME_STATE", "GLOBAL_STATE_UPDATE", new FractionalSelectivity(1.0)); // 1.0 tuples of type GLOBAL_STATE_UPDATE are emitted by Client module per incoming tuple of type GLOBAL_GAME_STATE - + /* - * Defining application loops to monitor the latency of. + * Defining application loops to monitor the latency of. * Here, we add only one loop for monitoring : EEG(sensor) -> Client -> Concentration Calculator -> Client -> DISPLAY (actuator) */ final AppLoop loop1 = new AppLoop(new ArrayList(){{add("EEG");add("client");add("concentration_calculator");add("client");add("DISPLAY");}});