#5, First Floor, 4th Street , Dr. Subbarayan Nagar, Kodambakkam, Chennai-600 024 pro@slogix.in

Office Address

  • #5, First Floor, 4th Street Dr. Subbarayan Nagar Kodambakkam, Chennai-600 024 Landmark : Samiyar Madam
  • pro@slogix.in
  • +91- 81240 01111

Social List

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.

Sample Code

# 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"

}


Screenshots

Routing process

Data Transmission