Home

Awesome

pFogSim : A Simulator For Evaluating Dynamic and Layered Fog-Computing Environments

Last Edit by Clayton Johnson on 7/17/2018

What is pFogSim?

Quick Summary

How to Run

(May have to change some of the files mentioned to tailor for your stuff)

Creating Custom Scenarios

General Outline + Comments:

There are a ton of function calls not mentioned here that are necessary for the simulator to function, however are unnecessary to discuss in the context of the simulator as a whole. In honor of proper coding etiquette:

less is more

And with that said, here is everything on pFogSim. Most of the follow can be gathered from the code and attempts have been made to consistently document files, however documentation appears to be inadequate when using other simulators. If there needs to be further documentation, please let us know and it will be added quickly.

The Flow

DataInterpreterEdgeServerManagerGPSVectorMobilityNetworkTopologyClusteringPuddlesSimManagerSimLogger

Note: When I say mobile devices, I mean mobile devices, sensors, actuators; anything that is on the lowest level of the network and is interacting with the network.

DataInterpreter:

EdgeServerManager:

GPSVectorMobility:

NetworkTopology:

Clustering:

Puddles:

SimManager:

SimLogger:

Classes in Detail:

DataIntepreter Details:

Elements:

Methods:


EdgeServerManager Details:

What it does when it imports...:


GPSVectorMobility Details:

Elements:

Methods:


NetworkTopology Details:

Elements:

Methods:


Clustering Details:

Order of Operations:


Puddles Details:

Structure:

Definitely Read the Paper introducing this idea if you want to understand this idea in depth linked here (insert link)

SimManager Details:

Order of Operations:

//If the scheduled task has an id of PRINT_PROGRESS
case PRINT_PROGRESS:
  //Updates the positions of FOG Devices if necessary
  HashSet<Link> links = ((ESBModel)SimManager.getInstance().getNetworkModel()).getNetworkTopology().getLinks();
  Set<NodeSim> nodes = ((ESBModel)SimManager.getInstance().getNetworkModel()).getNetworkTopology().getMobileNodes();
  			
  ArrayList<Link> newLinks = new ArrayList<Link>();
  ArrayList<NodeSim> newNodes = new ArrayList<NodeSim>();
  for(NodeSim node : nodes) {
  	//Update positions
  	Location currentLoc = node.getLocation();
  	if(currentLoc.getXPos() + node.getVector().getXPos() > MAX_WIDTH) 
  		node.setVector(new Location(node.getVector().getXPos() * -1, node.getVector().getYPos()));
  	if(currentLoc.getYPos() + node.getVector().getYPos() > MAX_HEIGHT) 
  		node.setVector(new Location(node.getVector().getXPos(), node.getVector().getYPos() * -1));
  		
  	//Change links
  	for(Link link : links) {
  		if(link.getLeftLink().equals(currentLoc)) {
  			//Sets that location to what it will be in a bit
  			link.setLeftLink(new Location(currentLoc.getXPos() + node.getVector().getXPos(), currentLoc.getYPos() + node.getVector().getYPos()));
  			//SimLogger.printLine("Left Link changed");
  		}
  		else if(link.getRightLink().equals(currentLoc)) {
  			//Sets that location to what it will be in a bit
  			link.setRightLink(new Location(currentLoc.getXPos() + node.getVector().getXPos(), currentLoc.getYPos() + node.getVector().getYPos()));
  			//SimLogger.printLine("Right Link changed");
  		}
  	}
  	node.setLocation(new Location(currentLoc.getXPos() + node.getVector().getXPos(), currentLoc.getYPos() + node.getVector().getYPos()));
  }
  ((ESBModel) SimManager.getInstance().getNetworkModel()).getNetworkTopology().setMobileNode(nodes);
  //Goes through all devices and checks to see if WAP ids have changed
  double time = CloudSim.clock();
  for(int q = 0; q < mobilityModel.getSize(); q++) {
  	//If the id has changed, update the value in our list and move the cloudlet to a more appropriate VM
  	if(wapIdList[q] != mobilityModel.getWlanId(q, time)) {
  		wapIdList[q] = mobilityModel.getWlanId(q, time);
  		if (mobileDeviceManager.getCloudletList().size() > q) {
  			Task task = (Task) mobileDeviceManager.getCloudletList().get(q);
  			task.setSubmittedLocation(mobilityModel.getLocation(q, time));
  			mobileDeviceManager.migrateTask(task);
  		}
  	}
  }
  //Prints progress
  int progress = (int)((CloudSim.clock()*100)/SimSettings.getInstance().getSimulationTime());
  if(progress % 10 == 0)
  	SimLogger.print(Integer.toString(progress));
  else
  	SimLogger.print(".");
  if(CloudSim.clock() < SimSettings.getInstance().getSimulationTime())
  	schedule(getId(), SimSettings.getInstance().getSimulationTime()/100, PRINT_PROGRESS);
  break;

SimLogger Details: