[ndnSIM] Question

Alex Afanasyev alexander.afanasyev at ucla.edu
Thu May 9 18:20:36 PDT 2013


Hi Aaron,

Hmm... Again, in general there is no notion of beginning or ending in PIT.  It is just a complex tree-like structure, where items are stored until they are explicitly removed (interest gets satisfied or timed out).

The default implementation of PIT in ndnSIM (ns3::ndn::pit::Persistent) has "persistent" item replace policy, meaning that if there is a limit on number of entires and this limit is reached, new entries will be rejected.

The behavior similar to what you described is happening with ns3::ndn::pit::Lru, where "item in the beginning" is the oldest PIT entry.  Is it what you're asking?  If yes, then you can "remove" second-old, third-old, or older items like this:
typename policy_container::iterator item = policy_container::begin ();
std::advance (item, 2);
if (item != policy_container::end ())
{
   base_.erase (&(*item));
}

std::advance operation is not very efficient (it has linear complexity), but if you don't go too far away from the beginning, it should work reasonably well.

---
Alex

On May 9, 2013, at 6:02 PM, "Aaron" <aaronishere at qq.com> wrote:

> hi, Alex
> since the insert function always erase the item in the beginning. if it's possible to delete the first several items something like when A comes, erases the beginning, then B comes,erases the second,C erases the third. Say we only replace the first five item, then when F comes, re-erases the beginning
> ------------------ 原始邮件 ------------------
> 发件人: "alexander.afanasyev"<alexander.afanasyev at ucla.edu>
> 发送时间: 2013年5月10日(星期五) 上午7:42
> 收件人: "aaronishere"<aaronishere at qq.com>;
> 抄送: "ndnsim at lists.cs.ucla.edu"<ndnsim at lists.cs.ucla.edu>;
> 主题: Re: Question
> Hi Aaron,
> 
> It is almost impossible to get a position number of an item, since the PIT data structure is a recursive hash-based container.  Is there any specific use case why you want to get this number?  If you really need such functionality, the custom PIT policy can track PIT item positions.
> 
> To iterate over all elements of PIT you can do the following:
> 
> Ptr<ndn::Pit> pit = ?;
> for (Ptr<pit::Entry> entry = pit->Begin (); entry != pit->End (); entry = pit->Next (entry))
> {
> ...
> }
> 
> ---
> Alex
> 
> On May 9, 2013, at 4:35 PM, aaronishere <aaronishere at qq.com> wrote:
> 
>> Hi, Alex
>>  
>>  Is there some way to get the position number of item in the *-policy.h,  such as the lookuped item is the 5th item in the container?
>>  
>> Another is how to  loop of all pit-entry, such as
>> for ( pitentry::begin, pitentry::end, Next( ) )
>> {
>> ......
>> },
>> I'm not clear abou it.
>>  
>> Thanks!!
>>  
>> Aaron
> 

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


More information about the ndnSIM mailing list