Skip to content

Commit ee699a8

Browse files
Fixed minor issues in energy, mobility, and network models
1 parent 13623c7 commit ee699a8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1298
-136
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## Version 3.2 (jun 18th 2020)
4+
5+
* Improved mobility model (new attributes added in edge_devices.xml file).
6+
7+
* Fixed an energy model bug.
8+
9+
* Fixed a live charts bug.
10+
11+
* Fixed minor network model bug.
12+
313
## Version 3.1 (may 7th 2020)
414

515
* Fixed Bugs (CPU utilization when update interval is high >= 1).

PureEdgeSim/com/mechalikh/pureedgesim/DataCentersManager/DataCenter.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
/**
2+
* PureEdgeSim: A Simulation Framework for Performance Evaluation of Cloud, Edge and Mist Computing Environments
3+
*
4+
* This file is part of PureEdgeSim Project.
5+
*
6+
* PureEdgeSim is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* PureEdgeSim is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with PureEdgeSim. If not, see <http://www.gnu.org/licenses/>.
18+
*
19+
* @author Mechalikh
20+
**/
121
package com.mechalikh.pureedgesim.DataCentersManager;
222

323
import java.util.ArrayList;

PureEdgeSim/com/mechalikh/pureedgesim/DataCentersManager/DefaultDataCenter.java

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
/**
2+
* PureEdgeSim: A Simulation Framework for Performance Evaluation of Cloud, Edge and Mist Computing Environments
3+
*
4+
* This file is part of PureEdgeSim Project.
5+
*
6+
* PureEdgeSim is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* PureEdgeSim is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with PureEdgeSim. If not, see <http://www.gnu.org/licenses/>.
18+
*
19+
* @author Mechalikh
20+
**/
121
package com.mechalikh.pureedgesim.DataCentersManager;
222

323
import java.util.List;
@@ -42,22 +62,17 @@ public void processEvent(final SimEvent ev) {
4262

4363
private void updateStatus() {
4464

45-
// Update energy consumption
46-
updateEnergyConsumption();
65+
// Check if the device is dead
66+
if (getEnergyModel().isBattery()
67+
&& this.getEnergyModel().getTotalEnergyConsumption() > getEnergyModel().getBatteryCapacity()) {
68+
setDeath(true, simulationManager.getSimulation().clock());
69+
}
4770

4871
// Update location
4972
if (getMobilityManager().isMobile()) {
5073
getMobilityManager().getNextLocation();
5174
}
5275
}
5376

54-
private void updateEnergyConsumption() {
55-
// update the energy consumption
56-
getEnergyModel().updateCpuEnergyConsumption(getResources().getCurrentCpuUtilization());
57-
58-
if (getEnergyModel().isBattery()
59-
&& this.getEnergyModel().getTotalEnergyConsumption() > getEnergyModel().getBatteryCapacity()) {
60-
setDeath(true, simulationManager.getSimulation().clock());
61-
}
62-
}
77+
6378
}

PureEdgeSim/com/mechalikh/pureedgesim/DataCentersManager/DefaultEnergyModel.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
/**
2+
* PureEdgeSim: A Simulation Framework for Performance Evaluation of Cloud, Edge and Mist Computing Environments
3+
*
4+
* This file is part of PureEdgeSim Project.
5+
*
6+
* PureEdgeSim is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* PureEdgeSim is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with PureEdgeSim. If not, see <http://www.gnu.org/licenses/>.
18+
*
19+
* @author Mechalikh
20+
**/
121
package com.mechalikh.pureedgesim.DataCentersManager;
222

323
import com.mechalikh.pureedgesim.Network.FileTransferProgress;

PureEdgeSim/com/mechalikh/pureedgesim/DataCentersManager/EnergyModel.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
/**
2+
* PureEdgeSim: A Simulation Framework for Performance Evaluation of Cloud, Edge and Mist Computing Environments
3+
*
4+
* This file is part of PureEdgeSim Project.
5+
*
6+
* PureEdgeSim is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* PureEdgeSim is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with PureEdgeSim. If not, see <http://www.gnu.org/licenses/>.
18+
*
19+
* @author Mechalikh
20+
**/
121
package com.mechalikh.pureedgesim.DataCentersManager;
222

323
import com.mechalikh.pureedgesim.Network.FileTransferProgress;
@@ -58,7 +78,7 @@ public void setBatteryCapacity(double batteryCapacity) {
5878

5979
public double getBatteryLevel() {
6080
if (!isBattery())
61-
return 0;
81+
return 100;
6282
if (batteryCapacity < getTotalEnergyConsumption())
6383
return 0;
6484
return batteryCapacity - getTotalEnergyConsumption();

PureEdgeSim/com/mechalikh/pureedgesim/DataCentersManager/Resources.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
/**
2+
* PureEdgeSim: A Simulation Framework for Performance Evaluation of Cloud, Edge and Mist Computing Environments
3+
*
4+
* This file is part of PureEdgeSim Project.
5+
*
6+
* PureEdgeSim is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* PureEdgeSim is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with PureEdgeSim. If not, see <http://www.gnu.org/licenses/>.
18+
*
19+
* @author Mechalikh
20+
**/
121
package com.mechalikh.pureedgesim.DataCentersManager;
222

323
import org.cloudbus.cloudsim.core.Simulation;

PureEdgeSim/com/mechalikh/pureedgesim/DataCentersManager/ServersManager.java

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
/**
2+
* PureEdgeSim: A Simulation Framework for Performance Evaluation of Cloud, Edge and Mist Computing Environments
3+
*
4+
* This file is part of PureEdgeSim Project.
5+
*
6+
* PureEdgeSim is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* PureEdgeSim is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with PureEdgeSim. If not, see <http://www.gnu.org/licenses/>.
18+
*
19+
* @author Mechalikh
20+
**/
121
package com.mechalikh.pureedgesim.DataCentersManager;
222

323
import java.io.File;
@@ -165,13 +185,24 @@ private DataCenter createDatacenter(Element datacenterElement, SimulationParamet
165185
Constructor<?> energyConstructor = energyModel.getConstructor(double.class, double.class);
166186
datacenter.setEnergyModel(energyConstructor.newInstance(maxConsumption, idleConsumption));
167187
Boolean mobile = false;
188+
double speed = 0, minPauseDuration = 0, maxPauseDuration = 0, minMobilityDuration = 0, maxMobilityDuration = 0;
168189
if (type == SimulationParameters.TYPES.EDGE_DATACENTER) {
169190
Element location = (Element) datacenterElement.getElementsByTagName("location").item(0);
170191
x_position = Integer.parseInt(location.getElementsByTagName("x_pos").item(0).getTextContent());
171192
y_position = Integer.parseInt(location.getElementsByTagName("y_pos").item(0).getTextContent());
172193
datacenterLocation = new Location(x_position, y_position);
173194
} else if (type == SimulationParameters.TYPES.EDGE_DEVICE) {
174195
mobile = Boolean.parseBoolean(datacenterElement.getElementsByTagName("mobility").item(0).getTextContent());
196+
speed = Double
197+
.parseDouble(datacenterElement.getElementsByTagName("speed").item(0).getTextContent());
198+
minPauseDuration = Double
199+
.parseDouble(datacenterElement.getElementsByTagName("minPauseDuration").item(0).getTextContent());
200+
maxPauseDuration = Double
201+
.parseDouble(datacenterElement.getElementsByTagName("maxPauseDuration").item(0).getTextContent());
202+
minMobilityDuration = Double.parseDouble(
203+
datacenterElement.getElementsByTagName("minMobilityDuration").item(0).getTextContent());
204+
maxMobilityDuration = Double.parseDouble(
205+
datacenterElement.getElementsByTagName("maxMobilityDuration").item(0).getTextContent());
175206
datacenter.getEnergyModel().setBattery(
176207
Boolean.parseBoolean(datacenterElement.getElementsByTagName("battery").item(0).getTextContent()));
177208
datacenter.getEnergyModel().setBatteryCapacity(Double
@@ -184,11 +215,11 @@ private DataCenter createDatacenter(Element datacenterElement, SimulationParamet
184215
getSimulationManager().getSimulationLogger().deepLog("ServersManager- Edge device:" + datacentersList.size()
185216
+ " location: ( " + datacenterLocation.getXPos() + "," + datacenterLocation.getYPos() + " )");
186217
}
187-
188218
datacenter.setType(type);
189-
Constructor<?> mobilityConstructor = mobilityManager.getConstructor(Location.class);
190-
datacenter.setMobilityManager(mobilityConstructor.newInstance(datacenterLocation));
191-
datacenter.getMobilityManager().setMobile(mobile);
219+
Constructor<?> mobilityConstructor = mobilityManager.getConstructor(Location.class, boolean.class, double.class,double.class,
220+
double.class, double.class, double.class);
221+
datacenter.setMobilityManager(mobilityConstructor.newInstance(datacenterLocation, mobile, speed, minPauseDuration,
222+
maxPauseDuration, minMobilityDuration, maxMobilityDuration));
192223
return datacenter;
193224
}
194225

@@ -257,7 +288,7 @@ private void loadVms(Host host, Element hostElement, long bandwidth, List<Vm> li
257288
: new CloudletSchedulerTimeShared();
258289

259290
Vm vm = new VmSimple(vmList.size(), vmMips, vmNumOfCores);
260-
vm.setRam(vmRam).setBw(vmBandwidth).setSize(vmStorage).setCloudletScheduler(tasksScheduler);
291+
vm.setRam(vmRam).setBw(vmBandwidth).setSize(vmStorage).setCloudletScheduler(tasksScheduler);
261292
vm.setHost(host);
262293
vmList.add(vm);
263294
list.add(vm);

PureEdgeSim/com/mechalikh/pureedgesim/LocationManager/DefaultMobilityModel.java

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
/**
2+
* PureEdgeSim: A Simulation Framework for Performance Evaluation of Cloud, Edge and Mist Computing Environments
3+
*
4+
* This file is part of PureEdgeSim Project.
5+
*
6+
* PureEdgeSim is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* PureEdgeSim is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with PureEdgeSim. If not, see <http://www.gnu.org/licenses/>.
18+
*
19+
* @author Mechalikh
20+
**/
121
package com.mechalikh.pureedgesim.LocationManager;
222

323
import java.util.Random;
@@ -7,11 +27,15 @@
727
public class DefaultMobilityModel extends Mobility {
828
private boolean pause = false;
929
private double pauseDuration = -1;
10-
private double mobilityDuration = new Random().nextInt(100);
30+
private double mobilityDuration = (maxMobilityDuration - minMobilityDuration) > 0
31+
? new Random().nextInt((int) (maxMobilityDuration - minMobilityDuration)) + minMobilityDuration
32+
: 0;
1133
private int orientationAngle = new Random().nextInt(359);
1234

13-
public DefaultMobilityModel(Location currentLocation) {
14-
super(currentLocation);
35+
public DefaultMobilityModel(Location currentLocation, boolean mobile, double speed, double minPauseDuration,
36+
double maxPauseDuration, double minMobilityDuration, double maxMobilityDuration) {
37+
super(currentLocation, mobile, speed, minPauseDuration, maxPauseDuration, minMobilityDuration,
38+
maxMobilityDuration);
1539
}
1640

1741
public DefaultMobilityModel() {
@@ -20,7 +44,7 @@ public DefaultMobilityModel() {
2044

2145
@Override
2246
public Location getNextLocation() {
23-
if (SimulationParameters.SPEED <= 0 || !isMobile)
47+
if (speed <= 0 || !isMobile)
2448
return currentLocation; // The speed must be > 0 in order to move/change the location
2549

2650
double X_position = currentLocation.getXPos(); // Get the initial X coordinate assigned to this device
@@ -49,7 +73,7 @@ public Location getNextLocation() {
4973
}
5074

5175
private Location updateLocation(double X_position, double Y_position) {
52-
double distance = SimulationParameters.SPEED * SimulationParameters.UPDATE_INTERVAL;
76+
double distance = speed * SimulationParameters.UPDATE_INTERVAL;
5377
double X_distance = Math.cos(Math.toRadians(orientationAngle)) * distance;
5478
double Y_distance = Math.sin(Math.toRadians(orientationAngle)) * distance;
5579
// Update the X_position
@@ -68,7 +92,7 @@ private void resume() {
6892

6993
private void pause() {
7094
// Pickup random duration from 50 to 200 seconds
71-
pauseDuration = 50 + new Random().nextInt(100);
95+
pauseDuration = minPauseDuration + new Random().nextInt((int) (maxPauseDuration - minPauseDuration));
7296
// Pause mobility (the device will stay in its location for the randomly
7397
// generated duration
7498
pause = true;

PureEdgeSim/com/mechalikh/pureedgesim/LocationManager/Location.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
/**
2+
* PureEdgeSim: A Simulation Framework for Performance Evaluation of Cloud, Edge and Mist Computing Environments
3+
*
4+
* This file is part of PureEdgeSim Project.
5+
*
6+
* PureEdgeSim is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* PureEdgeSim is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with PureEdgeSim. If not, see <http://www.gnu.org/licenses/>.
18+
*
19+
* @author Mechalikh
20+
**/
121
package com.mechalikh.pureedgesim.LocationManager;
222

323
public class Location {

0 commit comments

Comments
 (0)