Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. set ns [new Simulator]
  2. set nf [open lab3.nam w]
  3. $ns namtrace-all $nf
  4. set trf [open lab3.tr w]
  5. $ns trace-all $trf
  6. proc finish {} {
  7. global ns nf trf
  8. $ns flush-trace
  9. close $nf
  10. close $trf
  11. exit 0
  12. }
  13. for {set i 0} {$i < 4} {incr i} {
  14. set n($i) [$ns node]
  15. }
  16. $ns at 0.0 "$n(0) label GBN_sender"
  17. $ns at 0.0 "$n(3) label GBN_receiver"
  18. $ns at 0.0 "$n(1) label SW_sender"
  19. $ns at 0.0 "$n(2) label SW_receiver"
  20. for {set i 0} {$i < 4} {incr i} {
  21. $ns duplex-link $n($i) $n([expr ($i+1)%4]) 2Mb 48ms DropTail
  22. $ns queue-limit $n($i) $n([expr ($i+1)%4]) 150
  23. $ns queue-limit $n([expr ($i+1)%4]) $n($i) 150
  24. }
  25. $ns duplex-link-op $n(0) $n(1) orient right
  26. $ns duplex-link-op $n(1) $n(2) orient down
  27. $ns duplex-link-op $n(2) $n(3) orient left
  28. $ns duplex-link-op $n(3) $n(0) orient up
  29. $ns color 0 blue
  30. $ns color 1 yellow
  31. set tcp0 [new Agent/TCP/Reno]
  32. $tcp0 set packetSize_ 2500
  33. $tcp0 set window_ 8
  34. $tcp0 set syn_ false
  35. $tcp0 set windowInit_ 8
  36. $tcp0 set fid_ 0
  37. $ns attach-agent $n(0) $tcp0
  38. set sink0 [new Agent/TCPSink]
  39. $ns attach-agent $n(3) $sink0
  40. $ns connect $tcp0 $sink0
  41. set ftp0 [new Application/FTP]
  42. $ftp0 attach-agent $tcp0
  43. set tcp1 [new Agent/TCP/Reno]
  44. $tcp1 set packetSize_ 2500
  45. $tcp1 set window_ 1
  46. $tcp1 set syn_ false
  47. $tcp1 set windowInit_ 1
  48. $tcp1 set fid_ 1
  49. $ns attach-agent $n(1) $tcp1
  50. set sink1 [new Agent/TCPSink]
  51. $ns attach-agent $n(2) $sink1
  52. $ns connect $tcp1 $sink1
  53. set ftp1 [new Application/FTP]
  54. $ftp1 attach-agent $tcp1
  55. $tcp0 set window_ 8
  56. $tcp1 set window_ 1
  57. $ns at 1.0 "$ftp0 produce 120"
  58. $ns at 1.0 "$ftp1 produce 120"
  59. $ns at 12.0 "finish"
  60. $ns run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement