Advertisement
anik314159

Ass1.tcl Final

Jul 24th, 2022
1,406
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 2.79 KB | None | 0 0
  1. set ns [new Simulator]
  2. set nf [open ass1.nam w]
  3. set f [open ass1.tr w]
  4. $ns namtrace-all $nf
  5. $ns trace-all $f
  6.  
  7. $ns rtproto Session
  8. proc finish {} {
  9.  
  10. global ns f
  11. $ns flush-trace
  12. close $f
  13.  
  14. exec nam ass1.nam &
  15. exit 0
  16. }
  17.  
  18. set n0 [$ns node]
  19. set n1 [$ns node]
  20. set n2 [$ns node]
  21. set n3 [$ns node]
  22. set n4 [$ns node]
  23. set n5 [$ns node]
  24. set n6 [$ns node]
  25. set n7 [$ns node]
  26. set n8 [$ns node]
  27. set n9 [$ns node]
  28.  
  29. $n1 color red
  30. $n2 color blue
  31. $n3 color green
  32. $n6 color green
  33. $n0 color red
  34. $n7 color blue
  35.  
  36. $ns color 1 red
  37. $ns color 2 blue
  38. $ns color 3 green
  39.  
  40. $ns duplex-link $n1 $n2 20Mb 10ms DropTail
  41. $ns duplex-link-op $n1 $n2 orient right
  42. $ns duplex-link $n3 $n4 20Mb 10ms DropTail
  43. $ns duplex-link-op $n3 $n4 orient right
  44. $ns duplex-link $n4 $n5 20Mb 10ms DropTail
  45. $ns duplex-link-op $n4 $n5 orient right
  46. $ns duplex-link $n5 $n6 20Mb 10ms DropTail
  47. $ns duplex-link-op $n5 $n6 orient right
  48. $ns duplex-link $n1 $n4 20Mb 10ms DropTail
  49. $ns duplex-link-op $n1 $n4 orient down
  50. $ns duplex-link $n2 $n5 20Mb 10ms DropTail
  51. $ns duplex-link-op $n2 $n5 orient down
  52. $ns duplex-link $n8 $n9 20Mb 10ms DropTail
  53. $ns duplex-link-op $n8 $n9 orient right
  54.  
  55. $ns simplex-link $n3 $n7 10Mb 5ms SFQ
  56. $ns simplex-link-op $n3 $n7 orient down
  57. $ns simplex-link $n4 $n8 10Mb 5ms SFQ
  58. $ns simplex-link-op $n4 $n8 orient down
  59. $ns simplex-link $n9 $n5 10Mb 5ms SFQ
  60. $ns simplex-link-op $n9 $n5 orient up
  61. $ns simplex-link $n6 $n0 10Mb 5ms SFQ
  62. $ns simplex-link-op $n6 $n0 orient down
  63. $ns simplex-link $n7 $n8 10Mb 5ms SFQ
  64. $ns simplex-link-op $n7 $n8 orient right
  65. $ns simplex-link $n0 $n9 10Mb 5ms SFQ
  66. $ns simplex-link-op $n0 $n9 orient left
  67.  
  68.  
  69. set tcp [new Agent/TCP]
  70. $ns attach-agent $n1 $tcp
  71. set sink [new Agent/TCPSink]
  72. $ns attach-agent $n0 $sink
  73. $ns connect $tcp $sink
  74. $tcp set fid_ 1
  75. $tcp set packetSize_ 1024
  76.  
  77. set ftp [new Application/FTP]
  78. $ftp attach-agent $tcp
  79. $ftp set type_ FTP
  80. $ftp set random_ false
  81. $ftp set rate_ 0.02Mb
  82. $ns at 0.0 "$ftp start"
  83.  
  84. set udp0 [new Agent/UDP]
  85. $ns attach-agent $n2 $udp0
  86. $udp0 set fid_ 2
  87. set cbr0 [new Application/Traffic/CBR]
  88. $cbr0 set packetSize_ 1024
  89. $cbr0 set random_ false
  90. $cbr0 set rate_ 0.01Mb
  91. $cbr0 attach-agent $udp0
  92.  
  93. set null0 [new Agent/Null]
  94. $ns attach-agent $n7 $null0
  95. $ns connect $udp0 $null0
  96.  
  97. set udp1 [new Agent/UDP]
  98. $ns attach-agent $n3 $udp1
  99. $udp1 set fid_ 3
  100. set cbr1 [new Application/Traffic/CBR]
  101. $cbr1 set packetSize_ 1024
  102. $cbr1 set random_ false
  103. $cbr1 set rate_ 0.01Mb
  104. $cbr1 attach-agent $udp1
  105.  
  106. set null1 [new Agent/Null]
  107. $ns attach-agent $n6 $null1
  108. $ns connect $udp1 $null1
  109.  
  110. $ns at 0.0 "$cbr0 start"
  111. $ns at 1.0 "$cbr1 start"
  112. #$ns at 0.5 "$ftp stop"
  113. $ns rtmodel-at 5.0 down $n4 $n5
  114. $ns rtmodel-at 55.0 up $n4 $n5
  115.  
  116. $ns rtmodel-at 20.0 down $n8 $n9
  117. $ns rtmodel-at 40.0 up $n8 $n9
  118.  
  119.  
  120.  
  121.  
  122.  
  123. $ns at 100.0 "finish"
  124. $ns run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement