-1

I need help to solve this problem :

Starting Simulation...
    ns: start": invalid command name "start""
    while executing
   "start""

I have a file bash and a file tcl, but I don't know why it give me always this problem.

this is second me the problem in the file cbrgen

proc create-cbr-connection { src dst } {
global rng cbr_cnt opt

set stime [$rng uniform 0.0 10.0]

puts "#\n# $src connecting to $dst at time $stime\n#"

##puts "set cbr_($cbr_cnt) \[\$ns_ create-connection \
    ##CBR \$node_($src) CBR \$node_($dst) 0\]";

puts "set udp_($cbr_cnt) \[new Agent/UDP\]"
puts "\$ns_ attach-agent \$node_($src) \$udp_($cbr_cnt)"
puts "set null_($cbr_cnt) \[new Agent/Null\]"
puts "\$ns_ attach-agent \$node_($dst) \$null_($cbr_cnt)"
puts "set cbr_($cbr_cnt) \[new Application/Traffic/CBR\]"
puts "\$cbr_($cbr_cnt) set packetSize_ $opt(pktsize)"
puts "\$cbr_($cbr_cnt) set interval_ $opt(interval)"
puts "\$cbr_($cbr_cnt) set random_ 1"                                                           
puts "\$cbr_($cbr_cnt) set maxpkts_ 10000"
puts "\$cbr_($cbr_cnt) attach-agent \$udp_($cbr_cnt)"
puts "\$ns_ connect \$udp_($cbr_cnt) \$null_($cbr_cnt)"

set start [expr {10*rand()}]
puts "\$ns_ at $start \"\$cbr_($cbr_cnt) start\""
puts "\$ns_ at 100 \"\$cbr_($cbr_cnt) stop\""
Donal Fellows
  • 133,037
  • 18
  • 149
  • 215
Amiga 500
  • 19
  • 1
  • 9
  • Your code sample is waaaay too long. Narrow it down to the part you think might cause your problem. – Aserre Jul 18 '14 at 15:10
  • i think this is the part: set start [expr {10*rand()}] puts "\$ns_ at $start\"\$cbr_($cbr_cnt) start\"" puts "\$ns_ at 100\"\$cbr_($cbr_cnt) stop\"" – Amiga 500 Jul 18 '14 at 15:42

1 Answers1

0

It seems that you're writing code to write code. This is quite a bit harder than merely writing code.

The immediate error is that the simulator that you're invoking is trying to run a command called start, yet you don't have one defined in that context. This doesn't work, obviously, and you get that error message: it means exactly what it says.

Digging in more deeply, it seems that your code generator is (in the code you edited out) writing the call to start via:

puts $ns_ "blah blah blah...;start"

Is it supposed to write a call to start at that point? If not, that's your problem (; is a command terminator in Tcl if unquoted, even though it's rarely used.)

Otherwise, the problem is that you've got to supply a definition of start, probably via a procedure. I've no idea what it should do, but the two options are to either write:

puts $ns_ [list proc start {} { ... the definition in here ... }]

(The list constructs a quote-free command, which is useful here.)

Or better yet, write your procedure definitions to a separate file that doesn't change according to what cbrgen does, say static_definitions.tcl, and source that from the generated file by writing this near the top:

puts $ns_ [list source [file normalize static_definitions.tcl]]
# This is just the paranoid upgrade of this simpler form:
#      puts $ns_ "source static_definitions.tcl"

Tcl's source is rather a lot like C/C++'s #include, except it's part of Tcl and not part of a preprocessor…

Donal Fellows
  • 133,037
  • 18
  • 149
  • 215