blob: 69149f372952d1c4ca6173a9198c256b1fe7b2c1 [file] [log] [blame]
Alexander Afanasyevf249a192012-07-18 16:52:51 -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
22#ifndef NDNSIM_FW_STATS_H
23#define NDNSIM_FW_STATS_H
24
Alexander Afanasyeve55d1e32012-07-19 15:33:05 -070025#include "ns3/event-id.h"
26
Alexander Afanasyevf249a192012-07-18 16:52:51 -070027#include "best-route.h"
28#include "../../utils/stats-tree.h"
29
30namespace ns3 {
31namespace ndnSIM {
32
33/**
34 * \ingroup ccnx
Alexander Afanasyeve55d1e32012-07-19 15:33:05 -070035 * \brief Strategy based on best route and adding statistics gathering capabilities
Alexander Afanasyevf249a192012-07-18 16:52:51 -070036 */
37class FwStats :
38 public BestRoute
39{
40public:
41 static TypeId
42 GetTypeId (void);
43
44 /**
45 * @brief Default constructor
46 */
47 FwStats ();
48
Alexander Afanasyevb1b7f5d2012-08-09 09:59:43 -070049 inline
50 const ::ndnSIM::StatsTree &
51 GetStatsTree () const;
52
Alexander Afanasyev1c0248b2012-07-24 15:59:50 -070053 virtual void
54 OnInterest (const Ptr<CcnxFace> &face,
55 Ptr<CcnxInterestHeader> &header,
56 const Ptr<const Packet> &p);
57
58 virtual void
59 OnData (const Ptr<CcnxFace> &face,
60 Ptr<CcnxContentObjectHeader> &header,
61 Ptr<Packet> &payload,
62 const Ptr<const Packet> &packet);
Alexander Afanasyev33364b62012-07-26 17:53:56 -070063
64 virtual void
65 RemoveFace (Ptr<CcnxFace> face);
66
Alexander Afanasyevf249a192012-07-18 16:52:51 -070067protected:
68 virtual void
69 DidCreatePitEntry (const Ptr<CcnxFace> &incomingFace,
70 Ptr<CcnxInterestHeader> header,
71 const Ptr<const Packet> &packet,
72 Ptr<CcnxPitEntry> pitEntry);
73
74 virtual void
Alexander Afanasyev77495a92012-07-20 15:38:29 -070075 FailedToCreatePitEntry (const Ptr<CcnxFace> &incomingFace,
76 Ptr<CcnxInterestHeader> header,
77 const Ptr<const Packet> &packet);
78
79 virtual void
Alexander Afanasyevf249a192012-07-18 16:52:51 -070080 WillSatisfyPendingInterest (const Ptr<CcnxFace> &incomingFace,
81 Ptr<CcnxPitEntry> pitEntry);
82
83 virtual void
84 DidSendOutInterest (const Ptr<CcnxFace> &outgoingFace,
85 Ptr<CcnxInterestHeader> header,
Alexander Afanasyev1c0248b2012-07-24 15:59:50 -070086 const Ptr<const Packet> &packet,
Alexander Afanasyevf249a192012-07-18 16:52:51 -070087 Ptr<CcnxPitEntry> pitEntry);
88
89 virtual void
Alexander Afanasyev1c0248b2012-07-24 15:59:50 -070090 DidSendOutData (const Ptr<CcnxFace> &face,
91 Ptr<const CcnxContentObjectHeader> header,
92 Ptr<const Packet> payload,
93 const Ptr<const Packet> &packet);
94
95 virtual void
Alexander Afanasyevf249a192012-07-18 16:52:51 -070096 WillErasePendingInterest (Ptr<CcnxPitEntry> pitEntry);
Alexander Afanasyeve55d1e32012-07-19 15:33:05 -070097
98 // from Object
99 void
100 DoDispose ();
101
102private:
103 void
104 RefreshStats ();
105
106 void
107 ScheduleRefreshingIfNecessary ();
108
Alexander Afanasyevf249a192012-07-18 16:52:51 -0700109private:
110 ::ndnSIM::StatsTree m_stats;
Alexander Afanasyeve55d1e32012-07-19 15:33:05 -0700111 EventId m_statsRefreshEvent;
Alexander Afanasyev77495a92012-07-20 15:38:29 -0700112
113 TracedCallback< Ptr<CcnxForwardingStrategy>,
114 const ::ndnSIM::StatsTree & > m_statsTrace;
Alexander Afanasyevf249a192012-07-18 16:52:51 -0700115
116 typedef BestRoute super;
117};
118
Alexander Afanasyevb1b7f5d2012-08-09 09:59:43 -0700119const ::ndnSIM::StatsTree &
120FwStats::GetStatsTree () const
121{
122 return m_stats;
123}
124
Alexander Afanasyevf249a192012-07-18 16:52:51 -0700125} // namespace ndnSIM
126} // namespace ns3
127
128#endif // NDNSIM_FW_STATS_H