Advertisement
anik314159

Untitled

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