AnindyaBiswas

TCL 3rd class

Apr 22nd, 2022 (edited)
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 0.90 KB | None | 0 0
  1. set ns [new Simulator]
  2. set f [open out.tr w]
  3. set nf [open output.nam w]
  4. $ns namtrace-all $nf
  5. $ns trace-all $f
  6. $ns color 1 Blue
  7. $ns color 2 Red
  8. proc finish { } {
  9.     global ns f
  10.     $ns flush-trace
  11.     close $f
  12.     exec nam output.nam &
  13.     exit 0
  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.  
  23. $n0 color red
  24. $n1 color blue
  25. $n2 color green
  26. $n3 color yellow
  27. $n4 color cyan
  28. $n5 color magenta
  29. $n6 color orange
  30.  
  31. $ns duplex-link $n0 $n1 1mb 10ms DropTail
  32. $ns duplex-link $n2 $n4 1mb 10ms DropTail
  33. $ns duplex-link $n3 $n5 1mb 10ms DropTail
  34. $ns simplex-link $n4 $n6 5mb 10ms DropTail
  35.  
  36. $ns duplex-link $n0 $n6 1mb 10ms DropTail
  37. $ns duplex-link $n1 $n4 1mb 10ms DropTail
  38. $ns duplex-link $n0 $n5 1mb 10ms DropTail
  39. $ns duplex-link $n1 $n3 1mb 10ms DropTail
  40. $ns duplex-link $n2 $n6 1mb 10ms DropTail
  41.  
  42. $ns at 5.0 "finish"
  43. $ns run
Add Comment
Please, Sign In to add comment