How to Start Edge Computing Projects Using NS2
To start an Edge Computing project in Network Simulator 2 (NS2) which needs to replicate the distributed computing architecture in which data processing is completed nearer to the data source that is at the edge of the network instead of depending on the centralized cloud data centers. It can support to minimize latency, maximize responsiveness, and enhance the network bandwidth usage.
Steps to Start Edge Computing Projects in NS2
Step 1: Understand Edge Computing and Its Components
In Edge Computing, rather than transmitting every information toward the cloud or central data center that data is handled on devices at the “edge” of the network like:
- Edge Nodes: Local computing devices or servers, which execute the data near to the source node.
- Cloud Nodes: Centralized data centers, which manage more complex or large-scale computations, or serve like backup storage.
- IoT Devices: Devices to make information which is frequently transmitting the data to the edge for preliminary processing such as sensors, cameras.
Following is skey advantages of Edge Computing:
- Minimized the latency by means of executing data nearer to users.
- Enhanced bandwidth efficiency by minimizing the volume of data that are transmitted to the cloud.
- Developed privacy and security since sensitive information can be executed.
Step 2: Install NS2
Make sure that NS2 is installed on the machine. We need to verify installation instructions based on the OS like Linux, macOS, or Windows (via Cygwin).
Confirm the installation by commanding ns for verifying if the simulator is functioning properly.
Step 3: Design Your Edge Computing Network Topology
In NS2, we can create a network topology, which contains:
- Edge Nodes: Local processing units are located close to the IoT devices.
- Cloud Node: A central server or data center to manage more complex missions.
- IoT Devices: Devices, which make information like sensors, cameras.
- Communication Links: Connections among the IoT devices, edge nodes, and the cloud with latency and bandwidth deliberations.
Step 4: Create Your Edge Computing Simulation
In NS2, replicate the Edge Computing, we can:
- Configure the nodes for IoT devices, Edge devices, and a Cloud server.
- Make interaction connections among the nodes including diverse bandwidths, delays, and packet loss for denoting diverse network conditions.
- Configure applications such as Traffic/CBR, UDP or TCP on the IoT and edge devices to make data and interaction among the edge and the cloud.
- Mimic data processing tasks on the edge and within the cloud.
Example of NS2 Edge Computing Simulation
Below is an instance of a basic Edge Computing simulation including IoT devices, edge nodes, and a cloud server.
# Create the simulator object
set ns [new Simulator]
# Create nodes for IoT devices, edge nodes, and a cloud server
set cloud_node [$ns node] ;# Cloud node (centralized server)
set edge_node1 [$ns node] ;# Edge node 1
set edge_node2 [$ns node] ;# Edge node 2
set iot_device1 [$ns node] ;# IoT device 1
set iot_device2 [$ns node] ;# IoT device 2
# Create links between IoT devices, edge nodes, and cloud
$ns duplex-link $iot_device1 $edge_node1 1Mb 50ms DropTail
$ns duplex-link $iot_device2 $edge_node2 1Mb 50ms DropTail
$ns duplex-link $edge_node1 $cloud_node 5Mb 20ms DropTail
$ns duplex-link $edge_node2 $cloud_node 5Mb 20ms DropTail
# Attach applications to the nodes
# IoT Device 1 to Edge Node 1: Generate data
set udp1 [new Agent/UDP]
set null1 [new Agent/Null]
$ns attach-agent $iot_device1 $udp1
$ns attach-agent $edge_node1 $null1
$ns connect $udp1 $null1
# IoT Device 2 to Edge Node 2: Generate data
set udp2 [new Agent/UDP]
set null2 [new Agent/Null]
$ns attach-agent $iot_device2 $udp2
$ns attach-agent $edge_node2 $null2
$ns connect $udp2 $null2
# Set up Constant Bit Rate (CBR) applications for data transmission
set cbr1 [new Application/Traffic/CBR]
set cbr2 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp1
$cbr2 attach-agent $udp2
$cbr1 set packetSize_ 512
$cbr1 set interval_ 0.1
$cbr2 set packetSize_ 512
$cbr2 set interval_ 0.1
# Start sending data from IoT devices to Edge Nodes
$ns at 0.5 “$cbr1 start” ;# Start at time 0.5 seconds
$ns at 0.5 “$cbr2 start” ;# Start at time 0.5 seconds
$ns at 4.5 “$cbr1 stop” ;# Stop at time 4.5 seconds
$ns at 4.5 “$cbr2 stop” ;# Stop at time 4.5 seconds
# Set finish time for simulation
$ns at 5.0 “finish”
# Define finish procedure
proc finish {} {
global ns
$ns flush-trace
exit 0
}
# Run the simulation
$ns run
Explanation of the Script:
- Simulator Setup:
- set ns [new Simulator]: It makes the NS2 simulator entity.
- Node Creation:
- set cloud_node [$ns node]: The cloud node, which denotes the central server or data center.
- set edge_node1, edge_node2: Edge computing nodes, which manage the data processing.
- set iot_device1, iot_device2: IoT devices to produce information.
- Link Setup:
- duplex-link: It makes bidirectional interaction connections among the nodes with bandwidth and delay metrics.
- The IoT devices are linked to the edge nodes including 1Mb bandwidth and 50ms delay. The edge nodes are associated to the cloud node containing a higher bandwidth and lower delay.
- Agent Setup:
- Agent/UDP: It denotes the UDP protocol which is utilised for data transmission.
- Agent/Null: A Null agent on the destination nodes (edge or cloud) for replicating the behaviour of inheriting.
- Traffic Generation:
- Application/Traffic/CBR: It makes constant bit rate of traffic from the IoT devices to the edge nodes.
- The packet size is fixed to 512 bytes, and packets are transmitted at period of 0.1 seconds.
- Simulation Events:
- $ns at 0.5 “$cbr1 start”: It begins to transmit data from IoT device 1 at 0.5 seconds.
- $ns at 4.5 “$cbr1 stop”: Ends for forwarding information from IoT device 1 at 4.5 seconds.
- Likewise for the second IoT device.
- Finish Procedure:
- End of the simulation is known as finish to clear trace files and then exit.
- Running the Simulation:
- Now, we need to execute the simulation using the command ns edge_computing_simulation.tcl.
Step 5: Analyzing the Results
NS2 utilise a trace file (*.tr), which helps to record the events within the simulation like packet arrivals, drops, and delays. We need to examine these outcomes to utilise Xgraph or AWK.
For instance, examining the packet receptions, we need to utilise an AWK script staining the trace file:
awk ‘{ if ($1 == “r”) print $0 }’ tracefile.tr > received_packets.txt
To envision the outcomes to utilise Xgraph:
xgraph tracefile.tr
Step 6: Experimenting with Edge Computing Scenarios
When we have configured the simple edge computing simulation then we need to test with diverse sets up and network conditions:
- Varying Network Conditions: We can modify the metrics like link bandwidth, delay, and packet loss for replicating diverse network environments.
- Task Offloading: Design how tasks can be relieved from IoT devices to edge nodes or from edge nodes to the cloud according to the computing energy or network conditions.
- Edge Processing: Replicate the data processing tasks at the edge in which edge nodes execute the computations before transmitting the outcomes toward the cloud such as data aggregation, filtering.
- Multiple Edge Nodes: Integrate additional edge nodes under diverse geographic locations for replicating a distributed edge network.
- Latency and Bandwidth Optimization: Test with load balancing among the edge nodes and the cloud for minimizing latency and enhancing the bandwidth.
Step 7: Advanced Concepts in Edge Computing
We will want to discover more advanced edge computing concepts like:
- Edge-to-Cloud Integration: Design edge computing scenarios in which edge nodes execute the data and transmit related or brief information to the cloud.
- Real-Time Applications: Replicate the real time applications, which needs data processing at the edge like video streaming, autonomous vehicles.
- Task Scheduling and Load Balancing: Execute the task scheduling and load balancing algorithms among the edge and cloud nodes particularly when handling the computationally expensive tasks.
- Energy Efficiency: Replicate the energy utilisation of IoT devices, edge nodes, and cloud servers, to discover how energy-efficient algorithms can set up.
Step 8: Documentation and Reporting
As a final point, it provides clear documentation for the edge computing project that contains:
- Network Topology: Define the IoT devices, edge nodes, and the cloud configuration.
- Traffic and Data Models: Elucidate the type of traffic data that are created like CBR and how it denotes the real-time situation.
- Simulation Results: It offers to analyse the performance parameters like throughput, latency, and packet loss.
- Conclusion: Sum up the outcomes with how edge computing enhances the performance which is equated to traditional cloud computing.
We cover the overall insights that will understand the concepts and techniques that will help you to simulate the Edge Computing Projects using the tool of ns2. More information will be shared in the upcoming manual.