Advertisement
filipao223

exercicio2.tcl

Oct 9th, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 1.26 KB | None | 0 0
  1. set ns [new Simulator]
  2.  
  3. set nf [open out.nam w]
  4. $ns namtrace-all $nf
  5.  
  6. proc fim {} {
  7.  
  8.     global ns nf
  9.     $ns flush-trace
  10.     close $nf
  11.     exec nam out.nam
  12.     exit 0
  13. }
  14.  
  15. set n4 [$ns node]
  16. set n1 [$ns node]
  17. set n2 [$ns node]
  18. set n3 [$ns node]
  19.  
  20. $ns duplex-link $n1 $n2 1Gb 1.67ms DropTail
  21. $ns duplex-link $n3 $n4 6.9Mb 2.31s DropTail
  22.  
  23. $ns duplex-link-op $n1 $n2 orient right-up
  24. $ns duplex-link-op $n3 $n4 orient right-down
  25.  
  26. #Novo UDP
  27. set udp1 [new Agent/UDP]
  28. $ns attach-agent $n1 $udp1
  29.  
  30. #Novo CBR
  31. set cbr1 [new Application/Traffic/CBR]
  32. $cbr1 set packetSize_ 16000000
  33. $cbr1 set interval_ 0.005s
  34. $cbr1 set maxpkts_ 1
  35. $cbr1 attach-agent $udp1
  36.  
  37. #Novo UDP
  38. set udp2 [new Agent/UDP]
  39. $ns attach-agent $n3 $udp2
  40.  
  41. #Novo CBR
  42. set cbr2 [new Application/Traffic/CBR]
  43. $cbr2 set packetSize_ 16000000
  44. $cbr2 set interval_ 0.005s
  45. $cbr2 set maxpkts_ 1
  46. $cbr2 attach-agent $udp2
  47.  
  48. #Novo Null
  49. set null1 [new Agent/Null]
  50. $ns attach-agent $n2 $null1
  51.  
  52. #Novo Null
  53. set null2 [new Agent/Null]
  54. $ns attach-agent $n4 $null2
  55.  
  56. $ns connect $udp1 $null1
  57. $ns connect $udp2 $null2
  58.  
  59. $udp1 set class_ 1
  60. $udp2 set class_ 2
  61.  
  62. $ns color 1 red
  63. $ns color 2 blue
  64.  
  65. $ns at 0.5 "$cbr1 start"
  66. $ns at 0.5 "$cbr2 start"
  67.  
  68. $ns at 4.5 "$cbr1 stop"
  69. $ns at 4.5 "$cbr2 stop"
  70.  
  71. $ns at 5.0 "fim"
  72. $ns run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement