Comparision of roution algm
set ns [new Simulator]
$ns color 1 Blue
$ns color 2 Red
set nf [open /home/student/Desktop/ex12b2910007/vs.nam
w]
$ns namtrace-all $nf
set nd [open /home/student/Desktop/ex12b2910007/vs.tr
w]
$ns trace-all $nd
set f2 [open /home/student/Desktop/ex12b2910007/DV.tr
w]
set last_ack 0
proc record {} {
global
ns null tcp f2 last_ack
set
time 0.2 ;#Set Sampling Time to 0.2 Sec
set
c [$tcp set ack_]
set
d [$tcp set packetSize_]
set
now [$ns now]
if
{ $c > 0 } {
set
e [expr $c - $last_ack]
puts
$f2 "$now [expr $e*$d*8/$time]"
set
last_ack $c
}
else {
puts
$f2 "$now 0" }
$ns
at [expr $now+$time] "record" ;# Schedule Record after $time interval
sec
}
proc finish {} { global ns nf nd f2
$ns
flush-trace
close
$nf
close
$nd
close
$f2
exit
0
}
$ns rtproto DV
set n0 [$ns
node]
set n1 [$ns
node]
set n2 [$ns
node]
set n3 [$ns
node]
set n4 [$ns
node]
set n5 [$ns
node]
set n6 [$ns
node]
$ns duplex-link
$n0 $n1 2Mb 10ms DropTail
$ns duplex-link
$n1 $n2 2Mb 10ms DropTail
$ns duplex-link
$n2 $n5 1.7Mb 20ms DropTail
$ns duplex-link
$n5 $n4 2Mb 10ms DropTail
$ns duplex-link
$n4 $n3 2Mb 10ms DropTail
$ns duplex-link
$n3 $n1 2Mb 10ms DropTail
$ns duplex-link-op $n0 $n1 orient right
$ns duplex-link-op $n1 $n2 orient down
$ns duplex-link-op $n1 $n3 orient right
$ns duplex-link-op $n2 $n5 orient right
$ns duplex-link-op $n3 $n4 orient right-down
$ns duplex-link-op $n5 $n4 orient right-up
set tcp [new
Agent/TCP]
$ns attach-agent
$n0 $tcp
set sink [new
Agent/TCPSink]
$ns attach-agent
$n5 $sink
$ns connect $tcp
$sink
$tcp set fid_ 1
set ftp [new
Application/FTP]
$ftp
attach-agent $tcp
$ftp set type_
FTP
$ns rtmodel-at
1.0 down $n1 $n2
$ns rtmodel-at
2.5 up $n1 $n2
$ns at 0.0
"record"
$ns at 0.1
"$ftp start"
$ns at 4.5
"$ftp stop"
$ns at 4.8
"$ns detach-agent $n0 $tcp ; $ns detach-agent $n5 $sink"
$ns at 5.0
"finish"
$ns run
No comments:
Post a Comment