iFogSim2 Simulation Toolkit

repository·main·Indexed 41 days ago

https://github.com/cloudslab/ifogsim

A simulation toolkit for modeling resource management in IoT, Edge, and Fog computing environments. iFogSim2 provides specialized support for mobility, microservices, and dynamic distributed clustering, and is compatible with CloudSim and iFogSim1. It includes tools like PhysicalTopologyGenerator, VirtualTopologyGenerator, and VMRequestGenerator for programmatically creating network topologies and SDN requests exported to JSON.

Tokens
3.5K
Snippets
13
Records
16
Agent score
51%

What's inside iFogSim2

  1. Overview of iFogSim2 features

    main

    iFogSim2 is a toolkit for modeling and simulating resource management in IoT, Edge, and Fog computing environments.

    Key capabilities include:

    • Mobility-support and Migration Management: Supports real mobility datasets and various random mobility models.
    • Microservice Orchestration.
    • Dynamic Distributed Clustering.
    • Compatibility: Fully compatible with the latest CloudSim and the previous iFogSim version (iFogSim1).
  2. Set up iFogSim2 in Eclipse IDE

    main

    To use iFogSim2 in Eclipse, follow these steps to initialize a Java project and pull the source code via Git:

    1. Create a new Java project in Eclipse.
    2. Open a terminal in your project directory and initialize a Git repository:
      git init
    3. Add the iFogSim2 repository as the origin remote:
      git remote add origin https://github.com/Cloudslab/iFogSim
    4. Pull the repository contents:
      git pull origin main
    5. Manually include the required JAR files in your project's build path.
    6. Run existing example files to verify the setup.
    git init
    git remote add origin https://github.com/Cloudslab/iFogSim
    git pull origin main
  3. Set up iFogSim2 in IntelliJ IDEA

    main

    To use iFogSim2 in IntelliJ IDEA, follow these steps:

    1. Clone the repository to your local machine:
      git clone https://github.com/Cloudslab/iFogSim
    2. In IntelliJ, go to the File menu and select Open (or Project from Existing Resources).
    3. Verify that the correct Java version is selected for the project.
    4. Ensure that the external libraries located in the JARs folder are correctly added to the project dependencies.
    5. Run existing example files to verify the setup.
    git clone https://github.com/Cloudslab/iFogSim
  4. Generate SDN request JSON files with VMRequestGenerator

    main

    The VMRequestGenerator class is used to programmatically generate JSON specifications for Virtual Machines (VMs) and network links, which are typically used for SDN (Software Defined Networking) requests in iFogSim. It can generate random VM groups based on statistical distributions (Exponential and Pareto) and export the resulting configuration to a JSON file.

    Key capabilities:

    • VM Generation: Create VMs with specific types (WebServer, AppServer, DBServer, Proxy, Firewall) or custom hardware specifications.
    • Link Generation: Define network connections between nodes.
    • JSON Export: Save the entire topology (nodes and links) to a file using the wrtieJSON method.
    VMRequestGenerator reqg = new VMRequestGenerator();
    
    // Generate a list of VMs based on statistical distributions
    List<VMSpec> vms = reqg.generateVMs(100);
    
    // Generate a list of network links
    List<LinkSpec> links = reqg.generateLinks();
    
    // Export the configuration to a JSON file
    reqg.wrtieJSON(vms, links, "virtual2.json");
  5. Run iFogSim2 examples

    main

    Once the environment is set up, you can get started by running the provided example files. These examples demonstrate various features like clustering, microservices, and mobility.

    Key examples include:

    • TranslationServiceFog_Clustering.java
    • CrowdSensing_Microservices_RandomMobility_Clustering.java
  6. Generate physical network topologies using PhysicalTopologyGenerator

    main

    The PhysicalTopologyGenerator class is used to programmatically create a physical network topology consisting of switches (core, aggregation, edge) and hosts, and export the structure to a JSON file. This is useful for defining SDN-based network environments in CloudSim.

    To generate a topology, you typically:

    1. Create a HostSpec defining the hardware capabilities of your hosts.
    2. Call createTopology to build the hierarchical structure (e.g., connecting a core switch to edge switches, and edge switches to hosts).
    3. Call wrtieJSON to save the resulting topology to a file.

    The generated JSON follows a schema containing a nodes array (for hosts and switches) and a links array (for connections).

    PhysicalTopologyGenerator reqg = new PhysicalTopologyGenerator();
    
    // Define host capabilities: pes, mips, ram, storage, bw
    HostSpec hostSpec = reqg.createHostSpec(8, 4000, 10240, 10000000, 1000000000);
    
    // Create a topology with specific switch specs and fanout
    // Parameters: hostSpec, swIops, swBw, fanout, latency
    reqg.createTopology(hostSpec, 1000000000L, 1000000000, 2, 0.1);
    
    // Export to JSON file
    reqg.wrtieJSON("very_simple_physical.json");
  7. Export topology to JSON format

    main

    The wrtieJSON(String jsonFileName) method exports the configured nodes and links into a structured JSON file.

    JSON Schema Output:

    • nodes: An array of objects containing name, type (always "vm"), size, pes, mips, ram, bw, and optionally starttime and endtime.
    • links: An array of objects containing name, source (node name), destination (node name), and bandwidth.

    Note: The method also prints the topology object and a formatted workload list to the standard output.

    generator.wrtieJSON("output_topology.json");
  8. Generate virtual network topologies with VirtualTopologyGenerator

    main

    The VirtualTopologyGenerator class is used to programmatically define a virtual network topology consisting of Virtual Machines (VMs) and the links between them. It allows you to define VM specifications, establish links with specific bandwidths, and automatically generates a dummy workload based on the link connections.

    Once the topology is defined, you can export the configuration to a JSON file using wrtieJSON(String jsonFileName).

    VirtualTopologyGenerator generator = new VirtualTopologyGenerator();
    
    // 1. Create and add VMs
    // Parameters: name, pes, mips, ram, storage, bw, starttime, endtime
    VirtualTopologyGenerator.VMSpec vm1 = generator.addVM("VM1", 1, 1000, 512, 10000, 100, 0.0, 10.0);
    VirtualTopologyGenerator.VMSpec vm2 = generator.addVM("VM2", 2, 2000, 1024, 20000, 200, 0.0, 10.0);
    
    // 2. Add links between VMs
    // Parameters: linkname, source_VMSpec, dest_VMSpec, bandwidth
    generator.addLink("link1", vm1, vm2, 50L);
    
    // 3. Export to JSON
    generator.wrtieJSON("topology.json");
  9. Define network links with VirtualTopologyGenerator

    main

    To connect nodes in your topology, use the addLink method. This method creates a LinkSpec and automatically registers a DummyWorkloadSpec for that link.

    Method Signature: public LinkSpec addLink(String linkname, VMSpec source, VMSpec dest, Long bw)

    • linkname: A unique identifier for the link.
    • source: The VMSpec object representing the starting node.
    • dest: The VMSpec object representing the destination node.
    • bw: The bandwidth of the link.
    // Assuming vm1 and vm2 are already created via addVM
    generator.addLink("link_between_nodes", vm1, vm2, 100L);
  10. Define Virtual Machine specifications in VirtualTopologyGenerator

    main

    You can define VMs using two methods in VirtualTopologyGenerator:

    1. createVmSpec(...): Creates a standalone VMSpec object.
    2. addVM(...): Creates a VMSpec and immediately adds it to the generator's internal list.

    VMSpec Parameters:

    • pe (int): Processing Elements.
    • mips (long): Millions of Instructions Per Second.
    • ram (int): RAM in MB.
    • storage (long): Storage capacity.
    • bw (long): Bandwidth.
    • starttime (double): Simulation start time.
    • endtime (double): Simulation end time.
    // Using addVM directly
    VirtualTopologyGenerator.VMSpec vm = generator.addVM("VM_NAME", pes, mips, ram, storage, bw, starttime, endtime);
    
    // Using createVmSpec to get a spec object first
    VirtualTopologyGenerator.VMSpec spec = generator.createVmSpec(1, 1000, 512, 1000, 10, 0.0, 10.0);
    // Then add it with a name
    generator.addVM("VM_NAME", spec);
  11. Physical topology JSON schema

    main

    The PhysicalTopologyGenerator produces a JSON file representing the network. The schema is structured as follows:

    Nodes

    An array of objects representing either hosts or switches.

    Host Node Fields:

    • name: Unique identifier for the host.
    • type: Always "host".
    • pes: Number of processing elements.
    • mips: MIPS (Millions of Instructions Per Second).
    • ram: RAM in MB.
    • storage: Storage capacity.
    • bw: Bandwidth.

    Switch Node Fields:

    • name: Unique identifier for the switch.
    • type: The switch role (e.g., "core", "edge", "aggregation").
    • bw: Bandwidth.
    • iops: Input/Output Operations Per Second.

    An array of objects representing connections between nodes.

    Link Fields:

    • source: Name of the source node.
    • destination: Name of the destination node.
    • latency: Connection latency.
    {
      "nodes" : [
         {
          "name": "core",
          "type" : "core",
          "iops" : 1000000000,
          "bw" : 1000000000
        },
        {
          "name": "host01",
          "type" : "host",
          "pes" : 1,
          "mips" : 30000000,
          "ram" : 10240,
          "storage" : 10000000,
          "bw" : 200000000
        }
       ],
     "links" : [
        { "source" : "core" , "destination" : "edge1" , "latency" : 0.5 }
      ]
    }