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

  1. 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.

  1. 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:

  1. AODV (Ad hoc On-Demand Distance Vector): Reactive routing protocol.
  2. DSR (Dynamic Source Routing): Route discovery on-demand.
  3. HWMP (Hybrid Wireless Mesh Protocol): Describe the protocol for IEEE 802.11s mesh networks.
  1. 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
  1. 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

  1. Run the Simulation
  1. Store the script as mesh_protocol_simulation.tcl.
  2. Process for the script in NS2:

ns mesh_protocol_simulation.tcl

  1. Outputs:
    • Trace File: mesh_trace.tr for sample contains packet flow details.
    • NAM File: mesh_nam.nam for instance network visualization.
  1. Analyze Results

Performance Metrics:

  1. 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

  1. End-to-End Delay: Extract the packets are timestamps for calculate the delay.
  2. Throughput: Calculate the total data successfully received over replication time.
  3. Routing Overhead: Measure the number of control packets for instance route request, replies.
  1. Extend the Project

Here are some advanced ideas for extending the project:

  1. Comparison of Mesh Protocols:
    • The routing effectiveness is replicate and associate for AODV, DSR, and HWMP has efficiency.
  2. Mobility:
    • Use the mobility for replicate the mobile mesh nodes are Random Waypoint.
  3. Traffic Types:
    • Improve the FTP (TCP) and CBR (UDP) for performance comparison.
  4. QoS Metrics:
    • Execute the QoS metrics for packet prioritization or delay-sensitive traffic.
  5. Fault Tolerance:
    • Replicate the node or connection failures and calculate the network recovery time.
  1. Document the Results

Include:

  1. 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.
  2. Simulation Parameters: After the process for topology gives the simulation for Node count, bandwidth, and kind of congestion.
  3. Performance Metrics: It performance the outcomes give for PDR, throughput, delay, and routing overhead.
  4. Comparative Analysis:
    • Associate the performance by various mesh routing protocols.
  5. 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.