Advertisement
Guest User

High Speed Network

a guest
Oct 31st, 2014
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 2.02 KB | None | 0 0
  1. set ns [new Simulator]
  2.  
  3. #Define different colors for data flows (for NAM)
  4. $ns color 1 Blue
  5. $ns color 2 Red
  6.  
  7. #Open the Trace files
  8. set tracefile1 [open out.tr w]
  9. set winfile [open WinFile w]
  10. $ns trace-all $tracefile1
  11.  
  12. #open the NAM file
  13. set namefile [open out.nam w]
  14. $ns namtrace-all $namefile
  15.  
  16. #Define a finish procedure
  17. proc finish {} {
  18.     global ns tracefile1 namefile
  19.     $ns flush-trace
  20.     close $tracefile1
  21.     close $namefile
  22.     exec nam out.nam &
  23.     exit 0
  24. }
  25.  
  26. #create six nodes
  27. set n0 [$ns node]
  28. set n1 [$ns node]
  29. set n2 [$ns node]
  30. set n3 [$ns node]
  31. set n4 [$ns node]
  32. set n5 [$ns node]
  33.  
  34. #create links between the nodes
  35. $ns duplex-link $n0 $n2 1024Mb 10ms DropTail
  36. $ns duplex-link $n1 $n2 2Mb 10ms DropTail
  37. $ns simplex-link $n2 $n3 1024Mb 100ms DropTail
  38. $ns simplex-link $n3 $n2 0.3Mb 100ms DropTail
  39. $ns duplex-link $n3 $n4 1024Mb 40ms DropTail
  40. $ns duplex-link $n3 $n5 0.5Mb 30ms DropTail
  41.  
  42. #Give node position (for NAM)
  43. $ns duplex-link-op $n0 $n2 orient right-down
  44. $ns duplex-link-op $n1 $n2 orient right-up
  45. $ns simplex-link-op $n2 $n3 orient right
  46. $ns simplex-link-op $n3 $n2 orient left
  47. $ns duplex-link-op $n3 $n4 orient right-up
  48. $ns duplex-link-op $n3 $n5 orient right-down
  49.  
  50. #set Queue Size of link (n2-n3) to 20
  51. $ns queue-limit $n2 $n3 20
  52.  
  53. #setup a TCP connection
  54. set tcp [new Agent/TCP]
  55. $ns attach-agent $n0 $tcp
  56. set sink [new Agent/TCPSink]
  57. $ns attach-agent $n4 $sink
  58. $ns connect $tcp $sink
  59. $tcp set fid_ 1
  60. $tcp set packetSize_ 552
  61.  
  62. #Setup a FTP over TCP connection
  63. set ftp [new Application/FTP]
  64. $ftp attach-agent $tcp
  65.  
  66.  
  67.  
  68. $ns at 1.0 "$ftp start"
  69. $ns at 124.0 "$ftp stop"
  70.  
  71.  
  72. #procedure for plotting window size. Gets as arguments the name
  73. # of the tcp source code node (called "tcpSource") and of the output file
  74.  
  75. proc plotWindow {tcpSource file} {
  76.     global ns
  77.     set time 0.1
  78.     set now [$ns now]
  79.     set cwnd [$tcpSource set cwnd_]
  80.     puts $file "$now $cwnd"
  81.     $ns at [expr $now+$time] "plotWindow $tcpSource $file"
  82.  
  83. }
  84.  
  85. $ns at 0.1 "plotWindow $tcp $winfile"
  86.  
  87. $ns at 125.0 "finish"
  88. $ns run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement