Jan 25, 2006

Exercise 1

Write a Tcl script that forms a network consisting of 7 nodes, numbered from 1 to 7, forming a ring topology. The links have a 512Kbps bandwidth with 5ms delay. Set the routing protocol to DV (Distance vector). Send UDP packets from node 1 to node 4 with the rate of 100 packets/sec (using default packet size). Start transmission at 0.01. Bring down the link between node 2 and node 3 at 0.4. Finish the transmission at 1.000. Then run nam to view the results. Answer the following:


a. What path does the packets follow initially? and why?

b. What path does the packets take after the link fails? and why?

Answer :
Tcl script :
set ns [new Simulator]

# Set routing protocol
$ns rtproto DV

# Open nam tracefile
set nf [open prob1.nam w]

# Open tracefile
set nt [open trace.tr w]

$ns namtrace-all $nf
$ns trace-all $nt

#Define a 'finish' procedure
proc finish {} {
global ns nf nt
$ns flush-trace
close $nf
close $nt
exec nam -a prob1.nam &
exit 0
}

# create 7 nodes
puts "create 7 nodes now....."

set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]
set n6 [$ns node]
set n7 [$ns node]

puts "create connections now....."

# Create connection
$ns duplex-link $n1 $n2 0.512Mb 5ms DropTail
$ns duplex-link $n2 $n3 0.512Mb 5ms DropTail
$ns duplex-link $n3 $n4 0.512Mb 5ms DropTail
$ns duplex-link $n4 $n5 0.512Mb 5ms DropTail
$ns duplex-link $n5 $n6 0.512Mb 5ms DropTail
$ns duplex-link $n6 $n7 0.512Mb 5ms DropTail
$ns duplex-link $n7 $n1 0.512Mb 5ms DropTail

puts "Create agents and attach to appropriate nodes..."
...
...
...

puts "schedule transmitting packets..."
#schedule transmitting packets
$ns at 0.01 "$cbr start"
puts "link down node2 and node3............"
$ns rtmodel-at 0.40 down $n2 $n3
$ns at 1.00 "finish"
$ns run



Question a:
Intially the shortest path was chosen as according to Distance Vector, DV routing. The distance-vector routing is a type of algorithm used by routing protocols to discover routes on an interconnected network. The primary distance-vector routing algorithm is the Bellman-Ford algorithm. Distance-vector routing refers to a method for exchanging route information. A router will advertise a route as a vector of direction and distance. Direction refers to a port that leads to the next router along the path to the destination, and distance is a metric that indicates the number of hops to the destination, although it may also be an arbitrary value that gives one route precedence over another. Internetwork routers exchange this vector information and build route lookup tables from it.

Question b.
When the path failed, the packets will take the alternate route to the destination as the current shortest path is longer able to be used. The alternate path has been detected during the initialization of DV routing.

No comments: