[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ns] Re: nodeid from c++



You can also initialize it (call $self nodeid $id_) from
Node::init{}. Thus it's guaranteed a node knows its id no matter how
it's created. 

It's been like this since 2.1b7.

- Haobo

On Fri, 17 Nov 2000, Ratul Mahajan wrote:

> 
> > 	could one find a node's id with using some c++ method like we do
> > in tcl by $node id .
> 
> I don't think this feature is available by default. But a small change
> will enable you to do that.
> 
> The following is in ns-lib.tcl, 
> Simulator instproc node args {
> 
> 	....
> 	set node [eval new [Simulator set node_factory_] $args]
> 	set Node_([$node id]) $node
> 
> >	#set the nodeid in c++ Node 
> >	$node nodeid [$node id]
> 
> 	$node set ns_ $self
> 	$self check-node-num
> 	return $node
> 
> ...
> }
> 
> I will check this change in sometime soon, but till then you can do it
> yourself, and recompile.
> 
> Now the nodeid can be accessed by node->nodeid(), this method is already
> defined in the c++ code.
> 
> 
> 	- ratul
> 
> ps: its a good idea to have subject for your mail, helps ppl in parsing
> the long list of messages effectively.
> 
>