agent-gen-script.tcl
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:3k
源码类别:

通讯编程

开发平台:

Visual C++

  1. # This file is an example script for using the topology generator,
  2. # the routing generator and the agents generator together as part
  3. # of the scenario generator
  4. # Created by Ahmed Helmy, June 98.
  5. # source the generators code (this is not part of the release yet)
  6. source topo-gen.tcl
  7. source agent-gen.tcl
  8. source route-gen.tcl
  9. # setup the files that will contain the scripts generated
  10. set topofile topo1.tcl
  11. set agentfile agent1.tcl
  12. set routefile route1.tcl
  13. set hier_flag 1
  14. # we remove the agentfile, to start afresh... the agentfile is
  15. # opened in append mode and previous runs may cause problems
  16. if { [file exists $agentfile] } {
  17. catch { [exec rm $agentfile] }
  18. }
  19. # generate the topology creation script
  20. #puts {topology -outfile $topofile -num 50 -connection_prob 0.1}
  21. #topology -outfile $topofile -nodes 15 -connection_prob 0.1
  22. puts {topology -outfile $topofile -type transit_stub -nodes 50 -connection_prob 0.1}
  23. topology -outfile $topofile -type transit_stub -nodes 50 -connection_prob 0.1
  24. # set the route settings for unicast/mcast
  25. puts {routing -outfile $routefile -unicast Session -multicast CtrMcast}
  26. routing -outfile $routefile -unicast Session -multicast CtrMcast
  27. # generate the agent creation script
  28. # note that src and dest stub location info (for distribution of src and dest nodes)
  29. # should be given only when topology generated is of type transit-stub
  30. puts {agents -outfile $agentfile -transport TCP/Reno -src FTP 
  31. -sink TCPSink/DelAck -num 60% -srcstub 1-4,8,10 -deststub 5-7,9,11,12 -start 1-3 -stop 9-11}
  32. agents -outfile $agentfile -transport TCP/Reno -src FTP 
  33.     -sink TCPSink/DelAck -num 60% -srcstub 1-4,8,10 -deststub 5-7,9,11,12 -start 1-3 -stop 9-11
  34. #puts {agents -outfile $agentfile -transport TCP -sink TCPSink -num 8}
  35. #agents -outfile $agentfile -transport TCP -sink TCPSink -num 8
  36. #puts {agents -outfile $agentfile -transport SRM/Deterministic -num 75% 
  37. -join 0-2 -src CBR/UDP -traffic Pareto -srcnum 20% 
  38. -start 3-10}
  39. #agents -outfile $agentfile -transport SRM/Deterministic -num 75% 
  40. -join 0-2 -src CBR/UDP -traffic Pareto -srcnum 20% 
  41. -start 3-10 
  42. #puts {agents -outfile $agentfile -transport SRM -src CBR/UDP 
  43. -traffic Expoo }
  44. #agents -outfile $agentfile -transport SRM -src CBR/UDP 
  45. -traffic Expoo
  46. mark-end $agentfile
  47. # the marker merely serves as debugging aid to make sure that
  48. # all the code was written to file, and was not disrupted due
  49. # to failure or disk full... etc, it also contains all the 
  50. # the command lines used to generate the code.
  51. # now that we've generated the tcl scripts, source them and call
  52. # the procs to start the simulations.
  53. source $routefile
  54. source $topofile
  55. source $agentfile
  56. set ns [new Simulator]
  57. # set up hierarchical routing (if needed) or any other address format
  58. #$ns set-address-format hierarchical
  59. # comment out the ns trace for now... it consumes a lot of mem
  60. # set f [open out.tr w]
  61. # $ns trace-all $f
  62. set nf [open out.nam w]
  63. $ns namtrace-all $nf
  64. # have to call these before the topology is generated, as
  65. # artifact of current ns !!!
  66. setup-mcastNaddr ns
  67. # call the topology script
  68. if {$hier_flag} {
  69. create-hier-topology ns node 1.5Mb
  70. } else {
  71. create-topology ns node 1.5Mb
  72. }
  73. # set routing
  74. create-routing ns
  75. # call the agent script
  76. generate-agents ns node
  77. $ns at 3.0 "finish"
  78. proc finish {} {
  79. global ns nf; #f
  80. $ns flush-trace
  81. # close $f
  82. close $nf
  83. puts "running nam..."
  84. exec nam out.nam &
  85. exit 0
  86. }
  87. $ns run