Advertisement
anik314159

Net Lab 06

Aug 3rd, 2022
1,492
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 2.17 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. #TCP
  64. set tcp [new Agent/TCP]
  65. $ns attach-agent $n2 $tcp
  66. set sink [new Agent/TCPSink]
  67. $ns attach-agent $n5 $sink
  68. $ns connect $tcp $sink
  69. $tcp set fid_ 1
  70. $tcp set packetSize_ 500
  71.  
  72. #FTP
  73. set ftp [new Application/FTP]
  74. $ftp attach-agent $tcp
  75. $ftp set type_ FTP
  76. $ns at 0.0 "$ftp start"
  77.  
  78. #UDP
  79. set udp [new Agent/UDP]
  80. $ns attach-agent $n3 $udp
  81. set null [new Agent/Null]
  82. $ns attach-agent $n6 $null
  83. $ns connect $udp $null
  84. $udp set fid_ 2
  85.  
  86. #CBR
  87. set cbr [new Application/Traffic/CBR]
  88. $cbr attach-agent $udp
  89. $cbr set packetSize_ 1000
  90. $cbr set rate_ 0.1mb
  91. #$cbr set random_ false
  92. $ns at 0.0 "$cbr start"
  93.  
  94. $ns at 20.0 "finish"
  95. $ns run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement