How to Simulate DSDV Protocol Projects Using NS2

To simulate Destination-Sequenced Distance Vector (DSDV) protocol in NS2, we can take benefits of NS2’s built-in support for DSDV; by the way of NS2 that already has implementations for numerous routing protocols, that involves DSDV. The DSDV protocol is a proactive routing protocol for mobile ad-hoc networks (MANETs) that sustains a full routing table at every node and updates it intermittently.

Here’s a step-by-step guide on how to simulate DSDV protocol-based projects in NS2.

Steps to Simulate DSDV Protocol in NS2

  1. Install NS2:
    • Make sure NS2 is installed on the system. NS2 comes pre-configured with DSDV, so we don’t need to install any additional packages.
  2. Define Network Topology:
    • Generate a network topology using mobile nodes that will contribute in the DSDV routing process.

Example of a Simple Network Topology:

# Create the simulator instance

set ns [new Simulator]

# Open a trace file to record the simulation data

set tracefile [open dsdv.tr w]

$ns trace-all $tracefile

# Open a file to record the simulation results

set namfile [open dsdv.nam w]

$ns namtrace-all $namfile

# Define the topography object

set topo [new Topography]

$topo load_flatgrid 500 500

# Define the nodes

set n0 [$ns node]

set n1 [$ns node]

set n2 [$ns node]

  1. Enable DSDV Protocol:
    • In NS2, we can permit the DSDV protocol by specifying it in the TCL script when generating mobile nodes. Each node in the simulation will utilize DSDV to sustain routing information and interchange routing table updates with neighbours.

Example of Enabling DSDV in NS2:

# Setting up mobile nodes with DSDV routing protocol

set val(chan)       Channel/WirelessChannel   ;# Channel type

set val(prop)       Propagation/TwoRayGround  ;# Propagation model

set val(netif)      Phy/WirelessPhy           ;# Network interface type

set val(mac)        Mac/802_11                ;# MAC layer type

set val(ifq)        Queue/DropTail/PriQueue   ;# Interface queue type

set val(ll)         LL                        ;# Link layer type

set val(ant)        Antenna/OmniAntenna       ;# Antenna model

set val(ifqlen)     50                        ;# Max packet queue length

set val(nn)         3                         ;# Number of mobile nodes

set val(rp)         DSDV                      ;# Routing protocol (DSDV)

# Set up the channel

$ns node-config -adhocRouting $val(rp) \

-llType $val(ll) \

-macType $val(mac) \

-ifqType $val(ifq) \

-ifqLen $val(ifqlen) \

-antType $val(ant) \

-propType $val(prop) \

-phyType $val(netif) \

-channelType $val(chan) \

-topoInstance $topo \

-agentTrace ON \

-routerTrace ON \

-macTrace ON

  1. Set Up Mobility and Traffic Patterns:
    • DSDV is usually utilized in mobile ad-hoc networks (MANETs), so it’s essential to describe the mobility of the nodes and the traffic pattern among them.
    • We can describe mobility using the setdest command, and traffic is generated using traffic generators such as Constant Bit Rate (CBR) or FTP over TCP.

Example: Setting Node Mobility

# Set up node movement

$n0 set X_ 50

$n0 set Y_ 50

$n0 set Z_ 0.0

$n1 set X_ 100

$n1 set Y_ 100

$n1 set Z_ 0.0

$n2 set X_ 150

$n2 set Y_ 150

$n2 set Z_ 0.0

# Movement patterns for the nodes

$ns at 10.0 “$n0 setdest 200 300 15”

$ns at 20.0 “$n1 setdest 250 350 10”

Example: Setting Traffic Pattern

# Create a UDP agent and attach it to node 0

set udp0 [new Agent/UDP]

$ns attach-agent $n0 $udp0

# Create a traffic source

set cbr0 [new Application/Traffic/CBR]

$cbr0 set packetSize_ 512

$cbr0 set interval_ 0.2

$cbr0 attach-agent $udp0

# Create a Null agent (sink) and attach it to node 2

set null0 [new Agent/Null]

$ns attach-agent $n2 $null0

# Connect the UDP agent to the Null agent

$ns connect $udp0 $null0

# Start the traffic at 1.0 second

$ns at 1.0 “$cbr0 start”

  1. Set Simulation Time and Run the Simulation:
    • Set the simulation time and execute the simulation.

Example: Running the Simulation

# Set simulation time and run

$ns at 50.0 “finish”

proc finish {} {

global ns tracefile namfile

$ns flush-trace

close $tracefile

close $namfile

exec nam dsdv.nam &

exit 0

}

$ns run

  1. Analyse the Results:
    • After processing the simulation, we will have a trace file (dsdv.tr) and a NAM file (dsdv.nam) for envision the node movements and packet transmissions.
    • We can utilize awk or other tools to evaluate the trace file for numerous parameters such as packet delivery ratio, end-to-end delay, and routing overhead.

Example: Analysing Packet Delivery Ratio (PDR)

awk ‘{

if($1 == “s”) { sent++ }

if($1 == “r”) { received++ }

} END { printf(“Packet Delivery Ratio: %.2f%\n”, (received/sent)*100) }’ dsdv.tr

Advanced Simulation Ideas for DSDV

  1. Varying Node Density:
    • Increase or decrease the number of nodes in the network and learn on how node density impacts routing performance, that contain packet delivery ratio and delay.
  2. Mobility Models:
    • Utilize different mobility models such as random waypoint, random walk, or group mobility to learn on how DSDV act as in different environment.
  3. Traffic Variations:
    • Establish changing traffic patterns, like bursts of traffic, multiple CBR or FTP connections, or fluctuating packet sizes, to track the performance of DSDV under different loads.
  4. Simulate Link Failures:
    • Replicate link failures among nodes and track on how DSDV manage this environment; concentrate on convergence time and recovery behaviour.

Example: Simulating Link Failure

# Simulate link failure between node 0 and node 1 at time 20.0s

$ns rtmodel-at 20.0 down $n0 $n1

  1. Performance Comparison with Other Protocols:
    • Relate the performance of DSDV with other routing protocols such as AODV (Ad-hoc On-demand Distance Vector) or DSR (Dynamic Source Routing) in similar network topologies and traffic patterns.

Metrics for DSDV Performance Evaluation

  • Packet Delivery Ratio (PDR): The ratio of the number of successfully delivered data packets to the destination to the total number of data packets transmit by the sources.
  • End-to-End Delay: The time taken for a packet to travel from the source to the destination.
  • Routing Overhead: The number of control overhead created by DSDV that has periodic updates and caused updates because of topology changes.
  • Throughput: The rate of successful message delivery over the communication channel.
  • Route Convergence Time: The time taken by DSDV to adjust to a topology change such as after link failure or node mobility.

By utilizing the network simulator 2, you can simulate and measure the performance for Destination-Sequenced Distance Vector protocol projects that were simulated and visualized the results in the above following steps. We will be offer more information related this project in another manual.

If you want to connect with us, we can give you some cool project topics and ideas that fit what you’re looking for. Our team is experienced with many routing protocols, so reach out to us for the best outcomes. You can always count on us for great help with DSDV Protocol Projects. We offer personalized support to help you with your unique requirements.

Opening Time

9:00am

Lunch Time

12:30pm

Break Time

4:00pm

Closing Time

6:30pm

  • award1
  • award2