Alexander Afanasyev | f249a19 | 2012-07-18 16:52:51 -0700 | [diff] [blame] | 1 | /* -*- 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 Afanasyev | e55d1e3 | 2012-07-19 15:33:05 -0700 | [diff] [blame] | 25 | #include "ns3/event-id.h" |
| 26 | |
Alexander Afanasyev | f249a19 | 2012-07-18 16:52:51 -0700 | [diff] [blame] | 27 | #include "best-route.h" |
| 28 | #include "../../utils/stats-tree.h" |
| 29 | |
| 30 | namespace ns3 { |
| 31 | namespace ndnSIM { |
| 32 | |
| 33 | /** |
| 34 | * \ingroup ccnx |
Alexander Afanasyev | e55d1e3 | 2012-07-19 15:33:05 -0700 | [diff] [blame] | 35 | * \brief Strategy based on best route and adding statistics gathering capabilities |
Alexander Afanasyev | f249a19 | 2012-07-18 16:52:51 -0700 | [diff] [blame] | 36 | */ |
| 37 | class FwStats : |
| 38 | public BestRoute |
| 39 | { |
| 40 | public: |
| 41 | static TypeId |
| 42 | GetTypeId (void); |
| 43 | |
| 44 | /** |
| 45 | * @brief Default constructor |
| 46 | */ |
| 47 | FwStats (); |
| 48 | |
Alexander Afanasyev | b1b7f5d | 2012-08-09 09:59:43 -0700 | [diff] [blame] | 49 | inline |
| 50 | const ::ndnSIM::StatsTree & |
| 51 | GetStatsTree () const; |
| 52 | |
Alexander Afanasyev | 1c0248b | 2012-07-24 15:59:50 -0700 | [diff] [blame] | 53 | 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 Afanasyev | 33364b6 | 2012-07-26 17:53:56 -0700 | [diff] [blame] | 63 | |
| 64 | virtual void |
| 65 | RemoveFace (Ptr<CcnxFace> face); |
| 66 | |
Alexander Afanasyev | f249a19 | 2012-07-18 16:52:51 -0700 | [diff] [blame] | 67 | protected: |
| 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 Afanasyev | 77495a9 | 2012-07-20 15:38:29 -0700 | [diff] [blame] | 75 | FailedToCreatePitEntry (const Ptr<CcnxFace> &incomingFace, |
| 76 | Ptr<CcnxInterestHeader> header, |
| 77 | const Ptr<const Packet> &packet); |
| 78 | |
| 79 | virtual void |
Alexander Afanasyev | f249a19 | 2012-07-18 16:52:51 -0700 | [diff] [blame] | 80 | WillSatisfyPendingInterest (const Ptr<CcnxFace> &incomingFace, |
| 81 | Ptr<CcnxPitEntry> pitEntry); |
| 82 | |
| 83 | virtual void |
| 84 | DidSendOutInterest (const Ptr<CcnxFace> &outgoingFace, |
| 85 | Ptr<CcnxInterestHeader> header, |
Alexander Afanasyev | 1c0248b | 2012-07-24 15:59:50 -0700 | [diff] [blame] | 86 | const Ptr<const Packet> &packet, |
Alexander Afanasyev | f249a19 | 2012-07-18 16:52:51 -0700 | [diff] [blame] | 87 | Ptr<CcnxPitEntry> pitEntry); |
| 88 | |
| 89 | virtual void |
Alexander Afanasyev | 1c0248b | 2012-07-24 15:59:50 -0700 | [diff] [blame] | 90 | 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 Afanasyev | f249a19 | 2012-07-18 16:52:51 -0700 | [diff] [blame] | 96 | WillErasePendingInterest (Ptr<CcnxPitEntry> pitEntry); |
Alexander Afanasyev | e55d1e3 | 2012-07-19 15:33:05 -0700 | [diff] [blame] | 97 | |
| 98 | // from Object |
| 99 | void |
| 100 | DoDispose (); |
| 101 | |
| 102 | private: |
| 103 | void |
| 104 | RefreshStats (); |
| 105 | |
| 106 | void |
| 107 | ScheduleRefreshingIfNecessary (); |
| 108 | |
Alexander Afanasyev | f249a19 | 2012-07-18 16:52:51 -0700 | [diff] [blame] | 109 | private: |
| 110 | ::ndnSIM::StatsTree m_stats; |
Alexander Afanasyev | e55d1e3 | 2012-07-19 15:33:05 -0700 | [diff] [blame] | 111 | EventId m_statsRefreshEvent; |
Alexander Afanasyev | 77495a9 | 2012-07-20 15:38:29 -0700 | [diff] [blame] | 112 | |
| 113 | TracedCallback< Ptr<CcnxForwardingStrategy>, |
| 114 | const ::ndnSIM::StatsTree & > m_statsTrace; |
Alexander Afanasyev | f249a19 | 2012-07-18 16:52:51 -0700 | [diff] [blame] | 115 | |
| 116 | typedef BestRoute super; |
| 117 | }; |
| 118 | |
Alexander Afanasyev | b1b7f5d | 2012-08-09 09:59:43 -0700 | [diff] [blame] | 119 | const ::ndnSIM::StatsTree & |
| 120 | FwStats::GetStatsTree () const |
| 121 | { |
| 122 | return m_stats; |
| 123 | } |
| 124 | |
Alexander Afanasyev | f249a19 | 2012-07-18 16:52:51 -0700 | [diff] [blame] | 125 | } // namespace ndnSIM |
| 126 | } // namespace ns3 |
| 127 | |
| 128 | #endif // NDNSIM_FW_STATS_H |