Ns3 Projects for B.E/B.Tech M.E/M.Tech PhD Scholars.  Phone-Number:9790238391   E-mail: ns3simulation@gmail.com

How to Implement Edge computing in ns3

To implement the edge computing in ns-3 it includes setting up a network where computation is achieved at the edge of the network that closes to the data source. This decreases the latency and enhances the performance for time- sensitive applications. Here are the step by step procedures to set up fundamentals of edge computing scenario in ns-3 environment. 

Step-by-Step Guide to Implement Edge Computing in ns-3

  1. Set Up Your Development Environment
  1. Install ns-3:
    • Follow the official ns-3 installation guide.
  2. Install Required Modules:
    • Ensure you have all necessary ns-3 modules installed, such as Internet, Point-to-Point, WiFi, and Applications modules.
  1. Create a Basic Edge Computing Simulation Script

Here is the sample script to setting up a edge computing using the ns-3 environment:

#include “ns3/core-module.h”

#include “ns3/network-module.h”

#include “ns3/internet-module.h”

#include “ns3/point-to-point-module.h”

#include “ns3/wifi-module.h”

#include “ns3/applications-module.h”

#include “ns3/mobility-module.h”

#include “ns3/flow-monitor-module.h”

 

using namespace ns3;

NS_LOG_COMPONENT_DEFINE (“EdgeComputingExample”);

int main (int argc, char *argv[])

{

  // Set simulation parameters

  double simTime = 20.0; // Simulation time in seconds

  uint32_t numClients = 3;

  uint32_t numEdgeServers = 2;

  CommandLine cmd;

  cmd.AddValue(“simTime”, “Simulation time”, simTime);

  cmd.AddValue(“numClients”, “Number of client nodes”, numClients);

  cmd.AddValue(“numEdgeServers”, “Number of edge server nodes”, numEdgeServers);

  cmd.Parse(argc, argv);

  // Create nodes

  NodeContainer clients;

  clients.Create(numClients);

  NodeContainer edgeServers;

  edgeServers.Create(numEdgeServers);

  NodeContainer backboneRouter;

  backboneRouter.Create(1);

 

  // Create Wi-Fi network for clients

  WifiHelper wifi;

  wifi.SetStandard(WIFI_PHY_STANDARD_80211ac);

  YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default();

  YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default();

  wifiPhy.SetChannel(wifiChannel.Create());

  WifiMacHelper wifiMac;

  Ssid ssid = Ssid(“edge-computing-network”);

  wifiMac.SetType(“ns3::StaWifiMac”,

                  “Ssid”, SsidValue(ssid),

                  “ActiveProbing”, BooleanValue(false));

  NetDeviceContainer clientDevices;

  clientDevices = wifi.Install(wifiPhy, wifiMac, clients);

  wifiMac.SetType(“ns3::ApWifiMac”,

                  “Ssid”, SsidValue(ssid));

  NetDeviceContainer apDevices;

  apDevices = wifi.Install(wifiPhy, wifiMac, edgeServers);

  // Set up point-to-point links between edge servers and backbone router

  PointToPointHelper pointToPoint;

  pointToPoint.SetDeviceAttribute(“DataRate”, StringValue(“1Gbps”));

  pointToPoint.SetChannelAttribute(“Delay”, StringValue(“2ms”));

 

  NetDeviceContainer edgeServerDevices;

  for (uint32_t i = 0; i < numEdgeServers; ++i) {

    NetDeviceContainer link = pointToPoint.Install(edgeServers.Get(i), backboneRouter.Get(0));

    edgeServerDevices.Add(link.Get(0));

  }

  // Install the Internet stack on all nodes

  InternetStackHelper stack;

  stack.Install(clients);

  stack.Install(edgeServers);

  stack.Install(backboneRouter);

  // Assign IP addresses

  Ipv4AddressHelper address;

  address.SetBase(“10.1.1.0”, “255.255.255.0”);

  Ipv4InterfaceContainer clientInterfaces = address.Assign(clientDevices);

  address.SetBase(“10.1.2.0”, “255.255.255.0”);

  Ipv4InterfaceContainer edgeServerInterfaces = address.Assign(edgeServerDevices);

  address.SetBase(“10.1.3.0”, “255.255.255.0”);

  Ipv4InterfaceContainer apInterfaces = address.Assign(apDevices);

  // Set up mobility

  MobilityHelper mobility;

  mobility.SetPositionAllocator(“ns3::GridPositionAllocator”,

                                “MinX”, DoubleValue(0.0),

                                “MinY”, DoubleValue(0.0),

                                “DeltaX”, DoubleValue(5.0),

                                “DeltaY”, DoubleValue(10.0),

                                “GridWidth”, UintegerValue(3),

                                “LayoutType”, StringValue(“RowFirst”));

  mobility.SetMobilityModel(“ns3::ConstantPositionMobilityModel”);

  mobility.Install(clients);

  mobility.Install(edgeServers);

  // Create applications

  uint16_t port = 8080;

  // Install a UDP echo server on each edge server node

  for (uint32_t i = 0; i < numEdgeServers; ++i) {

    UdpEchoServerHelper echoServer(port);

    ApplicationContainer serverApp = echoServer.Install(edgeServers.Get(i));

    serverApp.Start(Seconds(1.0));

    serverApp.Stop(Seconds(simTime));

  }

  // Install a UDP echo client on each client node

  for (uint32_t i = 0; i < numClients; ++i) {

    UdpEchoClientHelper echoClient(edgeServerInterfaces.GetAddress(i % numEdgeServers), port);

    echoClient.SetAttribute(“MaxPackets”, UintegerValue(100));

    echoClient.SetAttribute(“Interval”, TimeValue(Seconds(1.0)));

    echoClient.SetAttribute(“PacketSize”, UintegerValue(1024));

    ApplicationContainer clientApp = echoClient.Install(clients.Get(i));

    clientApp.Start(Seconds(2.0));

    clientApp.Stop(Seconds(simTime));

  }

  // Enable Flow Monitor

  FlowMonitorHelper flowmon;

  Ptr<FlowMonitor> monitor = flowmon.InstallAll();

  // Enable tracing

  wifiPhy.EnablePcap(“edge-computing-example”, apDevices.Get(0));

  pointToPoint.EnablePcapAll(“edge-computing-example”);

  // Run the simulation

  Simulator::Stop(Seconds(simTime));

  Simulator::Run();

  // Print flow monitor statistics

  monitor->SerializeToXmlFile(“edge-computing-flowmon.xml”, true, true);

 

  Simulator::Destroy();

  return 0;

}

Explanation of the Script:

Here the given below are the process of the edge computing scripts

  1. Include Necessary Headers:
    • Include headers for ns-3 core, network, internet, point-to-point, WiFi, applications, mobility, and flow monitor modules.
  2. Set Simulation Parameters:
    • Define the simulation time and number of client and edge server nodes.
  3. Create Nodes:
    • Create nodes for clients, edge servers, and a backbone router using NodeContainer.
  4. Set Up Wi-Fi Network:
    • Configure the Wi-Fi network for client nodes using WifiHelper, YansWifiChannelHelper, YansWifiPhyHelper, and WifiMacHelper.
  5. Set Up Point-to-Point Links:
    • Configure point-to-point links between edge servers and the backbone router using PointToPointHelper.
  6. Install Internet Stack:
    • Install the Internet stack on all nodes using InternetStackHelper.
  7. Assign IP Addresses:
    • Assign IP addresses to the devices using Ipv4AddressHelper.
  8. Set Up Mobility:
    • Define the positions and mobility models for the nodes using MobilityHelper.
  9. Create Applications:
    • Install UDP echo servers on each edge server node.
    • Install UDP echo clients on each client node to request services from the edge servers.
  10. Enable Flow Monitor:
    • Install and configure the Flow Monitor to collect and analyze network performance statistics.
  11. Enable Tracing:
    • Enable pcap tracing to capture packet traces for analysis.
  12. Run the Simulation:
    • Set the simulation stop time, run the simulation, print flow monitor statistics, and clean up using Simulator::Stop, Simulator::Run, and Simulator::Destroy.

Further Enhancements:

We provide the future enhancement of the edge computing that are

  1. Dynamic Workload Management:
    • Implement dynamic workload distribution and scaling of resources based on demand.
  2. Advanced Mobility Models:
    • Implement more realistic mobility models for mobile clients accessing edge services.
  3. Quality of Service (QoS):
    • Implement QoS mechanisms to prioritize critical applications and ensure timely delivery.
  4. Network Performance Metrics:
    • Collect and analyze performance metrics such as throughput, latency, packet delivery ratio, and resource utilization.
  5. Interference Modeling:
    • Model interference and evaluate its impact on network performance, especially in densely deployed edge networks.
  6. Fault Tolerance and Resilience:
    • Implement and evaluate fault tolerance mechanisms and resilience strategies for edge services.

Finally, we offer fundamental information on implementing edge computing in the ns-3 environment, as well as comprehensive guidance on various edge computing networks.