How to do dynamic routing during link failure in wired network in ns2

Description

The link failure in the wired network leads to intolerable performance degradation. Therefore, it becomes necessary to use an efficient routing protocol that automatically recovers the link from the link failure. Distance Vector (DV) routing protocol automatically recovers the link failure by using alternative path for data transmission. In test8.tcl, the link between any two nodes can be failed using the command “rtmodel-at” along with keyword “down” with the time specification and the DV protocol recovers the link failure using dynamic route discovery mechanism.

# Filename: test8.tcl
# —————-Routing Protocol ————-#

$ns rtproto DV
$ns rtmodel-at 7.880511 down $ROU(1) $ROU(3)

# —————-ESTABLISHING COMMUNICATION ————-#

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

}

Data Transmission

dynamic routing during link failure in wired network in ns2

Link Failure

dynamic routing during link failure in wired network in ns2

Data Transmission over alternative path

dynamic routing during in wired link failure in ns2