How to use Distance Vector Routing (DV) protocol in ns2

Description

In Distance Vector (DV), each node sends periodic route updates for every 2 seconds. Apart from the periodic updates, each node/agent sends triggered updates as a result of changes in the forwarding table in the node if any. This occurs either due to changes in the network topology or the node received a route update and as a result, it composes a fresh route. The test7.tcl shows the sample tcl code that runs the application with DV routing protocol.

# Filename: test7.tcl

#———— Routing Protocol —————#

$ns rtproto DV

#————–TCP CONNECTION BETWEEN NODES—————#
$ns at 0.0 "Tranmission"
proc Tranmission {} {
global C ROU R ns

set now [$ns now]
set time 10.0
set x 3
set y 4

set tcp1 [$ns create-connection TCP $C($x) TCPSink $R($y) 1]
$ns at $now "$ns trace-annotate \"Time: $now Pkt Transfer between Client($x) Receiver($y)..\""
$tcp1 set class_ 1
$tcp1 set maxcwnd_ 16
$tcp1 set packetsize_ 4000
$tcp1 set fid_ 1
set ftp1 [$tcp1 attach-app FTP]
$ftp1 set interval_ .005
$ns at $now "$ftp1 start"
$ns at [expr $now+$time] "$ftp1 stop"

}

Routing process

Distance Vector Routing (DV) protocol used in NS2

Data Transmission

Distance Vector Routing (DV) protocol used in NS2