Advertisement
hgr24

Untitled

Mar 29th, 2022
907
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 1.54 KB | None | 0 0
  1. set ns [new Simulator]
  2. set tf [open lab3.tr w]
  3. $ns trace-all $tf
  4. set nf [open lab3.nam w]
  5. $ns namtrace-all $nf
  6. set n0 [$ns node]
  7. $n0 color "magenta"
  8. $n0 label "src1"
  9. set n1 [$ns node]
  10. set n2 [$ns node]
  11. $n2 color "magenta"
  12. $n2 label "src2"
  13. set n3 [$ns node]
  14. $n3 color "blue"
  15. $n3 label "dest2"
  16. set n4 [$ns node]
  17. set n5 [$ns node]
  18. $n5 color "blue"
  19. $n5 l
  20. abel "dest1"
  21. $ns make-lan "$n0 $n1 $n2 $n3 $n4" 100Mb 100ms LL Queue/DropTail Mac/802_3
  22. /* should come in single line */
  23. $ns duplex-link $n4 $n5 1Mb 1ms DropTail
  24. set tcp0 [new Agent/TCP]
  25. $ns attach-agent $n0 $tcp0
  26. set ftp0 [new Application/FTP]
  27. $ftp0 attach-agent $tcp0
  28. $ftp0 set packetSize_ 500
  29. $ftp0 set interval_ 0.0001
  30. set sink5 [new Agent/TCPSink]
  31. $ns attach-agent $n5 $sink5
  32. $ns connect $tcp0 $sink5
  33. set tcp2 [new Agent/TCP]
  34. $ns attach-agent $n2 $tcp2
  35. set ftp2 [new Application/FTP]
  36. $ftp2 attach-agent $tcp2
  37. $ftp2 set packetSize_ 600
  38. $ftp2 set interval_ 0.001
  39. set sink3 [new Agent/TCPSink]
  40. $ns attach-agent $n3 $sink3
  41. $ns connect $tcp2 $sink3
  42. set file1 [open file1.tr w]
  43. $tcp0 attach $file1
  44. set file2 [open file2.tr w]
  45. $tcp2 attach $file2
  46. $tcp0 trace cwnd_ /* must put underscore ( _ ) after cwnd and no space between
  47. them*/
  48. $tcp2 trace cwnd_
  49. proc finish { } {
  50. global ns nf tf
  51. $ns flush-trace
  52. close $tf
  53. close $nf
  54. exec nam lab3.nam &
  55. exit 0
  56. }
  57. $ns at 0.1 "$ftp0 start"
  58. $ns at 5 "$ftp0 stop"
  59. $ns at 7 "$ftp0 start"
  60. $ns at 0.2 "$ftp2 start"
  61. $ns at 8 "$ftp2 stop"
  62. $ns at 14 "$ftp0 stop"
  63. $ns at 10 "$ftp2 start"
  64. $ns at 15 "$ftp2 stop"
  65. $ns at 16 "finish"
  66. $ns run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement