Contents
Aim
To implement Distance Vector Routing algorithm.
S/W required
NS2
Background information
Distant vector routing protocol also called as Bellman-Ford algorithm or Ford Fulkerson algorithm used to find the shortest route from one node to another node in the network. A distance-vector protocol calculates the distance and direction of the vector of the next hop from the information obtained by the neighboring router. It is necessary to keep track of the topology and inform neighboring devices if any changes occur in the topology.
The routing protocol is used to calculate the best route from source to destination based on the distance or hops as its primary metric to define an optimal path. The distance vector refers to the distance to the neighbor nodes, where routing defines the routes to the established node.
The Distance Vector routing algorithm (DVR) shares the information of the routing table with the other routers in the network and keeps the information up-to-date to select an optimal path from source to destination. In DVR the data shared by the nodes are transmitted only to that node that is linked directly to one or more nodes in the network.
RIP or Routing Information Protocol is a routing protocol that uses the link state routing algorithm to exchange information (about neighboring routers, cost of the route, etc.) among the inter-network routers.
Activity
Program
#Create object for Simulator class
set ns [new Simulator]
#Initialization script
set tracefile [open out.tr w]
$ns trace-all $tracefile
set namfile [open out.nam w]
$ns namtrace-all $namfile
#Assign colors to traffic flows
$ns color 1 Red
$ns color 2 Blue
#Termination script
proc finish { } {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exec nam out.nam &
exit 0
}
#Creating nodes
for {set i 0} {$i < 12} {incr i 1} {
set n($i) [$ns node]
}
#Creating links
for {set i 0} {$i < 8} {incr i} {
$ns duplex-link $n($i) $n([expr $i+1]) 1Mb 10ms DropTail
}
$ns duplex-link $n(0) $n(8) 1Mb 10ms DropTail
$ns duplex-link $n(1) $n(10) 1Mb 10ms DropTail
$ns duplex-link $n(0) $n(9) 1Mb 10ms DropTail
$ns duplex-link $n(9) $n(11) 1Mb 10ms DropTail
$ns duplex-link $n(10) $n(11) 1Mb 10ms DropTail
$ns duplex-link $n(11) $n(5) 1Mb 10ms DropTail
#Creating UDP, Null agents and CBR applications
set udp0 [new Agent/UDP]
$ns attach-agent $n(0) $udp0
set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 500
$cbr0 set interval_ 0.005
$cbr0 attach-agent $udp0
set null0 [new Agent/Null]
$ns attach-agent $n(5) $null0
$ns connect $udp0 $null0
set udp1 [new Agent/UDP]
$ns attach-agent $n(1) $udp1
set cbr1 [new Application/Traffic/CBR]
$cbr1 set packetSize_ 500
$cbr1 set interval_ 0.005
$cbr1 attach-agent $udp1
set null0 [new Agent/Null]
$ns attach-agent $n(5) $null0
$ns connect $udp1 $null0
#Set routing protocol to DVR
$ns rtproto DV
#Make links up and down to test DVR
$ns rtmodel-at 10.0 down $n(11) $n(5)
$ns rtmodel-at 15.0 down $n(7) $n(6)
$ns rtmodel-at 30.0 up $n(11) $n(5)
$ns rtmodel-at 20.0 up $n(7) $n(6)
$udp0 set fid_ 1
$udp1 set fid_ 2
#Assign time to events
$ns at 1.0 "$cbr0 start"
$ns at 2.0 "$cbr1 start"
$ns at 45.0 "finish"
#Execute the script
$ns run
Input and output
Result
Distance Vector Routing has been understood and implemented successfully.
References
Suryateja Pericherla, at present is a Research Scholar (full-time Ph.D.) in the Dept. of Computer Science & Systems Engineering at Andhra University, Visakhapatnam. Previously worked as an Associate Professor in the Dept. of CSE at Vishnu Institute of Technology, India.
He has 11+ years of teaching experience and is an individual researcher whose research interests are Cloud Computing, Internet of Things, Computer Security, Network Security and Blockchain.
He is a member of professional societies like IEEE, ACM, CSI and ISCA. He published several research papers which are indexed by SCIE, WoS, Scopus, Springer and others.
Leave a Reply