#routeStatic.tcl
set ns [new Simulator]
set nf [open routeStatic.nam w]
$ns namtrace-all $nf
#Definisco il protocollo di routing che verra' usato da tutti i nodi.
#In realta' questa dichiarazione e' superflua dato che Static e' il
#valore di default di rtproto.
#$ns rtproto Static
proc finish {} {
global ns nf
$ns flush-trace
close $nf
exec nam routeStatic.nam &
exit 0 }
#Creazione della topologia
for {set i 0} {$i < 6} {incr i} {
set n($i) [$ns node]
}
for {set i 0 } {$i < 6} {incr i} {
$ns duplex-link $n($i) $n([expr ($i+1)%6]) 1Mb 10ms DropTail
}
$ns duplex-link $n(0) $n(4) 1Mb 10ms DropTail
#Costi dei link
$ns cost $n(0) $n(1) 2
$ns cost $n(1) $n(0) 2
$ns cost $n(1) $n(2) 1
$ns cost $n(2) $n(1) 1
$ns cost $n(2) $n(3) 5
$ns cost $n(3) $n(2) 5
$ns cost $n(3) $n(4) 10
$ns cost $n(4) $n(3) 10
$ns cost $n(4) $n(5) 10
$ns cost $n(5) $n(4) 10
$ns cost $n(5) $n(0) 10
$ns cost $n(0) $n(5) 10
$ns cost $n(4) $n(0) 10
$ns cost $n(0) $n(4) 10
#Monitoraggio della coda sul link 0-4
$ns duplex-link-op $n(0) $n(4) queuePos 0.5
$ns queue-limit $n(0) $n(4) 10
#Il livello di trasporto
#Sorgente 0
set udp0 [new Agent/UDP]
$ns attach-agent $n(0) $udp0
$udp0 set fid_ 0
$ns color 0 darkgreen
#Sorgente 1
set udp1 [new Agent/CBR]
$ns attach-agent $n(1) $udp1
$udp1 set fid_ 1
$ns color 1 red
#Destinatario
set null4 [new Agent/Null]
$ns attach-agent $n(4) $null4
#set loss0 [new Agent/LossMonitor]
#$ns attach-agent $n(0) $loss0
#$ns connect $cbr1 $loss0
$ns connect $udp0 $null4
$ns connect $udp1 $null4
#Il livello di applicazione
set cbr0 [new Application/Traffic/CBR]
$cbr0 attach-agent $udp0
set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp1
#Commenti
puts "\n\n##### COMMENTI #####\n"
puts "0.1 :cbr0 starts"
puts "0.3 :cbr1 starts"
puts "0.7 :link 0-4 down"
puts "1 :link 0-4 up\n"
#Temporizzazione della simulazione
$ns at 0.1 "$cbr0 start"
$ns at 0.3 "$cbr1 start"
$ns rtmodel-at 0.7 down $n(0) $n(4)
$ns rtmodel-at 1 up $n(0) $n(4)
$ns at 1.5 "finish"
$ns run
Torna ad unicast routing