Advertisement
SymphonySimper

cn1

Dec 11th, 2021
2,022
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 1.50 KB | None | 0 0
  1. set ns [new Simulator]
  2. /* Letter S is capital */
  3. set nf [open lab1.nam w] /* open a nam trace file in write mode */
  4. $ns namtrace-all $nf
  5. /* nf – nam file */
  6. set tf [open lab1.tr w] /* tf- trace file */
  7. $ns trace-all $tf
  8. proc finish { } { /* provide space b/w proc and finish and all are in small case */
  9. global ns nf tf
  10. $ns flush-trace /* clears trace file contents */
  11. close $nf
  12. close $tf
  13. exec nam lab1.nam &
  14. exit 0
  15. }
  16. set n0 [$ns node] /* creates 4 nodes */
  17. set n1 [$ns node]
  18. set n2 [$ns node]
  19. set n3 [$ns node]
  20. $ns duplex-link $n0 $n2 200Mb 10ms DropTail /*Letter M is capital Mb*/
  21. $ns duplex-link $n1 $n2 100Mb 5ms DropTail /*D and T are capital*/
  22. $ns duplex-link $n2 $n3 1Mb 1000ms DropTail
  23. $ns queue-limit $n0 $n2 50
  24. $ns queue-limit $n1 $n2 50
  25. set udp0 [new Agent/UDP] /* Letters A,U,D and P are capital */
  26. $ns attach-agent $n0 $udp0
  27. set cbr0 [new Application/Traffic/CBR] /* A,T,C,B and R are capital*/
  28. $cbr0 set packetSize_ 500 /*S is capital, space after underscore*/
  29. $cbr0 set interval_ 0.005
  30. $cbr0 attach-agent $udp0
  31. $cbr0 attach-agent $udp0
  32. set udp1 [new Agent/UDP]
  33. $ns attach-agent $n1 $udp1
  34. set cbr1 [new Application/Traffic/CBR]
  35. $cbr1 attach-agent $udp1
  36. set udp2 [new Agent/UDP]
  37.  
  38. $ns attach-agent $n2 $udp2
  39. set cbr2 [new Application/Traffic/CBR]
  40. $cbr2 attach-agent $udp2
  41. set null0 [new Agent/Null] /* A and N are capital */
  42. $ns attach-agent $n3 $null0
  43. $ns connect $udp0 $null0
  44. $ns connect $udp1 $null0
  45. $ns at 0.1 "$cbr0 start"
  46. $ns at 0.2 "$cbr1 start"
  47. $ns at 1.0 "finish"
  48. $ns run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement