A4-slow-start.tcl
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:2k
源码类别:

通讯编程

开发平台:

Visual C++

  1. # slow start mechanism with some features
  2. # such as labeling, annotation, nam-graph, and window size monitoring
  3. set ns [new Simulator]
  4. set n0 [$ns node]
  5. set n1 [$ns node]
  6. $ns at 0.0 "$n0 label Sender"
  7. $ns at 0.0 "$n1 label Receiver"
  8. set nf [open A4-slow-start.nam w]
  9. $ns namtrace-all $nf
  10. set f [open A4-slow-start.tr w]
  11. $ns trace-all $f
  12. $ns duplex-link $n0 $n1 0.2Mb 200ms DropTail
  13. $ns duplex-link-op $n0 $n1 orient right
  14. $ns queue-limit $n0 $n1 10
  15. Agent/TCP set nam_tracevar_ true
  16. set tcp [new Agent/TCP]
  17. $tcp set maxcwnd_ 8
  18. $ns attach-agent $n0 $tcp
  19. set sink [new Agent/TCPSink]
  20. $ns attach-agent $n1 $sink
  21. $ns connect $tcp $sink
  22. set ftp [new Application/FTP]
  23. $ftp attach-agent $tcp
  24. $ns add-agent-trace $tcp tcp
  25. $ns monitor-agent-trace $tcp
  26. $tcp tracevar cwnd_
  27. $ns at 0.1 "$ftp start"
  28. $ns at 3.0 "$ns detach-agent $n0 $tcp ; $ns detach-agent $n1 $sink"
  29. $ns at 3.5 "finish"
  30. $ns at 0.0 "$ns trace-annotate "Slow Start with maximum window size 8 (normal operation)""
  31. $ns at 0.05 "$ns trace-annotate "FTP starts at 0.1""
  32. $ns at 0.11 "$ns trace-annotate "Send Packet_0 : Initial window size = 1""
  33. $ns at 0.34 "$ns trace-annotate "Receive Ack_0"" 
  34. $ns at 0.56 "$ns trace-annotate "Send Packet_1,2 : Increase window size to 2""
  35. $ns at 0.79 "$ns trace-annotate "Receive Ack_1,2""
  36. $ns at 0.99 "$ns trace-annotate "Send Packet_3,4,5,6 : Increase window size to 4""
  37. $ns at 1.23 "$ns trace-annotate "Receive Ack_3,4,5,6  ""
  38. $ns at 1.43 "$ns trace-annotate "Send Packet_7,8,9,10,11,12,13,14 : Increase window size to 8""
  39. $ns at 1.67 "$ns trace-annotate "Receive Ack_7,8,9,10,11,12,13,14""
  40. $ns at 1.88 "$ns trace-annotate "Send Packet_15,16,17,18,19,20,21,22 : Keep maximum window size,8""
  41. $ns at 2.11 "$ns trace-annotate "Receive Ack_15,16,17,18,19,20,21,22""
  42. $ns at 2.32 "$ns trace-annotate "Send Packet_23,24,25,26,27,28,29,30 : Keep maximum window size, 8""
  43. $ns at 2.56 "$ns trace-annotate "Receive Ack_23,24,25,26,27,28,29,30""
  44. $ns at 2.78 "$ns trace-annotate "Send Packet_31,32,33,34,35,36,37,38 : Keep maximum window size, 8""
  45. $ns at 3.00 "$ns trace-annotate "Receive Ack_31""
  46. $ns at 3.1 "$ns trace-annotate "FTP stops""
  47. proc finish {} {
  48.         global ns nf
  49.         $ns flush-trace
  50.         close $nf
  51.         puts "filtering..."
  52.         exec tclsh ../bin/namfilter.tcl A4-slow-start.nam
  53.         puts "running nam..."
  54.         exec nam A4-slow-start.nam &
  55.         exit 0
  56. }
  57. $ns run