Advertisement
hgr24

Untitled

Mar 29th, 2022
1,394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 1.44 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 label "dest1"
  20. $ns make-lan "$n0 $n1 $n2 $n3 $n4" 100Mb 100ms LL Queue/DropTail Mac/802_3
  21. $ns duplex-link $n4 $n5 1Mb 1ms DropTail
  22. set tcp0 [new Agent/TCP]
  23. $ns attach-agent $n0 $tcp0
  24. set ftp0 [new Application/FTP]
  25. $ftp0 attach-agent $tcp0
  26. $ftp0 set packetSize_ 500
  27. $ftp0 set interval_ 0.0001
  28. set sink5 [new Agent/TCPSink]
  29. $ns attach-agent $n5 $sink5
  30. $ns connect $tcp0 $sink5
  31. set tcp2 [new Agent/TCP]
  32. $ns attach-agent $n2 $tcp2
  33. set ftp2 [new Application/FTP]
  34. $ftp2 attach-agent $tcp2
  35. $ftp2 set packetSize_ 600
  36. $ftp2 set interval_ 0.001
  37. set sink3 [new Agent/TCPSink]
  38. $ns attach-agent $n3 $sink3
  39. $ns connect $tcp2 $sink3
  40. set file1 [open file1.tr w]
  41. $tcp0 attach $file1
  42. set file2 [open file2.tr w]
  43. $tcp2 attach $file2
  44. $tcp0 trace cwnd_
  45. $tcp2 trace cwnd_
  46. proc finish { } {
  47. global ns nf tf
  48. $ns flush-trace
  49. close $tf
  50. close $nf
  51. exec nam lab3.nam &
  52. exit 0
  53. }
  54. $ns at 0.1 "$ftp0 start"
  55. $ns at 5 "$ftp0 stop"
  56. $ns at 7 "$ftp0 start"
  57. $ns at 0.2 "$ftp2 start"
  58. $ns at 8 "$ftp2 stop"
  59. $ns at 14 "$ftp0 stop"
  60. $ns at 10 "$ftp2 start"
  61. $ns at 15 "$ftp2 stop"
  62. $ns at 16 "finish"
  63.  
  64.     $ns run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement