[ndnSIM] How to get node id in lru-policy.hpp

Saran Tarnoi sarantarnoi at gmail.com
Tue Dec 29 00:48:02 PST 2015


Hi Alex,

Your solution works well. Putting template before GetObject<ns3::Node>()
solves the whole problem. Anyway, I will follow you advice and use
Simulator::GetContext()
method.
Thank you so much.

Best regards,
Saran Tarnoi

2015-12-29 17:14 GMT+09:00 Alex Afanasyev <aa at cs.ucla.edu>:

> You may needed to include <ns3/node.h> header file, use full namespace,
> and add additional C++ syntax sugar needed, given lru-policy is a template
> class.  I checked and the following should work, but I would still
> recommend the simpler Simulator::GetContext() method.
>
>     item->payload()->GetContentStore()->template
> GetObject<ns3::Node>()->GetId();
>
> ---
> Alex
>
> On Dec 28, 2015, at 7:46 PM, Saran Tarnoi <sarantarnoi at gmail.com> wrote:
>
> Hi Alex,
>
> Thanks a lot for your help. However, I cannot get the first solution to
> work.
> I got this log:
> ../src/ndnSIM/model/cs/../../utils/trie/lru-policy.hpp:81:72: error:
> ‘Node’ was not declared in this scope
> ../src/ndnSIM/model/cs/../../utils/trie/lru-policy.hpp:81:78: error:
> expected primary-expression before ‘)’ token
>
> After including "ns3/node.h", I still got the following errors:
> ../src/ndnSIM/model/cs/../../utils/trie/lru-policy.hpp:82:76: error:
> expected primary-expression before ‘>’ token
> ../src/ndnSIM/model/cs/../../utils/trie/lru-policy.hpp:82:78: error:
> expected primary-expression before ‘)’ token
>
> I do not know why GetObject<Node>() failed here. Using
> GetObject<ns3::Node>() did not help either. The compiler did not get it.
> Did I miss something?
>
> The second solution (Simulator::GetContext()) works well.
>
> Regards,
> Saran Tarnoi
>
>
> 2015-12-29 2:01 GMT+09:00 Alex Afanasyev <aa at cs.ucla.edu>:
>
>> Hi Saran,
>>
>> The solution you found is getting access to nodeId from the ndnSIM 1.0
>> strategy.  For the caching policy, you can do the following:
>>
>>    item->payload()->GetContentStore()->GetObject<Node>()->GetId()
>>
>> You can also use the following (cheaty) solution that can work in most of
>> the places:
>>
>>    Simulator::GetContext();  // context ID == nodeId
>>
>> --
>> Alex
>>
>> On Dec 28, 2015, at 1:05 AM, Saran Tarnoi <sarantarnoi at gmail.com> wrote:
>>
>> Dear All,
>>
>> I would like to get node id (or the node name) while being in
>> lru-policy.hpp for logging purpose.
>> I am using ndnSIM-2.0. A solution found at
>> http://www.lists.cs.ucla.edu/pipermail/ndnsim/2014-May/001307.html did
>> not work. I have no idea how I can get a pointer to Node from here.
>>
>> Could you give me some pieces of advice?
>>
>> Thanks a lot in advance for your help.
>>
>> --
>> Best regards,
>> Saran Tarnoi
>>
>>
>


-- 
Regards,
Saran Tarnoi
Graduate Student
Department of Informatics
The Graduate University for Advanced Studies (Sokendai)
Tokyo, Japan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20151229/c2cbbf26/attachment.html>


More information about the ndnSIM mailing list