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 make cluster of fog devices in iFogSim?

Description

Creating cluster of Fog devices. Here two fog devices, residing in the same level and connected with identical upper level Fog nodes, if located at a threshold distance, they are considered belonging to the same Fog cluster.

Source Code

static Map clusterInfo = new HashMap();

static Map> clusters = new HashMap

List>();

private void formClusters() {

for(FogDevice fd: getFogDevices()){

clusterInfo.put(fd.getId(), -1);

}

int clusterId = 0;

for(int i=0;i

FogDevice fd1 = getFogDevices().get(i);

for(int j=0;j

FogDevice fd2 = getFogDevices().get(j);

if(fd1.getId()!=fd2.getId()&& fd1.getParen-

tId()==fd2.getParentId()

&&calculateDistance(fd1, fd2)

TER_DISTANCE && fd1.getLevel()==fd2.getLevel())

{

int fd1ClusteriD = clusterInfo.get(fd1.getId());

int fd2ClusteriD = clusterInfo.get(fd2.getId());

if(fd1ClusteriD==-1 && fd2ClusteriD==-1){

clusterId++;

clusterInfo.put(fd1.getId(), clusterId);

clusterInfo.put(fd2.getId(), clusterId);

}

else if(fd1ClusteriD==-1)

clusterInfo.put(fd1.getId(), cluster-

Info.get(fd2.getId()));

else if(fd2ClusteriD==-1)

clusterInfo.put(fd2.getId(), cluster-

Info.get(fd1.getId()));

}

}

}

for(int id:clusterInfo.keySet()){

if(!clusters.containsKey(clusterInfo.get(id))){

ListclusterMembers = new ArrayList

ger>();

clusterMembers.add(id);

clusters.put(clusterInfo.get(id), clusterMembers);

}

else

{

ListclusterMembers = clusters.get(cluster-

Info.get(id));

clusterMembers.add(id);

clusters.put(clusterInfo.get(id), clusterMembers);

}

}

for(int id:clusters.keySet())

System.out.println(id+" "+clusters.get(id));

}

Inclusion in Controller constructor method:

formClusters();

Config Class:

public static final double CLUSTER_DISTANCE = 2.00;

Output

To make cluster of fog devices