#routeSession.tcl

set ns [new Simulator]

set nf [open routeSession.nam w]
$ns namtrace-all $nf

#Utilizzo il protocollo di routing Session
$ns rtproto Session

proc finish {} {
        global ns nf
        $ns flush-trace
        close $nf
        exec nam routeSession.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

#Livello di Trasporto
set udp0 [new Agent/UDP]
$ns attach-agent $n(0) $udp0
$udp0 set fid_ 0
$ns color 0 darkgreen

set udp1 [new Agent/UDP]
$ns attach-agent $n(1) $udp1
$udp1 set fid_ 1
$ns color 1 red

set null4 [new Agent/Null]
$ns attach-agent $n(4) $null4

$ns connect $udp0 $null4
$ns connect $udp1 $null4

#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.5 :link 0-4 down"
puts "0.7 :link 0-4 up\n\n"

#Temporizzazione della simulazione


$ns at 0.1 "$cbr0 start"
$ns at 0.3 "$cbr1 start"
$ns rtmodel-at 0.5 down $n(0) $n(4)
$ns rtmodel-at 0.7 up  $n(0) $n(4)
$ns at 1.5 "finish"

$ns run 

 

WB01337_.gif (904 bytes) Torna ad Unicast Routing