Advertisement
Guest User

Untitled

a guest
Nov 25th, 2018
490
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 2.10 KB | None | 0 0
  1. set ns [new Simulator]
  2.  
  3. #set nf [open out.nam w]
  4. #$ns namtrace-all $nf
  5.  
  6. #Définition de la proc finish
  7. proc finish {} {
  8.   global ns nf
  9.   $ns flush-trace
  10.   #Close the NAM trace file
  11. # close $nf
  12. # exec nam out.nam &
  13.   exit 0
  14. }
  15.  
  16. #noeuds centraux
  17. for {set i 0} {$i < 3} {incr i} {
  18.   set n($i-0) [$ns node]
  19. }
  20.  
  21. #feuilles
  22. for {set i 1} {$i < 31} {incr i} {
  23.   set n(0-$i) [$ns node]
  24.   set n(1-$i) [$ns node]
  25.   set n(2-$i) [$ns node]
  26. }
  27.  
  28. #relie les trois noeuds centraux
  29. $ns duplex-link $n(0-0) $n(1-0) 10Mb 0.1ms DropTail
  30. $ns duplex-link $n(1-0) $n(2-0) 10Mb 0.1ms DropTail
  31. $ns duplex-link $n(2-0) $n(0-0) 10Mb 0.1ms DropTail
  32.  
  33.  
  34. #liens noeuds et fils
  35. for {set i 0} {$i < 3} {incr i} {
  36.   for {set j 1} {$j < 31} {incr j} {
  37.     $ns duplex-link $n($i-0) $n($i-$j) 10Mb 0.1ms DropTail
  38.   }
  39. }
  40.  
  41.  
  42.  
  43. for {set i 0} {$i < 3} {incr i} {
  44.   for {set j 1} {$j < 31} {incr j} {
  45.     #udp
  46.     set udp($i-$j-0) [new Agent/UDP]
  47.     $ns attach-agent $n($i-$j) $udp($i-$j-0)
  48.     set null [new Agent/Null]
  49.     set res [expr ($i+1)%3]
  50.     $ns attach-agent $n($res-$j) $null
  51.     $ns connect $udp($i-$j-0) $null
  52.  
  53.     #cbr
  54.     set cbr($i-$j-0) [new Application/Traffic/CBR]
  55.     $cbr($i-$j-0) attach-agent $udp($i-$j-0)
  56.     $cbr($i-$j-0) set type_ CBR
  57.     $cbr($i-$j-0) set packet_size_ 1000
  58.     $cbr($i-$j-0) set rate_ 1mb
  59.     $cbr($i-$j-0) set random_ false
  60.  
  61.  
  62.     set udp($i-$j-1) [new Agent/UDP]
  63.     $ns attach-agent $n($i-$j) $udp($i-$j-1)
  64.     set null [new Agent/Null]
  65.     set res [expr ($i+2)%3]
  66.     $ns attach-agent $n($res-$j) $null
  67.     $ns connect $udp($i-$j-1) $null
  68.  
  69.     set cbr($i-$j-1) [new Application/Traffic/CBR]
  70.     $cbr($i-$j-1) attach-agent $udp($i-$j-1)
  71.     $cbr($i-$j-1) set type_ CBR
  72.     $cbr($i-$j-1) set packet_size_ 1000
  73.     $cbr($i-$j-1) set rate_ 1mb
  74.     $cbr($i-$j-1) set random_ false
  75.   }
  76. }
  77.  
  78. for {set l 0} {$l < 3} {incr l} {
  79.   for {set m 1} {$m < 31} {incr m} {
  80.   $ns at 1 "$cbr($l-$m-0) start"
  81.   $ns at 2 "$cbr($l-$m-1) start"
  82.   $ns at 9 "$cbr($l-$m-0) stop"
  83.   $ns at 9 "$cbr($l-$m-1) stop"
  84.   }
  85. }
  86.  
  87.  
  88. #Appel du finish
  89. $ns at 10.0 "finish"
  90.  
  91. #Lancer la simulation
  92. $ns run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement