NS-3 based Named Data Networking (NDN) simulator
ndnSIM: NDN, CCN, CCNx, content centric networks
API Documentation
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Groups
Pages
content-store-with-stats.h
1
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2012 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
#ifndef NDN_CONTENT_STORE_WITH_STATS_H_
22
#define NDN_CONTENT_STORE_WITH_STATS_H_
23
24
#include "content-store-impl.h"
25
26
#include "../../utils/trie/multi-policy.h"
27
#include "custom-policies/lifetime-stats-policy.h"
28
29
namespace
ns3 {
30
namespace
ndn {
31
namespace
cs {
32
37
template
<
class
Policy>
38
class
ContentStoreWithStats
:
39
public
ContentStoreImpl
< ndnSIM::multi_policy_traits< boost::mpl::vector2< Policy, ndnSIM::lifetime_stats_policy_traits > > >
40
{
41
public
:
42
typedef
ContentStoreImpl< ndnSIM::multi_policy_traits< boost::mpl::vector2< Policy, ndnSIM::lifetime_stats_policy_traits >
> >
super
;
43
44
typedef
typename
super::policy_container::template index<1>::type lifetime_stats_container;
45
46
ContentStoreWithStats
()
47
{
48
// connect traceback to the policy
49
super::getPolicy ().template get<1> ().set_traced_callback (&m_willRemoveEntry);
50
}
51
52
static
TypeId
53
GetTypeId ();
54
55
virtual
inline
void
56
Print
(std::ostream &os)
const
;
57
58
private
:
59
static
LogComponent g_log;
60
62
TracedCallback< Ptr<const Entry>, Time > m_willRemoveEntry;
63
};
64
68
69
70
template
<
class
Policy>
71
LogComponent
72
ContentStoreWithStats< Policy >::g_log
= LogComponent ((
"ndn.cs.Stats."
+ Policy::GetName ()).c_str ());
73
74
75
template
<
class
Policy>
76
TypeId
77
ContentStoreWithStats< Policy >::GetTypeId
()
78
{
79
static
TypeId tid = TypeId ((
"ns3::ndn::cs::Stats::"
+Policy::GetName ()).c_str ())
80
.SetGroupName (
"Ndn"
)
81
.SetParent<super> ()
82
.
template
AddConstructor<
ContentStoreWithStats< Policy >
> ()
83
84
.AddTraceSource (
"WillRemoveEntry"
,
"Trace called just before content store entry will be removed"
,
85
MakeTraceSourceAccessor (&
ContentStoreWithStats< Policy >::m_willRemoveEntry
))
86
87
// trace stuff here
88
;
89
90
return
tid;
91
}
92
93
template
<
class
Policy>
94
void
95
ContentStoreWithStats< Policy >::Print
(std::ostream &os)
const
96
{
97
// const freshness_policy_container &freshness = this->getPolicy ().template get<freshness_policy_container> ();
98
99
for
(
typename
super::policy_container::const_iterator
item = this->getPolicy ().begin ();
100
item != this->getPolicy ().end ();
101
item++)
102
{
103
Time alive = lifetime_stats_container::policy_base::get_time (&(*item)) - Simulator::Now ();
104
os << item->payload ()->GetName () <<
"(alive: "
<< alive.ToDouble (Time::S) <<
"s)"
<< std::endl;
105
}
106
}
107
108
109
110
}
// namespace cs
111
}
// namespace ndn
112
}
// namespace ns3
113
114
#endif // NDN_CONTENT_STORE_IMPL_H_
ns3::ndn::cs::ContentStoreWithStats
Special content store realization that provides ability to track stats of CS operations.
Definition:
content-store-with-stats.h:38
ns3::ndn::cs::ContentStoreImpl
Base implementation of NDN content store.
Definition:
content-store-impl.h:77
ns3::ndn::ndnSIM::trie
Definition:
trie.h:109
ns3::ndn::cs::ContentStoreWithStats::Print
virtual void Print(std::ostream &os) const
Print out content store entries.
Definition:
content-store-with-stats.h:95
ndnSIM
model
cs
content-store-with-stats.h
Generated on Mon Jan 19 2015 11:27:03 for ndnSIM by
1.8.7