Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set ns [new Simulator]
- #set nf [open out.nam w]
- #$ns namtrace-all $nf
- #Définition de la proc finish
- proc finish {} {
- global ns nf
- $ns flush-trace
- #Close the NAM trace file
- # close $nf
- # exec nam out.nam &
- exit 0
- }
- #noeuds centraux
- for {set i 0} {$i < 3} {incr i} {
- set n($i-0) [$ns node]
- }
- #feuilles
- for {set i 1} {$i < 31} {incr i} {
- set n(0-$i) [$ns node]
- set n(1-$i) [$ns node]
- set n(2-$i) [$ns node]
- }
- #relie les trois noeuds centraux
- $ns duplex-link $n(0-0) $n(1-0) 10Mb 0.1ms DropTail
- $ns duplex-link $n(1-0) $n(2-0) 10Mb 0.1ms DropTail
- $ns duplex-link $n(2-0) $n(0-0) 10Mb 0.1ms DropTail
- #liens noeuds et fils
- for {set i 0} {$i < 3} {incr i} {
- for {set j 1} {$j < 31} {incr j} {
- $ns duplex-link $n($i-0) $n($i-$j) 10Mb 0.1ms DropTail
- }
- }
- for {set i 0} {$i < 3} {incr i} {
- for {set j 1} {$j < 31} {incr j} {
- #udp
- set udp($i-$j-0) [new Agent/UDP]
- $ns attach-agent $n($i-$j) $udp($i-$j-0)
- set null [new Agent/Null]
- set res [expr ($i+1)%3]
- $ns attach-agent $n($res-$j) $null
- $ns connect $udp($i-$j-0) $null
- #cbr
- set cbr($i-$j-0) [new Application/Traffic/CBR]
- $cbr($i-$j-0) attach-agent $udp($i-$j-0)
- $cbr($i-$j-0) set type_ CBR
- $cbr($i-$j-0) set packet_size_ 1000
- $cbr($i-$j-0) set rate_ 1mb
- $cbr($i-$j-0) set random_ false
- set udp($i-$j-1) [new Agent/UDP]
- $ns attach-agent $n($i-$j) $udp($i-$j-1)
- set null [new Agent/Null]
- set res [expr ($i+2)%3]
- $ns attach-agent $n($res-$j) $null
- $ns connect $udp($i-$j-1) $null
- set cbr($i-$j-1) [new Application/Traffic/CBR]
- $cbr($i-$j-1) attach-agent $udp($i-$j-1)
- $cbr($i-$j-1) set type_ CBR
- $cbr($i-$j-1) set packet_size_ 1000
- $cbr($i-$j-1) set rate_ 1mb
- $cbr($i-$j-1) set random_ false
- }
- }
- for {set l 0} {$l < 3} {incr l} {
- for {set m 1} {$m < 31} {incr m} {
- $ns at 1 "$cbr($l-$m-0) start"
- $ns at 2 "$cbr($l-$m-1) start"
- $ns at 9 "$cbr($l-$m-0) stop"
- $ns at 9 "$cbr($l-$m-1) stop"
- }
- }
- #Appel du finish
- $ns at 10.0 "finish"
- #Lancer la simulation
- $ns run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement