NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
content-store-with-stats.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_STATS_H_
21
#define NDN_CONTENT_STORE_WITH_STATS_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"
28
#include "
custom-policies/lifetime-stats-policy.hpp
"
29
30
namespace
ns3
{
31
namespace
ndn
{
32
namespace
cs {
33
38
template
<
class
Policy>
39
class
ContentStoreWithStats
40
:
public
ContentStoreImpl
<ndnSIM::
41
multi_policy_traits<boost::mpl::
42
vector2<Policy,
43
ndnSIM::
44
lifetime_stats_policy_traits>>> {
45
public
:
46
typedef
ContentStoreImpl
<ndnSIM::
47
multi_policy_traits<boost::mpl::
48
vector2<Policy,
49
ndnSIM::lifetime_stats_policy_traits>>>
50
super
;
51
52
typedef
typename
super::policy_container::template index<1>::type
lifetime_stats_container
;
53
54
ContentStoreWithStats
()
55
{
56
// connect traceback to the policy
57
super::getPolicy().template get<1>().set_traced_callback(&m_willRemoveEntry);
58
}
59
60
static
TypeId
61
GetTypeId
();
62
63
virtual
inline
void
64
Print
(std::ostream& os)
const
;
65
66
public
:
67
typedef
void (*
RemoveCsEntryCallback
)(Ptr<const Entry>, Time);
68
69
private
:
70
static
LogComponent g_log;
71
74
TracedCallback<Ptr<const Entry>, Time> m_willRemoveEntry;
75
};
76
80
81
template
<
class
Policy>
82
LogComponent
ContentStoreWithStats<Policy>::g_log
= LogComponent((
"ndn.cs.Stats."
83
+ Policy::GetName()).c_str(), __FILE__);
84
85
template
<
class
Policy>
86
TypeId
87
ContentStoreWithStats<Policy>::GetTypeId
()
88
{
89
static
TypeId tid =
90
TypeId((
"ns3::ndn::cs::Stats::"
+ Policy::GetName()).c_str())
91
.SetGroupName(
"Ndn"
)
92
.SetParent<
super
>()
93
.
template
AddConstructor<
ContentStoreWithStats<Policy>
>()
94
95
.AddTraceSource(
"WillRemoveEntry"
,
96
"Trace called just before content store entry will be removed"
,
97
MakeTraceSourceAccessor(&
ContentStoreWithStats<Policy>::m_willRemoveEntry
),
98
"ns3::ndn::cs::ContentStoreWithStats::RemoveCsEntryCallback"
)
99
100
// trace stuff here
101
;
102
103
return
tid;
104
}
105
106
template
<
class
Policy>
107
void
108
ContentStoreWithStats<Policy>::Print
(std::ostream& os)
const
109
{
110
// const freshness_policy_container &freshness = this->getPolicy ().template
111
// get<freshness_policy_container> ();
112
113
for
(
typename
super::policy_container::const_iterator item = this->getPolicy().begin();
114
item != this->getPolicy().end(); item++) {
115
Time alive = lifetime_stats_container::policy_base::get_time(&(*item)) - Simulator::Now();
116
os << item->payload()->GetName() <<
"(alive: "
<< alive.ToDouble(Time::S) <<
"s)"
<< std::endl;
117
}
118
}
119
120
}
// namespace cs
121
}
// namespace ndn
122
}
// namespace ns3
123
124
#endif // NDN_CONTENT_STORE_IMPL_H_
ns3::ndn::cs::ContentStoreWithStats::Print
virtual void Print(std::ostream &os) const
Print out content store entries.
Definition:
content-store-with-stats.hpp:108
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ns3::ndn::cs::ContentStoreWithStats::lifetime_stats_container
super::policy_container::template index< 1 >::type lifetime_stats_container
Definition:
content-store-with-stats.hpp:52
ns3::ndn::cs::ContentStoreWithStats::GetTypeId
static TypeId GetTypeId()
Definition:
content-store-with-stats.hpp:87
content-store-impl.hpp
ns3::ndn::cs::ContentStoreWithStats
Special content store realization that provides ability to track stats of CS operations.
Definition:
content-store-with-stats.hpp:39
ns3
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
content-store-impl.cpp:38
ns3::ndn::cs::ContentStoreWithStats::super
ContentStoreImpl< ndnSIM::multi_policy_traits< boost::mpl::vector2< Policy, ndnSIM::lifetime_stats_policy_traits > > > super
Definition:
content-store-with-stats.hpp:50
lifetime-stats-policy.hpp
ns3::ndn::cs::ContentStoreImpl
Base implementation of NDN content store.
Definition:
content-store-impl.hpp:82
ns3::ndn::cs::ContentStoreWithStats::RemoveCsEntryCallback
void(* RemoveCsEntryCallback)(Ptr< const Entry >, Time)
Definition:
content-store-with-stats.hpp:67
ns3::ndn::cs::ContentStoreWithStats::ContentStoreWithStats
ContentStoreWithStats()
Definition:
content-store-with-stats.hpp:54
ndnSIM
model
cs
content-store-with-stats.hpp
Generated on Tue Feb 23 2016 22:18:43 for ndnSIM by
1.8.11