CloudSim仿真流程

CloudSim基礎仿真流程總結

這是在閱讀CloudSim Example1用例代碼後,對CloudSim仿真流程的一點總結

類總結:

  1. DataCenter類 ,數據中心,提供虛擬化網絡資源 (所有的Host必須綁定到DataCenter,並且必須保證每個數據中心至少創建一個Host)
  2. DataCenterBroker類 ,代理,用於提交虛擬機列表和雲任務列表(虛擬機和雲應用在內的資源)
  3. Host類 主機(物理機),擴展了對虛擬機的參數分配策略,一臺Host可以對應對臺VM
  4. VM類 虛擬機類,運行在Host上,與其他虛擬機共享資源
  5. Cloudlet類 雲任務類,構建雲環境任務
  6. 待補充。

流程

  • 初始化CloudSim
  • 創建數據中心Datacenter
  • 創建用戶代理Broker
  • 創建虛擬機VM,添加至Broker
  • 創建應用Cloudlet,添加至Broker
  • 開啓仿真
  • 結束模擬仿真
  • 打印輸出

相關參數

Host

參數:id、內存、帶寬、儲存容量、cpu。。

		int hostId = 0;
		int ram = 2048; // host memory (MB)
		long storage = 1000000; // host storage
		int bw = 10000;

hostList.add(
			new Host(
				hostId,
				new RamProvisionerSimple(ram),
				new BwProvisionerSimple(bw),
				storage,
				peList,
				new VmSchedulerTimeShared(peList)
			)
		); 

DataCenter

參數:主機架構、操作系統、虛擬機監視器種類??、時區、cpu的使用費用、內存的使用費用、storage的使用費用、帶寬的使用費用

		String arch = "x86"; // system architecture
		String os = "Linux"; // operating system
		String vmm = "Xen";
		double time_zone = 10.0; // time zone this resource located
		double cost = 3.0; // the cost of using processing in this resource
		double costPerMem = 0.05; // the cost of using memory in this resource
		double costPerStorage = 0.001; // the cost of using storage in this
										// resource
		double costPerBw = 0.0; // the cost of using bw in this resource
		LinkedList<Storage> storageList = new LinkedList<Storage>(); // we are not adding SAN
													// devices by now

		DatacenterCharacteristics characteristics = new DatacenterCharacteristics(
				arch, os, vmm, hostList, time_zone, cost, costPerMem,
				costPerStorage, costPerBw);  創建數據中心特徵對象來存儲數據中心的參數特徵
		
		Datacenter datacenter = null;
		try {
			datacenter = new Datacenter(name, characteristics, new VmAllocationPolicySimple(hostList), storageList, 0);
		} catch (Exception e) {
			e.printStackTrace();
		} 其中VmAllocationSimple表示將VM分配到已經使用Pe最少的物理機中

Virtual Machine

參數:id、mips(衡量CPU速度的一個指標,單字長定點指令平均執行速度)、鏡像大小??、內存大小、帶寬、CPU數、虛擬機命名

		// VM description
		int vmid = 0;
		int mips = 1000;
		long size = 10000; // image size (MB)
		int ram = 512; // vm memory (MB)
		long bw = 1000;
		int pesNumber = 1; // number of cpus
		String vmm = "Xen"; // VMM name

		// create VM
		Vm vm = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, vmm, new CloudletSchedulerTimeShared());
		
		之後// add the VM to the vmList
		vmlist.add(vm);

		// submit vm list to the broker
		broker.submitVmList(vmlist);

Cloudlet

參數:應用編號、執行時的應用長度(MI)、要使用到的處理器數量、提交應用前的文件大小(byte)、應用執行完成後的文件大小(byte)、cpu的使用模型/策略、ram的使用模型/策略、網絡帶寬的使用模型/策略

		// Cloudlet properties
		int id = 0;
		long length = 400000;
		long fileSize = 300;
		long outputSize = 300;
		UtilizationModel utilizationModel = new UtilizationModelFull();
		
		Cloudlet cloudlet = 
                          new Cloudlet(id, length, pesNumber, fileSize, 
                                       outputSize, utilizationModel, utilizationModel, 
                                       utilizationModel);
		cloudlet.setUserId(brokerId);
		cloudlet.setVmId(vmid);
		
		而後// add the cloudlet to the list
		cloudletList.add(cloudlet);

		// submit cloudlet list to the broker
		broker.submitCloudletList(cloudletList);
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章