2

I'm working on Cloudsim. How can I delay the cloudlet submission by 30 seconds? After the first cloudlet is submitted after 30 seconds, the second cloudlet has to start the execution.

Is there any way to do this?

Pika Supports Ukraine
  • 3,612
  • 10
  • 26
  • 42
anil Kumar
  • 31
  • 4

4 Answers4

1

To add some delay between cloudlets in CloudSim you need to acess the method "submitCloudLets" in the class "DatacenterBroker". In method "submitCloudlets" you need to acess and edit the method "sendNow". The following example code should be inserted:

protected void sendNow(int entityId, int cloudSimTag, Object data) {
    if(cloudSimTag==CloudSimTags.CLOUDLET_SUBMIT){               
          send(entityId, delay /* enter your delay value here or call a method that calculates the delay value randomly */, cloudSimTag, data);
    }
    else send(entityId, 0, cloudSimTag, data); // CASE the cloudsim tag was not "CLOUDLET_SUBMIT". !!! If you remove this line, your program does not work!!!!
 }
0

I am not sure about the api of Cloudsim, if you just need to add time delay using code, you can do that using java too..

use

Thread.sleep(3000);

You can read more about it at the documentation http://docs.oracle.com/javase/6/docs/api/java/lang/Thread.html#sleep(long, int)

AurA
  • 12,135
  • 7
  • 46
  • 63
  • 1
    This wouldn't work. CloudSim is an event based simulation, the concept of elapsed simulated time is completely decoupled from the actually elapsed time running the program. – cw' Jun 06 '18 at 12:04
-1

In datacenter broker class in submitCloudlets method comment the SendNow function and use send function.

This function has a Delay parameter. Change delay to time which you want. Then if you use getSubmissionTime of the cloudlet you get This Parameter.

gvlasov
  • 18,638
  • 21
  • 74
  • 110
M_R
  • 1
  • 1
  • 1
-1

CloudSim Plus supports such a feature natively. You just need to make this single method call broker.submitCloudletList(cloudletList, submissionDelay) and the Cloudlets will be submitted only after the given delay (in seconds).

This way, you don't need to change the framework code to implement such a basic feature. If you change a framework's class to include a basic feature to be used just for your simulation, you may struggle to update your fork of the framework with the latest versions.

Check feature #8 at https://cloudsimplus.org#main-exclusive-features for more details.

Manoel Campos
  • 933
  • 9
  • 12
  • 1
    exactly, it's really easy on CloudSim Plus. As Manoel said you have to use ```broker.submitCloudletList(cloudletList, submissionDelay);```. – Panagiss Jan 02 '21 at 15:57