Amazing technological breakthrough possible @S-Logix pro@slogix.in

Office Address

  • #5, First Floor, 4th Street Dr. Subbarayan Nagar Kodambakkam, Chennai-600 024 Landmark : Samiyar Madam
  • pro@slogix.in
  • +91- 81240 01111

Social List

How to create Gateways in iFogSim?

Description

In iFogSim, adding a fog device for every gateway in physical topology and the parent of each gateway is the Proxy Server. Also mobiles are added to the gateway and mobiles (smart phones) have been modeled as fog devices as well.

Sample Code

public class IotFogApplication
{

static List fogDevices = new ArrayList();
static List sensors = new ArrayList();
static List actuators = new ArrayList();
static boolean CLOUD = false;
static int numOfDepts = 4;
static int numOfMobilesPerDept = 6;
.
.

public static void main(String[] args) {

try {
Log.disable();
int num_user = 1;
Calendar calendar = Calendar.getInstance();
boolean trace_flag = false;

CloudSim.init(num_user, calendar, trace_flag);

String appId = “IoTFog_Apps”;

FogBroker broker = new FogBroker(“broker”);

Application application = createApplication(appId, broker.getId());
application.setUserId(broker.getId());

createFogDevices(broker.getId(), 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);
FogDevice proxy = createFogDevice(“proxy-server”, 2800, 4000, 10000, 10000, 1, 0.0, 107.339, 83.4333);
proxy.setParentId(cloud.getId());
proxy.setUplinkLatency(100);
fogDevices.add(cloud);
fogDevices.add(proxy);

for (int i = 0; i < numOfDepts; i++) {
addGw(i + “”, userId, appId, proxy.getId());
}

}

/* to create a gateways */
private static FogDevice addGw(String id, int userId, String appId, int parentId)
{
FogDevice dept = createFogDevice(“d-” + id, 2800, 4000, 10000, 10000, 1, 0.0, 107.339, 83.4333);
fogDevices.add(dept);
dept.setParentId(parentId);
dept.setUplinkLatency(4);

for (int i = 0; i < numOfMobilesPerDept; i++)
{
String mobileId = id + “-” + i;
FogDevice mobile = addMobile(mobileId, userId, appId, dept.getId()); mobile.setUplinkLatency(2);
fogDevices.add(mobile);
}
return dept;
}

// to create a fog devices
private static FogDevice createFogDevice(String nodeName, long mips, int ram, long upBw,long downBw, int level, double ratePerMips, double busyPower, double idlePower)

{
List peList = new ArrayList();

peList.add(new Pe(0, new PeProvisionerOverbooking(mips)));

int hostId = FogUtils.generateEntityId();
long storage = 1000000;
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”;
String os = “Linux”;
String vmm = “Xen”;
double time_zone = 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, 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;
}
}