Hi all, I fixed this problem by creating a shared library of ns (similar to the cygwin approach), i.e. libns.so, and linking it to my code.
Upon closer inspection, ~ns/lib/ns-lib.tcl:128 has "class Simulator" commented. It is instead provided by an OTcl class in ~ns/common/simulator.[h/cc]. Dynamically linking libns.so provided the missing class definition and solved the error that I reported earlier. I guess this falls under the "grey area" mentioned in the documentation: http://isi.edu/nsnam/ns/doc/node6.html On to greener pastures. Best, Nikhil On Tue, Dec 13, 2011 at 3:30 PM, Nikhil Karnad <[email protected]>wrote: > Hi everyone, > > Firstly, great job to the team on the wiki, forums, and mailing lists. It > really helped me to get to speed with ns2. > > I'd like to use ns2 along with external packet data sources in real-time, > e.g. a message received on a socket on my linux PC should be sent over the > network currently being simulated in ns2. My current understanding is that > the events have to be specified in a Tcl script before the simulation is > run (via the Simulator class/command). Once the simulation is running, and > a packet arrives on my socket, I would like to "inject" an event into the > simulator. > > The rest of my code is in C++. My approach: I extracted some of the code > from the ns source (~ns/common/tclAppInit.cc) and tried to create an > instance of the interpreter myself, and then plan to use Tcl::eval() and > its variants to interface with the simulator in real-time...similar to what > ns does on an input script file. I'm having trouble with the EmbeddedTcl > codes from "~ns/gen/ns_tcl.cc" and "~ns/gen/ptypes.cc". After calling > et_ns_ptypes.load() and et_ns_lib.load(), I was assuming that the ns2 OTcl > classes would be available, but when I run 'tcl.evalc("set ns [new > Simulator]");', I get the following run-time error: > > mytest: >> [code omitted because of length] >> : invalid command name "Simulator" >> while executing >> "Simulator proc address-format {} { >> return [Simulator set AddressFormat_] >> }" >> > > What am I missing from the ns2 source that imported the class definitions > into the Tcl interpreter? Is there a scoping difference between > Tcl::evalc() and Tcl_Eval()? > > Any help is greatly appreciated. For those interested, the simple code I > have is available here: > http://pastebin.com/LXmsgiya > > Thanks, > Nikhil
