To simulate STAR (Source Tree Adaptive Routing) protocol projects utilizing NS2 that encompasses setting up the routing protocol and making a network topology for the simulation. STAR is a table-driven, proactive routing protocol utilized for mobile ad-hoc networks (MANETs). It minimizes the amount of routing updates by maintaining source trees, which define paths to destinations, updating only when required.
Even though NS2 does not contain STAR protocol directly, it is possible to replicate STAR protocol behaviour by either prolonging NS2 with custom code or using a same proactive protocol (like DSDV) and fine-tuning it to reflect STAR’s operations.
Here’s a general procedure to simulate STAR protocol or make a custom simulation inspired by STAR in NS2:
Steps to Simulate STAR Protocol Projects in NS2
- Install and Set Up NS2
Make sure NS2 is installed and working appropriately on the machine. If we are utilizing a custom implementation of STAR then we will require to patch or prolong NS2 to contain STAR functionalities.
- Understanding STAR Protocol
The STAR protocol is according to the source tree concept:
- Source Tree: Each node maintains a tree, which offers the path to all reachable destinations.
- Routing Updates: Routing updates are swapped only when there is a modification in the source tree, unlike other table-driven protocols which periodically exchange updates.
- Simulating STAR Protocol in NS2
If we have a STAR implementation:
We can replicate the STAR protocol if we have a custom implementation or if we prolong NS2 with STAR support. We follow these steps for executing the routing protocol in the simulation.
If STAR isn’t available:
Since STAR is not obtainable by default in NS2, we can replicate a same proactive behaviour using the DSDV (Destination-Sequenced Distance Vector) protocol as a nearby alternative, or make a custom implementation, which simulates STAR’s source-tree-based behaviour.
Here’s an instance to replicate a proactive routing protocol (like DSDV) and modify the behaviour to be same to STAR.
- TCL Script to Simulate STAR-like Protocol (DSDV as an Example)
Here’s an examples TCL script to replicate a STAR-like behaviour in NS2 using a same proactive protocol:
# Create a simulator object
set ns [new Simulator]
# Define the network parameters
set topo [new Topography]
$topo load_flatgrid 500 500
# Set up the trace and NAM files
set tracefile [open star.tr w]
set namfile [open star.nam w]
$ns trace-all $tracefile
$ns namtrace-all-wireless $namfile 500 500
# Create a wireless channel with two-ray ground propagation model
set chan_1_ [new Channel/WirelessChannel]
set prop [new Propagation/TwoRayGround]
set netif [new Phy/WirelessPhy]
set mac [new Mac/802_11]
set ll [new LL]
set ifq [new Queue/DropTail/PriQueue]
set antenna [new Antenna/OmniAntenna]
# Define the routing protocol (use DSDV as a proxy for STAR behavior)
set adhocRouting DSDV
# Create a node configuration for the ad-hoc network
$ns node-config -adhocRouting $adhocRouting \
-llType $ll \
-macType $mac \
-ifqType $ifq \
-ifqLen 50 \
-antType $antenna \
-propType $prop \
-phyType $netif \
-channel $chan_1_ \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON
# Create mobile nodes
set num_nodes 10
for {set i 0} {$i < $num_nodes} {incr i} {
set node($i) [$ns node]
}
# Set node positions (you can adjust the positions to your needs)
$node(0) set X_ 100
$node(0) set Y_ 200
$node(1) set X_ 200
$node(1) set Y_ 250
$node(2) set X_ 300
$node(2) set Y_ 300
$node(3) set X_ 400
$node(3) set Y_ 350
# Mobility model (if necessary for dynamic scenarios)
for {set i 0} {$i < $num_nodes} {incr i} {
$ns at 0.0 “$node($i) setdest 100 100 10”
}
# Create a TCP agent and attach it to node 0 (source node)
set tcp0 [new Agent/TCP]
$ns attach-agent $node(0) $tcp0
# Create a TCP Sink agent and attach it to node 3 (destination node)
set sink0 [new Agent/TCPSink]
$ns attach-agent $node(3) $sink0
# Connect the TCP agent to the sink
$ns connect $tcp0 $sink0
# Create a traffic generator (FTP over TCP)
set ftp [new Application/FTP]
$ftp attach-agent $tcp0
$ns at 1.0 “$ftp start”
$ns at 10.0 “$ftp stop”
# Run simulation for 15 seconds
$ns at 15.0 “finish”
# Finish procedure to close trace files
proc finish {} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exec nam star.nam &
exit 0
}
# Run the simulation
$ns run
- Explanation of the Script
- Simulator Setup: The simulator object is made, and trace and NAM files are opened for recording.
- Node Configuration: Nodes are made with the routing protocol set to DSDV (proactive) as a proxy for STAR. We can substitute DSDV with STAR if we have executed it.
- Wireless Channel Setup: A wireless channel is described, together with the propagation model, MAC type, and antenna set up.
- Node Movement: We can mimic mobility for nodes by utilizing the setdest command.
- Traffic Generation: FTP traffic is made from node 0 to node 3 using TCP. We can prolong it to make more complex traffic scenarios with UDP or other applications.
- Simulation End: The simulation runs for 15 seconds, and the outcomes are saved in trace and NAM files.
- Running the Simulation
We can save the script as star_simulation.tcl and then we run it using NS2:
ns star_simulation.tcl
- Analyzing the Results
- NAM Visualization: We can utilize NAM (Network Animator) to envision the network topology and packet flow. We can open the .nam file generated by the simulation:
nam star.nam
- Trace File Analysis: The .tr trace file logs the packet-level events within the network. We can investigate this file to calculate parameters such as:
- Packet delivery ratio
- End-to-end delay
- Routing overhead
- Throughput
- Performance Metrics for STAR Protocol
When we have executed or replicated STAR then we can estimate the following performance parameters:
- Packet Delivery Ratio (PDR): The ratio of efficiently delivered packets to the total number of packets transmitted.
- Routing Overhead: The amount of control packets (routing updates) made by the protocol.
- End-to-End Delay: The average time it takes for a packet to travel from the source to the destination.
- Throughput: The total amount of data effectively delivered over the network.
- Advanced STAR Implementation
If we are executing STAR then we will require to change the C++ code within NS2 to describe the behaviour of source tree updates and optimizations. We would insert source tree handling, periodic updates, and neighbour discovery mechanisms to minimize overhead according to the STAR protocol design.
The simulation and analysis of the STAR Protocol projects were successfully done using the NS2 with the help of above detail approach. More extensive details can be shared based on your needs.For expert assistance with STAR Protocol Projects simulation using the ns2 tool, connect with phdprime.com. We guarantee comprehensive project support, specializing in proactive protocols such as DSDV, and providing excellent project guidance.