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

Alex Afanasyev aa at CS.UCLA.EDU
Tue Dec 29 00:14:58 PST 2015


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 <mailto: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 <mailto: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 <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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20151229/95f0e15e/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 841 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20151229/95f0e15e/attachment.bin>


More information about the ndnSIM mailing list