Re: [ns] good way to access node id in *.cc files?

2010-07-14 Thread Sarthak Grover

Hi Mubashir,

Thanks again but its not working when i use "index" as the argument to any
function,
such as cout<)’

ive included god.h in my code. is there something else i need to include?

where is the index variable actually located? im sure its not in the
mobilenode.cc
or node.cc files as node::index etc wont work..

or is there some way to map which mac header address (dh_ra/dh_ta) belongs
to which
 node id?

Awaiting your reply and thanks in advance!

Regards,
Sarthak

On Wed, Jul 14, 2010 at 11:45 AM, Mubashir Rehmani wrote:

> Hi Sarthank
>
> Try to use index here
> get_node_by_address(index)
>
> or simply print index, which is the current node id underconsideration by
> ns2
>
> Rebards
>
>
> On 14 July 2010 01:03, Sarthak Grover  wrote:
>
>> Hi Mubashir!
>>
>> Thanks for the prompt reply. I really appreciate your help!
>>
>> Could i ask you one more thing if thats ok?
>>
>> Im trying to get the current node being considered by ns using the
>> Node::nodeid() method.
>> For example in the recvCTS() function of mac-802.11, i want to store the
>> received power of
>> the CTS packet in a (nodeid).txt file, where (nodeid) is the current node
>> calling the recvCTS
>> function.
>>
>> Basically for 10 nodes, each node should have a separate recdpower.txt
>> file. For that i need
>> to know what the current node id of the node calling recvCTS() function
>> is...right?
>>
>> But when i used nodeid() command or even
>> get_node_by_address(netif_->node()->nodeid());
>> i still got the mac src and dst addresses as output. For my 10 nodes
>> system i got addresses
>>  as 15, 18, 27 etc.
>>
>> Any idea why that happened instead of giving me the node id (between 0 to
>> 9) as expected?
>>
>> Or am i doing something wrong here?
>>
>> Thanks again for replying and looking forward to your next email.
>> Hope you don't mind me mailing you directly instead of going through the
>> whole ns-users list!
>>
>> Warm regards,
>> Sarthak
>>
>>
>>
>> On Tue, Jul 13, 2010 at 1:33 AM, Mubashir Rehmani 
>> wrote:
>>
>>> Hi Sarthak,
>>>
>>> You can also get the node id like this
>>>
>>> Total number of Nodes: God::instance()->nodes();
>>> Node ID: Node::*nodeid*();
>>>
>>> Don't forget the include God.h
>>>
>>> You can access this node id which is mention in Node.cc File in a C++
>>> file by using
>>>
>>> Node* thisnode = Node::get_node_by_address(n_id); //you can also give
>>> index variable as an argument to this function
>>>
>>> cout<<"Node ID:\t"<*nodeid*()<>>
>>> Regards
>>> Mubashir Husain Rehmani
>>>
>>> On 12 July 2010 21:46, Sarthak Grover  wrote:
>>>

 Hi,

 I'm trying to access node ids through my mac-802_11.cc file as i want to
 implement different mac timers for different nodes.

 the src and dst addresses which i get from the headers dh->dh_ta and
 dh_ra
 are MAC addresses.

 But what i wanted to access was the node id i provided in my tcl script.
 #by
 set node_($i)

 Does anyone know a good way of getting mobile node ids?

 (i dont want the pointer to mobilenode but just the id which could be
 output
 as an integer say eg printf("%d\n",nodeid))

 i tried using get_node_by_id(netif_->node()->nodeid_) but got an error
 saying this function is out of scope. whereas using node() directly
 gives
 the octet address i think.

 also read some other suggestion on using netif_ in the archives but
 couldnt
 understand how to do it.

 i guess this is a common doubt so i apologize for its obvious
 "noobness"! if
 anyone has any suggestions please reply.

 thanx

 --
 Sarthak

>>>
>>>
>>>
>>> --
>>> Mubashir Husain Rehmani
>>>
>>>
>>>
>>
>
>
> --
> Mubashir Husain Rehmani
>
>
>


-- 
Sarthak


Re: [ns] good way to access node id in *.cc files?

2010-07-12 Thread Mubashir Rehmani

Hi Sarthak,

You can also get the node id like this

Total number of Nodes: God::instance()->nodes();
Node ID: Node::*nodeid*();

Don't forget the include God.h

You can access this node id which is mention in Node.cc File in a C++ file
by using

Node* thisnode = Node::get_node_by_address(n_id); //you can also give
index variable
as an argument to this function

cout<<"Node ID:\t"<*nodeid*()< wrote:

>
> Hi,
>
> I'm trying to access node ids through my mac-802_11.cc file as i want to
> implement different mac timers for different nodes.
>
> the src and dst addresses which i get from the headers dh->dh_ta and dh_ra
> are MAC addresses.
>
> But what i wanted to access was the node id i provided in my tcl script.
> #by
> set node_($i)
>
> Does anyone know a good way of getting mobile node ids?
>
> (i dont want the pointer to mobilenode but just the id which could be
> output
> as an integer say eg printf("%d\n",nodeid))
>
> i tried using get_node_by_id(netif_->node()->nodeid_) but got an error
> saying this function is out of scope. whereas using node() directly gives
> the octet address i think.
>
> also read some other suggestion on using netif_ in the archives but couldnt
> understand how to do it.
>
> i guess this is a common doubt so i apologize for its obvious "noobness"!
> if
> anyone has any suggestions please reply.
>
> thanx
>
> --
> Sarthak
>



-- 
Mubashir Husain Rehmani


Re: [ns] good way to access node id in *.cc files?

2010-07-12 Thread Mubashir Rehmani

Hi Sarthak,

One option is to use the index variable to print the node id but remember
that the value of "index" varies under different functions. In fact, at any
particular time, the value of "index" will print the node id which is under
consideration by the ns2. Second option is that you can get the node's
location in the mac layer by this:

double x,y,z;
Node* srcnode = 0 ;
srcnode = Node::get_node_by_address(2); //put here the node id
MobileNode* tmnode = (MobileNode*)srcnode;

tmnode->getLoc(&x, &y, &z);
cout<<"Node Location : "< wrote:

>
> Hi,
>
> I'm trying to access node ids through my mac-802_11.cc file as i want to
> implement different mac timers for different nodes.
>
> the src and dst addresses which i get from the headers dh->dh_ta and dh_ra
> are MAC addresses.
>
> But what i wanted to access was the node id i provided in my tcl script.
> #by
> set node_($i)
>
> Does anyone know a good way of getting mobile node ids?
>
> (i dont want the pointer to mobilenode but just the id which could be
> output
> as an integer say eg printf("%d\n",nodeid))
>
> i tried using get_node_by_id(netif_->node()->nodeid_) but got an error
> saying this function is out of scope. whereas using node() directly gives
> the octet address i think.
>
> also read some other suggestion on using netif_ in the archives but couldnt
> understand how to do it.
>
> i guess this is a common doubt so i apologize for its obvious "noobness"!
> if
> anyone has any suggestions please reply.
>
> thanx
>
> --
> Sarthak
>



-- 
Mubashir Husain Rehmani