blob: c57a44caa59fc47822e044f0c225b154bdfca078 [file] [log] [blame]
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -07001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2011 University of California, Los Angeles
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
19 */
20
21#include "ccnx-pit-impl.h"
Alexander Afanasyeve3d126f2012-07-16 17:07:31 -070022
23#include "ns3/ccnx-interest-header.h"
24#include "ns3/ccnx-content-object-header.h"
Alexander Afanasyevf249a192012-07-18 16:52:51 -070025#include "ns3/ccnx-forwarding-strategy.h"
Alexander Afanasyeve3d126f2012-07-16 17:07:31 -070026
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -070027#include "../../utils/empty-policy.h"
28#include "../../utils/persistent-policy.h"
29#include "../../utils/random-policy.h"
30#include "../../utils/lru-policy.h"
31
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070032#include "ns3/log.h"
33#include "ns3/string.h"
34#include "ns3/uinteger.h"
35#include "ns3/simulator.h"
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070036
37#include <boost/lambda/bind.hpp>
38#include <boost/lambda/lambda.hpp>
39
40NS_LOG_COMPONENT_DEFINE ("CcnxPitImpl");
41
42using namespace boost::tuples;
43using namespace boost;
44namespace ll = boost::lambda;
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -070045using namespace ndnSIM;
46
47#define NS_OBJECT_ENSURE_REGISTERED_TEMPL(type, templ) \
48 static struct X ## type ## templ ## RegistrationClass \
49 { \
50 X ## type ## templ ## RegistrationClass () { \
51 ns3::TypeId tid = type<templ>::GetTypeId (); \
52 tid.GetParent (); \
53 } \
54 } x_ ## type ## templ ## RegistrationVariable
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -070055
56namespace ns3 {
57
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -070058template<>
59TypeId
60CcnxPitImpl<persistent_policy_traits>::GetTypeId ()
61{
62 static TypeId tid = TypeId ("ns3::CcnxPit")
63 .SetGroupName ("Ccnx")
64 .SetParent<CcnxPit> ()
65 .AddConstructor< CcnxPitImpl< persistent_policy_traits > > ()
66 .AddAttribute ("MaxSize",
67 "Set maximum number of entries in PIT. If 0, limit is not enforced",
68 StringValue ("0"),
69 MakeUintegerAccessor (&CcnxPitImpl< persistent_policy_traits >::GetMaxSize,
70 &CcnxPitImpl< persistent_policy_traits >::SetMaxSize),
71 MakeUintegerChecker<uint32_t> ())
72 ;
73
Alexander Afanasyev0a0dc392012-07-27 13:41:49 -070074 return tid;
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -070075}
76
77template<>
78TypeId
79CcnxPitImpl<random_policy_traits>::GetTypeId ()
80{
81 static TypeId tid = TypeId ("ns3::CcnxPitRandom")
82 .SetGroupName ("Ccnx")
83 .SetParent<CcnxPit> ()
84 .AddConstructor< CcnxPitImpl< random_policy_traits > > ()
85 .AddAttribute ("MaxSize",
86 "Set maximum number of entries in PIT. If 0, limit is not enforced",
87 StringValue ("0"),
88 MakeUintegerAccessor (&CcnxPitImpl< random_policy_traits >::GetMaxSize,
89 &CcnxPitImpl< random_policy_traits >::SetMaxSize),
90 MakeUintegerChecker<uint32_t> ())
91 ;
92
Alexander Afanasyev0a0dc392012-07-27 13:41:49 -070093 return tid;
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -070094}
95
96template<>
97TypeId
98CcnxPitImpl<lru_policy_traits>::GetTypeId ()
99{
100 static TypeId tid = TypeId ("ns3::CcnxPitLru")
101 .SetGroupName ("Ccnx")
102 .SetParent<CcnxPit> ()
103 .AddConstructor< CcnxPitImpl< lru_policy_traits > > ()
104 .AddAttribute ("MaxSize",
105 "Set maximum number of entries in PIT. If 0, limit is not enforced",
106 StringValue ("0"),
107 MakeUintegerAccessor (&CcnxPitImpl< lru_policy_traits >::GetMaxSize,
108 &CcnxPitImpl< lru_policy_traits >::SetMaxSize),
109 MakeUintegerChecker<uint32_t> ())
110 ;
111
Alexander Afanasyev0a0dc392012-07-27 13:41:49 -0700112 return tid;
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700113}
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700114
Alexander Afanasyev0a0dc392012-07-27 13:41:49 -0700115// template<class Policy>
116// TypeId
117// CcnxPitImpl<Policy>::GetTypeId ()
118// {
119// static TypeId tid = TypeId ("ns3::UnknownPitPolicy");
120
121// return tid;
122// }
Alexander Afanasyev36b45772012-07-10 16:57:42 -0700123
124// CcnxPitEntryImpl::CcnxPitEntryImpl (CcnxPit &pit,
125// Ptr<const CcnxInterestHeader> header,
126// Ptr<CcnxFibEntry> fibEntry)
127// : CcnxPitEntry (pit, header, fibEntry)
128// , item_ (0)
129// {
130// static_cast<CcnxPitImpl&> (m_container).i_time.insert (*this);
131// }
132
133// CcnxPitEntryImpl::~CcnxPitEntryImpl ()
134// {
135// static_cast<CcnxPitImpl&> (m_container).i_time.erase (*this);
136// }
137
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700138// TypeId
139// CcnxPitImpl::GetTypeId ()
140// {
141// static TypeId tid = TypeId ("ns3::CcnxPit")
142// .SetGroupName ("Ccnx")
143// .SetParent<CcnxPit> ()
144// .AddConstructor<CcnxPitImpl> ()
145// .AddAttribute ("MaxSize",
146// "Set maximum number of entries in PIT. If 0, limit is not enforced",
147// StringValue ("0"),
148// MakeUintegerAccessor (&CcnxPitImpl::GetMaxSize, &CcnxPitImpl::SetMaxSize),
149// MakeUintegerChecker<uint32_t> ())
150// ;
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700151
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700152// return tid;
153// }
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700154
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700155
156// template<class AcceptanceAndReplacementPolicy>
157// TypeId
158// CcnxPitImpl::GetTypeId ()
159// {
160// #error "Not specialized version is not supported"
161// // static TypeId tid = TypeId ("ns3::CcnxPit")
162// // .SetGroupName ("Ccnx")
163// // .SetParent<CcnxPit> ()
164// // .AddConstructor<CcnxPitImpl> ()
165// // .AddAttribute ("MaxSize",
166// // "Set maximum number of entries in PIT. If 0, limit is not enforced",
167// // StringValue ("0"),
168// // MakeUintegerAccessor (&CcnxPitImpl::GetMaxSize, &CcnxPitImpl::SetMaxSize),
169// // MakeUintegerChecker<uint32_t> ())
170// // ;
171
172// return Typeid ();
173// }
174
175template<class Policy>
176CcnxPitImpl<Policy>::CcnxPitImpl ()
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700177{
178}
179
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700180template<class Policy>
181CcnxPitImpl<Policy>::~CcnxPitImpl ()
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700182{
183}
184
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700185template<class Policy>
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700186uint32_t
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700187CcnxPitImpl<Policy>::GetMaxSize () const
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700188{
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700189 return super::getPolicy ().get_max_size ();
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700190}
191
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700192template<class Policy>
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700193void
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700194CcnxPitImpl<Policy>::SetMaxSize (uint32_t maxSize)
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700195{
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700196 super::getPolicy ().set_max_size (maxSize);
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700197}
198
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700199template<class Policy>
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700200void
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700201CcnxPitImpl<Policy>::NotifyNewAggregate ()
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700202{
203 if (m_fib == 0)
204 {
205 m_fib = GetObject<CcnxFib> ();
206 }
Alexander Afanasyevf249a192012-07-18 16:52:51 -0700207 if (m_forwardingStrategy == 0)
208 {
209 m_forwardingStrategy = GetObject<CcnxForwardingStrategy> ();
210 }
211
212 CcnxPit::NotifyNewAggregate ();
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700213}
214
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700215template<class Policy>
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700216void
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700217CcnxPitImpl<Policy>::DoDispose ()
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700218{
Alexander Afanasyev413c7f12012-07-10 17:35:16 -0700219 super::clear ();
Alexander Afanasyevf249a192012-07-18 16:52:51 -0700220
221 m_forwardingStrategy = 0;
222 m_fib = 0;
223
224 CcnxPit::DoDispose ();
Alexander Afanasyev413c7f12012-07-10 17:35:16 -0700225}
226
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700227template<class Policy>
228void
229CcnxPitImpl<Policy>::RescheduleCleaning ()
Alexander Afanasyev413c7f12012-07-10 17:35:16 -0700230{
231 m_cleanEvent.Cancel ();
232 if (i_time.empty ())
Alexander Afanasyevf1e013f2012-07-11 17:59:40 -0700233 {
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700234 // NS_LOG_DEBUG ("No items in PIT");
Alexander Afanasyevf1e013f2012-07-11 17:59:40 -0700235 return;
236 }
Alexander Afanasyev413c7f12012-07-10 17:35:16 -0700237
Alexander Afanasyevf1e013f2012-07-11 17:59:40 -0700238 Time nextEvent = i_time.begin ()->GetExpireTime () - Simulator::Now ();
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700239 if (nextEvent <= 0) nextEvent = Seconds (0);
Alexander Afanasyevf1e013f2012-07-11 17:59:40 -0700240
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700241 // NS_LOG_DEBUG ("Schedule next cleaning in " <<
242 // nextEvent.ToDouble (Time::S) << "s (at " <<
243 // i_time.begin ()->GetExpireTime () << "s abs time");
244
Alexander Afanasyevf1e013f2012-07-11 17:59:40 -0700245 m_cleanEvent = Simulator::Schedule (nextEvent,
Alexander Afanasyev413c7f12012-07-10 17:35:16 -0700246 &CcnxPitImpl::CleanExpired, this);
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700247}
248
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700249template<class Policy>
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700250void
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700251CcnxPitImpl<Policy>::CleanExpired ()
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700252{
Alexander Afanasyev413c7f12012-07-10 17:35:16 -0700253 NS_LOG_LOGIC ("Cleaning PIT. Total: " << i_time.size ());
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700254 Time now = Simulator::Now ();
255
Alexander Afanasyev413c7f12012-07-10 17:35:16 -0700256 // uint32_t count = 0;
257 while (!i_time.empty ())
258 {
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700259 typename time_index::iterator entry = i_time.begin ();
Alexander Afanasyev413c7f12012-07-10 17:35:16 -0700260 if (entry->GetExpireTime () <= now) // is the record stale?
261 {
Alexander Afanasyevf249a192012-07-18 16:52:51 -0700262 m_forwardingStrategy->WillErasePendingInterest (entry->to_iterator ()->payload ());
Alexander Afanasyev413c7f12012-07-10 17:35:16 -0700263 super::erase (entry->to_iterator ());
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700264 // count ++;
Alexander Afanasyev413c7f12012-07-10 17:35:16 -0700265 }
266 else
267 break; // nothing else to do. All later records will not be stale
268 }
269
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700270 if (super::getPolicy ().size ())
271 {
272 NS_LOG_DEBUG ("Size: " << super::getPolicy ().size ());
273 }
Alexander Afanasyev413c7f12012-07-10 17:35:16 -0700274 RescheduleCleaning ();
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700275}
276
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700277template<class Policy>
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700278Ptr<CcnxPitEntry>
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700279CcnxPitImpl<Policy>::Lookup (const CcnxContentObjectHeader &header)
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700280{
Alexander Afanasyev30f60e32012-07-10 14:21:16 -0700281 /// @todo use predicate to search with exclude filters
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700282 typename super::iterator item = super::longest_prefix_match (header.GetName ());
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700283
Alexander Afanasyev30f60e32012-07-10 14:21:16 -0700284 if (item == super::end ())
285 return 0;
286 else
287 return item->payload (); // which could also be 0
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700288}
289
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700290template<class Policy>
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700291Ptr<CcnxPitEntry>
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700292CcnxPitImpl<Policy>::Lookup (const CcnxInterestHeader &header)
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700293{
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700294 // NS_LOG_FUNCTION (header.GetName ());
Alexander Afanasyev30f60e32012-07-10 14:21:16 -0700295 NS_ASSERT_MSG (m_fib != 0, "FIB should be set");
Alexander Afanasyevf249a192012-07-18 16:52:51 -0700296 NS_ASSERT_MSG (m_forwardingStrategy != 0, "Forwarding strategy should be set");
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700297
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700298 typename super::iterator foundItem, lastItem;
Alexander Afanasyev30f60e32012-07-10 14:21:16 -0700299 bool reachLast;
300 boost::tie (foundItem, reachLast, lastItem) = super::getTrie ().find (header.GetName ());
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700301
Alexander Afanasyev30f60e32012-07-10 14:21:16 -0700302 if (!reachLast || lastItem == super::end ())
303 return 0;
304 else
305 return lastItem->payload (); // which could also be 0
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700306}
307
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700308template<class Policy>
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700309Ptr<CcnxPitEntry>
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700310CcnxPitImpl<Policy>::Create (Ptr<const CcnxInterestHeader> header)
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700311{
Alexander Afanasyev30f60e32012-07-10 14:21:16 -0700312 Ptr<CcnxFibEntry> fibEntry = m_fib->LongestPrefixMatch (*header);
Alexander Afanasyev3c5b6a72012-07-20 15:35:48 -0700313 if (fibEntry == 0)
314 return 0;
315
316 // NS_ASSERT_MSG (fibEntry != 0,
317 // "There should be at least default route set" <<
318 // " Prefix = "<< header->GetName() << ", NodeID == " << m_fib->GetObject<Node>()->GetId() << "\n" << *m_fib);
Alexander Afanasyev30f60e32012-07-10 14:21:16 -0700319
Alexander Afanasyev36b45772012-07-10 16:57:42 -0700320 Ptr< entry > newEntry = ns3::Create< entry > (boost::ref (*this), header, fibEntry);
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700321 std::pair< typename super::iterator, bool > result = super::insert (header->GetName (), newEntry);
Alexander Afanasyev30f60e32012-07-10 14:21:16 -0700322 if (result.first != super::end ())
323 {
324 if (result.second)
325 {
326 newEntry->SetTrie (result.first);
327 return newEntry;
328 }
329 else
330 {
331 // should we do anything?
332 // update payload? add new payload?
333 return result.first->payload ();
334 }
335 }
336 else
337 return 0;
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700338}
339
340
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700341template<class Policy>
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700342void
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700343CcnxPitImpl<Policy>::MarkErased (Ptr<CcnxPitEntry> item)
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700344{
Alexander Afanasyev30f60e32012-07-10 14:21:16 -0700345 // entry->SetExpireTime (Simulator::Now () + m_PitEntryPruningTimout);
Alexander Afanasyev36b45772012-07-10 16:57:42 -0700346 super::erase (StaticCast< entry > (item)->to_iterator ());
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700347}
348
349
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700350template<class Policy>
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700351void
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700352CcnxPitImpl<Policy>::Print (std::ostream& os) const
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700353{
Alexander Afanasyev30f60e32012-07-10 14:21:16 -0700354 // !!! unordered_set imposes "random" order of item in the same level !!!
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700355 typename super::parent_trie::const_recursive_iterator item (super::getTrie ()), end (0);
Alexander Afanasyev30f60e32012-07-10 14:21:16 -0700356 for (; item != end; item++)
357 {
358 if (item->payload () == 0) continue;
359
360 os << item->payload ()->GetPrefix () << "\t" << *item->payload () << "\n";
361 }
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700362}
363
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700364template<class Policy>
Alexander Afanasyevf1e013f2012-07-11 17:59:40 -0700365uint32_t
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700366CcnxPitImpl<Policy>::GetSize () const
Alexander Afanasyevf1e013f2012-07-11 17:59:40 -0700367{
368 return super::getPolicy ().size ();
369}
370
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700371template<class Policy>
Alexander Afanasyev30f60e32012-07-10 14:21:16 -0700372Ptr<CcnxPitEntry>
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700373CcnxPitImpl<Policy>::Begin ()
Alexander Afanasyev30f60e32012-07-10 14:21:16 -0700374{
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700375 typename super::parent_trie::recursive_iterator item (super::getTrie ()), end (0);
Alexander Afanasyev30f60e32012-07-10 14:21:16 -0700376 for (; item != end; item++)
377 {
378 if (item->payload () == 0) continue;
379 break;
380 }
381
382 if (item == end)
383 return End ();
384 else
385 return item->payload ();
386}
387
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700388template<class Policy>
Alexander Afanasyev30f60e32012-07-10 14:21:16 -0700389Ptr<CcnxPitEntry>
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700390CcnxPitImpl<Policy>::End ()
Alexander Afanasyev30f60e32012-07-10 14:21:16 -0700391{
392 return 0;
393}
394
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700395template<class Policy>
Alexander Afanasyev30f60e32012-07-10 14:21:16 -0700396Ptr<CcnxPitEntry>
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700397CcnxPitImpl<Policy>::Next (Ptr<CcnxPitEntry> from)
Alexander Afanasyev30f60e32012-07-10 14:21:16 -0700398{
399 if (from == 0) return 0;
400
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700401 typename super::parent_trie::recursive_iterator
Alexander Afanasyev36b45772012-07-10 16:57:42 -0700402 item (*StaticCast< entry > (from)->to_iterator ()),
Alexander Afanasyev30f60e32012-07-10 14:21:16 -0700403 end (0);
404
405 for (item++; item != end; item++)
406 {
407 if (item->payload () == 0) continue;
408 break;
409 }
410
411 if (item == end)
412 return End ();
413 else
414 return item->payload ();
415}
416
417
Alexander Afanasyevbd6f3f42012-07-26 17:50:17 -0700418// explicit instantiation and registering
419template class CcnxPitImpl<persistent_policy_traits>;
420template class CcnxPitImpl<random_policy_traits>;
421template class CcnxPitImpl<lru_policy_traits>;
422
423NS_OBJECT_ENSURE_REGISTERED_TEMPL(CcnxPitImpl, persistent_policy_traits);
424NS_OBJECT_ENSURE_REGISTERED_TEMPL(CcnxPitImpl, random_policy_traits);
425NS_OBJECT_ENSURE_REGISTERED_TEMPL(CcnxPitImpl, lru_policy_traits);
426
427
Alexander Afanasyev11f7bb42012-07-09 17:06:30 -0700428} // namespace ns3