List of Topics:
Research Breakthrough Possible @S-Logix pro@slogix.in

Office Address

Social List

How to Create Fog Topology in IFogSim?

Create Fog Topology in IFogSim

Condition for Create Fog Topology in IFogSim

  • Description:
    Creating a Fog topology in iFogSim involves defining a hierarchy of fog devices, edge devices, and cloud resources. Fog devices are instantiated with specific resources, such as processing power, bandwidth, and power models, and connected to form a network with communication links specifying bandwidth and latency. Edge devices serve as intermediaries between fog devices and the cloud. The topology supports multiple levels of infrastructure, including cloud servers and sensors, with task routing, scheduling, and workload management defining how data and tasks flow across the devices in the network.
Sample Code
  • package org.fog.gui.example;

    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.Font;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.KeyEvent;
    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.IOException;

    import javax.swing.BoxLayout;
    import javax.swing.ButtonGroup;
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import javax.swing.JFileChooser;
    import javax.swing.JFrame;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JRadioButtonMenuItem;
    import javax.swing.JToolBar;
    import javax.swing.KeyStroke;
    import javax.swing.SwingUtilities;
    import javax.swing.UIManager;
    import javax.swing.filechooser.FileFilter;
    import javax.swing.filechooser.FileNameExtensionFilter;

    import org.fog.gui.core.Bridge;
    import org.fog.gui.core.Graph;
    import org.fog.gui.core.GraphView;
    import org.fog.gui.dialog.AddActuator;
    import org.fog.gui.dialog.AddFogDevice;
    import org.fog.gui.dialog.AddLink;
    import org.fog.gui.dialog.AddPhysicalEdge;
    import org.fog.gui.dialog.AddPhysicalNode;
    import org.fog.gui.dialog.AddSensor;
    import org.fog.gui.dialog.SDNRun;

    public class FogGui extends JFrame {
     private static final long serialVersionUID = -2238414769964738933L;

     private JPanel contentPane;

      /** Import file names */
     private String physicalTopologyFile = ""; //physical
     private String deploymentFile = ""; //virtual
     private String workloads_background = ""; //workload
     private String workloads = ""; //workload

     private JPanel panel;
     private JPanel graph;

     private Graph physicalGraph;
     private GraphView physicalCanvas;

     private JButton btnRun;

     private String mode; //'m':manual; 'i':import

     public FogGui() {
      setDefaultCloseOperation(EXIT_ON_CLOSE);
      setPreferredSize(new Dimension(1280, 800));
      setLocationRelativeTo(null);
      setTitle("Fog Topology Creator");
      contentPane = new JPanel();
      setContentPane(contentPane);
      contentPane.setLayout(new BorderLayout());
      initUI();
      initGraph();
      pack();
      setVisible(true);
     }

     public final void initUI() {
      setUIFont(new javax.swing.plaf.FontUIResource("Serif", Font.BOLD, 18));
      panel = new JPanel();
      panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
      graph = new JPanel(new java.awt.GridLayout(1, 2));
      initBar();
      doPosition();
     }

     private void doPosition() {
      Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
      int height = screenSize.height;
      int width = screenSize.width;
      int x = (width / 2 - 1280 / 2);
      int y = (height / 2 - 800 / 2);
      this.setLocation(x, y);
     }

     private final void initBar() {
      // Initialize menu and toolbar elements
      // Add relevant actions
     }

     protected void openAddActuatorDialog() {
      AddActuator actuator = new AddActuator(physicalGraph, FogGui.this);
      physicalCanvas.repaint();
     }

     protected void openAddLinkDialog() {
      AddLink phyEdge = new AddLink(physicalGraph, FogGui.this);
      physicalCanvas.repaint();
     }

     protected void openAddFogDeviceDialog() {
      AddFogDevice fogDevice = new AddFogDevice(physicalGraph, FogGui.this);
      physicalCanvas.repaint();
     }

     private void initGraph() {
      physicalGraph = new Graph();
      physicalCanvas = new GraphView(physicalGraph);
      graph.add(physicalCanvas);
      contentPane.add(graph, BorderLayout.CENTER);
     }

     private String importFile(String type) {
      JFileChooser fileopen = new JFileChooser();
      FileFilter filter = new FileNameExtensionFilter(type.toUpperCase() + " Files", type);
      fileopen.addChoosableFileFilter(filter);
      int ret = fileopen.showDialog(panel, "Import file");
      if (ret == JFileChooser.APPROVE_OPTION) {
       File file = fileopen.getSelectedFile();
       return file.getPath();
      }
      return "";
     }

     private void saveFile(String type, Graph graph) throws IOException {
      JFileChooser fileopen = new JFileChooser();
      FileFilter filter = new FileNameExtensionFilter(type.toUpperCase() + " Files", type);
      fileopen.addChoosableFileFilter(filter);
      int ret = fileopen.showSaveDialog(panel);
      if (ret == JFileChooser.APPROVE_OPTION) {
       String jsonText = graph.toJsonString();
       String path = fileopen.getSelectedFile().toString();
       File file = new File(path);
       FileOutputStream out = new FileOutputStream(file);
       out.write(jsonText.getBytes());
       out.close();
      }
     }

     public static void main(String args[]) throws InterruptedException {
      SwingUtilities.invokeLater(new Runnable() {
       public void run() {
        FogGui sdn = new FogGui();
        sdn.setVisible(true);
       }
      });
     }
Step 1
  • Run the FogGui.java:
    Fog Topology1
Step 2
  • Add Fog device:
    Fog Topology2
Step 3
  • Add Cloud and configure the parameter:
    Fog Topology3
  • Fog Topology4
Step 4
  • Add proxy server and configure the parameter:
    Fog Topology5
  • Fog Topology6
Step 5
  • Add fog nodes and configure the parameter:
    Fog Topology7
  • Fog Topology8
Step 6
  • Add Sensors(CAMERA_1, CAMERA_2) and configure the parameter:
    Fog Topology9
Step 7
  • Add Actuators(PTZ_CONTROL1, PTZ_CONTROL2) and configure the parameter:
    Fog Topology10
Step 8
  • Add links between fog devices, sensors and actuators:
    Fog Topology11
Step 9
  • Final fog topology:
    Fog Topology12
ScreenShots
  • Fog Topology in IFogSim1
  • Fog Topology in IFogSim2