How to Start on Demand Protocol Projects Using NS2

To create an on-demand protocol projects in NS2 has includes for operates through protocol which launch the routes dynamically required such as AODV (Ad Hoc On-Demand Distance Vector), DSR (Dynamic Source Routing), and TORA (Temporally Ordered Routing Algorithm). Here’s a step-by-step guide for starting projects focused on on-demand routing protocols in NS2:

Steps to Start on Demand Protocol Projects Using NS2

  1. Understand On-Demand Routing Protocols
  • Key Characteristics:
    • Routes are launch only after requires forwarding a data packet.
    • Reactive protocols are decrease the routing overhead nevertheless can increase latency for during discovery the route.
  • Popular Protocols:
    • AODV: Associate the traditional distance-vector routing by on-demand route discovery.
    • DSR: Uses source routing in which the complete route has included the packet header.
    • TORA: Assure the loop-free routes and maintain the network partitions efficiently.
  1. Define Your Project Goals

Identify the focus of your project:

  1. Protocol Simulation:
    • Replicate and examine the behavior of AODV, DSR, or TORA.
  2. Performance Comparison:
    • Associate the parameter metrics such as packet delivery ratio (PDR), delay, and routing overhead for various on-demand protocols.
  3. Optimization:
    • Improve the protocol for improved energy efficiency, scalability, or security.
  4. Scenario Analysis:
    • Calculate the performance below various node mobility, congestion design, or network size.
  5. Security Mechanisms:
    • Replicate the attacks such as blackhole, wormhole and propose solutions.
  1. Set up NS2
  1. Install NS2:
    • Use the tool like NS2.35 on Linux for compatibility by ad hoc protocols.
  2. Verify Installation:
    • Validate a basic instance of replication for operates confirm of NS2.
  1. Create a Simulation Script

Write a TCL script for replicate the chosen on-demand protocol.

Example: AODV Protocol Simulation

  1. Set Up the Network Topology:

set ns [new Simulator]

# Define trace and animation files

set tracefile [open ondemand.tr w]

$ns trace-all $tracefile

set namfile [open ondemand.nam w]

$ns namtrace-all $namfile

# Create nodes

set n0 [$ns node]

set n1 [$ns node]

set n2 [$ns node]

set n3 [$ns node]

# Create links

$ns duplex-link $n0 $n1 2Mb 10ms DropTail

$ns duplex-link $n1 $n2 2Mb 10ms DropTail

$ns duplex-link $n2 $n3 2Mb 10ms DropTail

  1. Specify the On-Demand Protocol:
    • We configure the AODV, DSR, or TORA as the routing protocol:

set val(rp) AODV ;# Use AODV as the routing protocol

  1. Add Traffic Sources:
    • Setting the TCP or UDP sources:

set udp [new Agent/UDP]

$ns attach-agent $n0 $udp

set null [new Agent/Null]

$ns attach-agent $n3 $null

$ns connect $udp $null

set cbr [new Application/Traffic/CBR]

$cbr set packetSize_ 512

$cbr set interval_ 0.1

$cbr attach-agent $udp

  1. Define Node Mobility:
    • Enhance the mobility design for the replication of dynamic topology:

$ns at 5.0 “$n0 setdest 100 200 10.0”

$ns at 10.0 “$n1 setdest 200 100 15.0”

  1. Run the Simulation:

$ns at 50.0 “finish”

proc finish {} {

global ns tracefile namfile

$ns flush-trace

close $tracefile

close $namfile

exec nam ondemand.nam &

exit 0

}

$ns run

  1. Analyze Simulation Results

Analyze the trace file like as ondemand.tr for estimate the performance of protocol.

Metrics to Evaluate:

  1. Packet Delivery Ratio (PDR):
    • Designed for total forwarding the packets are delivered in successfully ratio:

awk ‘{if ($1 == “r” && $4 == “AGT”) recd++; if ($1 == “s” && $4 == “AGT”) sent++} END {print “PDR:”, recd/sent*100 “%”}’ ondemand.tr

  1. End-to-End Delay:
    • Calculate the average delay for packets to reach their destination.
  2. Routing Overhead:
    • Total number of control packets are created during route discovery:

awk ‘{if ($7 == “AODV” || $7 == “DSR”) count++} END {print “Routing Overhead:”, count}’ ondemand.tr

  1. Throughput:
    • Calculate the number of data successfully delivered over time.
  1. Visualize Results
  1. Use NAM (Network Animator):
    • Envision for the node mobility, route discovery, and packet flow:

nam ondemand.nam

  1. Plot Metrics:
    • Use the tools Python, MATLAB, or Excel to graph parameter metrics like as PDR vs. node density, delay vs. mobility, etc.
  1. Extend or Modify Protocols

Example: Adding Energy Awareness to AODV

  1. Alter the AODV source files such as aodv.h, aodv.cc in the ns-2.35/adhoc/aodv/ directory.
  2. Improve the energy metric for route selection:

double energy = node->energy();

if (energy > threshold) {

// Prefer routes with higher residual energy

}

  1. Recompile NS2:

make clean

make

File Locations:

  • AODV: ns-2.35/adhoc/aodv/
  • DSR: ns-2.35/adhoc/dsr/
  • TORA: Further patches might be vital for ensure the TORA.
  1. Advanced Features
  1. Simulate Attacks:
    • The resilience replicates the attacks black hole, wormhole, or grayhole attacks and estimates the protocol.
  2. Energy-Efficient Routing:
    • Improve the protocols has involves the energy-aware metrics for route discovery.
  3. QoS Support:
    • Alter the protocols to prioritize the routes according to bandwidth, delay, or jitter.
  4. Scalability Testing:
    • Improve the number of nodes and estimate the protocol performance.
  5. Comparison Studies:
    • Associate the performance of AODV, DSR, and TORA below the network environments are different.
  1. Compare On-Demand Protocols
  1. It replicate the several protocols for instance AODV, DSR, TORA for below the similar network environments.
  2. Compare metrics:
    • PDR
    • Routing overhead
    • Convergence time
    • Energy consumption
  1. Document Your Project

Include:

  1. It starts with the objectives and problem definition.
  2. After the problem based on the network topology and simulation setup.
  3. The previous process gives the based on results and performance metrics.
  4. Finally it gives the contribution of document understandings and references for future developments.

Example Project Ideas

  1. Performance Analysis of On-Demand Protocols:
    • Associate the AODV and DSR below various mobility and design for the traffic.
  2. Energy-Aware On-Demand Protocols:
    • Enhance the energy-based metrics for improve the routing efficiency.
  3. Secure On-Demand Protocols:
    • Execute the cryptographic methods for secure the route discovery.
  4. On-Demand Protocols in IoT:
    • Validate the AODV or DSR in IoT networks by constrained devices.
  5. Load-Balancing in On-Demand Protocols:
    • It improves the route discovery for balancing the traffic load.

We demonstrate how the on demand protocol will simulate the network scenario and how to execute and analyse the outcomes on demand protocol projects using the ns2. Any queries related to this project will be clarified in a different manual.