-3

had done following steps Download "ex-linkage.cc" file, and save it under the "ns-2" directory. Open "Makefile", add "ex-linkage.o" at the end of object file list.

Re-compile NS using the "make" command. Download the "ex-linkage.tcl" file

that contains "MyAgent" testing OTcl commands.

Run the OTcl script using command "ns ex-linkage.tcl".


i am getting following error

$ ./ns ex-linkage.tcl
invalid command name "Agent/MyAgentOtcl" 
    while executing 
"Agent/MyAgentOtcl create o3 " 
    invoked from within 
"catch "$className create $o $args" msg" 
    invoked from within 
"if [catch "$className create $o $args" msg] { 
if [string match "__FAILED_SHADOW_OBJECT" $msg] { 
delete $o 
return "" 
} 
global errorInfo 
error "class $..." 
    (procedure "new" line 3) 
    invoked from within 
"new Agent/MyAgentOtcl" 
    invoked from within 
"set myagent [new Agent/MyAgentOtcl]" 
    (file "ex-linkage.tcl" line 8
Knud Larsen
  • 5,753
  • 2
  • 14
  • 19
Midhun Mohan
  • 552
  • 5
  • 18
  • Questions asking for tutorials are off-topic for SO. – Praetorian Nov 13 '15 at 04:35
  • im not asking for a full flow tutorial i am just asking for a some hints which will direct me to the linking process of c++ and ns2 – Midhun Mohan Nov 13 '15 at 04:37
  • i had already tried many methods that available over internet but since i am new to ns2 programming i couldn't make full use of it – Midhun Mohan Nov 13 '15 at 04:38
  • i even read ebooks https://books.google.co.in/books?id=_VkTzFLnwD4C&pg=PA39&lpg=PA39&dq=steps+to+link+ns2+and+c%2B%2B&source=bl&ots=__06kn9sok&sig=MWyzBwFvIseA05TACluZvLidsfc&hl=en&sa=X&ved=0CC8Q6AEwA2oVChMIoLHcqciMyQIVj3COCh0Jlg7Z#v=onepage&q=steps%20to%20link%20ns2%20and%20c%2B%2B&f=false – Midhun Mohan Nov 13 '15 at 04:40
  • Explain what did you try and how do you fail. Show errors you get if you don't understand them. Ask specific questions and you will get answers. – Paul Nov 13 '15 at 04:43
  • i had done following steps Download "ex-linkage.cc" file, and save it under the "ns-2" directory. Open "Makefile", add "ex-linkage.o" at the end of object file list. Re-compile NS using the "make" command. Download the "ex-linkage.tcl" file that contains "MyAgent" testing OTcl commands. (see Figure 22 for the input script and the result) Run the OTcl script using command "ns ex-linkage.tcl". – Midhun Mohan Nov 13 '15 at 05:13
  • i am getting following error $ ./ns ex-linkage.tcl invalid command name "Agent/MyAgentOtcl" while executing "Agent/MyAgentOtcl create _o3 " invoked from within "catch "$className create $o $args" msg" invoked from within "if [catch "$className create $o $args" msg] { if [string match "__FAILED_SHADOW_OBJECT_" $msg] { delete $o return "" } global errorInfo error "class $..." (procedure "new" line 3) invoked from within "new Agent/MyAgentOtcl" invoked from within "set myagent [new Agent/MyAgentOtcl]" (file "ex-linkage.tcl" line 8) – Midhun Mohan Nov 13 '15 at 05:14

3 Answers3

1

»» invalid command name "Agent/MyAgentOtcl" «« : Looks like you are using an executable 'ns' with no "Linkage".

tar xvf ns-allinone-2.35_gcc482.tar.gz

https://drive.google.com/file/d/0B7S255p3kFXNSGJCZ2YzUGJDVk0/view?usp=sharing

cd ns-allinone-2.35/
patch -p0 < linkage_ns235.patch

https://drive.google.com/file/d/0B7S255p3kFXNYmZ0SWFQaUNhWTA/view?usp=sharing

./install
cd ns-2.35/
sudo make install
cp ns ns235-linkage
sudo cp ns235-linkage /usr/local/bin/

Simulation : ns235-linkage ex-linkage.tcl
.
warning: no class variable Agent/MyAgentOtcl::my_var2_otcl
.
Message From MyPrivFunc
     my_var1 = 2
     my_var2 = 3.140000

Using the "ns235-linkage" command makes sure you are using the right 'ns'. P.S. : You are not recompiling with 'make', but with 'make clean && make'. Or by running './install' in the top directory ns-allinone-2.35/.


Knud Larsen
  • 5,753
  • 2
  • 14
  • 19
0

OK, Cygwin. ( Why hide important information http://www.catb.org/~esr/faqs/smart-questions.html ).

The patch command : Install 'patch' , or install the 'Developer tools' if available.

You can use the {ns-2.35/} that comes with ns-allinone-2.35_gcc482.tar.gz ,,, and use the otherwise Cygwin installed {tcl8, tk8, otcl, tclcl}.

Besides that, the patch is just containing the two files ex-linkage.*, and a line for Makefile.in . The patch is supposed to make things easier.

Using : Make a copy of "linkage_ns235.patch" in the folder where you keep ns-2.35/, and do $ patch -p0 < linkage_ns235.patch


Knud Larsen
  • 5,753
  • 2
  • 14
  • 19
  • i tried patch.exe and it shows me hung up when i used patch -i and promted command line when used-p0 what else can be done – Midhun Mohan Nov 16 '15 at 09:48
0

OK, no working patch function in your cygwin, it seems.

May be your previously setup was OK, and you just have to recompile :

$ cd ns-2.35/ && make clean && make

Knud Larsen
  • 5,753
  • 2
  • 14
  • 19
  • thank you i switch from cygwin to ubuntu and it worked sucessfully – Midhun Mohan Nov 20 '15 at 12:26
  • does it work for all cpp tcl code do we need to do any additional changes in the code – Midhun Mohan Nov 20 '15 at 12:27
  • »» does it work for all cpp tcl code «« : Not understandable. What do you mean by "it" ? ...... Please elaborate. . – Knud Larsen Nov 20 '15 at 21:09
  • i tried another code in which we are trying to communicate from tcl to c and vice versa i set a value for a variable in c using tcl and calling that function worked successfully but when i tried to bind the function it shows numerous errors – Midhun Mohan Nov 21 '15 at 07:44
  • `set myagent [new Agent/MyAgentOtcl] $myagent set my_var1_otcl 67 $myagent set my_var2_otcl 3.14 $myagent call-my-priv-func $myagent showvars `in this line i am getting errors ` invoked from within "_o3 cmd showvars" invoked from within "catch "$self cmd $args" ret" invoked from within "if [catch "$self cmd $args" ret] { set cls [$self info class] global errorInfo set savedInfo $errorInfo error "error when calling class $cls: $args" $..." (procedure "_o3" line 2) (SplitObject unknown line 2) invoked from within "$myagent showvars" (file "agent.tcl" line 9)` – Midhun Mohan Nov 21 '15 at 07:50