NS-3 based Named Data Networking (NDN) simulator
ndnSIM: NDN, CCN, CCNx, content centric networks
API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
ndn-pit-impl.cc
1 /* -*- 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 "ndn-pit-impl.h"
22 
23 #include "../../utils/trie/empty-policy.h"
24 #include "../../utils/trie/persistent-policy.h"
25 #include "../../utils/trie/random-policy.h"
26 #include "../../utils/trie/lru-policy.h"
27 #include "../../utils/trie/multi-policy.h"
28 #include "../../utils/trie/aggregate-stats-policy.h"
29 
30 #include "ns3/log.h"
31 
32 NS_LOG_COMPONENT_DEFINE ("ndn.pit.PitImpl");
33 
34 #include "custom-policies/serialized-size-policy.h"
35 
36 #include "ns3/string.h"
37 #include "ns3/uinteger.h"
38 #include "ns3/simulator.h"
39 
40 #include <boost/lambda/bind.hpp>
41 #include <boost/lambda/lambda.hpp>
42 
43 
44 using namespace boost::tuples;
45 using namespace boost;
46 namespace ll = boost::lambda;
47 
48 #define NS_OBJECT_ENSURE_REGISTERED_TEMPL(type, templ) \
49  static struct X ## type ## templ ## RegistrationClass \
50  { \
51  X ## type ## templ ## RegistrationClass () { \
52  ns3::TypeId tid = type<templ>::GetTypeId (); \
53  tid.GetParent (); \
54  } \
55  } x_ ## type ## templ ## RegistrationVariable
56 
57 namespace ns3 {
58 namespace ndn {
59 namespace pit {
60 
61 using namespace ndnSIM;
62 
63 template<>
64 uint32_t
65 PitImpl<serialized_size_policy_traits>::GetCurrentSize () const
66 {
67  return super::getPolicy ().get_current_space_used ();
68 }
69 
73 
74 // explicit instantiation and registering
75 template class PitImpl<persistent_policy_traits>;
76 template class PitImpl<random_policy_traits>;
77 template class PitImpl<lru_policy_traits>;
78 template class PitImpl<serialized_size_policy_traits>;
79 
80 NS_OBJECT_ENSURE_REGISTERED_TEMPL(PitImpl, persistent_policy_traits);
81 NS_OBJECT_ENSURE_REGISTERED_TEMPL(PitImpl, random_policy_traits);
82 NS_OBJECT_ENSURE_REGISTERED_TEMPL(PitImpl, lru_policy_traits);
83 NS_OBJECT_ENSURE_REGISTERED_TEMPL(PitImpl, serialized_size_policy_traits);
84 
85 
86 typedef multi_policy_traits< boost::mpl::vector2< persistent_policy_traits,
87  aggregate_stats_policy_traits > > PersistentWithCountsTraits;
88 typedef multi_policy_traits< boost::mpl::vector2< random_policy_traits,
89  aggregate_stats_policy_traits > > RandomWithCountsTraits;
90 typedef multi_policy_traits< boost::mpl::vector2< lru_policy_traits,
91  aggregate_stats_policy_traits > > LruWithCountsTraits;
92 typedef multi_policy_traits< boost::mpl::vector2< serialized_size_policy_traits,
93  aggregate_stats_policy_traits > > SerializedSizeWithCountsTraits;
94 
95 template class PitImpl<PersistentWithCountsTraits>;
96 NS_OBJECT_ENSURE_REGISTERED_TEMPL(PitImpl, PersistentWithCountsTraits);
97 
98 template class PitImpl<RandomWithCountsTraits>;
99 NS_OBJECT_ENSURE_REGISTERED_TEMPL(PitImpl, RandomWithCountsTraits);
100 
101 template class PitImpl<LruWithCountsTraits>;
102 NS_OBJECT_ENSURE_REGISTERED_TEMPL(PitImpl, LruWithCountsTraits);
103 
104 template class PitImpl<SerializedSizeWithCountsTraits>;
105 NS_OBJECT_ENSURE_REGISTERED_TEMPL(PitImpl, SerializedSizeWithCountsTraits);
106 
107 #ifdef DOXYGEN
108 // /**
109 // * \brief PIT in which new entries will be rejected if PIT size reached its limit
110 // */
112 
117 
122 class Lru : public PitImpl<lru_policy_traits> { };
123 
128 
129 #endif
130 
131 } // namespace pit
132 } // namespace ndn
133 } // namespace ns3
PIT in which PIT reaches its limit, random entry (could be the newly created one) will be removed fro...
A variant of persistent PIT implementation where size of PIT is based on size of interests in bytes (...
PIT in which the least recently used entry (the oldest entry with minimum number of incoming faces) w...
PIT in which new entries will be rejected if PIT size reached its limit.