Advertisement
AnindyaBiswas

TCL 5th class

May 6th, 2022
1,493
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 1.84 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. # Orientation
  43. $ns duplex-link-op $n0 $n1 orient right-down
  44. $ns duplex-link-op $n2 $n4 orient left-up
  45. $ns duplex-link-op $n0 $n5 orient right
  46.  
  47. # Color
  48. $ns duplex-link-op $n2 $n4 color "red"
  49. $ns duplex-link-op $n0 $n1 color "blue"
  50. $ns duplex-link-op $n3 $n5 color "yellow"
  51. $ns simplex-link-op $n4 $n6 color "green"
  52. $ns duplex-link-op $n1 $n4 color "magenta"
  53. $ns duplex-link-op $n1 $n3 color "pink"
  54.  
  55. # Labelling connections(relayout first, then play)
  56. $ns duplex-link-op $n0 $n5 label "n0 - n5 duplex"
  57. $ns duplex-link-op $n2 $n4 label "n2 - n4 duplex"
  58. $ns duplex-link-op $n3 $n5 label "n3 - n5 duplex"
  59. $ns simplex-link-op $n2 $n6 label "n2 - n6 simplex"
  60.  
  61.  
  62.  
  63. set tcp [new Agent/TCP]
  64. $ns attach-agent $n2 $tcp
  65. set sink [new Agent/TCPSink]
  66. $ns attach-agent $n5 $sink
  67. $ns connect $tcp $sink
  68. $tcp set fid_ 1
  69. $tcp set packetSize_ 500
  70.  
  71. set ftp [new Application/FTP]
  72. $ftp attach-agent $tcp
  73. $ftp set type_ FTP
  74. $ns at 0.0 "$ftp start"
  75.  
  76.  
  77. $ns at 20.0 "finish"
  78. $ns run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement