blob: 6ad7ff00c88f41bbad8eec72f923237070a7f97f [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"
Alexander Afanasyev1a2df6a2012-08-17 13:21:51 -070028#include "../../utils/stats/stats-tree.h"
Alexander Afanasyevf249a192012-07-18 16:52:51 -070029
30namespace ns3 {
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070031namespace ndn {
32namespace fw {
Alexander Afanasyevf249a192012-07-18 16:52:51 -070033
34/**
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070035 * \ingroup ndn
Alexander Afanasyeve55d1e32012-07-19 15:33:05 -070036 * \brief Strategy based on best route and adding statistics gathering capabilities
Alexander Afanasyevf249a192012-07-18 16:52:51 -070037 */
38class FwStats :
39 public BestRoute
40{
41public:
42 static TypeId
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070043 GetTypeId ();
Alexander Afanasyevf249a192012-07-18 16:52:51 -070044
45 /**
46 * @brief Default constructor
47 */
48 FwStats ();
49
Alexander Afanasyevb1b7f5d2012-08-09 09:59:43 -070050 inline
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070051 const ndnSIM::StatsTree &
Alexander Afanasyevb1b7f5d2012-08-09 09:59:43 -070052 GetStatsTree () const;
53
Alexander Afanasyev1c0248b2012-07-24 15:59:50 -070054 virtual void
Alexander Afanasyev31cb4692012-08-17 13:08:20 -070055 OnInterest (Ptr<Face> face,
56 Ptr<const InterestHeader> header,
57 Ptr<const Packet> origPacket);
Alexander Afanasyev1c0248b2012-07-24 15:59:50 -070058
59 virtual void
Alexander Afanasyev31cb4692012-08-17 13:08:20 -070060 OnData (Ptr<Face> face,
61 Ptr<const ContentObjectHeader> header,
62 Ptr<Packet> payload,
63 Ptr<const Packet> origPacket);
Alexander Afanasyev33364b62012-07-26 17:53:56 -070064
65 virtual void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070066 RemoveFace (Ptr<Face> face);
Alexander Afanasyev33364b62012-07-26 17:53:56 -070067
Alexander Afanasyevf249a192012-07-18 16:52:51 -070068protected:
69 virtual void
Alexander Afanasyev31cb4692012-08-17 13:08:20 -070070 DidCreatePitEntry (Ptr<Face> inFace,
71 Ptr<const InterestHeader> header,
72 Ptr<const Packet> packet,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070073 Ptr<pit::Entry> pitEntry);
Alexander Afanasyevf249a192012-07-18 16:52:51 -070074
75 virtual void
Alexander Afanasyev31cb4692012-08-17 13:08:20 -070076 FailedToCreatePitEntry (Ptr<Face> inFace,
77 Ptr<const InterestHeader> header,
78 Ptr<const Packet> packet);
Alexander Afanasyev77495a92012-07-20 15:38:29 -070079
80 virtual void
Alexander Afanasyev31cb4692012-08-17 13:08:20 -070081 WillSatisfyPendingInterest (Ptr<Face> inFace,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070082 Ptr<pit::Entry> pitEntry);
Alexander Afanasyevf249a192012-07-18 16:52:51 -070083
84 virtual void
Alexander Afanasyev31cb4692012-08-17 13:08:20 -070085 DidSendOutInterest (Ptr<Face> outFace,
86 Ptr<const InterestHeader> header,
87 Ptr<const Packet> origPacket,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070088 Ptr<pit::Entry> pitEntry);
Alexander Afanasyevf249a192012-07-18 16:52:51 -070089
90 virtual void
Alexander Afanasyev31cb4692012-08-17 13:08:20 -070091 DidSendOutData (Ptr<Face> outFace,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070092 Ptr<const ContentObjectHeader> header,
Alexander Afanasyev1c0248b2012-07-24 15:59:50 -070093 Ptr<const Packet> payload,
Alexander Afanasyev31cb4692012-08-17 13:08:20 -070094 Ptr<const Packet> origPacket,
95 Ptr<pit::Entry> pitEntry);
Alexander Afanasyev1c0248b2012-07-24 15:59:50 -070096
97 virtual void
Alexander Afanasyevea9b3e62012-08-13 19:02:54 -070098 WillEraseTimedOutPendingInterest (Ptr<pit::Entry> pitEntry);
Alexander Afanasyeve55d1e32012-07-19 15:33:05 -070099
Alexander Afanasyev70426a02012-08-15 15:39:18 -0700100 virtual void
Alexander Afanasyev31cb4692012-08-17 13:08:20 -0700101 DidExhaustForwardingOptions (Ptr<Face> inFace,
102 Ptr<const InterestHeader> header,
103 Ptr<const Packet> origPacket,
Alexander Afanasyev70426a02012-08-15 15:39:18 -0700104 Ptr<pit::Entry> pitEntry);
Alexander Afanasyev187cba22012-08-28 11:16:52 -0700105
106 virtual void
107 DidReceiveValidNack (Ptr<Face> inFace,
108 uint32_t nackCode,
109 Ptr<pit::Entry> pitEntry);
Alexander Afanasyev70426a02012-08-15 15:39:18 -0700110
Alexander Afanasyeve55d1e32012-07-19 15:33:05 -0700111 // from Object
112 void
113 DoDispose ();
114
115private:
116 void
117 RefreshStats ();
118
119 void
120 ScheduleRefreshingIfNecessary ();
121
Alexander Afanasyevf249a192012-07-18 16:52:51 -0700122private:
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700123 ndnSIM::StatsTree m_stats;
Alexander Afanasyeve55d1e32012-07-19 15:33:05 -0700124 EventId m_statsRefreshEvent;
Alexander Afanasyev77495a92012-07-20 15:38:29 -0700125
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700126 TracedCallback< Ptr<ForwardingStrategy>,
127 const ndnSIM::StatsTree & > m_statsTrace;
Alexander Afanasyevf249a192012-07-18 16:52:51 -0700128
129 typedef BestRoute super;
130};
131
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700132const ndnSIM::StatsTree &
Alexander Afanasyevb1b7f5d2012-08-09 09:59:43 -0700133FwStats::GetStatsTree () const
134{
135 return m_stats;
136}
137
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700138} // namespace fw
139} // namespace ndn
Alexander Afanasyevf249a192012-07-18 16:52:51 -0700140} // namespace ns3
141
142#endif // NDNSIM_FW_STATS_H