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

Office Address

  • 2nd Floor, #7a, High School Road, Secretariat Colony Ambattur, Chennai-600053 (Landmark: SRM School) Tamil Nadu, India
  • pro@slogix.in
  • +91- 81240 01111

Social List

How to create number of application in iFogSim?

Description

In fog environment possible to create two or more number of application using iFogSim toolkit. To create number of application in iFogSim, create individual edge devices for each applications.

Source Code

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 appId0 = "1";

String appId1 = "2";

FogBroker broker0 = new FogBroker("broker_0");

FogBroker broker1 = new FogBroker("broker_1");

Application application0 = createApplication0(appId0, broker0.getId());

Application application1 = createApplication1(appId1, broker1.getId());

application0.setUserId(broker0.getId());

application1.setUserId(broker1.getId());

createFogDevices();

createEdgeDevices0(broker0.getId(), appId0);

createEdgeDevices1(broker1.getId(), appId1);

ModuleMapping moduleMapping_0 = ModuleMapping.createModuleMapping(); ModuleMapping moduleMapping_1 = ModuleMapping.createModuleMapping();

Controller controller = new Controller("master-controller", fogDevices, sensors, actuators);

controller.submitApplication(application0, new ModulePlacementEdgewards(fogDevices, sensors, actuators, application0, moduleMapping_0));

controller.submitApplication(application1, new ModulePlacementOnlyCloud(fogDevices, sensors, actuators, application1));

TimeKeeper.getInstance().setSimulationStartTime(Calendar.getInstance().getTimeInMillis());

CloudSim.startSimulation();

CloudSim.stopSimulation();

Log.printLine("Two Application Finished!");

} catch (Exception e) {

e.printStackTrace();

Log.printLine("Unwanted errors happen");

}

}

private static void createEdgeDevices0(int userId, String appId) {

for (FogDevice mobile : mobiles) {

String id = mobile.getName();

Sensor eegSensor = new Sensor("s-" + appId + "-" + id, "EEG", userId, appId, new DeterministicDistribution(EEG_TRANSMISSION_TIME)); // inter-transmission time of EEG sensor follows a deterministic distribution

sensors.add(eegSensor);

Actuator display = new Actuator("a-" + appId + "-" + id, userId, appId, "DISPLAY");

actuators.add(display);

eegSensor.setGatewayDeviceId(mobile.getId());

eegSensor.setLatency(6.0); // latency of connection between EEG sensors and the parent Smartphone is 6 ms

display.setGatewayDeviceId(mobile.getId());

display.setLatency(1.0); // latency of connection between Display actuator and the parent Smartphone is 1 ms

}

}

private static void createEdgeDevices1(int userId, String appId) {

for (FogDevice mobile : mobiles) {

String id = mobile.getName();

Sensor eegSensor = new Sensor("s-" + appId + "-" + id, "EEG_1", userId, appId, new DeterministicDistribution(EEG_TRANSMISSION_TIME)); // inter-transmission time of EEG sensor follows a deterministic distribution

sensors.add(eegSensor);

Actuator display = new Actuator("a-" + appId + "-" + id, userId, appId, "DISPLAY_1");

actuators.add(display);

eegSensor.setGatewayDeviceId(mobile.getId());

eegSensor.setLatency(6.0); // latency of connection between EEG sensors and the parent Smartphone is 6 ms

display.setGatewayDeviceId(mobile.getId());

display.setLatency(1.0); // latency of connection between Display actuator and the parent Smartphone is 1 ms

}

}

Output

create number of application
Number of application created in iFogSim