Advertisement
filipao223

exercicio3.tcl

Oct 10th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 1.30 KB | None | 0 0
  1. set ns [new Simulator]
  2.  
  3. $ns rtproto DV
  4.  
  5. set nf [open out.nam w]
  6. $ns namtrace-all $nf
  7.  
  8. proc fim {} {
  9.  
  10.     global ns nf
  11.     $ns flush-trace
  12.     close $nf
  13.     exec nam out.nam
  14.     exit 0
  15. }
  16.  
  17.  
  18. set n0 [$ns node]
  19. set n1 [$ns node]
  20. set n2 [$ns node]
  21. set n3 [$ns node]
  22.  
  23. $ns duplex-link $n0 $n1 1Mb 0.03ms DropTail
  24. $ns duplex-link $n1 $n2 1Mb 20ms DropTail
  25. $ns duplex-link $n1 $n3 2Mb 116ms DropTail
  26.  
  27. #Altera o tamanho da fila
  28. $ns queue-limit $n0 $n1 30
  29.  
  30. #Agente TCP
  31. set tcp0 [new Agent/TCP]
  32. $tcp0 set window_ 10
  33. $ns attach-agent $n0 $tcp0
  34.  
  35. #TCP end
  36. set tcp_end [new Agent/TCPSink]
  37. $ns attach-agent $n2 $tcp_end
  38.  
  39. $ns connect $tcp0 $tcp_end
  40.  
  41. #Primeiro CBR
  42. set cbr0 [new Application/Traffic/CBR]
  43. $cbr0 attach-agent $tcp0
  44. $cbr0 set maxpkts_ 10
  45. $cbr0 set packetsize_ 1000
  46. $cbr0 set interval_ 0.5
  47.  
  48. #Agente UDP
  49. set udp0 [new Agent/UDP]
  50. $ns attach-agent $n2 $udp0
  51.  
  52. #Segundo CBR
  53. set cbr1 [new Application/Traffic/CBR]
  54. $cbr0 attach-agent $udp0
  55. $cbr0 set rate_ 240
  56.  
  57. #Agente Null
  58. set null0 [new Agent/Null]
  59. $ns attach-agent $n3 $null0
  60.  
  61. $ns connect $udp0 $null0
  62.  
  63. #Gere os periodos de envio
  64. $ns at 0.5 "$cbr0 start"
  65. $ns at 0.5 "$cbr1 start"
  66. $ns at 2.5 "$cbr1 stop"
  67.  
  68. #Simula a quebra de ligaçao entre no e n1
  69. $ns rtmodel-at 1.0 down $n0 $n1
  70. $ns rtmodel-at 1.5 up $n0 $n1
  71.  
  72. $ns at 3.5 "fim"
  73.  
  74. $ns run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement