How to Start Mesh Protocols Projects Using NS2
To create a Mesh Protocols projects using NS2 (Network Simulator 2), we will replicate a wireless mesh network (WMN) in which several nodes are linked in the dynamically and non-hierarchically. These networks rely on routing protocols for sample AODV, DSR, HWMP for assure the efficient communication.
Steps to Start Mesh Protocol Projects in NS2
- Set up the NS2 Environment
Make sure NS2 is installed and working.
- On Ubuntu/Linux:
sudo apt-get update
sudo apt-get install ns2 nam xgraph
- Validate the installation:
ns
You should see the % prompt.
- Understand Mesh Protocols
In a Wireless Mesh Network:
- Nodes are performing as the routers and endpoints.
- Communication occurs over multi-hop paths.
- Mesh protocols has maintain the route discovery and data forwarding efficiently.
Common Mesh Protocols:
- AODV (Ad hoc On-Demand Distance Vector): Reactive routing protocol.
- DSR (Dynamic Source Routing): Route discovery on-demand.
- HWMP (Hybrid Wireless Mesh Protocol): Describe the protocol for IEEE 802.11s mesh networks.
- Plan the Simulation
- Topology: Replicate the mesh network through fixed or mobile nodes.
- Traffic: Use the tool for data transmission for UDP such as CBR) or TCP like as FTP.
- Metrics to Measure:
- Packet Delivery Ratio (PDR)
- End-to-End Delay
- Throughput
- Routing Overhead
- Create a TCL Script for Mesh Networks
Below is a sample TCL script that uses AODV routing in a mesh topology:
NS2 Mesh Protocol Simulation Script
# Initialize the Simulator
set ns [new Simulator]
set tracefile [open mesh_trace.tr w]
$ns trace-all $tracefile
set namfile [open mesh_nam.nam w]
$ns namtrace-all $namfile
# Define Simulation Parameters
set val(nn) 10 ;# Number of nodes
set val(stop) 20.0 ;# Simulation time
set val(x) 500 ;# X-dimension of the topology
set val(y) 500 ;# Y-dimension of the topology
# Define Routing Protocol as AODV (Mesh Protocol)
$ns rtproto AODV
# Create Nodes
for {set i 0} {$i < $val(nn)} {incr i} {
set node_($i) [$ns node]
}
# Define Topology and Node Placement
$node_(0) set X_ 50.0
$node_(0) set Y_ 50.0
$node_(1) set X_ 100.0
$node_(1) set Y_ 100.0
$node_(2) set X_ 150.0
$node_(2) set Y_ 150.0
$node_(3) set X_ 200.0
$node_(3) set Y_ 200.0
# Define Wireless Network Configuration
$ns configure-wireless $val(x) $val(y)
# Add Traffic Source (UDP/CBR)
set udp [new Agent/UDP]
set null [new Agent/Null]
$ns attach-agent $node_(0) $udp
$ns attach-agent $node_(3) $null
$ns connect $udp $null
set cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp
$cbr set packetSize_ 512
$cbr set rate_ 1Mb
# Schedule Traffic
$ns at 1.0 “$cbr start”
$ns at 19.0 “$cbr stop”
# Define Mobility (Optional)
$ns at 2.0 “$node_(0) setdest 250 250 10.0”
$ns at 3.0 “$node_(1) setdest 300 300 10.0”
# Finish Procedure
proc finish {} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exec nam mesh_nam.nam &
exit 0
}
# Run the Simulation
$ns at $val(stop) “finish”
$ns run
- Run the Simulation
- Store the script as mesh_protocol_simulation.tcl.
- Process for the script in NS2:
ns mesh_protocol_simulation.tcl
- Outputs:
- Trace File: mesh_trace.tr for sample contains packet flow details.
- NAM File: mesh_nam.nam for instance network visualization.
- Analyze Results
Performance Metrics:
- Packet Delivery Ratio (PDR): Estimate the forward and received packets:
awk ‘BEGIN {sent=0; recv=0} {if ($1==”s”) sent++; if ($1==”r”) recv++}
END {print “PDR:”, recv/sent*100 “%”}’ mesh_trace.tr
- End-to-End Delay: Extract the packets are timestamps for calculate the delay.
- Throughput: Calculate the total data successfully received over replication time.
- Routing Overhead: Measure the number of control packets for instance route request, replies.
- Extend the Project
Here are some advanced ideas for extending the project:
- Comparison of Mesh Protocols:
- The routing effectiveness is replicate and associate for AODV, DSR, and HWMP has efficiency.
- Mobility:
- Use the mobility for replicate the mobile mesh nodes are Random Waypoint.
- Traffic Types:
- Improve the FTP (TCP) and CBR (UDP) for performance comparison.
- QoS Metrics:
- Execute the QoS metrics for packet prioritization or delay-sensitive traffic.
- Fault Tolerance:
- Replicate the node or connection failures and calculate the network recovery time.
- Document the Results
Include:
- Network Topology: Initially the document gathers the information and analyzes the scope and then process for network topology has contains the Node placement, connection, and protocol setup.
- Simulation Parameters: After the process for topology gives the simulation for Node count, bandwidth, and kind of congestion.
- Performance Metrics: It performance the outcomes give for PDR, throughput, delay, and routing overhead.
- Comparative Analysis:
- Associate the performance by various mesh routing protocols.
- Conclusion:
- It concerns the observations and protocol efficiency.
The given above is the fundamental approach that was illustrated with sample coding for mesh topology project that were simulated across the ns2 environment. A dedicated manual will be shared to handle further inquiries about this project.