0
votes

When I run tclsh aodv1.tcl, I get an error from this tcl command:

set ns_ [new Simulator]

The error message is:

invalid command name "new"
    while executing
"new Simulator"
    invoked from within
"set ns_ [new Simulator]"
    (file "aodv1.tcl" line 3)
child process exited abnormally

How can I rectify this error?

1

1 Answers

0
votes

That's a reasonably clear error message; it says that the command new is not understood. It's not a standard part of Tcl, so that's relatively expected. What the code probably needs is a package require of the library package that provides the functionality (which belongs at the top of the script, just below the #! line if you're using one).

Which package might that be? Well, the main candidates are [incr Tcl] and OTcl; in general Tcl code, [incr Tcl] would be the most likely, but in this case — because of the word Simulator as the name of the class to instantiate — I'm guessing that it's actually OTcl code, and probably NS2 code at that. That means that you're looking at either

package require OTcl

or running with the ns program as outlined in NS2 tutorials (as that automatically requires the relevant package for you).