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

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



One can find the node's id from C++, if you are an agent by:

    cout << Address::instance().get_nodeaddr(addr());

But I agree with this message, notably, you probably DON'T want to set the
node's ID from C++.

This returns the node's ID, which may be a hierarchical address if you have
that turned on and "looks funny". Not to despair however, Address has a
method for pretty printing that too if needed.

-scooter

----- Original Message -----
From: "Ratul Mahajan" <[email protected]>
To: "Pushpendra Singh" <[email protected]>
Cc: <[email protected]>
Sent: Friday, November 17, 2000 12:54 PM
Subject: [ns] Re: nodeid from c++


>
> > 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.
>