blob: 67f2763916bcca0b11b0a4548d4af982ba3becdf [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 Afanasyev1c0248b2012-07-24 15:59:50 -070049 virtual void
50 OnInterest (const Ptr<CcnxFace> &face,
51 Ptr<CcnxInterestHeader> &header,
52 const Ptr<const Packet> &p);
53
54 virtual void
55 OnData (const Ptr<CcnxFace> &face,
56 Ptr<CcnxContentObjectHeader> &header,
57 Ptr<Packet> &payload,
58 const Ptr<const Packet> &packet);
Alexander Afanasyev33364b62012-07-26 17:53:56 -070059
60 virtual void
61 RemoveFace (Ptr<CcnxFace> face);
62
Alexander Afanasyevf249a192012-07-18 16:52:51 -070063protected:
64 virtual void
65 DidCreatePitEntry (const Ptr<CcnxFace> &incomingFace,
66 Ptr<CcnxInterestHeader> header,
67 const Ptr<const Packet> &packet,
68 Ptr<CcnxPitEntry> pitEntry);
69
70 virtual void
Alexander Afanasyev77495a92012-07-20 15:38:29 -070071 FailedToCreatePitEntry (const Ptr<CcnxFace> &incomingFace,
72 Ptr<CcnxInterestHeader> header,
73 const Ptr<const Packet> &packet);
74
75 virtual void
Alexander Afanasyevf249a192012-07-18 16:52:51 -070076 WillSatisfyPendingInterest (const Ptr<CcnxFace> &incomingFace,
77 Ptr<CcnxPitEntry> pitEntry);
78
79 virtual void
80 DidSendOutInterest (const Ptr<CcnxFace> &outgoingFace,
81 Ptr<CcnxInterestHeader> header,
Alexander Afanasyev1c0248b2012-07-24 15:59:50 -070082 const Ptr<const Packet> &packet,
Alexander Afanasyevf249a192012-07-18 16:52:51 -070083 Ptr<CcnxPitEntry> pitEntry);
84
85 virtual void
Alexander Afanasyev1c0248b2012-07-24 15:59:50 -070086 DidSendOutData (const Ptr<CcnxFace> &face,
87 Ptr<const CcnxContentObjectHeader> header,
88 Ptr<const Packet> payload,
89 const Ptr<const Packet> &packet);
90
91 virtual void
Alexander Afanasyevf249a192012-07-18 16:52:51 -070092 WillErasePendingInterest (Ptr<CcnxPitEntry> pitEntry);
Alexander Afanasyeve55d1e32012-07-19 15:33:05 -070093
94 // from Object
95 void
96 DoDispose ();
97
98private:
99 void
100 RefreshStats ();
101
102 void
103 ScheduleRefreshingIfNecessary ();
104
Alexander Afanasyevf249a192012-07-18 16:52:51 -0700105private:
106 ::ndnSIM::StatsTree m_stats;
Alexander Afanasyeve55d1e32012-07-19 15:33:05 -0700107 EventId m_statsRefreshEvent;
Alexander Afanasyev77495a92012-07-20 15:38:29 -0700108
109 TracedCallback< Ptr<CcnxForwardingStrategy>,
110 const ::ndnSIM::StatsTree & > m_statsTrace;
Alexander Afanasyevf249a192012-07-18 16:52:51 -0700111
112 typedef BestRoute super;
113};
114
115} // namespace ndnSIM
116} // namespace ns3
117
118#endif // NDNSIM_FW_STATS_H