These kind of questions appear a lot in this mailing list.
The answer is "yes", and is explained here:
http://inesc-0.tagus.ist.utl.pt/~pmsrve/ns2/ns2_tips.html#_Toc124667331
Now follows an even simpler explanation, using global variables and tcl
a) Arrange in TCL the appropriate construct to find the value that you want.
You can use global variables for this and a simple proc.
Eg, if "$node1" is a global variable that has the handle (_oXXX) for a node
object, then this proc returns its ID, and it can be called anywhere:
proc get_the_value_that_i_want { } {
global node1
return [$node1 id]
}
b) arrange it to be called in C++, and collect the result:
tcl.eval("get_the_value_that_i_want "); // call the proc
assert(*tcl.result()); // make sure it returned
something
int node_id = atoi(tcl.result()); // convert the result to a
integer
c) specialize this method to:
- pass parameters to the proc
tcl.eval("my_global_proc %s %i", param1, param2);
- call otcl methods of the current C++ object
tcl.eval("%s my_method %s %i", name(), param1, param2 );
- perform more complex calculations on TCL
(just add more code to the TCL proc)
- return error flags that are catched in C++ part
- etc
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
> Of elise hu
> Sent: terça-feira, 14 de Fevereiro de 2006 13:35
> To: [email protected]
> Subject: [ns] retrieving node from routing agent in ad-hoc routing
>
>
> Is it possible to access the node object (or better yet, the mobilenode
> object), from the routing agent ? For instance in AODV, is it possible to
> retrieve the node object, using for instance the address (index) ?
> Thank you,
>
> Elise
> (using ns-2.29)
>
> _________________________________________________________________
> Free blogging with MSN Spaces http://spaces.msn.com/?mkt=nl-be