How to Launch Stealthy Denial of Service(DoS) Attack using CloudSim?
Share
Condition for Launch Stealthy Denial of Service(DoS) Attack using CloudSim
Description: To simulate a stealthy DoS attack in CloudSim, create a cloud environment with a datacenter, hosts, and VMs. Introduce an attacker as a broker submitting malicious cloudlets with high resource demands, competing with normal users for resources. This causes bottlenecks, reducing resource availability for legitimate tasks. Using CloudSim's event-driven simulation, then can analyze the impact on task execution times, delays, or failures, demonstrating how such attacks disrupt cloud service availability.
Normal User Workflow: The normal broker submits a list of VMs and cloudlets with moderate requirements.
Malicious User Workflow: The attacker broker submits a small number of malicious VMs. The cloudlets from the attacker have abnormally high resource requirements (e.g., long runtimes, high memory, bandwidth).
Stealthy DoS Attack: The malicious cloudlets create a resource bottleneck by consuming excessive CPU, RAM, or bandwidth. Other users (normal broker) face delays or failures due to resource contention.
Sample Code
import org.cloudbus.cloudsim.*;
import org.cloudbus.cloudsim.core.CloudSim;
import java.util.*;
import org.cloudbus.cloudsim.provisioners.*;
public class StealthyDosSimulation {
public static void main(String[] args) {
try {
// Initialize the CloudSim package
int numUsers = 2; // Normal user and attacker
Calendar calendar = Calendar.getInstance();
boolean traceFlag = false;
// Initialize the CloudSim simulation
CloudSim.init(numUsers, calendar, traceFlag);
// Create Datacenter
Datacenter datacenter = createDatacenter("Datacenter_1");
// Create Brokers
DatacenterBroker normalBroker = createBroker("NormalUser");
DatacenterBroker attackerBroker = createBroker("Attacker");
// Create VMs and Cloudlets for normal user
List normalVmList = createVMs(normalBroker.getId(), 3); // 3 VMs
normalBroker.submitVmList(normalVmList);
List normalCloudletList = createCloudlets(normalBroker.getId(), 6); // 6 Cloudlets
normalBroker.submitCloudletList(normalCloudletList);
// Create malicious VMs and Cloudlets for attacker
List attackerVmList = createVMs(attackerBroker.getId(), 1); // 1 malicious VM
attackerBroker.submitVmList(attackerVmList);
List attackerCloudletList = createMaliciousCloudlets(attackerBroker.getId(), 5); // 5 Malicious Cloudlets
attackerBroker.submitCloudletList(attackerCloudletList);
// Start the simulation
CloudSim.startSimulation();
// Print results of the simulation
printCloudletResults(normalBroker.getCloudletReceivedList(), "Normal User");
printCloudletResults(attackerBroker.getCloudletReceivedList(), "Attacker");
// Stop the simulation
CloudSim.stopSimulation();
} catch (Exception e) {
e.printStackTrace();
}
}
// Method to create a Datacenter
private static Datacenter createDatacenter(String name) {
List hostList = new ArrayList<>();
List peList = new ArrayList<>();
// Create PEs (Processing Elements)
for (int i = 0; i < 4; i++) {
peList.add(new Pe(i, new PeProvisionerSimple(1000))); // 1000 MIPS
}
// Create Hosts
hostList.add(new Host(
0,
new RamProvisionerSimple(8192), // 8 GB RAM
new BwProvisionerSimple(10000), // 10 Gbps Bandwidth
1000000, // 1 TB Storage
peList,
new VmSchedulerTimeShared(peList)
));
// Define Datacenter characteristics
String arch = "x86";
String os = "Linux";
String vmm = "Xen";
double timeZone = 10.0;
double costPerSec = 3.0;
double costPerMem = 0.05;
double costPerStorage = 0.1;
double costPerBw = 0.1;
DatacenterCharacteristics characteristics = new DatacenterCharacteristics(
arch, os, vmm, hostList, timeZone, costPerSec, costPerMem, costPerStorage, costPerBw);
Datacenter datacenter = null;
try {
datacenter = new Datacenter(name, characteristics, new VmAllocationPolicySimple(hostList), new LinkedList<>(), 0);
} catch (Exception e) {
e.printStackTrace();
}
return datacenter;
}
// Method to create a broker
private static DatacenterBroker createBroker(String name) {
DatacenterBroker broker = null;
try {
broker = new DatacenterBroker(name);
} catch (Exception e) {
e.printStackTrace();
}
return broker;
}
// Method to create normal VMs
private static List createVMs(int brokerId, int count) {
List vms = new ArrayList<>();
for (int i = 0; i < count; i++) {
vms.add(new Vm(i, brokerId, 1000, 2, 2048, 1000, 10000, "Xen", new CloudletSchedulerTimeShared()));
}
return vms;
}
// Method to create normal Cloudlets
private static List createCloudlets(int brokerId, int count) {
List cloudlets = new ArrayList<>();
for (int i = 0; i < count; i++) {
cloudlets.add(new Cloudlet(i, 1000, 2, 300, 300, new UtilizationModelFull(), new UtilizationModelFull(), new UtilizationModelFull()));
cloudlets.get(i).setUserId(brokerId);
}
return cloudlets;
}
// Method to create malicious Cloudlets
private static List createMaliciousCloudlets(int brokerId, int count) {
List cloudlets = new ArrayList<>();
for (int i = 0; i < count; i++) {
cloudlets.add(new Cloudlet(i + 1000, 50000, 2, 10000, 10000, new UtilizationModelFull(), new UtilizationModelFull(), new UtilizationModelFull()));
cloudlets.get(i).setUserId(brokerId);
}
return cloudlets;
}
// Method to print the results of the simulation
private static void printCloudletResults(List list, String userType) {
System.out.println("========== " + userType + " Results ==========");
for (Cloudlet cloudlet : list) {
System.out.println("Cloudlet ID: " + cloudlet.getCloudletId() + ", Status: " + (cloudlet.getStatus() == Cloudlet.SUCCESS ? "SUCCESS" : "FAILED"));
}
}
}