NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
content-store-with-probability.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
20 #ifndef NDN_CONTENT_STORE_WITH_PROBABILITY_H_
21 #define NDN_CONTENT_STORE_WITH_PROBABILITY_H_
22 
23 #include "ns3/ndnSIM/model/ndn-common.hpp"
24 
25 #include "content-store-impl.hpp"
26 
27 #include "../../utils/trie/multi-policy.hpp"
29 #include "ns3/double.h"
30 #include "ns3/type-id.h"
31 
32 namespace ns3 {
33 namespace ndn {
34 namespace cs {
35 
41 template<class Policy>
43  : public ContentStoreImpl<ndnSIM::multi_policy_traits<boost::mpl::
44  vector2<ndnSIM::probability_policy_traits,
45  Policy>>> {
46 public:
47  typedef ContentStoreImpl<ndnSIM::multi_policy_traits<boost::mpl::
48  vector2<ndnSIM::probability_policy_traits,
49  Policy>>> super;
50 
51  typedef typename super::policy_container::template index<0>::type probability_policy_container;
52 
54 
55  static TypeId
56  GetTypeId();
57 
58 private:
59  void
60  SetCacheProbability(double probability)
61  {
62  this->getPolicy().template get<probability_policy_container>().set_probability(probability);
63  }
64 
65  double
66  GetCacheProbability() const
67  {
68  return this->getPolicy().template get<probability_policy_container>().get_probability();
69  }
70 };
71 
75 
76 template<class Policy>
77 TypeId
79 {
80  static TypeId tid =
81  TypeId(("ns3::ndn::cs::Probability::" + Policy::GetName()).c_str())
82  .SetGroupName("Ndn")
83  .SetParent<super>()
84  .template AddConstructor<ContentStoreWithProbability<Policy>>()
85 
86  .AddAttribute("CacheProbability",
87  "Set probability of caching in ContentStore. "
88  "If 1, every content is cached. If 0, no content is cached.",
89  DoubleValue(1.0), //(+)
92  MakeDoubleChecker<double>());
93 
94  return tid;
95 }
96 
97 } // namespace cs
98 } // namespace ndn
99 } // namespace ns3
100 
101 #endif // NDN_CONTENT_STORE_WITH_PROBABILITY_H_
Copyright (c) 2011-2015 Regents of the University of California.
ndnSIM::trie_with_policy< Name, ndnSIM::smart_pointer_payload_traits< EntryImpl< ContentStoreImpl< ndnSIM::multi_policy_traits< boost::mpl::vector2< ndnSIM::probability_policy_traits, lru_policy_traits > > > >, Entry >, ndnSIM::multi_policy_traits< boost::mpl::vector2< ndnSIM::probability_policy_traits, lru_policy_traits > > > super
super::policy_container::template index< 0 >::type probability_policy_container
Special content store realization that probabilistically accepts data packet into CS (placement polic...
ContentStoreImpl< ndnSIM::multi_policy_traits< boost::mpl::vector2< ndnSIM::probability_policy_traits, Policy > > > super
Copyright (c) 2011-2015 Regents of the University of California.
Base implementation of NDN content store.