0% found this document useful (0 votes)
8 views7 pages

static and dynamic routing

Uploaded by

haricharanorsu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views7 pages

static and dynamic routing

Uploaded by

haricharanorsu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

EXPERIMENT NO.

:6

STATIC AND DYNAMIC ROUTING PROTOCOL

AIM:

SOFTWARE REQUIREMENTS:

THEORY:
Static Protocol
set ns [new Simulator]

$ns color 1 Red

set nf [open SR.nam w]

$ns namtrace-all $nf

proc finish {} {

global ns nf

$ns flush-trace

close $nf

exec nam SR.nam &

exit 0

#creating nodes

for {set i 0} {$i < 7} {incr i} {

set n($i) [$ns node]

#creating links

for {set i 0} {$i < 7} {incr i} {

$ns duplex-link $n($i) $n([expr ($i+1)%7]) 1Mb 10ms DropTail

$ns duplex-link $n(0) $n(3) 1Mb 10ms DropTail

#create a udp agent and attach it to noe n(0) and sink it to sink n(3)

set udp0 [new Agent/UDP]

$ns attach-agent $n(0) $udp0

set null0 [new Agent/Null]

$ns attach-agent $n(3) $null0

# $udp0 set fid_1


#create a cbr traffic source and attach it to udp0

set cbr0 [new Application/Traffic/CBR]

$cbr0 set packetSize_ 500

$cbr0 set interval_ 0.01

$cbr0 attach-agent $udp0

$ns connect $udp0 $null0

#Assign costs to links

$ns cost $n(0) $n(3) 5

$ns cost $n(0) $n(1) 5

$ns cost $n(1) $n(2) 2

$ns cost $n(2) $n(3) 2

$ns cost $n(3) $n(4) 3

$ns cost $n(4) $n(5) 2

$ns cost $n(5) $n(6) 1

$ns cost $n(6) $n(0) 2

$ns at 0.5 "$cbr0 start"

$ns at 4.5 "$cbr0 stop"

#Define static routing protocol

$ns rtproto LS

#Link failure

$ns rtmodel-at 1.5 down $n(0) $n(3)

$ns rtmodel-at 2.5 up $n(0) $n(3)

$ns at 5.0 "finish"


#Run the simulation

$ns run
Dynamic Routing Protocol

set ns [new Simulator]

$ns color 1 Red

set nf [open SR.nam w]

$ns namtrace-all $nf

proc finish {} {

global ns nf

$ns flush-trace

close $nf

exec nam SR.nam &

exit 0

#creating nodes

for {set i 0} {$i < 7} {incr i} {

set n($i) [$ns node]

#creating links

for {set i 0} {$i < 7} {incr i} {

$ns duplex-link $n($i) $n([expr ($i+1)%7]) 1Mb 10ms DropTail

$ns duplex-link $n(0) $n(3) 1Mb 10ms DropTail

#create a udp agent and attach it to noe n(0) and sink it to sink n(3)

set udp0 [new Agent/UDP]

$ns attach-agent $n(0) $udp0

set null0 [new Agent/Null]

$ns attach-agent $n(3) $null0


# $udp0 set fid_1

#create a cbr traffic source and attach it to udp0

set cbr0 [new Application/Traffic/CBR]

$cbr0 set packetSize_ 500

$cbr0 set interval_ 0.01

$cbr0 attach-agent $udp0

$ns connect $udp0 $null0

#Assign costs to links

$ns cost $n(0) $n(3) 5

$ns cost $n(0) $n(1) 5

$ns cost $n(1) $n(2) 2

$ns cost $n(2) $n(3) 2

$ns cost $n(3) $n(4) 3

$ns cost $n(4) $n(5) 2

$ns cost $n(5) $n(6) 1

$ns cost $n(6) $n(0) 2

$ns at 0.5 "$cbr0 start"

$ns at 4.5 "$cbr0 stop"

#Define dynamic routing protocol

$ns rtproto DV

#Link failure

#$ns rtmodel-at 1.5 down $n(0) $n(3)

#$ns rtmodel-at 2.5 up $n(0) $n(3)

#$ns at 5.0 "finish"


#Run the simulation

$ns run

For Link Failure Condition

You might also like