[ndnSIM] query about interfaces of a node

Alex Afanasyev alexander.afanasyev at ucla.edu
Wed Oct 15 21:09:23 PDT 2014


Hi Shahneela,

You're trying to modify value, which is used for indexing purposes inside the policy (i.e., policy sorts all items based on the lifetime, which results in trivial eviction when time comes).

Unfortunately, you cannot directly modify time for the items in the policy container.  What you need to do instead is to remove item from the container, update the value, and then reinsert the value into the container.  There is basic example of this in lfu-policy.h, though it doesn't deal with const iterators.

With boost::intrusive::multiset you should be able to use `typename policy_container::iterator`.  You still should not directly modify the value (as it would invalidate order), but you should be able to do the conversions.

--
Alex

On Oct 15, 2014, at 11:55 AM, Shahneela Naz <shahneela.cs at gmail.com> wrote:

> Dear Sir,
> 
> I want to loop over cache contents to change their lifetime with respect to passing time.. for this I am using policy_container::iterator e.g.
> 
> for (typename policy_container::const_iterator item = policy_container::begin ();
>                 item != policy_container::end (); item++)
> 
> the problem is that I can read time value against an item using get_time(&(*item))..
> but when I want to set new value to the same item it requires Container::const_iterator type...
> I am finding it hard to typecast between iterator and const_iterator types which is required to set a value against an item..
> 
> can you kindly help me in this regard..
> 
> regards,
> 
> shahneela  
> 
> 
> 
> On Fri, Sep 12, 2014 at 7:07 PM, Alex Afanasyev <alexander.afanasyev at ucla.edu> wrote:
> 
> On Sep 12, 2014, at 7:16 AM, Shahneela Naz <shahneela.cs at gmail.com> wrote:
> 
> > Dear Users,
> >
> > I want to make a little change in cache-with-probability class that if a node has certain number of interfaces it should add a content. For this I want to know number of interfaces to which the node is attached.
> >
> > but when I try to get a node as follows
> >
> > Ptr<Node> n = This->GetObject<Node>();
> >
> > it gives error that the function is defined out of scope. it is the problem due to virtual or inline function calls...
> >
> > can any one kindly help me on this.. If I want to get information related to a node while using policy traits. how can I do this..
> 
> Hi Shaneela,
> 
> Where exactly you're adding this? If you're inside any of the policy methods, you can do something like:
> 
> Ptr<Node> n = item->payload ()->GetContentStore()->template GetObject<Node>();
> 
> Note that there is "template" keyword before GetObject.  Is is necessary, since policy and all policy methods are part of the template implementation.
> 
> ---
> Alex
> 
> 
> > regards,
> >
> > Shahneela
> > _______________________________________________
> > ndnSIM mailing list
> > ndnSIM at lists.cs.ucla.edu
> > http://www.lists.cs.ucla.edu/mailman/listinfo/ndnsim
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20141015/bfb9ccf8/attachment.html>


More information about the ndnSIM mailing list