major modifications for v2.0 release

Release notes

1- Cloud server processing was simplified in the initial version, it is handled via cloudsim components now.

2- Cloud server manager, edge server manager, mobile device manager and vm allocation policy are used as abstract class in factory pattern to allow developers to use different business logic without modifying EdgeCloudSim source code.

3- The task and place types are no longer defined as enumeration. They are used as integer value in order to manipulate more place type without modifying enum variable.

4- Two sample applications (one of them is simple and the other one extended application) are added along with the corresponding matlab files to plot statistics.

5- Cloud server properties are added to the simulation settings file

6- New log items are added to simulation result files

7- Code refactoring is applied including the modification of comments
This commit is contained in:
Cagatay Sonmez
2018-09-10 14:22:27 +03:00
parent e01833bda6
commit d4545f009f
89 changed files with 10699 additions and 4689 deletions

View File

@@ -1,222 +1,223 @@
/*
* Title: EdgeCloudSim - M/M/1 Queue model implementation
*
* Description:
* MM1Queue implements M/M/1 Queue model for WLAN and WAN communication
*
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* Copyright (c) 2017, Bogazici University, Istanbul, Turkey
*/
package edu.boun.edgecloudsim.network;
import org.cloudbus.cloudsim.core.CloudSim;
import edu.boun.edgecloudsim.core.SimManager;
import edu.boun.edgecloudsim.core.SimSettings;
import edu.boun.edgecloudsim.edge_server.EdgeHost;
import edu.boun.edgecloudsim.utils.Location;
public class MM1Queue extends NetworkModel {
private double WlanPoissonMean; //seconds
private double WanPoissonMean; //seconds
private double avgTaskInputSize; //bytes
private double avgTaskOutputSize; //bytes
private int maxNumOfClientsInPlace;
public MM1Queue(int _numberOfMobileDevices) {
super(_numberOfMobileDevices);
}
@Override
public void initialize() {
WlanPoissonMean=0;
WanPoissonMean=0;
avgTaskInputSize=0;
avgTaskOutputSize=0;
maxNumOfClientsInPlace=0;
//Calculate interarrival time and task sizes
double numOfTaskType = 0;
SimSettings SS = SimSettings.getInstance();
for (SimSettings.APP_TYPES taskType : SimSettings.APP_TYPES.values()) {
double weight = SS.getTaskLookUpTable()[taskType.ordinal()][0]/(double)100;
if(weight != 0) {
WlanPoissonMean += (SS.getTaskLookUpTable()[taskType.ordinal()][2])*weight;
double percentageOfCloudCommunication = SS.getTaskLookUpTable()[taskType.ordinal()][1];
WanPoissonMean += (WlanPoissonMean)*((double)100/percentageOfCloudCommunication)*weight;
avgTaskInputSize += SS.getTaskLookUpTable()[taskType.ordinal()][5]*weight;
avgTaskOutputSize += SS.getTaskLookUpTable()[taskType.ordinal()][6]*weight;
numOfTaskType++;
}
}
WlanPoissonMean = WlanPoissonMean/numOfTaskType;
avgTaskInputSize = avgTaskInputSize/numOfTaskType;
avgTaskOutputSize = avgTaskOutputSize/numOfTaskType;
}
/**
* source device is always mobile device in our simulation scenarios!
*/
@Override
public double getUploadDelay(int sourceDeviceId, int destDeviceId, double dataSize) {
double delay = 0;
Location accessPointLocation = SimManager.getInstance().getMobilityModel().getLocation(sourceDeviceId,CloudSim.clock());
//mobile device to cloud server
if(destDeviceId == SimSettings.CLOUD_DATACENTER_ID){
double wlanDelay = getWlanUploadDelay(accessPointLocation, CloudSim.clock());
double wanDelay = getWanUploadDelay(accessPointLocation, CloudSim.clock() + wlanDelay);
if(wlanDelay > 0 && wanDelay >0)
delay = wlanDelay + wanDelay;
}
//mobile device to edge orchestrator
else if(destDeviceId == SimSettings.EDGE_ORCHESTRATOR_ID){
delay = getWlanUploadDelay(accessPointLocation, CloudSim.clock()) +
SimSettings.getInstance().getInternalLanDelay();
}
//mobile device to edge device (wifi access point)
else if (destDeviceId == SimSettings.GENERIC_EDGE_DEVICE_ID) {
delay = getWlanUploadDelay(accessPointLocation, CloudSim.clock());
}
return delay;
}
/**
* destination device is always mobile device in our simulation scenarios!
*/
@Override
public double getDownloadDelay(int sourceDeviceId, int destDeviceId, double dataSize) {
//Special Case -> edge orchestrator to edge device
if(sourceDeviceId == SimSettings.EDGE_ORCHESTRATOR_ID &&
destDeviceId == SimSettings.GENERIC_EDGE_DEVICE_ID){
return SimSettings.getInstance().getInternalLanDelay();
}
double delay = 0;
Location accessPointLocation = SimManager.getInstance().getMobilityModel().getLocation(destDeviceId,CloudSim.clock());
//cloud server to mobile device
if(sourceDeviceId == SimSettings.CLOUD_DATACENTER_ID){
double wlanDelay = getWlanDownloadDelay(accessPointLocation, CloudSim.clock());
double wanDelay = getWanDownloadDelay(accessPointLocation, CloudSim.clock() + wlanDelay);
if(wlanDelay > 0 && wanDelay >0)
delay = wlanDelay + wanDelay;
}
//edge device (wifi access point) to mobile device
else{
delay = getWlanDownloadDelay(accessPointLocation, CloudSim.clock());
EdgeHost host = (EdgeHost)(SimManager.
getInstance().
getLocalServerManager().
getDatacenterList().get(sourceDeviceId).
getHostList().get(0));
//if source device id is the edge server which is located in another location, add internal lan delay
//in our scenasrio, serving wlan ID is equal to the host id, because there is only one host in one place
if(host.getLocation().getServingWlanId() != accessPointLocation.getServingWlanId())
delay += (SimSettings.getInstance().getInternalLanDelay() * 2);
}
return delay;
}
public int getMaxNumOfClientsInPlace(){
return maxNumOfClientsInPlace;
}
private int getDeviceCount(Location deviceLocation, double time){
int deviceCount = 0;
for(int i=0; i<numberOfMobileDevices; i++) {
Location location = SimManager.getInstance().getMobilityModel().getLocation(i,time);
if(location.equals(deviceLocation))
deviceCount++;
}
//record max number of client just for debugging
if(maxNumOfClientsInPlace<deviceCount)
maxNumOfClientsInPlace = deviceCount;
return deviceCount;
}
private double calculateMM1(double propogationDelay, int bandwidth /*Kbps*/, double PoissonMean, double avgTaskSize /*KB*/, int deviceCount){
double Bps=0, mu=0, lamda=0;
avgTaskSize = avgTaskSize * (double)1000; //convert from KB to Byte
Bps = bandwidth * (double)1000 / (double)8; //convert from Kbps to Byte per seconds
lamda = ((double)1/(double)PoissonMean); //task per seconds
mu = Bps / avgTaskSize ; //task per seconds
double result = (double)1 / (mu-lamda*(double)deviceCount);
result += propogationDelay;
return (result > 5) ? -1 : result;
}
private double getWlanDownloadDelay(Location accessPointLocation, double time) {
return calculateMM1(0,
SimSettings.getInstance().getWlanBandwidth(),
WlanPoissonMean,
avgTaskOutputSize,
getDeviceCount(accessPointLocation, time));
}
private double getWlanUploadDelay(Location accessPointLocation, double time) {
return calculateMM1(0,
SimSettings.getInstance().getWlanBandwidth(),
WlanPoissonMean,
avgTaskInputSize,
getDeviceCount(accessPointLocation, time));
}
private double getWanDownloadDelay(Location accessPointLocation, double time) {
return calculateMM1(SimSettings.getInstance().getWanPropogationDelay(),
SimSettings.getInstance().getWanBandwidth(),
WanPoissonMean,
avgTaskOutputSize,
getDeviceCount(accessPointLocation, time));
}
private double getWanUploadDelay(Location accessPointLocation, double time) {
return calculateMM1(SimSettings.getInstance().getWanPropogationDelay(),
SimSettings.getInstance().getWanBandwidth(),
WanPoissonMean,
avgTaskInputSize,
getDeviceCount(accessPointLocation, time));
}
@Override
public void uploadStarted(Location accessPointLocation, int destDeviceId) {
// TODO Auto-generated method stub
}
@Override
public void uploadFinished(Location accessPointLocation, int destDeviceId) {
// TODO Auto-generated method stub
}
@Override
public void downloadStarted(Location accessPointLocation, int sourceDeviceId) {
// TODO Auto-generated method stub
}
@Override
public void downloadFinished(Location accessPointLocation, int sourceDeviceId) {
// TODO Auto-generated method stub
}
}
/*
* Title: EdgeCloudSim - M/M/1 Queue model implementation
*
* Description:
* MM1Queue implements M/M/1 Queue model for WLAN and WAN communication
*
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* Copyright (c) 2017, Bogazici University, Istanbul, Turkey
*/
package edu.boun.edgecloudsim.network;
import org.cloudbus.cloudsim.core.CloudSim;
import edu.boun.edgecloudsim.core.SimManager;
import edu.boun.edgecloudsim.core.SimSettings;
import edu.boun.edgecloudsim.edge_client.Task;
import edu.boun.edgecloudsim.edge_server.EdgeHost;
import edu.boun.edgecloudsim.utils.Location;
public class MM1Queue extends NetworkModel {
private double WlanPoissonMean; //seconds
private double WanPoissonMean; //seconds
private double avgTaskInputSize; //bytes
private double avgTaskOutputSize; //bytes
private int maxNumOfClientsInPlace;
public MM1Queue(int _numberOfMobileDevices, String _simScenario) {
super(_numberOfMobileDevices, _simScenario);
}
@Override
public void initialize() {
WlanPoissonMean=0;
WanPoissonMean=0;
avgTaskInputSize=0;
avgTaskOutputSize=0;
maxNumOfClientsInPlace=0;
//Calculate interarrival time and task sizes
double numOfTaskType = 0;
SimSettings SS = SimSettings.getInstance();
for (int i=0; i<SimSettings.getInstance().getTaskLookUpTable().length; i++) {
double weight = SS.getTaskLookUpTable()[i][0]/(double)100;
if(weight != 0) {
WlanPoissonMean += (SS.getTaskLookUpTable()[i][2])*weight;
double percentageOfCloudCommunication = SS.getTaskLookUpTable()[i][1];
WanPoissonMean += (WlanPoissonMean)*((double)100/percentageOfCloudCommunication)*weight;
avgTaskInputSize += SS.getTaskLookUpTable()[i][5]*weight;
avgTaskOutputSize += SS.getTaskLookUpTable()[i][6]*weight;
numOfTaskType++;
}
}
WlanPoissonMean = WlanPoissonMean/numOfTaskType;
avgTaskInputSize = avgTaskInputSize/numOfTaskType;
avgTaskOutputSize = avgTaskOutputSize/numOfTaskType;
}
/**
* source device is always mobile device in our simulation scenarios!
*/
@Override
public double getUploadDelay(int sourceDeviceId, int destDeviceId, Task task) {
double delay = 0;
Location accessPointLocation = SimManager.getInstance().getMobilityModel().getLocation(sourceDeviceId,CloudSim.clock());
//mobile device to cloud server
if(destDeviceId == SimSettings.CLOUD_DATACENTER_ID){
double wlanDelay = getWlanUploadDelay(accessPointLocation, CloudSim.clock());
double wanDelay = getWanUploadDelay(accessPointLocation, CloudSim.clock() + wlanDelay);
if(wlanDelay > 0 && wanDelay >0)
delay = wlanDelay + wanDelay;
}
//mobile device to edge orchestrator
else if(destDeviceId == SimSettings.EDGE_ORCHESTRATOR_ID){
delay = getWlanUploadDelay(accessPointLocation, CloudSim.clock()) +
SimSettings.getInstance().getInternalLanDelay();
}
//mobile device to edge device (wifi access point)
else if (destDeviceId == SimSettings.GENERIC_EDGE_DEVICE_ID) {
delay = getWlanUploadDelay(accessPointLocation, CloudSim.clock());
}
return delay;
}
/**
* destination device is always mobile device in our simulation scenarios!
*/
@Override
public double getDownloadDelay(int sourceDeviceId, int destDeviceId, Task task) {
//Special Case -> edge orchestrator to edge device
if(sourceDeviceId == SimSettings.EDGE_ORCHESTRATOR_ID &&
destDeviceId == SimSettings.GENERIC_EDGE_DEVICE_ID){
return SimSettings.getInstance().getInternalLanDelay();
}
double delay = 0;
Location accessPointLocation = SimManager.getInstance().getMobilityModel().getLocation(destDeviceId,CloudSim.clock());
//cloud server to mobile device
if(sourceDeviceId == SimSettings.CLOUD_DATACENTER_ID){
double wlanDelay = getWlanDownloadDelay(accessPointLocation, CloudSim.clock());
double wanDelay = getWanDownloadDelay(accessPointLocation, CloudSim.clock() + wlanDelay);
if(wlanDelay > 0 && wanDelay >0)
delay = wlanDelay + wanDelay;
}
//edge device (wifi access point) to mobile device
else{
delay = getWlanDownloadDelay(accessPointLocation, CloudSim.clock());
EdgeHost host = (EdgeHost)(SimManager.
getInstance().
getEdgeServerManager().
getDatacenterList().get(sourceDeviceId).
getHostList().get(0));
//if source device id is the edge server which is located in another location, add internal lan delay
//in our scenasrio, serving wlan ID is equal to the host id, because there is only one host in one place
if(host.getLocation().getServingWlanId() != accessPointLocation.getServingWlanId())
delay += (SimSettings.getInstance().getInternalLanDelay() * 2);
}
return delay;
}
public int getMaxNumOfClientsInPlace(){
return maxNumOfClientsInPlace;
}
private int getDeviceCount(Location deviceLocation, double time){
int deviceCount = 0;
for(int i=0; i<numberOfMobileDevices; i++) {
Location location = SimManager.getInstance().getMobilityModel().getLocation(i,time);
if(location.equals(deviceLocation))
deviceCount++;
}
//record max number of client just for debugging
if(maxNumOfClientsInPlace<deviceCount)
maxNumOfClientsInPlace = deviceCount;
return deviceCount;
}
private double calculateMM1(double propogationDelay, int bandwidth /*Kbps*/, double PoissonMean, double avgTaskSize /*KB*/, int deviceCount){
double Bps=0, mu=0, lamda=0;
avgTaskSize = avgTaskSize * (double)1000; //convert from KB to Byte
Bps = bandwidth * (double)1000 / (double)8; //convert from Kbps to Byte per seconds
lamda = ((double)1/(double)PoissonMean); //task per seconds
mu = Bps / avgTaskSize ; //task per seconds
double result = (double)1 / (mu-lamda*(double)deviceCount);
result += propogationDelay;
return (result > 5) ? -1 : result;
}
private double getWlanDownloadDelay(Location accessPointLocation, double time) {
return calculateMM1(0,
SimSettings.getInstance().getWlanBandwidth(),
WlanPoissonMean,
avgTaskOutputSize,
getDeviceCount(accessPointLocation, time));
}
private double getWlanUploadDelay(Location accessPointLocation, double time) {
return calculateMM1(0,
SimSettings.getInstance().getWlanBandwidth(),
WlanPoissonMean,
avgTaskInputSize,
getDeviceCount(accessPointLocation, time));
}
private double getWanDownloadDelay(Location accessPointLocation, double time) {
return calculateMM1(SimSettings.getInstance().getWanPropogationDelay(),
SimSettings.getInstance().getWanBandwidth(),
WanPoissonMean,
avgTaskOutputSize,
getDeviceCount(accessPointLocation, time));
}
private double getWanUploadDelay(Location accessPointLocation, double time) {
return calculateMM1(SimSettings.getInstance().getWanPropogationDelay(),
SimSettings.getInstance().getWanBandwidth(),
WanPoissonMean,
avgTaskInputSize,
getDeviceCount(accessPointLocation, time));
}
@Override
public void uploadStarted(Location accessPointLocation, int destDeviceId) {
// TODO Auto-generated method stub
}
@Override
public void uploadFinished(Location accessPointLocation, int destDeviceId) {
// TODO Auto-generated method stub
}
@Override
public void downloadStarted(Location accessPointLocation, int sourceDeviceId) {
// TODO Auto-generated method stub
}
@Override
public void downloadFinished(Location accessPointLocation, int sourceDeviceId) {
// TODO Auto-generated method stub
}
}

View File

@@ -1,48 +1,51 @@
/*
* Title: EdgeCloudSim - Network Model
*
* Description:
* NetworkModel is an abstract class which is used for calculating the
* network delay from device to device. For those who wants to add a
* custom Network Model to EdgeCloudSim should extend this class and
* provide a concreate instance via ScenarioFactory
*
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* Copyright (c) 2017, Bogazici University, Istanbul, Turkey
*/
package edu.boun.edgecloudsim.network;
import edu.boun.edgecloudsim.utils.Location;
public abstract class NetworkModel {
protected int numberOfMobileDevices;
public NetworkModel(int _numberOfMobileDevices){
numberOfMobileDevices=_numberOfMobileDevices;
};
/**
* initializes costom network model
*/
public abstract void initialize();
/**
* calculates the upload delay from source to destination device
*/
public abstract double getUploadDelay(int sourceDeviceId, int destDeviceId, double dataSize);
/**
* calculates the download delay from source to destination device
*/
public abstract double getDownloadDelay(int sourceDeviceId, int destDeviceId, double dataSize);
/**
* Mobile device manager should inform network manager about the network operation
* This information may be important for some network delay models
*/
public abstract void uploadStarted(Location accessPointLocation, int destDeviceId);
public abstract void uploadFinished(Location accessPointLocation, int destDeviceId);
public abstract void downloadStarted(Location accessPointLocation, int sourceDeviceId);
public abstract void downloadFinished(Location accessPointLocation, int sourceDeviceId);
}
/*
* Title: EdgeCloudSim - Network Model
*
* Description:
* NetworkModel is an abstract class which is used for calculating the
* network delay from device to device. For those who wants to add a
* custom Network Model to EdgeCloudSim should extend this class and
* provide a concreate instance via ScenarioFactory
*
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* Copyright (c) 2017, Bogazici University, Istanbul, Turkey
*/
package edu.boun.edgecloudsim.network;
import edu.boun.edgecloudsim.edge_client.Task;
import edu.boun.edgecloudsim.utils.Location;
public abstract class NetworkModel {
protected int numberOfMobileDevices;
protected String simScenario;
public NetworkModel(int _numberOfMobileDevices, String _simScenario){
numberOfMobileDevices=_numberOfMobileDevices;
simScenario = _simScenario;
};
/**
* initializes custom network model
*/
public abstract void initialize();
/**
* calculates the upload delay from source to destination device
*/
public abstract double getUploadDelay(int sourceDeviceId, int destDeviceId, Task task);
/**
* calculates the download delay from source to destination device
*/
public abstract double getDownloadDelay(int sourceDeviceId, int destDeviceId, Task task);
/**
* Mobile device manager should inform network manager about the network operation
* This information may be important for some network delay models
*/
public abstract void uploadStarted(Location accessPointLocation, int destDeviceId);
public abstract void uploadFinished(Location accessPointLocation, int destDeviceId);
public abstract void downloadStarted(Location accessPointLocation, int sourceDeviceId);
public abstract void downloadFinished(Location accessPointLocation, int sourceDeviceId);
}